13
0

Fix frame-based beat calculation in MidiRegionView::snap_frame_to_grid_underneath()

- this caused the ghost note under the pointer to behave badly when
	  hovering near an audio-locked meter.
This commit is contained in:
nick_m 2016-08-16 00:48:54 +10:00
parent 4848cb6d42
commit 62372b48ea

View File

@ -4122,18 +4122,19 @@ MidiRegionView::snap_frame_to_grid_underneath (framepos_t p, framecnt_t& grid_fr
{ {
PublicEditor& editor = trackview.editor (); PublicEditor& editor = trackview.editor ();
const Evoral::Beats grid_beats = get_grid_beats(p); const Evoral::Beats grid_beats = get_grid_beats(p);
const Evoral::Beats p_beat = max (Evoral::Beats(), region_frames_to_region_beats (p)); Evoral::Beats p_beat = max (Evoral::Beats(), region_frames_to_region_beats (p));
const double rem = fmod (p_beat.to_double(), grid_beats.to_double());
grid_frames = region_beats_to_region_frames (p_beat + grid_beats) - region_beats_to_region_frames (p_beat);
/* Hack so that we always snap to the note that we are over, instead of snapping /* 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. to the next one if we're more than halfway through the one we're over.
*/ */
if (editor.snap_mode() == SnapNormal && p >= grid_frames / 2) { if (editor.snap_mode() == SnapNormal && rem >= grid_beats.to_double() / 2.0) {
p -= grid_frames / 2; p_beat -= Evoral::Beats(grid_beats.to_double() / 2.0);
} }
return snap_frame_to_frame (p); const framepos_t snap_me = trackview.session()->tempo_map().frame_at_beat (p_beat.to_double() + _region->beat()) - _region->position();
return snap_frame_to_frame (snap_me);
} }
ChannelMode ChannelMode