Offer all of a bundle's ports for disconnection / removal when opening a menu over...
authorCarl Hetherington <carl@carlh.net>
Mon, 14 Dec 2009 16:44:20 +0000 (16:44 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 14 Dec 2009 16:44:20 +0000 (16:44 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6365 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_matrix.cc
gtk2_ardour/port_matrix.h
gtk2_ardour/port_matrix_column_labels.cc
gtk2_ardour/port_matrix_component.cc
gtk2_ardour/port_matrix_row_labels.cc
libs/ardour/ardour/bundle.h

index 1b07e80bf321a54d3e2636a2af543b73a26e18ce..b9285de7c7924b57213c63cae57f0248f908c29f 100644 (file)
@@ -414,29 +414,31 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
                        }
 
                        if (can_remove_channels (bc[dim].bundle)) {
-                               snprintf (buf, sizeof (buf), _("Remove '%s'"), bc[dim].bundle->channel_name (bc[dim].channel).c_str());
-                               sub.push_back (
-                                       MenuElem (
-                                               buf,
-                                               sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_channel_proxy), w, bc[dim].channel)
-                                               )
-                                       );
+                               if (bc[dim].channel != -1) {
+                                       add_remove_option (sub, w, bc[dim].channel);
+                               } else {
+                                       for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
+                                               add_remove_option (sub, w, i);
+                                       }
+                               }
                        }
 
                        if (_show_only_bundles || bc[dim].bundle->nchannels() <= 1) {
                                snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
-                       } else {
-                               snprintf (
-                                       buf, sizeof (buf), _("%s all from '%s'"),
-                                       disassociation_verb().c_str(),
-                                       bc[dim].bundle->channel_name (bc[dim].channel).c_str()
+                               sub.push_back (
+                                       MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim))
                                        );
+                               
+                       } else {
+                               if (bc[dim].channel != -1) {
+                                       add_disassociate_option (sub, w, dim, bc[dim].channel);
+                               } else {
+                                       for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
+                                               add_disassociate_option (sub, w, dim, i);
+                                       }
+                               }
                        }
 
-                       sub.push_back (
-                               MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim))
-                               );
-
                        items.push_back (MenuElem (bc[dim].bundle->name().c_str(), *m));
                        need_separator = true;
                }
@@ -761,3 +763,33 @@ PortMatrix::visible_ports (int d) const
 
        return *j;
 }
+
+void
+PortMatrix::add_remove_option (Menu_Helpers::MenuList& m, boost::weak_ptr<Bundle> w, int c)
+{
+       using namespace Menu_Helpers;
+
+       boost::shared_ptr<Bundle> b = w.lock ();
+       if (!b) {
+               return;
+       }
+       
+       char buf [64];
+       snprintf (buf, sizeof (buf), _("Remove '%s'"), b->channel_name (c).c_str());
+       m.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_channel_proxy), w, c)));
+}
+
+void
+PortMatrix::add_disassociate_option (Menu_Helpers::MenuList& m, boost::weak_ptr<Bundle> w, int d, int c)
+{
+       using namespace Menu_Helpers;
+
+       boost::shared_ptr<Bundle> b = w.lock ();
+       if (!b) {
+               return;
+       }
+       
+       char buf [64];
+       snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), b->channel_name (c).c_str());
+       m.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, c, d)));
+}
index 477b0947dcf05a085207a15e6b2639ef5d7dd6f9..cfa4cdbadc7fe730493891bcc6794973a0f0edaf 100644 (file)
@@ -47,6 +47,12 @@ namespace ARDOUR {
        class Bundle;
 }
 
+namespace Gtk {
+       namespace Menu_Helpers {
+               class MenuList;
+       }
+}
+
 class PortMatrixBody;
 
 class PortMatrix : public Gtk::Table
@@ -177,6 +183,8 @@ private:
        void route_processors_changed (ARDOUR::RouteProcessorChange);
        void body_dimensions_changed ();
        void session_going_away ();
+       void add_remove_option (Gtk::Menu_Helpers::MenuList &, boost::weak_ptr<ARDOUR::Bundle>, int);
+       void add_disassociate_option (Gtk::Menu_Helpers::MenuList &, boost::weak_ptr<ARDOUR::Bundle>, int, int);
 
        Gtk::Window* _parent;
 
index c10bb01a2b5ba061ac9a00ac18705b3f06f9857a..be26474e7510afcd123f75ddd25b1d9d67fe4400 100644 (file)
@@ -436,11 +436,19 @@ PortMatrixColumnLabels::position_to_channel (double p, double o, boost::shared_p
 void
 PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t, guint)
 {
-       ARDOUR::BundleChannel const gc = position_to_channel (x, y, _matrix->visible_columns());
+       ARDOUR::BundleChannel w = position_to_channel (x, y, _matrix->visible_columns());
+
+       if (
+               (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM && y > (_height - _longest_bundle_name * sin (angle ()))) ||
+               (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT && y < (_longest_bundle_name * sin (angle ())))
+               ) {
+
+               w.channel = -1;
+       }
 
        if (b == 3) {
                _matrix->popup_menu (
-                       gc,
+                       w,
                        ARDOUR::BundleChannel (),
                        t
                        );
index 0bb8d496e7c3c1955fcbb1a88208ba459d7183fd..d98c557c3a3a8aff74e2842ba7812142f83715f1 100644 (file)
@@ -187,7 +187,7 @@ PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr<co
                if (_matrix->show_only_bundles()) {
                        
                        if (p < 1) {
-                               return ARDOUR::BundleChannel (j->bundle, 0);
+                               return ARDOUR::BundleChannel (j->bundle, -1);
                        } else {
                                p -= 1;
                        }
@@ -205,5 +205,5 @@ PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr<co
                
        }
        
-       return ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0);
+       return ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), -1);
 }
index 9878dc23dd9ba597723b01fcf4c553e2be9b36dd..80a0bb0c4f956a17dea74fd6a601d19281d6034d 100644 (file)
@@ -127,7 +127,15 @@ PortMatrixRowLabels::render (cairo_t* cr)
 void
 PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t, guint)
 {
-       ARDOUR::BundleChannel const w = position_to_channel (y, x, _matrix->visible_rows());
+       ARDOUR::BundleChannel w = position_to_channel (y, x, _matrix->visible_rows());
+
+       if (
+               (_matrix->arrangement() == PortMatrix::TOP_TO_RIGHT && x > (_longest_port_name + name_pad() * 2)) ||
+               (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM && x < (_longest_bundle_name + name_pad() * 2))
+               
+               ) {
+                       w.channel = -1;
+       }
 
        if (b == 3) {
 
index 1af7a3bad0e979bf07ae1fc0442317e9667ba7d3..196b1f2a091c1ac8757b5d8bb79084016b28ebf0 100644 (file)
@@ -144,9 +144,9 @@ class Bundle : public sigc::trackable
 
 struct BundleChannel
 {
-       BundleChannel () : channel (0) {}
+       BundleChannel () : channel (-1) {}
 
-       BundleChannel (boost::shared_ptr<Bundle> b, uint32_t c)
+       BundleChannel (boost::shared_ptr<Bundle> b, int c)
                : bundle (b), channel (c) {}
 
        bool operator== (BundleChannel const& other) const {
@@ -158,7 +158,7 @@ struct BundleChannel
        }
 
        boost::shared_ptr<Bundle> bundle;
-       uint32_t channel;
+       int channel; ///< channel index, or -1 for "all"
 };
 
 }