add mask selection btns
authorGood Guy <good1.2guy@gmail.com>
Thu, 30 May 2019 02:21:51 +0000 (20:21 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 30 May 2019 02:21:51 +0000 (20:21 -0600)
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/cwindowtool.h
cinelerra-5.1/cinelerra/cwindowtool.inc

index 17623a3d78f456f6841c15cf6d112205ff79564c..c38daafb0420a3502fff4087d5b89a9d0ff4c0a1 100644 (file)
@@ -1482,8 +1482,8 @@ int CWindowProjectorBottom::handle_event()
 }
 
 
-CWindowMaskName::CWindowMaskName(MWindow *mwindow,
-       CWindowToolGUI *gui, int x, int y, const char *text)
+CWindowMaskName::CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
+               int x, int y, const char *text)
  : BC_PopupTextBox(gui, 0, text, x, y, 100, 160)
 {
        this->mwindow = mwindow;
@@ -1502,7 +1502,7 @@ int CWindowMaskName::handle_event()
        SubMask *mask;
        MaskPoint *point;
 //printf("CWindowMaskGUI::update 1\n");
-       ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
+       gui->get_keyframe(track, autos, keyframe, mask, point, 0);
        if( track ) {
                int k = get_number();
                if( k < 0 ) k = mwindow->edl->session->cwindow_mask;
@@ -1527,6 +1527,9 @@ int CWindowMaskName::handle_event()
                                (MaskAuto*)autos->first : (MaskAuto*)NEXT;
                }
 #endif
+               int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]);
+               for( int i=0; i<total_buttons; ++i )
+                       gui->mask_buttons[i]->update(i==k ? 1 : 0);
                gui->update();
                gui->update_preview();
        }
@@ -1546,6 +1549,67 @@ void CWindowMaskName::update_items(MaskAuto *keyframe)
 }
 
 
+CWindowMaskButton::CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
+                int x, int y, int no, int v)
+ : BC_CheckBox(x, y, v)
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+       this->no = no;
+}
+
+CWindowMaskButton::~CWindowMaskButton()
+{
+}
+
+int CWindowMaskButton::handle_event()
+{
+       mwindow->edl->session->cwindow_mask = no;
+       int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]);
+       for( int i=0; i<total_buttons; ++i )
+               gui->mask_buttons[i]->update(i==no ? 1 : 0);
+       gui->name->update(gui->name->mask_items[no]->get_text());
+       gui->update_preview();
+       return 1;
+}
+
+CWindowMaskThumbler::CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
+               int x, int y)
+ : BC_Tumbler(x, y)
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+}
+
+CWindowMaskThumbler::~CWindowMaskThumbler()
+{
+}
+
+int CWindowMaskThumbler::handle_up_event()
+{
+       return do_event(1);
+}
+
+int CWindowMaskThumbler::handle_down_event()
+{
+       return do_event(-1);
+}
+
+int CWindowMaskThumbler::do_event(int dir)
+{
+       int k = mwindow->edl->session->cwindow_mask;
+       if( (k+=dir) >= SUBMASKS ) k = 0;
+       else if( k < 0 ) k = SUBMASKS-1;
+       mwindow->edl->session->cwindow_mask = k;
+       int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]);
+       for( int i=0; i<total_buttons; ++i )
+               gui->mask_buttons[i]->update(i==k ? 1 : 0);
+       gui->name->update(gui->name->mask_items[k]->get_text());
+       gui->update_preview();
+       return 1;
+}
+
+
 CWindowMaskDelMask::CWindowMaskDelMask(MWindow *mwindow,
        CWindowToolGUI *gui, int x, int y)
  : BC_GenericButton(x, y, _("Delete"))
