From f2e542afe7de8487eafeb38d9e5f10724840ce31 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 25 Jan 2012 19:39:20 +0000 Subject: [PATCH] in non-note-edit mouse object mode, single click on midi track creates a region if nothing is selected (because said click would then clear the selection, as before). this makes getting started with hand-edited MIDI regions massively easier git-svn-id: svn://localhost/ardour2/branches/3.0@11350 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_drag.cc | 53 +++++++++++++++++++++++++------------- gtk2_ardour/editor_drag.h | 3 ++- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index dd4249f597..269539dd72 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -396,6 +396,22 @@ Drag::show_verbose_cursor_text (string const & text) ); } +boost::shared_ptr +Drag::add_midi_region (MidiTimeAxisView* view) +{ + if (_editor->session()) { + const TempoMap& map (_editor->session()->tempo_map()); + framecnt_t pos = grab_frame(); + const Meter& m = map.meter_at (pos); + /* not that the frame rate used here can be affected by pull up/down which + might be wrong. + */ + framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate()); + return view->add_region (grab_frame(), len, true); + } + + return boost::shared_ptr(); +} struct EditorOrderTimeAxisViewSorter { bool operator() (TimeAxisView* a, TimeAxisView* b) { @@ -1443,7 +1459,7 @@ void RegionCreateDrag::motion (GdkEvent* event, bool first_move) { if (first_move) { - add_region(); + _region = add_midi_region (_view); _view->playlist()->freeze (); } else { if (_region) { @@ -1469,7 +1485,7 @@ void RegionCreateDrag::finished (GdkEvent*, bool movement_occurred) { if (!movement_occurred) { - add_region (); + add_midi_region (_view); } else { _view->playlist()->thaw (); } @@ -1479,21 +1495,6 @@ RegionCreateDrag::finished (GdkEvent*, bool movement_occurred) } } -void -RegionCreateDrag::add_region () -{ - if (_editor->session()) { - const TempoMap& map (_editor->session()->tempo_map()); - framecnt_t pos = grab_frame(); - const Meter& m = map.meter_at (pos); - /* not that the frame rate used here can be affected by pull up/down which - might be wrong. - */ - framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate()); - _region = _view->add_region (grab_frame(), len, false); - } -} - void RegionCreateDrag::aborted (bool) { @@ -3221,7 +3222,23 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred) } else { - deselect_things (); + /* just a click */ + + bool do_deselect = true; + MidiTimeAxisView* mtv; + + if ((mtv = dynamic_cast(_editor->clicked_axisview)) != 0) { + /* MIDI track */ + if (_editor->selection->empty()) { + /* nothing selected */ + add_midi_region (mtv); + do_deselect = false; + } + } + + if (do_deselect) { + deselect_things (); + } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e4270b9d9d..c6679af065 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -212,6 +212,8 @@ protected: return _last_pointer_frame; } + boost::shared_ptr add_midi_region (MidiTimeAxisView*); + void show_verbose_cursor_time (framepos_t); void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0); void show_verbose_cursor_text (std::string const &); @@ -417,7 +419,6 @@ public: private: MidiTimeAxisView* _view; boost::shared_ptr _region; - void add_region (); }; /** Drags to resize MIDI notes */