X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcwindowgui.C;h=af778e598350e08dc69eb829a6578edc10bf7496;hp=19ff101e3f0383a56ba20b8e9df6a2c981922416;hb=abf5c6bb4dec2c2d03df2872e1d337e3905b3619;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 19ff101e..af778e59 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -119,6 +119,7 @@ CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow) CWindowGUI::~CWindowGUI() { + cwindow->stop_playback(1); if(tool_panel) delete tool_panel; delete meters; delete composite_panel; @@ -419,7 +420,7 @@ void CWindowGUI::zoom_canvas(double value, int update_menu) canvas->reposition_window(mwindow->edl, mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y, mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h); - canvas->draw_refresh(); + canvas->refresh(0); } void CWindowGUI::set_operation(int value) @@ -443,7 +444,7 @@ void CWindowGUI::set_operation(int value) edit_panel->update(); tool_panel->start_tool(value); - canvas->draw_refresh(); + canvas->refresh(0); } void CWindowGUI::update_tool() @@ -463,113 +464,141 @@ int CWindowGUI::keypress_event() int result = 0; int cwindow_operation = CWINDOW_NONE; - switch(get_keypress()) - { - case 'w': - case 'W': - close_event(); - result = 1; - break; - case '+': - case '=': - keyboard_zoomin(); - result = 1; - break; - case '-': - keyboard_zoomout(); - result = 1; - break; - case 'f': + switch( get_keypress() ) { + case 'w': + case 'W': + close_event(); + result = 1; + break; + case '+': + case '=': + keyboard_zoomin(); + result = 1; + break; + case '-': + keyboard_zoomout(); + result = 1; + break; + case 'f': + unlock_window(); + if( canvas->get_fullscreen() ) + canvas->stop_fullscreen(); + else + canvas->start_fullscreen(); + lock_window("CWindowGUI::keypress_event 1"); + result = 1; + break; + case 'x': + if( ctrl_down() || shift_down() || alt_down() ) break; + unlock_window(); + mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); + mwindow->cut(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 2"); + result = 1; + break; + case DELETE: + unlock_window(); + mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); + mwindow->clear_entry(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 3"); + result = 1; + break; + case ESC: + unlock_window(); + if( canvas->get_fullscreen() ) + canvas->stop_fullscreen(); + lock_window("CWindowGUI::keypress_event 4"); + result = 1; + break; + case LEFT: + if( !ctrl_down() ) { + int alt_down = this->alt_down(); + int shift_down = this->shift_down(); unlock_window(); - if(mwindow->session->cwindow_fullscreen) - canvas->stop_fullscreen(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 5"); + if( alt_down ) + mwindow->prev_edit_handle(shift_down); else - canvas->start_fullscreen(); - lock_window("CWindowGUI::keypress_event 1"); - break; - case 'x': - if( ctrl_down() || shift_down() || alt_down() ) break; + mwindow->move_left(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 6"); + result = 1; + } + break; + + case ',': + if( !ctrl_down() && !alt_down() ) { unlock_window(); - mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); - mwindow->cut(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 7"); + mwindow->move_left(); mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 2"); - break; - case DELETE: + lock_window("CWindowGUI::keypress_event 8"); + result = 1; + } + break; + + case RIGHT: + if( !ctrl_down() ) { + int alt_down = this->alt_down(); + int shift_down = this->shift_down(); unlock_window(); - mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); - mwindow->clear_entry(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 8"); + if( alt_down ) + mwindow->next_edit_handle(shift_down); + else + mwindow->move_right(); mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 3"); - break; - case ESC: + lock_window("CWindowGUI::keypress_event 9"); + result = 1; + } + break; + + case '.': + if( !ctrl_down() && !alt_down() ) { unlock_window(); - if(mwindow->session->cwindow_fullscreen) - canvas->stop_fullscreen(); - lock_window("CWindowGUI::keypress_event 4"); - break; - case LEFT: - if( !ctrl_down() ) { - int alt_down = this->alt_down(); - int shift_down = this->shift_down(); - unlock_window(); - stop_transport(0); - mwindow->gui->lock_window("CWindowGUI::keypress_event 5"); - if( alt_down ) - mwindow->prev_edit_handle(shift_down); - else - mwindow->move_left(); - mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 6"); - result = 1; - } - break; + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 10"); + mwindow->move_right(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 11"); + result = 1; + } + break; + } - case ',': - if( !ctrl_down() && !alt_down() ) { - unlock_window(); - stop_transport(0); - mwindow->gui->lock_window("CWindowGUI::keypress_event 7"); - mwindow->move_left(); - mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 8"); - result = 1; - } + if( !result && cwindow_operation < 0 && ctrl_down() && shift_down() ) { + switch( get_keypress() ) { + case KEY_F1 ... KEY_F4: // mainmenu, load layout + resend_event(mwindow->gui); + result = 1; break; - - case RIGHT: - if( !ctrl_down() ) { - int alt_down = this->alt_down(); - int shift_down = this->shift_down(); - unlock_window(); - stop_transport(0); - mwindow->gui->lock_window("CWindowGUI::keypress_event 8"); - if( alt_down ) - mwindow->next_edit_handle(shift_down); - else - mwindow->move_right(); - mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 9"); - result = 1; + } + } + if( !result && !ctrl_down() ) { + switch( get_keypress() ) { + case KEY_F1: + if( shift_down() ) { + mwindow->toggle_camera_xyz(); result = 1; } + else + cwindow_operation = CWINDOW_PROTECT; break; - - case '.': - if( !ctrl_down() && !alt_down() ) { - unlock_window(); - stop_transport(0); - mwindow->gui->lock_window("CWindowGUI::keypress_event 10"); - mwindow->move_right(); - mwindow->gui->unlock_window(); - lock_window("CWindowGUI::keypress_event 11"); - result = 1; + case KEY_F2: + if( shift_down() ) { + mwindow->toggle_projector_xyz(); result = 1; } + else + cwindow_operation = CWINDOW_ZOOM; break; - - case KEY_F1: if( shift_down() ) { mwindow->toggle_camera_xyz(); break; } - cwindow_operation = CWINDOW_PROTECT; break; - case KEY_F2: if( shift_down() ) { mwindow->toggle_projector_xyz(); break; } - cwindow_operation = CWINDOW_ZOOM; break; + } + } + if( !result && cwindow_operation < 0 && !ctrl_down() && !shift_down() ) { + switch( get_keypress() ) { case KEY_F3: cwindow_operation = CWINDOW_MASK; break; case KEY_F4: cwindow_operation = CWINDOW_RULER; break; case KEY_F5: cwindow_operation = CWINDOW_CAMERA; break; @@ -578,8 +607,25 @@ int CWindowGUI::keypress_event() case KEY_F8: cwindow_operation = CWINDOW_EYEDROP; break; case KEY_F9: cwindow_operation = CWINDOW_TOOL_WINDOW; break; case KEY_F10: cwindow_operation = CWINDOW_TITLESAFE; break; - case KEY_F11: canvas->reset_camera(); break; - case KEY_F12: canvas->reset_projector(); break; + } + } + if( !result && cwindow_operation < 0 && !ctrl_down() ) { + switch( get_keypress() ) { + case KEY_F11: + if( !shift_down() ) + canvas->reset_camera(); + else + canvas->camera_keyframe(); + result = 1; + break; + case KEY_F12: + if( !shift_down() ) + canvas->reset_projector(); + else + canvas->projector_keyframe(); + result = 1; + break; + } } if( cwindow_operation >= 0 ) { @@ -587,7 +633,8 @@ int CWindowGUI::keypress_event() result = 1; } - if(!result) result = transport->keypress_event(); + if( !result ) + result = transport->keypress_event(); return result; } @@ -622,6 +669,25 @@ void CWindowGUI::keyboard_zoomout() // } } +void CWindowGUI::sync_parameters(int change_type, int redraw, int overlay) +{ + if( redraw ) { + update_tool(); + canvas->refresh(1); + } + if( change_type < 0 && !overlay ) return; + unlock_window(); + if( change_type >= 0 ) { + mwindow->restart_brender(); + mwindow->sync_parameters(change_type); + } + if( overlay ) { + mwindow->gui->lock_window("CWindowGUI::sync_parameters"); + mwindow->gui->draw_overlays(1); + mwindow->gui->unlock_window(); + } + lock_window("CWindowGUI::sync_parameters"); +} void CWindowGUI::drag_motion() { @@ -633,7 +699,7 @@ void CWindowGUI::drag_motion() int need_highlight = cursor_above() && get_cursor_over_window(); if( highlighted == need_highlight ) return; highlighted = need_highlight; - canvas->draw_refresh(); + canvas->refresh(1); } int CWindowGUI::drag_stop() @@ -645,7 +711,7 @@ int CWindowGUI::drag_stop() mwindow->session->current_operation != DRAG_VTRANSITION && mwindow->session->current_operation != DRAG_VEFFECT) return 0; highlighted = 0; - canvas->draw_refresh(); + canvas->refresh(1); result = 1; if(mwindow->session->current_operation == DRAG_ASSET) @@ -689,10 +755,10 @@ int CWindowGUI::drag_stop() { mwindow->save_backup(); mwindow->restart_brender(); - mwindow->gui->update(1, 1, 1, 1, 0, 1, 0); + mwindow->gui->update(1, NORMAL_DRAW, 1, 1, 0, 1, 0); mwindow->undo->update_undo_after(_("insert assets"), LOAD_ALL); mwindow->gui->unlock_window(); - mwindow->sync_parameters(CHANGE_ALL); + sync_parameters(CHANGE_ALL); } } @@ -746,8 +812,6 @@ CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) 1, // use_keyframe 0, // use_splice 0, // use_overwrite - 1, // use_lift - 1, // use_extract 1, // use_copy 1, // use_paste 1, // use_undo @@ -765,51 +829,72 @@ CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) this->cwindow = cwindow; } -#define CWrapper(fn) void CWindowEditing::fn() { \ - mwindow->gui->lock_window("CWrapper::" #fn); \ - EditPanel::fn(); \ - mwindow->gui->unlock_window(); \ -} +#define relock_cm(s) \ + cwindow->gui->unlock_window(); \ + mwindow->gui->lock_window("CWindowEditing::" s) +#define relock_mc(s) \ + mwindow->gui->unlock_window(); \ + cwindow->gui->lock_window("CWindowEditing::" s) +#define panel_fn(fn, args, s) \ + CWindowEditing::fn args { relock_cm(#fn); s; relock_mc(#fn); } + +// transmit lock to mwindow, and run mbutton->edit_panel->s +#define panel_btn(fn, args, s) \ + panel_fn(panel_##fn, args, mwindow->gui->mbuttons->edit_panel->panel_##s) -CWrapper(copy_selection) -CWrapper(splice_selection) -CWrapper(overwrite_selection) -CWrapper(set_inpoint) -CWrapper(set_outpoint) -CWrapper(unset_inoutpoint) -CWrapper(toggle_label) -#define CWrapper_cut(fn) void CWindowEditing::fn(int cut) { \ - mwindow->gui->lock_window("CWrapper::" #fn); \ - EditPanel::fn(cut); \ - mwindow->gui->unlock_window(); \ +double CWindowEditing::get_position() +{ + relock_cm("get_position"); + double ret = mwindow->edl->local_session->get_selectionstart(1); + relock_mc("get_position"); + return ret; } -CWrapper_cut(prev_label) -CWrapper_cut(next_label) -CWrapper_cut(prev_edit) -CWrapper_cut(next_edit) -void CWindowEditing::to_clip() +void CWindowEditing::set_position(double position) { - mwindow->to_clip(mwindow->edl, _("composer window: "), 0); + relock_cm("set_position"); + mwindow->gui->mbuttons->edit_panel->set_position(position); + relock_mc("set_position"); } +void CWindowEditing::set_click_to_play(int v) +{ + relock_cm("set_position"); + mwindow->edl->session->cwindow_click2play = v; + relock_mc("set_position"); + click2play->update(v); +} + + +void panel_btn(stop_transport,(), stop_transport()) +void panel_btn(toggle_label,(), toggle_label()) +void panel_btn(next_label,(int cut), next_label(cut)) +void panel_btn(prev_label,(int cut), prev_label(cut)) +void panel_btn(next_edit,(int cut), next_edit(cut)) +void panel_btn(prev_edit,(int cut), prev_edit(cut)) +void panel_fn(panel_copy_selection,(), mwindow->copy()) +void CWindowEditing::panel_overwrite_selection() {} // not used +void CWindowEditing::panel_splice_selection() {} // not used +void panel_btn(set_inpoint,(), set_inpoint()) +void panel_btn(set_outpoint,(), set_outpoint()) +void panel_btn(unset_inoutpoint,(), unset_inoutpoint()) +void panel_fn(panel_to_clip,(), mwindow->to_clip(mwindow->edl, _("main window: "), 0)) +void panel_btn(cut,(), cut()) +void panel_btn(paste,(), paste()) +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_labels_follow_edits,(int v), set_labels_follow_edits(v)) + CWindowMeters::CWindowMeters(MWindow *mwindow, - CWindowGUI *gui, - int x, - int y, - int h) - : MeterPanel(mwindow, - gui, - x, - y, - -1, - h, + CWindowGUI *gui, int x, int y, int h) + : MeterPanel(mwindow, gui, x, y, -1, h, mwindow->edl->session->audio_channels, mwindow->edl->session->cwindow_meter, - 0, - 0) + 0, 0) { this->mwindow = mwindow; this->gui = gui; @@ -1009,17 +1094,6 @@ void CWindowCanvas::status_event() gui->draw_status(1); } -int CWindowCanvas::get_fullscreen() -{ - return mwindow->session->cwindow_fullscreen; -} - -void CWindowCanvas::set_fullscreen(int value) -{ - mwindow->session->cwindow_fullscreen = value; -} - - void CWindowCanvas::update_zoom(int x, int y, float zoom) { use_scrollbars = mwindow->edl->session->cwindow_scrollbars; @@ -1052,43 +1126,23 @@ float CWindowCanvas::get_zoom() void CWindowCanvas::draw_refresh(int flush) { - if(get_canvas() && !get_canvas()->get_video_on()) - { - - if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0) - { + BC_WindowBase *window = get_canvas(); + if( window && !window->get_video_on() ) { + clear(0); + if( refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0 ) { float in_x1, in_y1, in_x2, in_y2; float out_x1, out_y1, out_x2, out_y2; get_transfers(mwindow->edl, - in_x1, - in_y1, - in_x2, - in_y2, - out_x1, - out_y1, - out_x2, - out_y2); - - if(!EQUIV(out_x1, 0) || - !EQUIV(out_y1, 0) || - !EQUIV(out_x2, get_canvas()->get_w()) || - !EQUIV(out_y2, get_canvas()->get_h())) - { - get_canvas()->clear_box(0, - 0, - get_canvas()->get_w(), - get_canvas()->get_h()); - } + in_x1, in_y1, in_x2, in_y2, + out_x1, out_y1, out_x2, out_y2); + //printf("CWindowCanvas::draw_refresh %.2f %.2f %.2f %.2f -> %.2f %.2f %.2f %.2f\n", //in_x1, in_y1, in_x2, in_y2, out_x1, out_y1, out_x2, out_y2); - if(out_x2 > out_x1 && - out_y2 > out_y1 && - in_x2 > in_x1 && - in_y2 > in_y1) - { + if( out_x2 > out_x1 && out_y2 > out_y1 && + in_x2 > in_x1 && in_y2 > in_y1 ) { // input scaled from session to refresh frame coordinates int ow = get_output_w(mwindow->edl); int oh = get_output_h(mwindow->edl); @@ -1100,31 +1154,19 @@ void CWindowCanvas::draw_refresh(int flush) in_y1 *= ys; in_y2 *= ys; // Can't use OpenGL here because it is called asynchronously of the // playback operation. - get_canvas()->draw_vframe(refresh_frame, - (int)out_x1, - (int)out_y1, + window->draw_vframe(refresh_frame, + (int)out_x1, (int)out_y1, (int)(out_x2 - out_x1), (int)(out_y2 - out_y1), - (int)in_x1, - (int)in_y1, + (int)in_x1, (int)in_y1, (int)(in_x2 - in_x1), (int)(in_y2 - in_y1), 0); } } - else - { - get_canvas()->clear_box(0, - 0, - get_canvas()->get_w(), - get_canvas()->get_h()); - } - +//usleep(10000); draw_overlays(); -// allow last opengl write to complete before redraw -// tried sync_display, glFlush, glxMake*Current(0..) -usleep(20000); - get_canvas()->flash(flush); + window->flash(flush); } //printf("CWindowCanvas::draw_refresh 10\n"); } @@ -1138,10 +1180,6 @@ void CWindowCanvas::draw_crophandle(int x, int y) } - - - - #define CONTROL_W 10 #define CONTROL_H 10 #define FIRST_CONTROL_W 20 @@ -1152,8 +1190,6 @@ void CWindowCanvas::draw_crophandle(int x, int y) #define RULERHANDLE_W 16 #define RULERHANDLE_H 16 - - int CWindowCanvas::do_ruler(int draw, int motion, int button_press, @@ -1447,11 +1483,17 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, if(!track) return 0; //printf("CWindowCanvas::do_mask 3\n"); - + CWindowMaskGUI *mask_gui = (CWindowMaskGUI *) + (gui->tool_panel ? gui->tool_panel->tool_gui : 0); + int draw_markers = mask_gui ? mask_gui->markers : 0; + int draw_boundary = mask_gui ? mask_gui->boundary : 0; MaskAutos *mask_autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK]; int64_t position = track->to_units( mwindow->edl->local_session->get_selectionstart(1), 0); + Auto *prev_auto = 0; + mask_autos->get_prev_auto(position, PLAY_FORWARD, (Auto *&)prev_auto, 1); + MaskAuto *prev_mask = (MaskAuto *)prev_auto; ArrayList points; // Determine the points based on whether @@ -1459,19 +1501,16 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, // If keyframe generation occurs, use the interpolated mask. // If no keyframe generation occurs, use the previous mask. int use_interpolated = 0; - if(button_press || cursor_motion) { + if( button_press || cursor_motion ) { #ifdef USE_KEYFRAME_SPANNING double selection_start = mwindow->edl->local_session->get_selectionstart(0); double selection_end = mwindow->edl->local_session->get_selectionend(0); - - Auto *first = 0; - mask_autos->get_prev_auto(track->to_units(selection_start, 0), - PLAY_FORWARD, first, 1); - Auto *last = 0; - mask_autos->get_prev_auto(track->to_units(selection_end, 0), - PLAY_FORWARD, last, 1); - - if(last == first && (!mwindow->edl->session->auto_keyframes)) + int64_t start_pos = track->to_units(selection_start, 0); + int64_t end_pos = track->to_units(selection_end, 0); + Auto *first = 0, *last = 0; + mask_autos->get_prev_auto(start_pos, PLAY_FORWARD, first, 1); + mask_autos->get_prev_auto(end_pos, PLAY_FORWARD, last, 1); + if( last == first && (!mwindow->edl->session->auto_keyframes) ) use_interpolated = 0; else // If keyframe spanning occurs, use the interpolated points. @@ -1479,28 +1518,22 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, use_interpolated = 1; #else - if(mwindow->edl->session->auto_keyframes) + if( mwindow->edl->session->auto_keyframes ) use_interpolated = 1; #endif } else use_interpolated = 1; - if(use_interpolated) { + if( use_interpolated ) { // Interpolate the points to get exactly what is being rendered at this position. mask_autos->get_points(&points, mwindow->edl->session->cwindow_mask, - position, - PLAY_FORWARD); + position, PLAY_FORWARD); } else { // Use the prev mask - Auto *prev = 0; - mask_autos->get_prev_auto(position, - PLAY_FORWARD, - prev, - 1); - ((MaskAuto*)prev)->get_points(&points, + prev_mask->get_points(&points, mwindow->edl->session->cwindow_mask); } @@ -1674,15 +1707,15 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, output_to_canvas(mwindow->edl, 0, canvas_x, canvas_y); - if(j > 0) { + if( j > 0 ) { - if(draw) { // Draw joining line + if( draw ) { // Draw joining line x_points.append((int)canvas_x); y_points.append((int)canvas_y); } - if(j == segments) { - if(draw) { // Draw second anchor + if( j == segments ) { + if( draw && draw_markers ) { // Draw second anchor if(i < points.size() - 1) { if(i == gui->affected_point - 1) get_canvas()->draw_disc( @@ -1712,23 +1745,29 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, } else { // Draw first anchor - if(i == 0 && draw) { - char mask_label[BCSTRLEN]; - sprintf(mask_label, "%d", - mwindow->edl->session->cwindow_mask); - get_canvas()->draw_text( - (int)canvas_x - FIRST_CONTROL_W, - (int)canvas_y - FIRST_CONTROL_H, - mask_label); - - get_canvas()->draw_disc( - (int)canvas_x - FIRST_CONTROL_W / 2, - (int)canvas_y - FIRST_CONTROL_H / 2, - FIRST_CONTROL_W, FIRST_CONTROL_H); + if( i == 0 && draw ) { + if( draw_boundary ) { + char mask_label[BCSTRLEN]; + int k = mwindow->edl->session->cwindow_mask; + if( !prev_mask || k < 0 || k >= prev_mask->masks.size() ) + sprintf(mask_label, "%d", k); + else + sprintf(mask_label, "%s", prev_mask->masks[k]->name); + get_canvas()->draw_text( + (int)canvas_x - FIRST_CONTROL_W, + (int)canvas_y - FIRST_CONTROL_H, + mask_label); + } + if( draw_markers ) { + get_canvas()->draw_disc( + (int)canvas_x - FIRST_CONTROL_W / 2, + (int)canvas_y - FIRST_CONTROL_H / 2, + FIRST_CONTROL_W, FIRST_CONTROL_H); + } } // Draw first control point. - if(draw) { + if( draw && draw_markers ) { output_to_canvas(mwindow->edl, 0, canvas_x1, canvas_y1); get_canvas()->draw_line( (int)canvas_x, (int)canvas_y, @@ -1748,9 +1787,23 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, } //printf("CWindowCanvas::do_mask 1\n"); - if(draw) { - get_canvas()->draw_polygon(&x_points, &y_points); - get_canvas()->set_opaque(); + BC_WindowBase *cvs_win = get_canvas(); + if( draw && draw_boundary ) { + cvs_win->draw_polygon(&x_points, &y_points); + cvs_win->set_opaque(); + } + 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()); + output_to_canvas(mwindow->edl, 0, fx, fy); + float r = bmax(cvs_win->get_w(), cvs_win->get_h()); + float d = 0.005*r; + cvs_win->set_line_width((int)(0.0025*r) + 1); + cvs_win->set_color(BLUE); + cvs_win->draw_line(fx-d,fy-d, fx+d, fy+d); + cvs_win->draw_line(fx-d,fy+d, fx+d, fy-d); + cvs_win->set_line_width(0); + cvs_win->set_color(WHITE); } //printf("CWindowCanvas::do_mask 1\n"); } @@ -1779,7 +1832,18 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, } SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask); - + if( get_buttonpress() == WHEEL_UP || get_buttonpress() == WHEEL_DOWN ) { + if( !gui->shift_down() ) { + mwindow->undo->update_undo_before(_("mask rotate"), this); + gui->current_operation = CWINDOW_MASK_ROTATE; + } + else { + mwindow->undo->update_undo_before(_("mask scale"), this); + gui->current_operation = CWINDOW_MASK_SCALE; + } + gui->affected_point = 0; + } + else // Translate entire keyframe if(gui->alt_down() && mask->points.size()) { mwindow->undo->update_undo_before(_("mask translate"), 0); @@ -1949,36 +2013,36 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, if(button_press && result) { #ifdef USE_KEYFRAME_SPANNING - MaskPoint *point = points.values[gui->affected_point]; - gui->center_x = point->x; - gui->center_y = point->y; - gui->control_in_x = point->control_x1; - gui->control_in_y = point->control_y1; - gui->control_out_x = point->control_x2; - gui->control_out_y = point->control_y2; - gui->tool_panel->raise_window(); + ArrayList &mask_points = points; #else SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask); - MaskPoint *point = mask->points.values[gui->affected_point]; - gui->center_x = point->x; - gui->center_y = point->y; - gui->control_in_x = point->control_x1; - gui->control_in_y = point->control_y1; - gui->control_out_x = point->control_x2; - gui->control_out_y = point->control_y2; - gui->tool_panel->raise_window(); + ArrayList &mask_points = mask->points; #endif + int k = gui->affected_point; + if( k >= 0 && k < mask_points.size() ) { + MaskPoint *point = mask_points.values[k]; + gui->center_x = point->x; + gui->center_y = point->y; + gui->control_in_x = point->control_x1; + gui->control_in_y = point->control_y1; + gui->control_out_x = point->control_x2; + gui->control_out_y = point->control_y2; + } + else { + gui->center_x = gui->center_y = 0; + gui->control_in_x = gui->control_in_y = 0; + gui->control_out_x = gui->control_out_y = 0; + } + gui->tool_panel->raise_window(); } //printf("CWindowCanvas::do_mask 8\n"); - if(cursor_motion) { + if( cursor_motion ) { #ifdef USE_KEYFRAME_SPANNING // Must update the reference keyframes for every cursor motion - gui->mask_keyframe = - (MaskAuto*)gui->cwindow->calculate_affected_auto( - mask_autos, - 0); + gui->mask_keyframe = (MaskAuto*)gui->cwindow-> + calculate_affected_auto(mask_autos, 0); gui->orig_mask_keyframe->copy_data(gui->mask_keyframe); #endif @@ -1989,12 +2053,13 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, gui->current_operation != CWINDOW_NONE) { // mwindow->undo->update_undo_before(_("mask point"), this); #ifdef USE_KEYFRAME_SPANNING - MaskPoint *point = points.get(gui->affected_point); + ArrayList &mask_points = points; #else - MaskPoint *point = mask->points.get(gui->affected_point); + ArrayList &mask_points = mask->points; #endif + MaskPoint *point = mask_points.get(gui->affected_point); // canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); -//printf("CWindowCanvas::do_mask 9 %d %d\n", mask->points.size(), gui->affected_point); +//printf("CWindowCanvas::do_mask 9 %d %d\n", mask_points.size(), gui->affected_point); float last_x = point->x; float last_y = point->y; @@ -2002,39 +2067,62 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, float last_control_y1 = point->control_y1; float last_control_x2 = point->control_x2; float last_control_y2 = point->control_y2; + int rotate = 0; switch(gui->current_operation) { - case CWINDOW_MASK: + case CWINDOW_MASK: //printf("CWindowCanvas::do_mask %d %d\n", __LINE__, gui->affected_point); - point->x = mask_cursor_x - gui->x_origin + gui->center_x; - point->y = mask_cursor_y - gui->y_origin + gui->center_y; - break; + point->x = mask_cursor_x - gui->x_origin + gui->center_x; + point->y = mask_cursor_y - gui->y_origin + gui->center_y; + break; - case CWINDOW_MASK_CONTROL_IN: - point->control_x1 = mask_cursor_x - gui->x_origin + gui->control_in_x; - point->control_y1 = mask_cursor_y - gui->y_origin + gui->control_in_y; - break; + case CWINDOW_MASK_CONTROL_IN: + point->control_x1 = mask_cursor_x - gui->x_origin + gui->control_in_x; + point->control_y1 = mask_cursor_y - gui->y_origin + gui->control_in_y; + break; - case CWINDOW_MASK_CONTROL_OUT: - point->control_x2 = mask_cursor_x - gui->x_origin + gui->control_out_x; - point->control_y2 = mask_cursor_y - gui->y_origin + gui->control_out_y; - break; + case CWINDOW_MASK_CONTROL_OUT: + point->control_x2 = mask_cursor_x - gui->x_origin + gui->control_out_x; + point->control_y2 = mask_cursor_y - gui->y_origin + gui->control_out_y; + break; - case CWINDOW_MASK_TRANSLATE: -#ifdef USE_KEYFRAME_SPANNING - for(int i = 0; i < points.size(); i++) { - points.values[i]->x += mask_cursor_x - gui->x_origin; - points.values[i]->y += mask_cursor_y - gui->y_origin; - } -#else - 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; - } -#endif - gui->x_origin = mask_cursor_x; - gui->y_origin = mask_cursor_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; + } + gui->x_origin = mask_cursor_x; + gui->y_origin = mask_cursor_y; + 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); + gui->x_origin = mask_cursor_x; + gui->y_origin = mask_cursor_y; + if( mask_gui && mask_gui->focused ) { + gui->x_origin = atof(mask_gui->focus_x->get_text()); + gui->y_origin = atof(mask_gui->focus_y->get_text()); + } + 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; + } + break; } } if( !EQUIV(last_x, point->x) || @@ -2112,6 +2200,20 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, return result; } +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); + int v = mask_gui->focused ? 0 : 1; + get_canvas()->unlock_window(); + mask_gui->lock_window("CWindowCanvas::do_mask_focus"); + mask_gui->set_focused(v, cx, cy); + mask_gui->unlock_window(); + get_canvas()->lock_window("CWindowCanvas::do_mask_focus"); + return 1; +} + int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw) { int result = 0; @@ -2385,11 +2487,11 @@ void CWindowCanvas::draw_overlays() switch(mwindow->edl->session->cwindow_operation) { case CWINDOW_CAMERA: - draw_bezier(1); + draw_outlines(1); break; case CWINDOW_PROJECTOR: - draw_bezier(0); + draw_outlines(0); break; case CWINDOW_CROP: @@ -2449,44 +2551,60 @@ void CWindowCanvas::draw_safe_regions() get_canvas()->set_opaque(); } -void CWindowCanvas::reset_keyframe(int do_camera) -{ - FloatAuto *x_keyframe = 0; - FloatAuto *y_keyframe = 0; - FloatAuto *z_keyframe = 0; - Track *affected_track = 0; - affected_track = gui->cwindow->calculate_affected_track(); +void CWindowCanvas::create_keyframe(int do_camera) +{ + Track *affected_track = gui->cwindow->calculate_affected_track(); + if( affected_track ) { + double pos = mwindow->edl->local_session->get_selectionstart(1); + int64_t position = affected_track->to_units(pos, 0); + int ix = do_camera ? AUTOMATION_CAMERA_X : AUTOMATION_PROJECTOR_X; + int iy = do_camera ? AUTOMATION_CAMERA_Y : AUTOMATION_PROJECTOR_Y; + int iz = do_camera ? AUTOMATION_CAMERA_Z : AUTOMATION_PROJECTOR_Z; + FloatAuto *prev, *next; + FloatAutos **autos = (FloatAutos**)affected_track->automation->autos; + FloatAutos *x_autos = autos[ix]; prev = 0; next = 0; + float x_value = x_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAutos *y_autos = autos[iy]; prev = 0; next = 0; + float y_value = y_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAutos *z_autos = autos[iz]; prev = 0; next = 0; + float z_value = z_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAuto *x_keyframe = 0, *y_keyframe = 0, *z_keyframe = 0; + + gui->cwindow->calculate_affected_autos(affected_track, + &x_keyframe, &y_keyframe, &z_keyframe, + do_camera, -1, -1, -1, 0); + x_keyframe->set_value(x_value); + y_keyframe->set_value(y_value); + z_keyframe->set_value(z_value); + + gui->sync_parameters(CHANGE_PARAMS, 1, 1); + } +} - if(affected_track) - { - gui->cwindow->calculate_affected_autos(&x_keyframe, - &y_keyframe, - &z_keyframe, - affected_track, - do_camera, - 1, - 1, - 1); +void CWindowCanvas::camera_keyframe() { create_keyframe(1); } +void CWindowCanvas::projector_keyframe() { create_keyframe(0); } + +void CWindowCanvas::reset_keyframe(int do_camera) +{ + Track *affected_track = gui->cwindow->calculate_affected_track(); + if( affected_track ) { + FloatAuto *x_keyframe = 0, *y_keyframe = 0, *z_keyframe = 0; + gui->cwindow->calculate_affected_autos(affected_track, + &x_keyframe, &y_keyframe, &z_keyframe, + do_camera, 1, 1, 1); x_keyframe->set_value(0); y_keyframe->set_value(0); z_keyframe->set_value(1); - mwindow->sync_parameters(CHANGE_PARAMS); - gui->update_tool(); + gui->sync_parameters(CHANGE_PARAMS, 1, 1); } } -void CWindowCanvas::reset_camera() -{ - reset_keyframe(1); -} +void CWindowCanvas::reset_camera() { reset_keyframe(1); } +void CWindowCanvas::reset_projector() { reset_keyframe(0); } -void CWindowCanvas::reset_projector() -{ - reset_keyframe(0); -} int CWindowCanvas::test_crop(int button_press, int &redraw) { @@ -2784,71 +2902,58 @@ void CWindowCanvas::draw_crop() } - - - - - - -void CWindowCanvas::draw_bezier(int do_camera) +void CWindowCanvas::draw_outlines(int do_camera) { Track *track = gui->cwindow->calculate_affected_track(); if(!track) return; - float center_x; - float center_y; - float center_z; + float proj_x, proj_y, proj_z; int64_t position = track->to_units( mwindow->edl->local_session->get_selectionstart(1), 0); - - track->automation->get_projector(¢er_x, - ¢er_y, - ¢er_z, - position, - PLAY_FORWARD); - -// center_x += track->track_w / 2; -// center_y += track->track_h / 2; - center_x += mwindow->edl->session->output_w / 2; - center_y += mwindow->edl->session->output_h / 2; - float track_x1 = center_x - track->track_w / 2 * center_z; - float track_y1 = center_y - track->track_h / 2 * center_z; - float track_x2 = track_x1 + track->track_w * center_z; - float track_y2 = track_y1 + track->track_h * center_z; - - output_to_canvas(mwindow->edl, 0, track_x1, track_y1); - output_to_canvas(mwindow->edl, 0, track_x2, track_y2); + track->automation->get_projector(&proj_x, &proj_y, &proj_z, + position, PLAY_FORWARD); + + proj_x += mwindow->edl->session->output_w/2.; + proj_y += mwindow->edl->session->output_h/2.; + float proj_x1 = proj_x - track->track_w/2. * proj_z; + float proj_y1 = proj_y - track->track_h/2. * proj_z; + float proj_x2 = proj_x + track->track_w/2. * proj_z; + float proj_y2 = proj_y + track->track_h/2. * proj_z; + float x1 = proj_x1, x2 = proj_x2; + float y1 = proj_y1, y2 = proj_y2; + output_to_canvas(mwindow->edl, 0, x1, y1); + output_to_canvas(mwindow->edl, 0, x2, y2); #define DRAW_PROJECTION(offset) \ - get_canvas()->draw_rectangle((int)track_x1 + offset, \ - (int)track_y1 + offset, \ - (int)(track_x2 - track_x1), \ - (int)(track_y2 - track_y1)); \ - get_canvas()->draw_line((int)track_x1 + offset, \ - (int)track_y1 + offset, \ - (int)track_x2 + offset, \ - (int)track_y2 + offset); \ - get_canvas()->draw_line((int)track_x2 + offset, \ - (int)track_y1 + offset, \ - (int)track_x1 + offset, \ - (int)track_y2 + offset); \ - + get_canvas()->draw_rectangle(x1+offset, y1+offset, (x2-x1), (y2-y1)); \ + get_canvas()->draw_line(x1+offset, y1+offset, x2+offset, y2+offset); \ + get_canvas()->draw_line(x2+offset, y1+offset, x1+offset, y2+offset); \ // Drop shadow get_canvas()->set_color(BLACK); DRAW_PROJECTION(1); - -// canvas->set_inverse(); - if(do_camera) - get_canvas()->set_color(GREEN); - else - get_canvas()->set_color(RED); - + get_canvas()->set_color(do_camera ? GREEN : RED); DRAW_PROJECTION(0); -// canvas->set_opaque(); + if( do_camera ) { + float cam_x, cam_y, cam_z; + track->automation->get_camera(&cam_x, &cam_y, &cam_z, + position, PLAY_FORWARD); + cam_x += track->track_w / 2.; + cam_y += track->track_h / 2.; +// follow image, not camera + cam_x = -cam_x; cam_y = -cam_y; cam_z *= proj_z; + float cam_x1 = cam_x * cam_z + proj_x; + float cam_y1 = cam_y * cam_z + proj_y; + float cam_x2 = (cam_x + track->track_w) * cam_z + proj_x; + float cam_y2 = (cam_y + track->track_h) * cam_z + proj_y; + output_to_canvas(mwindow->edl, 0, cam_x1, cam_y1); + output_to_canvas(mwindow->edl, 0, cam_x2, cam_y2); + get_canvas()->set_color(YELLOW); + get_canvas()->draw_rectangle(cam_x1, cam_y1, cam_x2-cam_x1, cam_y2-cam_y1); + } } int CWindowCanvas::test_bezier(int button_press, @@ -2861,114 +2966,71 @@ int CWindowCanvas::test_bezier(int button_press, // Processing drag operation. // Create keyframe during first cursor motion. - if(!button_press) - { + if( !button_press ) { float cursor_x = get_cursor_x(); float cursor_y = get_cursor_y(); canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); - if(gui->current_operation == CWINDOW_CAMERA || - gui->current_operation == CWINDOW_PROJECTOR) - { - if(!gui->ctrl_down() && gui->shift_down() && !gui->translating_zoom) - { + if( gui->current_operation == CWINDOW_CAMERA || + gui->current_operation == CWINDOW_PROJECTOR ) { + if( !gui->ctrl_down() && gui->shift_down() && !gui->translating_zoom ) { gui->translating_zoom = 1; gui->reset_affected(); } - else - if(!gui->ctrl_down() && !gui->shift_down() && gui->translating_zoom) - { + else if( !gui->ctrl_down() && !gui->shift_down() && gui->translating_zoom ) { gui->translating_zoom = 0; gui->reset_affected(); } // Get target keyframe - float last_center_x; - float last_center_y; - float last_center_z; - int created; - - if(!gui->affected_x && !gui->affected_y && !gui->affected_z) - { - FloatAutos *affected_x_autos; - FloatAutos *affected_y_autos; - FloatAutos *affected_z_autos; + if( !gui->affected_x && !gui->affected_y && !gui->affected_z ) { if(!gui->affected_track) return 0; + FloatAutos *affected_x_autos, *affected_y_autos, *affected_z_autos; + FloatAutos** autos = (FloatAutos**) gui->affected_track->automation->autos; + if( mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA ) { + affected_x_autos = autos[AUTOMATION_CAMERA_X]; + affected_y_autos = autos[AUTOMATION_CAMERA_Y]; + affected_z_autos = autos[AUTOMATION_CAMERA_Z]; + } + else { + affected_x_autos = autos[AUTOMATION_PROJECTOR_X]; + affected_y_autos = autos[AUTOMATION_PROJECTOR_Y]; + affected_z_autos = autos[AUTOMATION_PROJECTOR_Z]; + } double position = mwindow->edl->local_session->get_selectionstart(1); int64_t track_position = gui->affected_track->to_units(position, 0); - - if(mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA) - { - affected_x_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_X]; - affected_y_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_Y]; - affected_z_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_CAMERA_Z]; - } - else - { - affected_x_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_X]; - affected_y_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_Y]; - affected_z_autos = (FloatAutos*)gui->affected_track->automation->autos[AUTOMATION_PROJECTOR_Z]; + FloatAuto *prev_x = 0, *next_x = 0; + float new_x = affected_x_autos->get_value(track_position, PLAY_FORWARD, prev_x, next_x); + FloatAuto *prev_y = 0, *next_y = 0; + float new_y = affected_y_autos->get_value(track_position, PLAY_FORWARD, prev_y, next_y); + FloatAuto *prev_z = 0, *next_z = 0; + float new_z = affected_z_autos->get_value(track_position, PLAY_FORWARD, prev_z, next_z); + int zooming = gui->translating_zoom, created; + gui->affected_x = (FloatAuto*)gui->cwindow->calculate_affected_auto( + affected_x_autos, !zooming, &created, 0); + if( created ) { + gui->affected_x->set_value(new_x); + redraw_canvas = 1; } - - - if(gui->translating_zoom) - { - FloatAuto *previous = 0; - FloatAuto *next = 0; - float new_z = affected_z_autos->get_value( - track_position, - PLAY_FORWARD, - previous, - next); - gui->affected_z = - (FloatAuto*)gui->cwindow->calculate_affected_auto( - affected_z_autos, 1, &created, 0); - if(created) { - gui->affected_z->set_value(new_z); - redraw_canvas = 1; - } + gui->affected_y = (FloatAuto*)gui->cwindow->calculate_affected_auto( + affected_y_autos, !zooming, &created, 0); + if( created ) { + gui->affected_y->set_value(new_y); + redraw_canvas = 1; } - else - { - FloatAuto *previous = 0; - FloatAuto *next = 0; - float new_x = affected_x_autos->get_value( - track_position, - PLAY_FORWARD, - previous, - next); - previous = 0; - next = 0; - float new_y = affected_y_autos->get_value( - track_position, - PLAY_FORWARD, - previous, - next); - gui->affected_x = - (FloatAuto*)gui->cwindow->calculate_affected_auto( - affected_x_autos, 1, &created, 0); - if(created) { - gui->affected_x->set_value(new_x); - redraw_canvas = 1; - } - gui->affected_y = - (FloatAuto*)gui->cwindow->calculate_affected_auto( - affected_y_autos, 1, &created, 0); - if(created) { - gui->affected_y->set_value(new_y); - redraw_canvas = 1; - } + gui->affected_z = (FloatAuto*)gui->cwindow->calculate_affected_auto( + affected_z_autos, zooming, &created, 0); + if( created ) { + gui->affected_z->set_value(new_z); + redraw_canvas = 1; } - calculate_origin(); - if(gui->translating_zoom) - { + if( gui->translating_zoom ) { gui->center_z = gui->affected_z->get_value(); } - else - { + else { gui->center_x = gui->affected_x->get_value(); gui->center_y = gui->affected_y->get_value(); } @@ -2977,40 +3039,36 @@ int CWindowCanvas::test_bezier(int button_press, redraw = 1; } - if(gui->translating_zoom) - { - last_center_z = gui->affected_z->get_value(); + float x_val = gui->affected_x->get_value(); + float y_val = gui->affected_y->get_value(); + float z_val = gui->affected_z->get_value(); + + if( gui->translating_zoom ) { float z = gui->center_z + (cursor_y - gui->y_origin) / 128; if( z < 0 ) z = 0; - if(!EQUIV(last_center_z, z)) - { + if( !EQUIV(z_val, z) ) { rerender = 1; redraw = 1; redraw_canvas = 1; } gui->affected_z->set_value(z); } - else - { - last_center_x = gui->affected_x->get_value(); - last_center_y = gui->affected_y->get_value(); + else { float dx = cursor_x - gui->x_origin; float dy = cursor_y - gui->y_origin; - if(gui->current_operation == CWINDOW_CAMERA ) { - dx = -dx; dy = -dy; +// follow image, not camera + if( gui->current_operation == CWINDOW_CAMERA ) { + dx = -dx / z_val; dy = -dy / z_val; } float x = gui->center_x + dx; float y = gui->center_y + dy; gui->affected_x->set_value(x); gui->affected_y->set_value(y); - if( !EQUIV(last_center_x, x) || !EQUIV(last_center_y, y) ) - { + if( !EQUIV(x_val, x) || !EQUIV(y_val, y) ) { rerender = 1; redraw = 1; redraw_canvas = 1; } - gui->affected_x->set_value(x); - gui->affected_y->set_value(y); } } @@ -3027,7 +3085,7 @@ int CWindowCanvas::test_bezier(int button_press, if(gui->affected_track) { - if(gui->current_operation == CWINDOW_CAMERA) + if( do_camera ) mwindow->undo->update_undo_before(_("camera"), this); else mwindow->undo->update_undo_before(_("projector"), this); @@ -3239,38 +3297,9 @@ int CWindowCanvas::cursor_motion_event() } } + int change_type = rerender ? CHANGE_PARAMS : -1; + gui->sync_parameters(change_type, redraw, redraw_canvas); -// If the window is never unlocked before calling send_command the -// display shouldn't get stuck on the old video frame although it will -// flicker between the old video frame and the new video frame. - - if(redraw) - { - draw_refresh(); - gui->update_tool(); - } - - if(redraw_canvas) - { - gui->unlock_window(); - - - mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1"); - mwindow->gui->draw_overlays(1); - mwindow->gui->unlock_window(); - - gui->lock_window("CWindowCanvas::cursor_motion_event 1"); - } - - if(rerender) - { - gui->unlock_window(); - mwindow->restart_brender(); - mwindow->sync_parameters(CHANGE_PARAMS); - mwindow->cwindow->refresh_frame(CHANGE_NONE); - if(!redraw) gui->update_tool(); - gui->lock_window("CWindowCanvas::cursor_motion_event 2"); - } return result; } @@ -3295,7 +3324,7 @@ int CWindowCanvas::button_press_event() // Scroll view if( mwindow->edl->session->cwindow_operation != CWINDOW_PROTECT && - get_buttonpress() == 2 ) + get_buttonpress() == MIDDLE_BUTTON && !get_canvas()->shift_down() ) { gui->current_operation = CWINDOW_SCROLL; result = 1; @@ -3326,8 +3355,21 @@ int CWindowCanvas::button_press_event() break; case CWINDOW_MASK: - if(get_buttonpress() == 1) + switch( get_buttonpress() ) { + case LEFT_BUTTON: result = do_mask(redraw, rerender, 1, 0, 0); + break; + case MIDDLE_BUTTON: { // && shift_down() + result = do_mask_focus(); + redraw = 1; + redraw_canvas = 1; + break; } + case WHEEL_UP: + case WHEEL_DOWN: + result = do_mask(redraw, rerender, 1, 1, 0); + break; + } + if( result ) redraw_canvas = 1; break; case CWINDOW_EYEDROP: @@ -3336,37 +3378,16 @@ int CWindowCanvas::button_press_event() } } - if(redraw) - { - draw_refresh(); - gui->unlock_window(); - - - mwindow->gui->lock_window("CWindowCanvas::button_press_event 1"); - mwindow->gui->draw_overlays(1); - mwindow->gui->unlock_window(); - gui->update_tool(); - - gui->lock_window("CWindowCanvas::button_press_event 1"); - } + int change_type = rerender ? CHANGE_PARAMS : -1; + gui->sync_parameters(change_type, redraw, redraw_canvas); -// rerendering can also be caused by press event - if(rerender) - { - gui->unlock_window(); - - mwindow->restart_brender(); - mwindow->sync_parameters(CHANGE_PARAMS); - mwindow->cwindow->refresh_frame(CHANGE_NONE); - if(!redraw) gui->update_tool(); - gui->lock_window("CWindowCanvas::button_press_event 2"); - } return result; } int CWindowCanvas::button_release_event() { int result = 0; + const char *undo_label = 0; switch(gui->current_operation) { @@ -3379,11 +3400,11 @@ int CWindowCanvas::button_release_event() break; case CWINDOW_CAMERA: - mwindow->undo->update_undo_after(_("camera"), LOAD_AUTOMATION); + undo_label = _("camera"); break; case CWINDOW_PROJECTOR: - mwindow->undo->update_undo_after(_("projector"), LOAD_AUTOMATION); + undo_label = _("projector"); break; case CWINDOW_MASK: @@ -3392,13 +3413,23 @@ int CWindowCanvas::button_release_event() case CWINDOW_MASK_TRANSLATE: // Finish mask operation gui->mask_keyframe = 0; - mwindow->undo->update_undo_after(_("mask"), LOAD_AUTOMATION); + undo_label = _("mask"); + break; + case CWINDOW_MASK_ROTATE: + gui->mask_keyframe = 0; + undo_label = _("mask rotate"); + break; + case CWINDOW_MASK_SCALE: + gui->mask_keyframe = 0; + undo_label = _("mask scale"); break; case CWINDOW_NONE: result = Canvas::button_release_event(); break; } + if( undo_label ) + mwindow->undo->update_undo_after(undo_label, LOAD_AUTOMATION); gui->current_operation = CWINDOW_NONE; return result; }