fix mask focus point for cam/proj transform, fix shift-btn2 mask focus pt update...
authorGood Guy <good1.2guy@gmail.com>
Wed, 24 Jul 2019 00:40:31 +0000 (18:40 -0600)
committerGood Guy <good1.2guy@gmail.com>
Wed, 24 Jul 2019 00:40:31 +0000 (18:40 -0600)
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowtool.C

index a15942a..3493bd3 100644 (file)
@@ -1756,6 +1756,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
                if( draw && mask_gui && mask_gui->focused ) {
                        float fx = atof(mask_gui->focus_x->get_text());
                        float fy = atof(mask_gui->focus_y->get_text());
+                       fx = (fx - half_track_w) * projector_z + projector_x;
+                       fy = (fy - half_track_h) * projector_z + projector_y;
                        output_to_canvas(mwindow->edl, 0, fx, fy);
                        float r = bmax(cvs_win->get_w(), cvs_win->get_h());
                        float d = 0.005*r;
@@ -2275,9 +2277,23 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender,
 
 int CWindowCanvas::do_mask_focus()
 {
-       CWindowMaskGUI *mask_gui = (CWindowMaskGUI*) gui->tool_panel->tool_gui;
+       Track *track = gui->cwindow->calculate_affected_track();
+       int64_t position = track->to_units(
+               mwindow->edl->local_session->get_selectionstart(1),
+               0);
+       float projector_x, projector_y, projector_z;
+       track->automation->get_projector(
+               &projector_x, &projector_y, &projector_z,
+               position, PLAY_FORWARD);
        float cx = get_cursor_x(), cy = get_cursor_y();
        canvas_to_output(mwindow->edl, 0, cx, cy);
+       projector_x += mwindow->edl->session->output_w / 2;
+       projector_y += mwindow->edl->session->output_h / 2;
+       float half_track_w = (float)track->track_w / 2;
+       float half_track_h = (float)track->track_h / 2;
+       cx = (cx - projector_x) / projector_z + half_track_w;
+       cy = (cy - projector_y) / projector_z + half_track_h;
+       CWindowMaskGUI *mask_gui = (CWindowMaskGUI*) gui->tool_panel->tool_gui;
        mask_gui->set_focused(1, cx, cy);
        return 1;
 }
index 9e022d8..fb4e895 100644 (file)
@@ -2810,47 +2810,53 @@ void CWindowMaskGUI::update()
 
 void CWindowMaskGUI::handle_event()
 {
-       if( event_caller != this->x &&
-           event_caller != this->y ) return;
-       Track *track;
-       MaskAuto *keyframe;
-       MaskAutos *autos;
-       SubMask *mask;
-       MaskPoint *point;
-       get_keyframe(track, autos, keyframe, mask, point, 0);
-
-       mwindow->undo->update_undo_before(_("mask point"), this);
-
-       if( point ) {
-               float px = atof(x->get_text());
-               float py = atof(y->get_text());
-               float dx = px - point->x, dy = py - point->y;
+       int redraw = 0;
+       if( event_caller == this->focus_x ||
+           event_caller == this->focus_y ) {
+               redraw = 1;
+       }
+       else if( event_caller == this->x ||
+                event_caller == this->y ) {
+               Track *track;
+               MaskAuto *keyframe;
+               MaskAutos *autos;
+               SubMask *mask;
+               MaskPoint *point;
+               get_keyframe(track, autos, keyframe, mask, point, 0);
+
+               mwindow->undo->update_undo_before(_("mask point"), this);
+
+               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);
+                       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);
+                       mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
 #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;
-               }
-
+                       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;
+                       }
 #ifdef USE_KEYFRAME_SPANNING
 // Commit to spanned keyframes
-               autos->update_parameter(&temp_keyframe);
+                       autos->update_parameter(&temp_keyframe);
 #endif
+               }
+               mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
+               redraw = 1;
        }
 
-       update_preview();
-       mwindow->undo->update_undo_after(_("mask point"), LOAD_AUTOMATION);
+       if( redraw )
+               update_preview();
 }
 
 void CWindowMaskGUI::set_focused(int v, float cx, float cy)