13
0

Clean up duplicate snap-related code.

git-svn-id: svn://localhost/ardour2/branches/3.0@9397 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-04-20 23:48:49 +00:00
parent e90e1cc771
commit 8fc896a24d

View File

@ -511,11 +511,7 @@ MidiRegionView::motion (GdkEventMotion* ev)
group->w2i(event_x, event_y);
// convert event_x to global frame
event_frame = trackview.editor().pixel_to_frame(event_x) + _region->position();
trackview.editor().snap_to(event_frame);
// convert event_frame back to local coordinates relative to position
event_frame -= _region->position();
event_frame = snap_pixel_to_frame (event_x);
if (!_ghost_note && trackview.editor().current_mouse_mode() != MouseRange
&& Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())
@ -811,7 +807,7 @@ MidiRegionView::create_note_at(double x, double y, double length, bool sh)
assert(note <= 127.0);
// Start of note in frames relative to region start
framepos_t const start_frames = snap_frame_to_frame(trackview.editor().pixel_to_frame(x));
framepos_t const start_frames = snap_pixel_to_frame (x);
assert(start_frames >= 0);
// Snap length
@ -2231,11 +2227,8 @@ MidiRegionView::note_dropped(CanvasNoteEvent *, frameoffset_t dt, int8_t dnote)
framepos_t
MidiRegionView::snap_pixel_to_frame(double x)
{
PublicEditor& editor = trackview.editor();
// x is region relative, convert it to global absolute frames
framepos_t frame = editor.pixel_to_frame(x) + _region->position();
editor.snap_to(frame);
return frame - _region->position(); // convert back to region relative
PublicEditor& editor (trackview.editor());
return snap_frame_to_frame (editor.pixel_to_frame (x));
}
/** Snap a frame offset within our region using the current snap settings.
@ -3158,9 +3151,7 @@ MidiRegionView::update_ghost_note (double x, double y)
_last_ghost_y = y;
_note_group->w2i (x, y);
framepos_t f = trackview.editor().pixel_to_frame (x) + _region->position ();
trackview.editor().snap_to (f);
f -= _region->position ();
framepos_t const f = snap_pixel_to_frame (x);
bool success;
Evoral::MusicalTime beats = trackview.editor().get_grid_type_as_beats (success, f);