From c4e6b368ae493a15d466d1ec2a5e13b35481153c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 20 Jun 2010 21:24:48 +0000 Subject: [PATCH] When creating notes with the pencil tool, make them 1 frame shorter than the grid subdivision to prevent overlaps. Fixes #3237. git-svn-id: svn://localhost/ardour2/branches/3.0@7281 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 14 ++++++++++---- gtk2_ardour/midi_region_view.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 9062b369fb..486e09900f 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -348,7 +348,7 @@ MidiRegionView::button_release (GdkEventButton* ev) if (!success) { beats = 1; } - create_note_at (event_x, event_y, beats); + create_note_at (event_x, event_y, beats, true); break; } default: @@ -369,7 +369,7 @@ MidiRegionView::button_release (GdkEventButton* ev) const double length = trackview.editor().pixel_to_frame (_drag_rect->property_x2() - _drag_rect->property_x1()); - create_note_at (x, _drag_rect->property_y1(), frames_to_beats(length)); + create_note_at (x, _drag_rect->property_y1(), frames_to_beats(length), false); } delete _drag_rect; @@ -650,9 +650,11 @@ MidiRegionView::show_list_editor () /** Add a note to the model, and the view, at a canvas (click) coordinate. * \param x horizontal position in pixels * \param y vertical position in pixels - * \param length duration of the note in beats */ + * \param length duration of the note in beats, which will be snapped to the grid + * \param sh true to make the note 1 frame shorter than the snapped version of \a length. + */ void -MidiRegionView::create_note_at(double x, double y, double length) +MidiRegionView::create_note_at(double x, double y, double length, bool sh) { MidiTimeAxisView* const mtv = dynamic_cast(&trackview); MidiStreamView* const view = mtv->midi_view(); @@ -672,6 +674,10 @@ MidiRegionView::create_note_at(double x, double y, double length) assert (length != 0); + if (sh) { + length = frames_to_beats (beats_to_frames (length) - 1); + } + const boost::shared_ptr new_note(new NoteType(0, frames_to_beats(start_frames + _region->start()), length, (uint8_t)note, 0x40)); diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 6c5dff9ff2..23904c9ddc 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -169,7 +169,7 @@ class MidiRegionView : public RegionView void end_write(); void extend_active_notes(); - void create_note_at(double x, double y, double length); + void create_note_at(double x, double y, double length, bool); void display_model(boost::shared_ptr model);