diff options
author | Carl Hetherington <carl@carlh.net> | 2011-07-16 21:53:30 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-07-16 21:53:30 +0000 |
commit | 7b8efcc25002c1b747fcaa00be8f19f23c930735 (patch) | |
tree | 54ec5783e973287eed986378d15b2a1fba551433 /gtk2_ardour | |
parent | 0cd67582cb5f67958a950fc269efc03ee43f4ad5 (diff) |
Snap ghost note more intuitively (#4189).
git-svn-id: svn://localhost/ardour2/branches/3.0@9885 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 24 |
1 files changed, 20 insertions, 4 deletions
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); |