do not reset session for MonitorSection just because monitor out was removed
[ardour.git] / gtk2_ardour / route_processor_selection.cc
index 0dc15e7f8a2b17a1d66013d4889d35ca10bc594a..50a8a75b9c96a490b04ba0561a32b3c7a91e5197 100644 (file)
@@ -21,7 +21,6 @@
 #include <sigc++/bind.h>
 
 #include "pbd/error.h"
-#include "pbd/i18n.h"
 
 #include "ardour/selection.h"
 #include "ardour/session.h"
@@ -34,6 +33,8 @@
 #include "route_processor_selection.h"
 #include "route_ui.h"
 
+#include "pbd/i18n.h"
+
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
@@ -43,16 +44,6 @@ RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewP
 {
 }
 
-RouteProcessorSelection&
-RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
-{
-       if (&other != this) {
-               (*((ProcessorSelection*) this)) = (*((ProcessorSelection const *) &other));
-               axes = other.axes;
-       }
-       return *this;
-}
-
 bool
 operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b)
 {
@@ -76,6 +67,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 +121,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 +171,9 @@ RouteProcessorSelection::set (AxisView* r)
        if (!shp.session()) {
                return;
        }
-       shp.session()->selection().set (r->stripable(), boost::shared_ptr<AutomationControl>());
+       PresentationInfo::ChangeSuspender cs;
+       shp.session()->selection().clear_stripables ();
+       add (r, true);
 }
 
 bool