summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_drag.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-08-15 11:20:17 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-08-15 11:20:23 -0400
commit9421e0b4a7c021ef6ac19fe7d003767a986deb4e (patch)
tree050e7aaaf6fc9f65a753e5de321fd21b19f2eaef /gtk2_ardour/editor_drag.cc
parenta9b72f87a648619907667203cbbd7fcb651c9ce4 (diff)
allow constrained-drag of MIDI notes to work
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r--gtk2_ardour/editor_drag.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 7e027a06ef..98ccf4a6a2 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -5564,6 +5564,10 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
frameoffset_t
NoteDrag::total_dx (const guint state) const
{
+ if (_x_constrained) {
+ return 0;
+ }
+
/* dx in frames */
frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x());
@@ -5610,6 +5614,10 @@ NoteDrag::total_dx (const guint state) const
int8_t
NoteDrag::total_dy () const
{
+ if (_y_constrained) {
+ return 0;
+ }
+
MidiStreamView* msv = _region->midi_stream_view ();
double const y = _region->midi_view()->y_position ();
/* new current note */
@@ -5629,8 +5637,8 @@ NoteDrag::motion (GdkEvent * event, bool)
int8_t const dy = total_dy ();
/* Now work out what we have to do to the note canvas items to set this new drag delta */
- double const tdx = _editor->sample_to_pixel (dx) - _cumulative_dx;
- double const tdy = -dy * _note_height - _cumulative_dy;
+ double const tdx = _x_constrained ? 0 : _editor->sample_to_pixel (dx) - _cumulative_dx;
+ double const tdy = _y_constrained ? 0 : -dy * _note_height - _cumulative_dy;
if (tdx || tdy) {
_cumulative_dx += tdx;
@@ -5638,17 +5646,19 @@ NoteDrag::motion (GdkEvent * event, bool)
int8_t note_delta = total_dy();
- _region->move_selection (tdx, tdy, note_delta);
+ if (tdx || tdy) {
+ _region->move_selection (tdx, tdy, note_delta);
- /* the new note value may be the same as the old one, but we
- * don't know what that means because the selection may have
- * involved more than one note and we might be doing something
- * odd with them. so show the note value anyway, always.
- */
+ /* the new note value may be the same as the old one, but we
+ * don't know what that means because the selection may have
+ * involved more than one note and we might be doing something
+ * odd with them. so show the note value anyway, always.
+ */
- uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
+ uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
- _region->show_verbose_cursor_for_new_note_value (_primary->note(), new_note);
+ _region->show_verbose_cursor_for_new_note_value (_primary->note(), new_note);
+ }
}
}