X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=5d925e6e1a3650180ba13526f339be1033192108;hp=e79654d4c9ab82a98f8c4cb2a1c8139f56b4c564;hb=55ccff122957ddfaa871cf8f251cfe866732c870;hpb=d0f9735ae263eebd484a22d1e49bd3e1cd16cf70 diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index e79654d4..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() @@ -1277,7 +1279,7 @@ void TrackCanvas::draw_highlight_rectangle(int x, int y, int w, int h) h = MIN(h, get_h() + 20); if(w > 0 && h > 0) { - set_color(WHITE); + set_color(mwindow->preferences->highlight_inverse); set_inverse(); //draw_rectangle(x, y, w, h); draw_rectangle(x + 1, y + 1, w - 2, h - 2); @@ -1339,7 +1341,7 @@ void TrackCanvas::draw_highlight_insertion(int x, int y, int w, int h) } w = MIN(w, get_w() + 20); h = MIN(h, get_h() + 20); - set_color(WHITE); + set_color(mwindow->preferences->highlight_inverse); set_inverse(); draw_rectangle(x, y, w, h); draw_rectangle(x + 1, y + 1, w - 2, h - 2); @@ -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; @@ -4814,6 +4852,7 @@ int TrackCanvas::button_press_event() gui->flash_canvas(1); } } + return result; }