provide MidiView methods for use in NoteDrags (fixes note drags to earlier times in pianoroll)
This commit is contained in:
@@ -6136,7 +6136,7 @@ NoteDrag::NoteDrag (EditingContext& ec, ArdourCanvas::Item* i)
|
||||
void
|
||||
NoteDrag::setup_pointer_offset ()
|
||||
{
|
||||
_pointer_offset = _view->midi_region()->source_beats_to_absolute_time (_primary->note ()->time ()).distance (raw_grab_time ());
|
||||
_pointer_offset = _view->source_beats_to_timeline (_primary->note ()->time ()).distance (raw_grab_time ());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -6150,7 +6150,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
||||
_copy = false;
|
||||
}
|
||||
|
||||
setup_snap_delta (_view->midi_region()->source_beats_to_absolute_time (_primary->note ()->time ()));
|
||||
setup_snap_delta (_view->source_beats_to_timeline (_primary->note ()->time ()));
|
||||
|
||||
if (!(_was_selected = _primary->selected ())) {
|
||||
/* tertiary-click means extend selection - we'll do that on button release,
|
||||
@@ -6191,7 +6191,7 @@ NoteDrag::total_dx (GdkEvent* event) const
|
||||
// std::cerr << "apparent dx " << dx << " beats " << dx.beats().str() << " from " << current_pointer_x() << " - " << grab_x() << " = " << current_pointer_x() - grab_x() << std::endl;
|
||||
|
||||
/* primary note time in quarter notes */
|
||||
timepos_t const n_qn = _view->midi_region()->source_beats_to_absolute_time (_primary->note ()->time ());
|
||||
timepos_t const n_qn = _view->source_beats_to_timeline (_primary->note ()->time ());
|
||||
|
||||
/* prevent (n_qn + dx) from becoming negative */
|
||||
if (-dx.distance() > timecnt_t(n_qn).distance ()) {
|
||||
@@ -6216,8 +6216,8 @@ NoteDrag::total_dx (GdkEvent* event) const
|
||||
timecnt_t ret (snap.earlier (n_qn).earlier (snap_delta (event->button.state)), n_qn);
|
||||
|
||||
/* prevent the earliest note being dragged earlier than the region's start position */
|
||||
if (_earliest + ret < _view->midi_region()->start ()) {
|
||||
ret -= (ret + _earliest) - _view->midi_region()->start ();
|
||||
if (_earliest + ret < _view->start ()) {
|
||||
ret -= (ret + _earliest) - _view->start ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -6283,7 +6283,7 @@ NoteDrag::motion (GdkEvent* event, bool first_move)
|
||||
|
||||
_view->show_verbose_cursor_for_new_note_value (_primary->note (), new_note);
|
||||
|
||||
editing_context.set_snapped_cursor_position (_view->midi_region()->region_beats_to_absolute_time (_primary->note ()->time ()) + dx_qn);
|
||||
editing_context.set_snapped_cursor_position (_view->source_beats_to_timeline (_primary->note ()->time ()) + dx_qn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3008,6 +3008,25 @@ MidiView::relative_position (timepos_t const & p) const
|
||||
return _midi_region->region_relative_position (p);
|
||||
}
|
||||
|
||||
timepos_t
|
||||
MidiView::source_beats_to_timeline (Beats const & source_beats) const
|
||||
{
|
||||
if (_midi_region && !_show_source) {
|
||||
return _midi_region->source_beats_to_absolute_time (source_beats);
|
||||
}
|
||||
|
||||
return timepos_t (source_beats);
|
||||
}
|
||||
|
||||
timepos_t
|
||||
MidiView::start() const
|
||||
{
|
||||
if (_midi_region && !_show_source) {
|
||||
return _midi_region->start();
|
||||
}
|
||||
return timepos_t (Temporal::BeatTime);
|
||||
}
|
||||
|
||||
/** @param x Pixel relative to the region position.
|
||||
* @param ensure_snap defaults to false. true = ignore magnetic snap and snap mode (used for snap delta calculation).
|
||||
* @return Snapped pixel relative to the region position.
|
||||
|
||||
@@ -293,6 +293,10 @@ class MidiView : public virtual sigc::trackable, public LineMerger
|
||||
|
||||
Temporal::timecnt_t relative_position (Temporal::timepos_t const & p) const;
|
||||
|
||||
Temporal::timepos_t source_beats_to_timeline (Temporal::Beats const &) const;
|
||||
|
||||
Temporal::timepos_t start() const;
|
||||
|
||||
/** Snap a region relative pixel coordinate to pixel units.
|
||||
* @param x a pixel coordinate relative to region start
|
||||
* @param ensure_snap do not use magnetic snap (required for snap delta calculation)
|
||||
|
||||
Reference in New Issue
Block a user