add gang points to mask_gui, add missing projector xform to centroid marker, fix...
authorGood Guy <good1.2guy@gmail.com>
Tue, 23 Jul 2019 00:34:53 +0000 (18:34 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 23 Jul 2019 00:34:53 +0000 (18:34 -0600)
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/cwindowtool.h
cinelerra-5.1/cinelerra/cwindowtool.inc

index 935a5f9fc9798ee6611e5348945dba722a9bd27a..26bc2bb01d40dd5a4d31765969ab416f38a04efa 100644 (file)
@@ -435,7 +435,9 @@ void CWindowGUI::set_operation(int value)
        }
 
        edit_panel->update();
+       unlock_window();
        tool_panel->start_tool(value);
+       lock_window("CWindowGUI::set_operation");
        canvas->refresh(0);
 }
 
@@ -1785,6 +1787,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                        cx /= n;  cy /= n;
                        if( !mask_gui->focused )
                                mask_gui->set_focused(0, cx, cy);
+                       cx = (cx - half_track_w) * projector_z + projector_x;
+                       cy = (cy - half_track_h) * projector_z + projector_y;
                        output_to_canvas(mwindow->edl, 0, cx, cy);
                        float r = bmax(cvs_win->get_w(), cvs_win->get_h());
                        float d = 0.007*r;
@@ -2094,8 +2098,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                        MaskPoints &points = sub_mask->points;
                                        for( int i=0; i<points.size(); ++i ) {
                                                MaskPoint *point = points[i];
-                                               if( mode == 0 || mode == 2) point->x += dx;
-                                               if( mode == 1 || mode == 2) point->y += dy;
+                                               if( mode == MASK_SCALE_X || mode == MASK_SCALE_XY ) point->x += dx;
+                                               if( mode == MASK_SCALE_Y || mode == MASK_SCALE_XY ) point->y += dy;
                                        }
                                }
                                gui->x_origin = mask_cursor_x;
@@ -2133,8 +2137,10 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                                double ds = accel/64., dt = accel*M_PI/360.;
                                double scale = button_no == WHEEL_UP ? 1.+ds : 1.-ds;
                                int mode = mask_gui->scale_mode;
-                               double xscale = !rotate && (mode == 0 || mode == 2 ) ? scale : 1.;
-                               double yscale = !rotate && (mode == 1 || mode == 2 ) ? scale : 1.;
+                               double xscale = !rotate && (mode == MASK_SCALE_X ||
+                                       mode == MASK_SCALE_XY ) ? scale : 1.;
+                               double yscale = !rotate && (mode == MASK_SCALE_Y ||
+                                       mode == MASK_SCALE_XY ) ? scale : 1.;
                                double theta = button_no == WHEEL_UP ? dt : -dt;
                                if( rotate ? theta==0 : scale==1 ) break;
                                float st = sin(theta), ct = cos(theta);
index 04457c838d41b8364cb956f21c90fafaf0e68b8b..9e022d8f114676d9e6f20dcb3caeba7ca3ecd2fd 100644 (file)
@@ -2018,9 +2018,9 @@ CWindowMaskScaleXY::~CWindowMaskScaleXY()
 int CWindowMaskScaleXY::handle_event()
 {
        gui->scale_mode = id;
-       gui->mask_scale_x->update(id == 0);
-       gui->mask_scale_y->update(id == 1);
-       gui->mask_scale_xy->update(id == 2);
+       gui->mask_scale_x->update(id == MASK_SCALE_X);
+       gui->mask_scale_y->update(id == MASK_SCALE_Y);
+       gui->mask_scale_xy->update(id == MASK_SCALE_XY);
        return 1;
 }
 
@@ -2351,6 +2351,24 @@ int CWindowMaskGangFocus::handle_event()
        return 1;
 }
 
+CWindowMaskGangPoint::CWindowMaskGangPoint(MWindow *mwindow,
+               CWindowMaskGUI *gui, int x, int y)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("gangpatch_data"), 0)
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+       set_tooltip(_("Gang points"));
+}
+
+CWindowMaskGangPoint::~CWindowMaskGangPoint()
+{
+}
+
+int CWindowMaskGangPoint::handle_event()
+{
+       return 1;
+}
+
 
 CWindowMaskSmoothButton::CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
                const char *tip, int type, int on, int x, int y, const char *images)
@@ -2600,11 +2618,11 @@ void CWindowMaskGUI::create_objects()
        add_subwindow(mask_normal = new CWindowMaskNormal(mwindow, this, t[1], y, 80));
 
        add_subwindow(mask_scale_x = new CWindowMaskScaleXY(mwindow, this,
-               t[5], y, theme->get_image_set("mask_scale_x"), 0, 0, _("xlate/scale x")));
+               t[5], y, theme->get_image_set("mask_scale_x"), 0, MASK_SCALE_X, _("xlate/scale x")));
        add_subwindow(mask_scale_y = new CWindowMaskScaleXY(mwindow, this,
-               t[6], y, theme->get_image_set("mask_scale_y"), 0, 1, _("xlate/scale y")));
+               t[6], y, theme->get_image_set("mask_scale_y"), 0, MASK_SCALE_Y, _("xlate/scale y")));
        add_subwindow(mask_scale_xy = new CWindowMaskScaleXY(mwindow, this,
-               t[7], y, theme->get_image_set("mask_scale_xy"), 1, 2, _("xlate/scale xy")));
+               t[7], y, theme->get_image_set("mask_scale_xy"), 1, MASK_SCALE_XY, _("xlate/scale xy")));
        y += mask_center->get_h() + 2*margin;
        add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, 20, 10, _("Fade & Feather")));
        y += title_bar->get_h() + 2*margin;
