From: Good Guy Date: Tue, 23 Jul 2019 00:34:53 +0000 (-0600) Subject: add gang points to mask_gui, add missing projector xform to centroid marker, fix... X-Git-Tag: 2019-08~13 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=a9a62511f2f31cf17307d877ec4e345bf0925aee;p=goodguy%2Fcinelerra.git add gang points to mask_gui, add missing projector xform to centroid marker, fix tool_gui deadlock --- diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 935a5f9f..26bc2bb0 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -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; ix += 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); diff --git a/cinelerra-5.1/cinelerra/cwindowtool.C b/cinelerra-5.1/cinelerra/cwindowtool.C index 04457c83..9e022d8f 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.C +++ b/cinelerra-5.1/cinelerra/cwindowtool.C @@ -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= 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 } diff --git a/cinelerra-5.1/cinelerra/cwindowtool.h b/cinelerra-5.1/cinelerra/cwindowtool.h index 4c755729..5e290b13 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.h +++ b/cinelerra-5.1/cinelerra/cwindowtool.h @@ -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; diff --git a/cinelerra-5.1/cinelerra/cwindowtool.inc b/cinelerra-5.1/cinelerra/cwindowtool.inc index 0400264a..39fd3df0 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.inc +++ b/cinelerra-5.1/cinelerra/cwindowtool.inc @@ -43,6 +43,7 @@ class CWindowMaskFade; class CWindowMaskFadeSlider; class CWindowMaskGangFader; class CWindowMaskGangFocus; +class CWindowMaskGangPoint; class CWindowMaskSmoothButton; class CWindowMaskAffectedPoint; class CWindowMaskFocus;