summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_group.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-01-23 21:24:11 +0000
committerCarl Hetherington <carl@carlh.net>2009-01-23 21:24:11 +0000
commitf6652f07ae2bfa9d7984c5b6feffd6479faec034 (patch)
tree8f02ca41d0f56eb20be3f684eefdf29e218c3a1e /gtk2_ardour/port_group.cc
parent9245b7f95947ae196b8bb734ecb9767a362cccfe (diff)
Add global port matrix dialogs.
git-svn-id: svn://localhost/ardour2/branches/3.0@4434 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_group.cc')
-rw-r--r--gtk2_ardour/port_group.cc103
1 files changed, 99 insertions, 4 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 405e721e42..c47bda3030 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -67,7 +67,7 @@ PortGroupUI::PortGroupUI (PortMatrix* m, PortGroup* g)
, _port_group (g)
, _visibility_checkbutton (g->name)
{
- _port_group->visible = true;
+ _port_group->set_visible (true);
setup_visibility_checkbutton ();
_visibility_checkbutton.signal_toggled().connect (sigc::mem_fun (*this, &PortGroupUI::visibility_checkbutton_toggled));
@@ -77,7 +77,7 @@ PortGroupUI::PortGroupUI (PortMatrix* m, PortGroup* g)
void
PortGroupUI::visibility_checkbutton_toggled ()
{
- _port_group->visible = _visibility_checkbutton.get_active ();
+ _port_group->set_visible (_visibility_checkbutton.get_active ());
setup_visibility_checkbutton ();
_port_matrix->setup ();
}
@@ -86,8 +86,8 @@ PortGroupUI::visibility_checkbutton_toggled ()
void
PortGroupUI::setup_visibility_checkbutton ()
{
- if (_visibility_checkbutton.get_active () != _port_group->visible) {
- _visibility_checkbutton.set_active (_port_group->visible);
+ if (_visibility_checkbutton.get_active () != _port_group->visible()) {
+ _visibility_checkbutton.set_active (_port_group->visible());
}
}
@@ -106,6 +106,10 @@ PortGroupList::PortGroupList (ARDOUR::Session & session, ARDOUR::DataType type,
_other (_("Other"), mask & OTHER)
{
refresh ();
+
+ for (iterator i = begin(); i != end(); ++i) {
+ (*i)->VisibilityChanged.connect (sigc::mem_fun (*this, &PortGroupList::visibility_changed));
+ }
}
/** Find or re-find all our bundles and set up our lists */
@@ -213,3 +217,94 @@ PortGroupList::maybe_add_session_bundle (boost::shared_ptr<ARDOUR::Bundle> b)
_system.bundles.push_back (b);
}
}
+
+std::vector<boost::shared_ptr<ARDOUR::Bundle> >
+PortGroupList::bundles ()
+{
+ std::vector<boost::shared_ptr<ARDOUR::Bundle> > bundles;
+
+ for (iterator i = begin (); i != end (); ++i) {
+ if ((*i)->visible()) {
+
+ std::copy ((*i)->bundles.begin(), (*i)->bundles.end(), std::back_inserter (bundles));
+
+ /* make a bundle for the ports, if there are any */
+ if (!(*i)->ports.empty()) {
+
+ boost::shared_ptr<ARDOUR::Bundle> b (new ARDOUR::Bundle ("", _type, !_offer_inputs));
+
+ std::string const pre = common_prefix ((*i)->ports);
+ if (!pre.empty()) {
+ b->set_name (pre.substr (0, pre.length() - 1));
+ }
+
+ for (uint32_t j = 0; j < (*i)->ports.size(); ++j) {
+ std::string const p = (*i)->ports[j];
+ b->add_channel (p.substr (pre.length()));
+ b->set_port (j, p);
+ }
+
+ bundles.push_back (b);
+ }
+ }
+ }
+
+ return bundles;
+}
+
+std::string
+PortGroupList::common_prefix (std::vector<std::string> const & p) const
+{
+ /* common prefix before '/' ? */
+ if (p[0].find_first_of ("/") != std::string::npos) {
+ std::string const fp = p[0].substr (0, (p[0].find_first_of ("/") + 1));
+ uint32_t j = 1;
+ while (j < p.size()) {
+ if (p[j].substr (0, fp.length()) != fp) {
+ break;
+ }
+ ++j;
+ }
+
+ if (j == p.size()) {
+ return fp;
+ }
+ }
+
+ /* or before ':' ? */
+ if (p[0].find_first_of (":") != std::string::npos) {
+ std::string const fp = p[0].substr (0, (p[0].find_first_of (":") + 1));
+ uint32_t j = 1;
+ while (j < p.size()) {
+ if (p[j].substr (0, fp.length()) != fp) {
+ break;
+ }
+ ++j;
+ }
+
+ if (j == p.size()) {
+ return fp;
+ }
+ }
+
+ return "";
+}
+
+void
+PortGroupList::visibility_changed ()
+{
+ VisibilityChanged ();
+}
+
+void
+PortGroupList::take_visibility_from (PortGroupList const & o)
+{
+ iterator i = begin ();
+ const_iterator j = o.begin ();
+
+ while (i != end() && j != o.end()) {
+ (*i)->set_visible ((*j)->visible());
+ ++i;
+ ++j;
+ }
+}