summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-10-21 15:12:13 +0200
committerRobin Gareus <robin@gareus.org>2014-10-21 15:48:11 +0200
commitf3692083344ee375e30c0f7fe6c9ec7e6f719b66 (patch)
tree4fb5bb51ed270a8e1ff981abf383765be3b7723e /gtk2_ardour/midi_region_view.cc
parent4cde08cdb86d9b41454e02e7757e9f125a04a326 (diff)
Disallow midi-note duration changes beyond region boundaries
Fixes crash/assert with negative Beats. TODO discuss alternative: automatically extend/trim region (if possible) or accept but hide notes that are out of bounds. That would need some solution for ghost notes which still can have negative Beats while dragging.
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index d62fd789ee..83a325a9ad 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -2601,6 +2601,15 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
}
}
+ if (current_x < 0) {
+ // This works even with snapping because RegionView::snap_frame_to_frame()
+ // snaps forward if the snapped sample is before the beginning of the region
+ current_x = 0;
+ }
+ if (current_x > trackview.editor().sample_to_pixel(_region->length())) {
+ current_x = trackview.editor().sample_to_pixel(_region->length());
+ }
+
if (at_front) {
resize_rect->set_x0 (snap_to_pixel(current_x));
resize_rect->set_x1 (canvas_note->x1());
@@ -2675,6 +2684,13 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
}
}
+ if (current_x < 0) {
+ current_x = 0;
+ }
+ if (current_x > trackview.editor().sample_to_pixel(_region->length())) {
+ current_x = trackview.editor().sample_to_pixel(_region->length());
+ }
+
/* Convert that to a frame within the source */
current_x = snap_pixel_to_sample (current_x) + _region->start ();
@@ -3525,6 +3541,7 @@ MidiRegionView::create_ghost_note (double x, double y)
_ghost_note = new Note (*this, _note_group, g);
_ghost_note->set_ignore_events (true);
_ghost_note->set_outline_color (0x000000aa);
+ if (x < 0) { x = 0; }
update_ghost_note (x, y);
_ghost_note->show ();