diff options
author | Carl Hetherington <carl@carlh.net> | 2010-05-25 00:00:11 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-05-25 00:00:11 +0000 |
commit | bd2cbe9e76b28d5cc3d9688c7df6c5206d6be771 (patch) | |
tree | 7ddd1fd68f1050dc56968ac5496cdf625407afa5 /gtk2_ardour/midi_region_view.cc | |
parent | 943edf1b5dbc8cd16432636b5f95c6bcfebf2eb6 (diff) |
Ensure a create note drag rectangle starts with both ends snapped,
otherwise it is possible to drag a note with a size large enough to
be considered valid and smaller than half the grid distance. These
get snapped to zero length and thus appear infinitely long in the view.
A second try at fixing #3159.
git-svn-id: svn://localhost/ardour2/branches/3.0@7151 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index d904305146..0aff288394 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -424,7 +424,7 @@ MidiRegionView::canvas_event(GdkEvent* ev) drag_rect->property_y1() = midi_stream_view()->note_to_y( midi_stream_view()->y_to_note(event_y)); - drag_rect->property_x2() = event_x; + drag_rect->property_x2() = trackview.editor().frame_to_pixel(event_frame); drag_rect->property_y2() = drag_rect->property_y1() + floor(midi_stream_view()->note_height()); drag_rect->property_outline_what() = 0xFF; @@ -565,13 +565,15 @@ MidiRegionView::create_note_at(double x, double y, double length) assert(note <= 127.0); // Start of note in frames relative to region start - nframes64_t start_frames = snap_frame_to_frame(trackview.editor().pixel_to_frame(x)); + nframes64_t const start_frames = snap_frame_to_frame(trackview.editor().pixel_to_frame(x)); assert(start_frames >= 0); // Snap length length = frames_to_beats( snap_frame_to_frame(start_frames + beats_to_frames(length)) - start_frames); + assert (length != 0); + const boost::shared_ptr<NoteType> new_note(new NoteType(0, frames_to_beats(start_frames + _region->start()), length, (uint8_t)note, 0x40)); |