Honor groups for mixer selection
authorRobin Gareus <robin@gareus.org>
Wed, 12 Jul 2017 04:55:44 +0000 (06:55 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 12 Jul 2017 04:55:44 +0000 (06:55 +0200)
gtk2_ardour/mixer_ui.cc
gtk2_ardour/route_processor_selection.cc
gtk2_ardour/route_processor_selection.h

index 35e8ecd516c88bcc62cd89b39950f989855ecb02..02391a3a443c18c71319bef7d7e5bbb99c204c39 100644 (file)
@@ -897,14 +897,14 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                if (_selection.selected (strip)) {
                        /* primary-click: toggle selection state of strip */
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-                               _selection.remove (strip);
+                               _selection.remove (strip, true);
                        } else if (_selection.axes.size() > 1) {
                                /* de-select others */
                                _selection.set (strip);
                        }
                } else {
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-                               _selection.add (strip);
+                               _selection.add (strip, true);
                        } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
 
                                /* extend selection */
@@ -952,7 +952,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                                if (found_another) {
                                        PresentationInfo::ChangeSuspender cs;
                                        for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
-                                               _selection.add (*i);
+                                               _selection.add (*i, true);
                                        }
                                } else {
                                        _selection.set (strip);  //user wants to start a range selection, but there aren't any others selected yet
index 0dc15e7f8a2b17a1d66013d4889d35ca10bc594a..ed182db415305a77697eed2a86c6040de9e37dcf 100644 (file)
@@ -76,6 +76,26 @@ RouteProcessorSelection::clear_routes ()
        }
 }
 
+std::list<AxisView*>
+RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
+{
+       std::list<AxisView*> rv;
+
+       boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route>(r->stripable());
+       if (route) {
+               ARDOUR::RouteGroup* rg = route->route_group ();
+               if (rg && rg->is_active() && rg->is_select ()) {
+
+                       boost::shared_ptr<RouteList> rl = rg->route_list ();
+                       for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
+                               AxisView* av = avp.axis_view_by_stripable (*i);
+                               rv.push_back (av);
+                       }
+               }
+       }
+       return rv;
+}
+
 void
 RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
 {
@@ -110,32 +130,48 @@ RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_
 }
 
 void
-RouteProcessorSelection::add (AxisView* r)
+RouteProcessorSelection::add (AxisView* r, bool with_groups)
 {
        if (!shp.session()) {
                return;
        }
 
-       if (axes.insert (r).second) {
-
-               shp.session()->selection().add (r->stripable(), boost::shared_ptr<AutomationControl>());
-
-               MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
-
-               if (ms) {
-                       ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context());
+       std::list<AxisView*> avl;
+       if (with_groups) {
+               avl= add_grouped_tracks (r);
+       }
+       avl.push_back (r);
+
+       PresentationInfo::ChangeSuspender cs;
+       for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
+               if (axes.insert (*i).second) {
+                       shp.session()->selection().add ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
+                       MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
+                       if (ms) {
+                               ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
+                       }
                }
        }
 }
 
 void
-RouteProcessorSelection::remove (AxisView* r)
+RouteProcessorSelection::remove (AxisView* r, bool with_groups)
 {
        if (!shp.session()) {
                return;
        }
        ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
-       shp.session()->selection().remove (r->stripable(), boost::shared_ptr<AutomationControl>());
+
+       std::list<AxisView*> avl;
+       if (with_groups) {
+               avl= add_grouped_tracks (r);
+       }
+       avl.push_back (r);
+
+       PresentationInfo::ChangeSuspender cs;
+       for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
+               shp.session()->selection().remove ((*i)->stripable(), boost::shared_ptr<AutomationControl>());
+       }
 }
 
 void
@@ -144,7 +180,8 @@ RouteProcessorSelection::set (AxisView* r)
        if (!shp.session()) {
                return;
        }
-       shp.session()->selection().set (r->stripable(), boost::shared_ptr<AutomationControl>());
+       shp.session()->selection().clear_stripables ();
+       add (r, true);
 }
 
 bool
index 6c2b7c94aed43339e467574f554aef5e25265024..d92436dbc4821dd23c8077287112a8b61c55cbf0 100644 (file)
@@ -45,8 +45,8 @@ public:
        bool empty();
 
        void set (AxisView*);
-       void add (AxisView*);
-       void remove (AxisView*);
+       void add (AxisView*, bool with_groups = false);
+       void remove (AxisView*, bool with_groups = false);
        bool selected (AxisView*);
 
        void clear_routes ();
@@ -57,6 +57,7 @@ private:
        ARDOUR::SessionHandlePtr& shp;
        AxisViewProvider& avp;
        void removed (AxisView*);
+       std::list<AxisView*> add_grouped_tracks (AxisView*) const;
 };
 
 bool operator==(const RouteProcessorSelection& a, const RouteProcessorSelection& b);