summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-12-22 01:10:25 +0000
committerCarl Hetherington <carl@carlh.net>2009-12-22 01:10:25 +0000
commit8e59a26ccf13de93ac681d761bad09cd6bcf0c90 (patch)
treeb9a5454636005856da201b99efb1dae3aaf7993f /gtk2_ardour
parent06f094d4b64a826ddd71c970aaa1679867a75975 (diff)
Add remove all and disconnect all to port matrix menu. Hide bundles whose channels are already represented by other, larger bundles.
git-svn-id: svn://localhost/ardour2/branches/3.0@6381 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/port_group.cc53
-rw-r--r--gtk2_ardour/port_group.h1
-rw-r--r--gtk2_ardour/port_matrix.cc38
-rw-r--r--gtk2_ardour/port_matrix.h2
4 files changed, 94 insertions, 0 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 3b10ff1abf..9f5b73c68d 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -207,6 +207,55 @@ PortGroup::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
return (*i)->io;
}
+/** Remove bundles whose channels are already represented by other, larger bundles */
+void
+PortGroup::remove_duplicates ()
+{
+ BundleList::iterator i = _bundles.begin();
+ while (i != _bundles.end()) {
+
+ BundleList::iterator tmp = i;
+ ++tmp;
+
+ bool remove = false;
+
+ for (BundleList::iterator j = _bundles.begin(); j != _bundles.end(); ++j) {
+
+ if (j->bundle->nchannels() > i->bundle->nchannels()) {
+ /* this bundle is larger */
+
+ uint32_t k = 0;
+ while (k < i->bundle->nchannels()) {
+ /* see if this channel on *i has an equivalent on *j */
+ uint32_t l = 0;
+ while (l < j->bundle->nchannels() && i->bundle->channel_ports (k) != j->bundle->channel_ports (l)) {
+ ++l;
+ }
+
+ if (l == j->bundle->nchannels()) {
+ /* it does not */
+ break;
+ }
+
+ ++k;
+ }
+
+ if (k == i->bundle->nchannels ()) {
+ /* all channels on *i are represented by the larger bundle *j, so remove *i */
+ remove = true;
+ break;
+ }
+ }
+ }
+
+ if (remove) {
+ _bundles.erase (i);
+ }
+
+ i = tmp;
+ }
+}
+
/** PortGroupList constructor.
*/
@@ -398,6 +447,10 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
other->add_bundle (make_bundle_from_ports (extra_other, inputs));
}
+ if (!allow_dups) {
+ system->remove_duplicates ();
+ }
+
add_group_if_not_empty (system);
add_group_if_not_empty (bus);
add_group_if_not_empty (track);
diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h
index d5868bddd6..17d1963e19 100644
--- a/gtk2_ardour/port_group.h
+++ b/gtk2_ardour/port_group.h
@@ -60,6 +60,7 @@ public:
void clear ();
uint32_t total_channels () const;
boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
+ void remove_duplicates ();
std::string name; ///< name for the group
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 33115432e6..247d750534 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -411,6 +411,12 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
if (bc[dim].channel != -1) {
add_remove_option (sub, w, bc[dim].channel);
} else {
+
+ snprintf (buf, sizeof (buf), _("Remove all"));
+ sub.push_back (
+ MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_all_channels), w))
+ );
+
for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
add_remove_option (sub, w, i);
}
@@ -424,9 +430,15 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
);
} else {
+
if (bc[dim].channel != -1) {
add_disassociate_option (sub, w, dim, bc[dim].channel);
} else {
+ snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
+ sub.push_back (
+ MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_bundle), w, dim))
+ );
+
for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
add_disassociate_option (sub, w, dim, i);
}
@@ -477,6 +489,19 @@ PortMatrix::rename_channel_proxy (boost::weak_ptr<Bundle> b, uint32_t c)
}
void
+PortMatrix::disassociate_all_on_bundle (boost::weak_ptr<Bundle> bundle, int dim)
+{
+ boost::shared_ptr<Bundle> sb = bundle.lock ();
+ if (!sb) {
+ return;
+ }
+
+ for (uint32_t i = 0; i < sb->nchannels(); ++i) {
+ disassociate_all_on_channel (bundle, i, dim);
+ }
+}
+
+void
PortMatrix::disassociate_all_on_channel (boost::weak_ptr<Bundle> bundle, uint32_t channel, int dim)
{
boost::shared_ptr<Bundle> sb = bundle.lock ();
@@ -621,6 +646,19 @@ PortMatrix::remove_channel (ARDOUR::BundleChannel b)
}
void
+PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
+{
+ boost::shared_ptr<Bundle> b = w.lock ();
+ if (!b) {
+ return;
+ }
+
+ for (uint32_t i = 0; i < b->nchannels(); ++i) {
+ remove_channel (ARDOUR::BundleChannel (b, i));
+ }
+}
+
+void
PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w)
{
boost::shared_ptr<Bundle> b = w.lock ();
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index 373a316257..a33d8c2910 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -140,6 +140,7 @@ public:
virtual void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
virtual bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
virtual void remove_channel (ARDOUR::BundleChannel);
+ virtual void remove_all_channels (boost::weak_ptr<ARDOUR::Bundle>);
virtual bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
return false;
}
@@ -175,6 +176,7 @@ private:
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle>, uint32_t, int);
+ void disassociate_all_on_bundle (boost::weak_ptr<ARDOUR::Bundle>, int);
void setup_global_ports ();
void toggle_show_only_bundles ();
bool on_scroll_event (GdkEventScroll *);