X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=5d925e6e1a3650180ba13526f339be1033192108;hb=55ccff122957ddfaa871cf8f251cfe866732c870;hp=a0ba9f27a4c406391329bb31d50d85c5719ef855;hpb=b5c58822be78c8820692c916e296a2230bb2b9e2;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index a0ba9f27..5d925e6e 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -26,7 +26,7 @@ #include "bcsignals.h" #include "bctimer.h" #include "clip.h" -#include "colors.h" +#include "bccolors.h" #include "cplayback.h" #include "cursors.h" #include "cwindowgui.h" @@ -46,6 +46,7 @@ #include "keyframepopup.h" #include "keyframes.h" #include "keys.h" +#include "labels.h" #include "localsession.h" #include "mainclock.h" #include "maincursor.h" @@ -109,6 +110,7 @@ TrackCanvas::TrackCanvas(MWindow *mwindow, render_timer = new Timer; hourglass_enabled = 0; timebar_position = -1; + snapped = 0; } TrackCanvas::~TrackCanvas() @@ -1763,7 +1765,7 @@ void TrackCanvas::draw_drag_handle() mwindow->edl->local_session->zoom_sample - mwindow->edl->local_session->view_start[pane->number]); //printf("TrackCanvas::draw_drag_handle 2 %d %jd\n", pane->number, pixel1); - set_color(GREEN); + set_color(!snapped ? GREEN : (snapped=0, YELLOW)); set_inverse(); //printf("TrackCanvas::draw_drag_handle 3\n"); draw_line(pixel1, 0, pixel1, get_h()); @@ -3472,15 +3474,46 @@ int TrackCanvas::deactivate() void TrackCanvas::update_drag_handle() { double new_position; + int cursor_x = get_cursor_x(); new_position = - (double)(get_cursor_x() + + (double)(cursor_x + mwindow->edl->local_session->view_start[pane->number]) * mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; + new_position = mwindow->edl->align_to_frame(new_position, 0); + if( ctrl_down() && alt_down() ) { +#define snapper(v) do { \ + double pos = (v); \ + if( pos < 0 ) break; \ + double dist = fabs(new_position - pos); \ + if( dist >= snap_min ) break; \ + snap_position = pos; snap_min = dist; \ +} while(0) + double snap_position = new_position; + double snap_min = DBL_MAX; + if( mwindow->edl->local_session->inpoint_valid() ) + snapper(mwindow->edl->local_session->get_inpoint()); + if( mwindow->edl->local_session->outpoint_valid() ) + snapper(mwindow->edl->local_session->get_outpoint()); + snapper(mwindow->edl->prev_edit(new_position)); + snapper(mwindow->edl->next_edit(new_position)); + Label *prev_label = mwindow->edl->labels->prev_label(new_position); + if( prev_label ) snapper(prev_label->position); + Label *next_label = mwindow->edl->labels->next_label(new_position); + if( next_label ) snapper(next_label->position); + int snap_x = snap_position * mwindow->edl->session->sample_rate / + mwindow->edl->local_session->zoom_sample - + mwindow->edl->local_session->view_start[pane->number]; + if( abs(snap_x - cursor_x) < HANDLE_W ) { + snapped = 1; + new_position = snap_position; + } +#undef snapper + } if(new_position != mwindow->session->drag_position) { @@ -4398,7 +4431,7 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) int64_t track_x, track_y, track_w, track_h; track_dimensions(track, track_x, track_y, track_w, track_h); - if(button_press && get_buttonpress() == 3 && + if(button_press && get_buttonpress() == RIGHT_BUTTON && cursor_y >= track_y && cursor_y < track_y + track_h) { gui->edit_menu->update(track, 0); gui->edit_menu->activate_menu(); @@ -4474,10 +4507,12 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; + int cx, cy; + get_abs_cursor(cx, cy); + cx -= mwindow->theme->get_image("clip_icon")->get_w() / 2, + cy -= mwindow->theme->get_image("clip_icon")->get_h() / 2; gui->drag_popup = new BC_DragWindow(gui, - mwindow->theme->get_image("clip_icon") /*, - get_abs_cursor_x(0) - mwindow->theme->get_image("clip_icon")->get_w() / 2, - get_abs_cursor_y(0) - mwindow->theme->get_image("clip_icon")->get_h() / 2 */); + mwindow->theme->get_image("clip_icon"), cx, cy); result = 1; } @@ -4586,19 +4621,22 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start, frame = mwindow->theme->get_image("veffect_icon"); } } - - gui->drag_popup = new BC_DragWindow(gui, frame /*, - get_abs_cursor_x(0) - frame->get_w() / 2, - get_abs_cursor_y(0) - frame->get_h() / 2 */); + int cx, cy; + get_abs_cursor(cx, cy); + cx -= frame->get_w() / 2; + cy -= frame->get_h() / 2; + gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); break; } case PLUGIN_SHAREDPLUGIN: - case PLUGIN_SHAREDMODULE: - gui->drag_popup = new BC_DragWindow(gui, - mwindow->theme->get_image("clip_icon") /*, - get_abs_cursor_x(0) - mwindow->theme->get_image("clip_icon")->get_w() / 2, - get_abs_cursor_y(0) - mwindow->theme->get_image("clip_icon")->get_h() / 2 */); - break; + case PLUGIN_SHAREDMODULE: { + VFrame *frame = mwindow->theme->get_image("clip_icon"); + int cx, cy; + get_abs_cursor(cx, cy); + cx -= frame->get_w() / 2; + cy -= frame->get_h() / 2; + gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); + break; } } result = 1; @@ -4658,7 +4696,6 @@ int TrackCanvas::button_press_event() int result = 0; int cursor_x, cursor_y; int new_cursor; - double start_position = mwindow->edl->local_session->get_selectionstart(1); cursor_x = get_cursor_x(); cursor_y = get_cursor_y(); @@ -4815,23 +4852,7 @@ int TrackCanvas::button_press_event() gui->flash_canvas(1); } } -// if snapping to selection point - if( gui->ctrl_down() && gui->alt_down() ) { - switch( mwindow->session->current_operation ) { - case DRAG_EDITHANDLE1: - mwindow->session->drag_position = start_position; - mwindow->session->current_operation = NO_OPERATION; - drag_scroll = 0; - end_edithandle_selection(); - break; - case DRAG_PLUGINHANDLE1: - mwindow->session->drag_position = start_position; - mwindow->session->current_operation = NO_OPERATION; - drag_scroll = 0; - end_pluginhandle_selection(); - break; - } - } + return result; }