From efc6b2869fc5840cd1ffd85eb51b1ffbf737c897 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 19 Aug 2011 13:40:37 +0000 Subject: Fix up note snapping so that we snap to the note we're over. git-svn-id: svn://localhost/ardour2/branches/3.0@10008 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index dd9f686561..cf60580327 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3327,7 +3327,7 @@ MidiRegionView::update_ghost_note (double x, double y) PublicEditor& editor = trackview.editor (); - framepos_t const unsnapped_frame = editor.pixel_to_frame (x); + framepos_t unsnapped_frame = editor.pixel_to_frame (x); bool success; Evoral::MusicalTime grid_beats = editor.get_grid_type_as_beats (success, unsnapped_frame); @@ -3336,7 +3336,16 @@ MidiRegionView::update_ghost_note (double x, double y) } framecnt_t const grid_frames = region_beats_to_region_frames (grid_beats); + + /* Hack so that we always snap to the note that we are over, instead of snapping + to the next one if we're more than halfway through the one we're over. + */ + if (unsnapped_frame >= grid_frames / 2) { + unsnapped_frame -= grid_frames / 2; + } + framepos_t f = snap_frame_to_frame (unsnapped_frame); + /* use region_frames... because we are converting a delta within the region */ -- cgit v1.2.3