@@ -2158,7 +2222,7 @@ int CWindowMaskGangFeather::handle_event()
 
 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
  : CWindowToolGUI(mwindow, thread,
-       _(PROGRAM_NAME ": Mask"), 360, 440)
+       _(PROGRAM_NAME ": Mask"), 360, 500)
 {
        this->mwindow = mwindow;
        this->thread = thread;
@@ -2197,10 +2261,32 @@ void CWindowMaskGUI::create_objects()
        add_subwindow(clr_mask = new CWindowMaskClrMask(mwindow, this, clr_x, y));
        add_subwindow(del_mask = new CWindowMaskDelMask(mwindow, this, del_x, y));
        y += name->get_h() + margin;
+
+       int bw = 0, bh = 0;
+       BC_CheckBox::calculate_extents(this, &bw, &bh);
+       int bdx = bw + margin;
+       int x2 = x;
+       for( int i=0; i<SUBMASKS; x2+=bdx, ++i ) {
+               int v = i == mwindow->edl->session->cwindow_mask ? 1 : 0;
+               mask_buttons[i] = new CWindowMaskButton(mwindow, this, x2, y, i, v);
+               add_subwindow(mask_buttons[i]);
+       }
+       x2 += margin;
+       add_subwindow(mask_thumbler = new CWindowMaskThumbler(mwindow, this, x2, y));
+       y += bh + margin;
+       x2 = x;
+       for( int i=0; i<SUBMASKS; x2+=bdx, ++i ) {
+               char text[BCSTRLEN];  sprintf(text, "%d", i);
+               int tx = (bw - get_text_width(MEDIUMFONT, text)) / 2;
+               mask_blabels[i] = new BC_Title(x2+tx, y, text);
+               add_subwindow(mask_blabels[i]);
+       }
+       y += bh + 2*margin;
+
        add_subwindow(title = new BC_Title(x, y, _("Fade:")));
        fade = new CWindowMaskFade(mwindow, this, x1, y);
        fade->create_objects();
-       int x2 = x1 + fade->get_w() + 2*margin;
+       x2 = x1 + fade->get_w() + 2*margin;
        int w2 = clr_x-2*margin - x2;
        add_subwindow(fade_slider = new CWindowMaskFadeSlider(mwindow, this, x2, y, w2));
        add_subwindow(gang_fader = new CWindowMaskGangFader(mwindow, this, clr_x, y));
index ccdb3c26e04c4b23751c41373519e2b5650924a0..db0b32b7cec5294b196e05b54875f125dd701005 100644 (file)
@@ -93,8 +93,10 @@ public:
 class CWindowCoord : public BC_TumbleTextBox
 {
 public:
-       CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int logincrement);
-       CWindowCoord(CWindowToolGUI *gui, int x, int y, int value);
+       CWindowCoord(CWindowToolGUI *gui, int x, int y,
+                       float value, int logincrement);
+       CWindowCoord(CWindowToolGUI *gui, int x, int y,
+                       int value);
 
 // Calls the window's handle_event
        int handle_event();
@@ -105,7 +107,8 @@ public:
 class CWindowCropOK : public BC_GenericButton
 {
 public:
-       CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
 // Perform the cropping operation
        int handle_event();
        int keypress_event();
@@ -135,10 +138,11 @@ public:
 class CWindowMaskName : public BC_PopupTextBox
 {
 public:
-       CWindowMaskName(MWindow *mwindow, CWindowToolGUI *gui, int x, int y, const char *text);
+       CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
+                       int x, int y, const char *text);
        ~CWindowMaskName();
        MWindow *mwindow;
-       CWindowToolGUI *gui;
+       CWindowMaskGUI *gui;
        CWindowMaskItems mask_items;
 
        int handle_event();
@@ -148,7 +152,8 @@ public:
 class CWindowMaskDelMask : public BC_GenericButton
 {
 public:
-       CWindowMaskDelMask(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskDelMask(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowToolGUI *gui;
@@ -157,7 +162,8 @@ public:
 class CWindowMaskClrMask : public BC_Button
 {
 public:
-       CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui, int x, int y);
+       CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
+                       int x, int y);
        ~CWindowMaskClrMask();
        static int calculate_w(MWindow *mwindow);
        int handle_event();
@@ -165,10 +171,38 @@ public:
        CWindowMaskGUI *gui;
 };
 
+class CWindowMaskButton : public BC_CheckBox
+{
+public:
+       CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
+                        int x, int y, int no, int v);
+       ~CWindowMaskButton();
+
+       int handle_event();
+       MWindow *mwindow;
+       CWindowMaskGUI *gui;
+       int no;
+};
+
+class CWindowMaskThumbler : public BC_Tumbler
+{
+public:
+       CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
+                       int x, int y);
+       ~CWindowMaskThumbler();
+       int handle_up_event();
+       int handle_down_event();
+       int do_event(int dir);
+
+       MWindow *mwindow;
+       CWindowMaskGUI *gui;
+};
+
 class CWindowMaskFade : public BC_TumbleTextBox
 {
 public:
-       CWindowMaskFade(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskFade(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskFade();
        int update(float v);
        int update_value(float v);
@@ -196,7 +230,8 @@ public:
 class CWindowMaskGangFader : public BC_Toggle
 {
 public:
-       CWindowMaskGangFader(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskGangFader(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskGangFader();
        int handle_event();
        MWindow *mwindow;
@@ -206,7 +241,8 @@ public:
 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
 {
 public:
-       CWindowMaskAffectedPoint(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskAffectedPoint(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskAffectedPoint();
        int handle_event();
        MWindow *mwindow;
@@ -216,7 +252,8 @@ public:
 class CWindowMaskFocus : public BC_CheckBox
 {
 public:
-       CWindowMaskFocus(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskFocus(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskFocus();
        int handle_event();
        MWindow *mwindow;
@@ -226,7 +263,8 @@ public:
 class CWindowMaskDrawMarkers : public BC_CheckBox
 {
 public:
-       CWindowMaskDrawMarkers(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskDrawMarkers(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskDrawMarkers();
        int handle_event();
        MWindow *mwindow;
@@ -236,7 +274,8 @@ public:
 class CWindowMaskDrawBoundary : public BC_CheckBox
 {
 public:
-       CWindowMaskDrawBoundary(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskDrawBoundary(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskDrawBoundary();
        int handle_event();
        MWindow *mwindow;
@@ -246,7 +285,8 @@ public:
 class CWindowMaskDelPoint : public BC_GenericButton
 {
 public:
-       CWindowMaskDelPoint(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskDelPoint(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        int handle_event();
        int keypress_event();
        MWindow *mwindow;
@@ -256,7 +296,8 @@ public:
 class CWindowMaskFeather : public BC_TumbleTextBox
 {
 public:
-       CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskFeather();
        int update(float v);
        int update_value(float v);
@@ -284,7 +325,8 @@ public:
 class CWindowMaskGangFeather : public BC_Toggle
 {
 public:
-       CWindowMaskGangFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
+       CWindowMaskGangFeather(MWindow *mwindow, CWindowToolGUI *gui,
+                       int x, int y);
        ~CWindowMaskGangFeather();
        int handle_event();
        MWindow *mwindow;
@@ -294,7 +336,8 @@ public:
 class CWindowMaskBeforePlugins : public BC_CheckBox
 {
 public:
-       CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y);
+       CWindowMaskBeforePlugins(CWindowToolGUI *gui,
+                       int x, int y);
        int handle_event();
        CWindowToolGUI *gui;
 };
@@ -302,7 +345,8 @@ public:
 class CWindowDisableOpenGLMasking : public BC_CheckBox
 {
 public:
-       CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y);
+       CWindowDisableOpenGLMasking(CWindowToolGUI *gui,
+                       int x, int y);
        int handle_event();
        CWindowToolGUI *gui;
 };
@@ -321,6 +365,9 @@ public:
        void update_preview();
 
        CWindowMaskName *name;
+       CWindowMaskButton *mask_buttons[SUBMASKS];
+       CWindowMaskThumbler *mask_thumbler;
+       BC_Title *mask_blabels[SUBMASKS];
        CWindowMaskDelMask *del_mask;
        CWindowMaskClrMask *clr_mask;
        CWindowMaskFade *fade;
@@ -399,7 +446,8 @@ private:
 class CWindowCameraLeft : public BC_Button
 {
 public:
-       CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -408,7 +456,8 @@ public:
 class CWindowCameraCenter : public BC_Button
 {
 public:
-       CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -417,7 +466,8 @@ public:
 class CWindowCameraRight : public BC_Button
 {
 public:
-       CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -426,7 +476,8 @@ public:
 class CWindowCameraTop : public BC_Button
 {
 public:
-       CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -435,7 +486,8 @@ public:
 class CWindowCameraMiddle : public BC_Button
 {
 public:
-       CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -444,7 +496,8 @@ public:
 class CWindowCameraBottom : public BC_Button
 {
 public:
-       CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
+       CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowCameraGUI *gui;
@@ -469,7 +522,8 @@ private:
 class CWindowProjectorLeft : public BC_Button
 {
 public:
-       CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
@@ -478,7 +532,8 @@ public:
 class CWindowProjectorCenter : public BC_Button
 {
 public:
-       CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
@@ -487,7 +542,8 @@ public:
 class CWindowProjectorRight : public BC_Button
 {
 public:
-       CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
@@ -496,7 +552,8 @@ public:
 class CWindowProjectorTop : public BC_Button
 {
 public:
-       CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
@@ -505,7 +562,8 @@ public:
 class CWindowProjectorMiddle : public BC_Button
 {
 public:
-       CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
@@ -514,7 +572,8 @@ public:
 class CWindowProjectorBottom : public BC_Button
 {
 public:
-       CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
+       CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
+                       int x, int y);
        int handle_event();
        MWindow *mwindow;
        CWindowProjectorGUI *gui;
index 47e02ef916e7b0157ac61be04c721f4474318a8b..2a8ed55fd1aa74ca38e50cc2da3e7d0711ebbea0 100644 (file)
 
 class CWindowTool;
 class CWindowToolGUI;
-class CWindowCoord;
 class CWindowCurveToggle;
+class CWindowCoord;
 class CWindowCropOK;
 class CWindowCropGUI;
 class CWindowMaskItems;
 class CWindowMaskName;
 class CWindowMaskDelMask;
 class CWindowMaskClrMask;
+class CWindowMaskButton;
+class CWindowMaskThumbler;
 class CWindowMaskFade;
 class CWindowMaskFadeSlider;
 class CWindowMaskGangFader;