From d8571e2572e750f5cbe4f439ba3d6f9655713bc9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 29 Mar 2019 15:57:07 +0100 Subject: cont'd AutomationRangeDrag updates -- safety commit This is work in progress towards fixing stacked region's region-gain and multiple discontinuous regions spanning multiple tracks. AutomationRangeDrag::setup() still does not collect all AutomationLine points for certain overlap scenarios. There's more to come... --- gtk2_ardour/editor_mouse.cc | 70 +++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 24 deletions(-) (limited to 'gtk2_ardour/editor_mouse.cc') diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 00f292c5b0..15f74b2491 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -37,6 +37,7 @@ #include "canvas/canvas.h" +#include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/operations.h" #include "ardour/playlist.h" @@ -1116,15 +1117,43 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case SelectionItem: - { - if (dynamic_cast(clicked_regionview) || - dynamic_cast(clicked_regionview)) { - - /* collect all regions-views in the given range selection - * perhaps this should be a dedicated method: - * Editor::get_region_views_from_range_selection() ? - * except c-pointer list is not very reliable. - */ + { + if (selection->time.empty ()) { + /* nothing to do */ + return true; + } + pair tvp = trackview_by_y_position (event->button.y, false); + if (!tvp.first) { + /* clicked outside of a track */ + return true; + } + /* handle automation lanes first */ + AutomationTimeAxisView* atv = dynamic_cast (tvp.first); + if (atv) { + /* smart "join" mode: drag automation */ + _drags->set (new AutomationRangeDrag (this, atv, selection->time), event, _cursors->up_down); + return true; + } + if (dynamic_cast(clicked_regionview)) { + /* MIDI CC or similar -- TODO handle multiple? */ + list rvl; + rvl.push_back (clicked_regionview); + _drags->set (new AutomationRangeDrag (this, rvl, selection->time, clicked_regionview->get_time_axis_view().y_position()), event, _cursors->up_down); + return true; + } + + /* no shift+drag: only apply to clicked_regionview (if any) */ + if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + if (dynamic_cast(clicked_regionview) == 0) { + return true; + } + list rvl; + rvl.push_back (clicked_regionview); + _drags->set (new AutomationRangeDrag (this, rvl, selection->time, clicked_regionview->get_time_axis_view().y_position()), event, _cursors->up_down); + return true; + } + + /* collect all audio regions-views in the given range selection */ list rvl; TrackViewList ts = selection->tracks.filter_to_unique_playlists (); for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { @@ -1136,6 +1165,9 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT if ((playlist = (*i)->playlist()) == 0) { continue; } + if (boost::dynamic_pointer_cast (playlist) == 0) { + continue; + } for (list::const_iterator j = selection->time.begin(); j != selection->time.end(); ++j) { boost::shared_ptr rl = playlist->regions_touched (j->start, j->end); for (RegionList::iterator ir = rl->begin(); ir != rl->end(); ++ir) { @@ -1146,23 +1178,13 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } } } - - _drags->set (new AutomationRangeDrag (this, clicked_regionview, rvl, selection->time), - event, _cursors->up_down); - } else { - double const y = event->button.y; - pair tvp = trackview_by_y_position (y, false); - if (tvp.first) { - AutomationTimeAxisView* atv = dynamic_cast (tvp.first); - if (atv) { - /* smart "join" mode: drag automation */ - _drags->set (new AutomationRangeDrag (this, atv, selection->time), event, _cursors->up_down); - } + /* region-gain drag */ + if (!rvl.empty ()) { + _drags->set (new AutomationRangeDrag (this, rvl, selection->time, tvp.first->y_position()), event, _cursors->up_down); } + return true; + break; } - return true; - break; - } case AutomationLineItem: _drags->set (new LineDrag (this, item), event); -- cgit v1.2.3