From 7b8efcc25002c1b747fcaa00be8f19f23c930735 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Jul 2011 21:53:30 +0000 Subject: Snap ghost note more intuitively (#4189). git-svn-id: svn://localhost/ardour2/branches/3.0@9885 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index eb0f87e117..ea5d2f0510 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3235,16 +3235,32 @@ MidiRegionView::update_ghost_note (double x, double y) _last_ghost_y = y; _note_group->w2i (x, y); - framepos_t const f = snap_pixel_to_frame (x); + + PublicEditor& editor = trackview.editor (); + + framepos_t const unsnapped_frame = editor.pixel_to_frame (x); bool success; - Evoral::MusicalTime beats = trackview.editor().get_grid_type_as_beats (success, f); + Evoral::MusicalTime grid_beats = editor.get_grid_type_as_beats (success, unsnapped_frame); if (!success) { - beats = 1; + grid_beats = 1; + } + + framecnt_t const grid_frames = beats_to_frames (grid_beats); + + framepos_t f; + + if (unsnapped_frame < grid_frames / 2) { + f = snap_frame_to_frame (unsnapped_frame); + } else { + /* snap to half the grid spacing behind the mouse pointer; + this makes the snapped note time more intuitive + */ + f = snap_frame_to_frame (unsnapped_frame - grid_frames / 2); } - double length = frames_to_beats (snap_frame_to_frame (f + beats_to_frames (beats)) - f); + double length = frames_to_beats (snap_frame_to_frame (f + grid_frames) - f); _ghost_note->note()->set_time (frames_to_beats (f + _region->start())); _ghost_note->note()->set_length (length); -- cgit v1.2.3