X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcwindowgui.C;h=97ca8e6726f852df57838a31e08111e699847bad;hp=27a065117a8590e490f5d9c7a61638fc752df715;hb=f41ee8a0f00338fffb7fd6760a5ecd04c0101a41;hpb=9668279ccef86a9cc9138aaa1a659f158698f829 diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 27a06511..97ca8e67 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -1455,7 +1455,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, mask_autos->get_prev_auto(position, PLAY_FORWARD, (Auto *&)prev_auto, 1); MaskAuto *prev_mask = (MaskAuto *)prev_auto; ArrayList points; - + int update_points = 1; // Determine the points based on whether // new keyframes will be generated or drawing is performed. // If keyframe generation occurs, use the interpolated mask. @@ -1782,6 +1782,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, cx += point->x; cy += point->y; } cx /= n; cy /= n; + if( !mask_gui->focused ) + mask_gui->set_focused(0, cx, cy); output_to_canvas(mwindow->edl, 0, cx, cy); float r = bmax(cvs_win->get_w(), cvs_win->get_h()); float d = 0.007*r; @@ -1791,8 +1793,6 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, cvs_win->draw_line(cx,cy-d, cx, cy+d); cvs_win->set_line_width(0); cvs_win->set_color(WHITE); - if( !mask_gui->focused ) - mask_gui->set_focused(0, cx, cy); } //printf("CWindowCanvas::do_mask 1\n"); } @@ -2038,8 +2038,9 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, //printf("CWindowCanvas::do_mask %d %d\n", __LINE__, gui->affected_point); SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask); - if( gui->affected_point >= 0 && gui->affected_point < mask->points.size() && - gui->current_operation != CWINDOW_NONE) { + if( mask && gui->affected_point >= 0 && + gui->affected_point < mask->points.size() && + gui->current_operation != CWINDOW_NONE ) { // mwindow->undo->update_undo_before(_("mask point"), this); #ifdef USE_KEYFRAME_SPANNING ArrayList &mask_points = points; @@ -2075,24 +2076,42 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, point->control_y2 = mask_cursor_y - gui->y_origin + gui->control_out_y; break; - case CWINDOW_MASK_TRANSLATE: - for(int i = 0; i < mask_points.size(); i++) { - mask_points.values[i]->x += mask_cursor_x - gui->x_origin; - mask_points.values[i]->y += mask_cursor_y - gui->y_origin; + case CWINDOW_MASK_TRANSLATE: { + if( !mask_gui ) break; + MaskAuto *keyframe = gui->mask_keyframe; + int gang = mask_gui->gang_focus->get_value(); + float dx = mask_cursor_x - gui->x_origin; + float dy = mask_cursor_y - gui->y_origin; + if( !dx && !dy ) break; + int k = mwindow->edl->session->cwindow_mask; + int n = gang ? keyframe->masks.size() : k+1; + for( int j=gang? 0 : k; jget_submask(j); + if( !sub_mask ) continue; + ArrayList &points = sub_mask->points; + for( int i=0; ix += dx; + point->y += dy; + } } gui->x_origin = mask_cursor_x; gui->y_origin = mask_cursor_y; - break; + rerender = 1; + redraw = 1; + update_points = 0; + break; } case CWINDOW_MASK_ROTATE: rotate = 1; case CWINDOW_MASK_SCALE: { if( !mask_gui || !mask_points.size() ) break; + float cx = gui->x_origin, cy = gui->y_origin; if( mask_gui->focused ) { - gui->x_origin = atof(mask_gui->focus_x->get_text()); - gui->y_origin = atof(mask_gui->focus_y->get_text()); + cx = atof(mask_gui->focus_x->get_text()); + cy = atof(mask_gui->focus_y->get_text()); } - else { - float cx = 0, cy = 0; + else if( !gui->ctrl_down() ) { + cx = cy = 0; int n = mask_points.size(); for( int i=0; iset_focused(0, cx, cy); } + gui->x_origin = cx; + gui->y_origin = cy; + double accel = + gui->get_triple_click() ? 8. : + gui->get_double_click() ? 4. : + 1.; int button_no = get_buttonpress(); - double scale = button_no == WHEEL_UP ? 1.02 : 0.98; - double theta = button_no == WHEEL_UP ? M_PI/360. : -M_PI/360.; + double ds = accel/64., dt = accel*M_PI/360.; + double scale = button_no == WHEEL_UP ? 1.+ds : 1.-ds; + double theta = button_no == WHEEL_UP ? dt : -dt; + if( rotate ? theta==0 : scale==1 ) break; float st = sin(theta), ct = cos(theta); - for( int i=0; ix - gui->x_origin; - float py = point->y - gui->y_origin; - float nx = !rotate ? px*scale : px*ct + py*st; - float ny = !rotate ? py*scale : py*ct - px*st; - point->x = nx + gui->x_origin; - point->y = ny + gui->y_origin; - px = point->control_x1; py = point->control_y1; - point->control_x1 = !rotate ? px*scale : px*ct + py*st; - point->control_y1 = !rotate ? py*scale : py*ct - px*st; - px = point->control_x2; py = point->control_y2; - point->control_x2 = !rotate ? px*scale : px*ct + py*st; - point->control_y2 = !rotate ? py*scale : py*ct - px*st; + MaskAuto *keyframe = gui->mask_keyframe; + int gang = mask_gui->gang_focus->get_value(); + int k = mwindow->edl->session->cwindow_mask; + int n = gang ? keyframe->masks.size() : k+1; + for( int j=gang? 0 : k; jget_submask(j); + ArrayList &points = sub_mask->points; + if( !sub_mask ) continue; + for( int i=0; ix - gui->x_origin; + float py = point->y - gui->y_origin; + float nx = !rotate ? px*scale : px*ct + py*st; + float ny = !rotate ? py*scale : py*ct - px*st; + point->x = nx + gui->x_origin; + point->y = ny + gui->y_origin; + px = point->control_x1; py = point->control_y1; + point->control_x1 = !rotate ? px*scale : px*ct + py*st; + point->control_y1 = !rotate ? py*scale : py*ct - px*st; + px = point->control_x2; py = point->control_y2; + point->control_x2 = !rotate ? px*scale : px*ct + py*st; + point->control_y2 = !rotate ? py*scale : py*ct - px*st; + } } rerender = 1; redraw = 1; + update_points = 0; break; } } - if( !EQUIV(last_x, point->x) || + if( !(rerender && redraw) && (!EQUIV(last_x, point->x) || !EQUIV(last_y, point->y) || !EQUIV(last_control_x1, point->control_x1) || !EQUIV(last_control_y1, point->control_y1) || !EQUIV(last_control_x2, point->control_x2) || - !EQUIV(last_control_y2, point->control_y2)) { + !EQUIV(last_control_y2, point->control_y2)) ) { rerender = 1; redraw = 1; } @@ -2189,7 +2226,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, MaskAuto temp_keyframe(mwindow->edl, mask_autos); temp_keyframe.copy_data(gui->mask_keyframe); // Apply interpolated points back to keyframe - temp_keyframe.set_points(&points, mwindow->edl->session->cwindow_mask); + if( update_points ) + temp_keyframe.set_points(&points, mwindow->edl->session->cwindow_mask); gui->mask_keyframe->copy_data(gui->orig_mask_keyframe); mask_autos->update_parameter(&temp_keyframe); }