X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcwindowgui.C;h=935a5f9fc9798ee6611e5348945dba722a9bd27a;hp=99c395bee41f314ebe9ba94f527f3f0d15d6bcc0;hb=6d8835a537ca709e122226506548de0d4942aa32;hpb=505506bd554eff241bd0a5b5b84c220cb2c59971 diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 99c395be..935a5f9f 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -878,6 +878,7 @@ void panel_btn(fit_selection,(), fit_selection()) void panel_btn(fit_autos,(int all), fit_autos(all)) void panel_btn(set_editing_mode,(int mode), set_editing_mode(mode)) void panel_btn(set_auto_keyframes,(int v), set_auto_keyframes(v)) +void panel_btn(set_span_keyframes,(int v), set_span_keyframes(v)) void panel_btn(set_labels_follow_edits,(int v), set_labels_follow_edits(v)) @@ -1454,8 +1455,8 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, Auto *prev_auto = 0; mask_autos->get_prev_auto(position, PLAY_FORWARD, (Auto *&)prev_auto, 1); MaskAuto *prev_mask = (MaskAuto *)prev_auto; - ArrayList points; - + MaskPoints 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 +1783,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; @@ -2000,10 +2003,10 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, if(button_press && result) { #ifdef USE_KEYFRAME_SPANNING - ArrayList &mask_points = points; + MaskPoints &mask_points = points; #else SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask); - ArrayList &mask_points = mask->points; + MaskPoints &mask_points = mask->points; #endif int k = gui->affected_point; if( k >= 0 && k < mask_points.size() ) { @@ -2036,13 +2039,14 @@ 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; + MaskPoints &mask_points = points; #else - ArrayList &mask_points = mask->points; + MaskPoints &mask_points = mask->points; #endif MaskPoint *point = mask_points.get(gui->affected_point); // canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); @@ -2073,62 +2077,104 @@ 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; + int mode = mask_gui->scale_mode; + 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; jmask_enables[j]->get_value() ) continue; + SubMask *sub_mask = keyframe->get_submask(j); + if( !sub_mask ) continue; + MaskPoints &points = sub_mask->points; + for( int i=0; ix += dx; + if( mode == 1 || mode == 2) 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: { - 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.; - float st = sin(theta), ct = cos(theta); - float cx = 0, cy = 0; - int n = mask_points.size(); - if( mask_gui && mask_gui->focused ) { + if( !mask_gui || !mask_points.size() ) break; + float cx = gui->x_origin, cy = gui->y_origin; + if( mask_gui->focused ) { cx = atof(mask_gui->focus_x->get_text()); cy = atof(mask_gui->focus_y->get_text()); } - else if( n > 0 ) { + else if( !gui->ctrl_down() ) { + cx = cy = 0; + int n = mask_points.size(); for( int i=0; ix; cy += point->y; } cx /= n; cy /= n; + mask_gui->set_focused(0, cx, cy); } gui->x_origin = cx; gui->y_origin = cy; - 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; + double accel = + gui->get_triple_click() ? 8. : + gui->get_double_click() ? 4. : + 1.; + int button_no = get_buttonpress(); + 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 theta = button_no == WHEEL_UP ? dt : -dt; + if( rotate ? theta==0 : scale==1 ) break; + float st = sin(theta), ct = cos(theta); + 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; jmask_enables[j]->get_value() ) continue; + SubMask *sub_mask = keyframe->get_submask(j); + if( !sub_mask ) continue; + MaskPoints &points = sub_mask->points; + for( int i=0; ix - gui->x_origin; + float py = point->y - gui->y_origin; + float nx = !rotate ? px*xscale : px*ct + py*st; + float ny = !rotate ? py*yscale : 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*xscale : px*ct + py*st; + point->control_y1 = !rotate ? py*yscale : py*ct - px*st; + px = point->control_x2; py = point->control_y2; + point->control_x2 = !rotate ? px*xscale : px*ct + py*st; + point->control_y2 = !rotate ? py*yscale : 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; } @@ -2187,14 +2233,39 @@ 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); } #endif - - points.remove_all_objects(); //printf("CWindowCanvas::do_mask 20\n"); + + if( draw && draw_boundary && !draw_markers ) { + BC_WindowBase *cvs_win = get_canvas(); + cvs_win->set_inverse(); + cvs_win->set_color(RED+GREEN); + for( int k=0; kedl->session->cwindow_mask ) continue; + points.remove_all_objects(); + if( use_interpolated ) + mask_autos->get_points(&points, k, position, PLAY_FORWARD); + else + prev_mask->get_points(&points, k); + MaskEdge edge; + edge.load(points, 0); + for( int i=0; iedl, 0, ax, ay); + output_to_canvas(mwindow->edl, 0, bx, by); + cvs_win->draw_line(ax,ay, bx,by); + } + } + } + return result; } @@ -2203,11 +2274,7 @@ int CWindowCanvas::do_mask_focus() CWindowMaskGUI *mask_gui = (CWindowMaskGUI*) gui->tool_panel->tool_gui; float cx = get_cursor_x(), cy = get_cursor_y(); canvas_to_output(mwindow->edl, 0, cx, cy); - get_canvas()->unlock_window(); - mask_gui->lock_window("CWindowCanvas::do_mask_focus"); mask_gui->set_focused(1, cx, cy); - mask_gui->unlock_window(); - get_canvas()->lock_window("CWindowCanvas::do_mask_focus"); return 1; }