From 6de15a79cfc9f9156700e2fe84287a5abe4f9893 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 25 Jan 2017 21:46:24 +0100 Subject: improve range drag semantics If a track is selected during the drag (by moving the mouse pointer into a new track), but it was not selected at the start, and is then de-selected (by moving the mouse back out of it), then remove it from the selection. --- gtk2_ardour/editor_drag.cc | 29 +++++++++++++++++++++++++---- gtk2_ardour/editor_drag.h | 3 ++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index cdbdf7fce8..9e763ff264 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5038,6 +5038,7 @@ SelectionDrag::SelectionDrag (Editor* e, ArdourCanvas::Item* i, Operation o) : Drag (e, i) , _operation (o) , _add (false) + , _track_selection_at_start (e) , _time_selection_at_start (!_editor->get_selection().time.empty()) { DEBUG_TRACE (DEBUG::Drags, "New SelectionDrag\n"); @@ -5134,6 +5135,10 @@ SelectionDrag::motion (GdkEvent* event, bool first_move) return; } + if (first_move) { + _track_selection_at_start = _editor->selection->tracks; + } + switch (_operation) { case CreateSelection: { @@ -5209,10 +5214,26 @@ SelectionDrag::motion (GdkEvent* event, bool first_move) //( NOTE: most mouse moves don't change the selection so we can't just SET it for every mouse move; it gets clunky ) TrackViewList tracks_to_add; TrackViewList tracks_to_remove; - for (TrackViewList::const_iterator i = new_selection.begin(); i != new_selection.end(); ++i) - if ( !_editor->selection->tracks.contains ( *i ) ) - tracks_to_add.push_back ( *i ); - _editor->selection->add(tracks_to_add); + + if (!first_move) { + for (TrackViewList::const_iterator i = _editor->selection->tracks.begin(); i != _editor->selection->tracks.end(); ++i) { + if (!new_selection.contains (*i) && !_track_selection_at_start.contains (*i)) { + tracks_to_remove.push_back (*i); + } + } + } + + for (TrackViewList::const_iterator i = new_selection.begin(); i != new_selection.end(); ++i) { + if (!_editor->selection->tracks.contains (*i)) { + tracks_to_add.push_back (*i); + } + } + + _editor->selection->add (tracks_to_add); + + if (!tracks_to_remove.empty()) { + _editor->selection->remove (tracks_to_remove); + } } } break; diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 91fb37b82e..b5ebc3b39d 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -34,6 +34,7 @@ #include "editor_items.h" #include "mouse_cursors.h" #include "editing.h" +#include "track_selection.h" namespace ARDOUR { class Location; @@ -1106,7 +1107,7 @@ public: private: Operation _operation; bool _add; - std::list _added_time_axes; + TrackSelection _track_selection_at_start; bool _time_selection_at_start; framepos_t start_at_start; framepos_t end_at_start; -- cgit v1.2.3