@@ -2637,6 +2655,7 @@ void CWindowMaskGUI::create_objects()
        add_subwindow(mask_pnt_smooth = new CWindowMaskSmoothButton(mwindow, this,
                _("smooth point"), 0, 1, t[4], y, "mask_pnt_smooth_images"));
        add_subwindow(del_point = new CWindowMaskDelPoint(mwindow, this, del_x, y));
+       add_subwindow(gang_point = new CWindowMaskGangPoint(mwindow, this, clr_x, y));
        y += active_point->get_h() + margin;
        add_subwindow(title = new BC_Title(x, y, "X:"));
        this->x = new CWindowCoord(this, t[0], y, (float)0.0);
@@ -2791,6 +2810,8 @@ void CWindowMaskGUI::update()
 
 void CWindowMaskGUI::handle_event()
 {
+       if( event_caller != this->x &&
+           event_caller != this->y ) return;
        Track *track;
        MaskAuto *keyframe;
        MaskAutos *autos;
@@ -2800,30 +2821,31 @@ void CWindowMaskGUI::handle_event()
 
        mwindow->undo->update_undo_before(_("mask point"), this);
 
-       if(point)
-       {
+       if( point ) {
+               float px = atof(x->get_text());
+               float py = atof(y->get_text());
+               float dx = px - point->x, dy = py - point->y;
 #ifdef USE_KEYFRAME_SPANNING
 // Create temp keyframe
                MaskAuto temp_keyframe(mwindow->edl, autos);
                temp_keyframe.copy_data(keyframe);
 // Get affected point in temp keyframe
                mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
-               if(mwindow->cwindow->gui->affected_point < mask->points.total &&
-                       mwindow->cwindow->gui->affected_point >= 0)
-               {
-                       point = mask->points.values[mwindow->cwindow->gui->affected_point];
+#endif
+               
+               MaskPoints &points = mask->points;
+               int gang = gang_point->get_value();
+               int k = mwindow->cwindow->gui->affected_point;
+               int n = gang ? points.size() : k+1;
+               for( int i=gang? 0 : k; i<n; ++i ) {
+                       if( i < 0 || i >= points.size() ) continue;
+                       MaskPoint *point = points[i];
+                       point->x += dx;  point->y += dy;
                }
 
-               if(point)
-               {
-                       point->x = atof(x->get_text());
-                       point->y = atof(y->get_text());
+#ifdef USE_KEYFRAME_SPANNING
 // Commit to spanned keyframes
-                       autos->update_parameter(&temp_keyframe);
-               }
-#else
-               point->x = atof(x->get_text());
-               point->y = atof(y->get_text());
+               autos->update_parameter(&temp_keyframe);
 #endif
        }
 
index 4c7557295330d35a8f1cbdd08d4eaae5b7698680..5e290b1370a69745f4ee72ea3cc6a1e3eef32c2f 100644 (file)
@@ -37,6 +37,11 @@ enum {
        MASK_SHAPE_TRIANGLE,
        MASK_SHAPE_OVAL,
 };
+enum {
+       MASK_SCALE_X,
+       MASK_SCALE_Y,
+       MASK_SCALE_XY,
+};
 
 // This common thread supports all the tool GUI's.
 class CWindowTool : public Thread
@@ -329,6 +334,17 @@ public:
        CWindowMaskGUI *gui;
 };
 
+class CWindowMaskGangPoint : public BC_Toggle
+{
+public:
+       CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
+                       int x, int y);
+       ~CWindowMaskGangPoint();
+       int handle_event();
+       MWindow *mwindow;
+       CWindowMaskGUI *gui;
+};
+
 class CWindowMaskSmoothButton : public BC_Button
 {
 public:
@@ -652,6 +668,7 @@ public:
        CWindowMaskGangFader *gang_fader;
        CWindowMaskAffectedPoint *active_point;
        CWindowMaskDelPoint *del_point;
+       CWindowMaskGangPoint *gang_point;
        CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
        CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
        CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
index 0400264a28384fe582514a89d53a2d89085b1ed2..39fd3df03b56b0bb6b43fb387ee186c006e24b79 100644 (file)
@@ -43,6 +43,7 @@ class CWindowMaskFade;
 class CWindowMaskFadeSlider;
 class CWindowMaskGangFader;
 class CWindowMaskGangFocus;
+class CWindowMaskGangPoint;
 class CWindowMaskSmoothButton;
 class CWindowMaskAffectedPoint;
 class CWindowMaskFocus;