summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_group.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour/port_group.cc')
-rw-r--r--gtk2_ardour/port_group.cc159
1 files changed, 63 insertions, 96 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 3de45eee73..4157348d8e 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -18,28 +18,42 @@
*/
#include "port_group.h"
+#include "port_matrix.h"
#include "i18n.h"
#include "ardour/session.h"
#include "ardour/audio_track.h"
#include "ardour/midi_track.h"
#include "ardour/audioengine.h"
+#include "ardour/bundle.h"
#include <boost/shared_ptr.hpp>
#include <cstring>
using namespace std;
using namespace Gtk;
+/** Add a bundle to a group.
+ * @param b Bundle.
+ */
+void
+PortGroup::add_bundle (boost::shared_ptr<ARDOUR::Bundle> b)
+{
+ bundles.push_back (b);
+}
+
/** Add a port to a group.
- * @param p Port name, with or without prefix.
+ * @param p Port.
*/
void
-PortGroup::add (std::string const & p)
+PortGroup::add_port (std::string const &p)
{
- if (prefix.empty() == false && p.substr (0, prefix.length()) == prefix) {
- ports.push_back (p.substr (prefix.length()));
- } else {
- ports.push_back (p);
- }
+ ports.push_back (p);
+}
+
+void
+PortGroup::clear ()
+{
+ bundles.clear ();
+ ports.clear ();
}
/** PortGroupUI constructor.
@@ -47,14 +61,14 @@ PortGroup::add (std::string const & p)
* @Param g PortGroup to represent.
*/
-PortGroupUI::PortGroupUI (PortMatrix& m, PortGroup& g)
+PortGroupUI::PortGroupUI (PortMatrix* m, PortGroup* g)
: _port_matrix (m)
, _port_group (g)
- , _ignore_check_button_toggle (false)
- , _visibility_checkbutton (g.name)
+ , _visibility_checkbutton (g->name)
{
- _port_group.visible = true;
- _ignore_check_button_toggle = false;
+ _port_group->visible = true;
+ setup_visibility_checkbutton ();
+
_visibility_checkbutton.signal_toggled().connect (sigc::mem_fun (*this, &PortGroupUI::visibility_checkbutton_toggled));
}
@@ -62,66 +76,49 @@ PortGroupUI::PortGroupUI (PortMatrix& m, PortGroup& g)
void
PortGroupUI::visibility_checkbutton_toggled ()
{
- _port_group.visible = _visibility_checkbutton.get_active ();
+ _port_group->visible = _visibility_checkbutton.get_active ();
+ setup_visibility_checkbutton ();
+ _port_matrix->setup ();
}
-/** @return Checkbutton used to toggle visibility */
-Widget&
-PortGroupUI::get_visibility_checkbutton ()
-{
- return _visibility_checkbutton;
-}
-
-
-/** Handle a toggle of a port check button */
+/** Set up the visibility checkbutton according to PortGroup::visible */
void
-PortGroupUI::port_checkbutton_toggled (CheckButton* b, int r, int c)
+PortGroupUI::setup_visibility_checkbutton ()
{
- if (_ignore_check_button_toggle == false) {
- // _port_matrix.hide_group (_port_group);
- }
-}
-
-/** Set up visibility of the port group according to PortGroup::visible */
-void
-PortGroupUI::setup_visibility ()
-{
- 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);
}
}
/** PortGroupList constructor.
- * @param session Session to get ports from.
- * @param type Type of ports to offer (audio or MIDI)
- * @param offer_inputs true to offer output ports, otherwise false.
+ * @param session Session to get bundles from.
+ * @param type Type of bundles to offer (audio or MIDI)
+ * @param offer_inputs true to offer output bundles, otherwise false.
* @param mask Mask of groups to make visible by default.
*/
PortGroupList::PortGroupList (ARDOUR::Session & session, ARDOUR::DataType type, bool offer_inputs, Mask mask)
: _session (session), _type (type), _offer_inputs (offer_inputs),
- _buss (_("Bus"), "ardour:", mask & BUSS),
- _track (_("Track"), "ardour:", mask & TRACK),
- _system (_("System"), "system:", mask & SYSTEM),
- _other (_("Other"), "", mask & OTHER)
+ _buss (_("Bus"), mask & BUSS),
+ _track (_("Track"), mask & TRACK),
+ _system (_("System"), mask & SYSTEM),
+ _other (_("Other"), mask & OTHER)
{
refresh ();
}
-/** Find or re-find all our ports and set up our lists */
+/** Find or re-find all our bundles and set up our lists */
void
PortGroupList::refresh ()
{
clear ();
-
- _buss.ports.clear ();
- _track.ports.clear ();
- _system.ports.clear ();
- _other.ports.clear ();
- /* Find the ports provided by ardour; we can't derive their type just from their
- names, so we'll have to be more devious.
- */
+ _buss.clear ();
+ _track.clear ();
+ _system.clear ();
+ _other.clear ();
+
+ /* Find the bundles for routes */
boost::shared_ptr<ARDOUR::Session::RouteList> routes = _session.get_routes ();
@@ -148,14 +145,12 @@ PortGroupList::refresh ()
}
if (g) {
- ARDOUR::PortSet const & p = _offer_inputs ? ((*i)->inputs()) : ((*i)->outputs());
- for (uint32_t j = 0; j < p.num_ports(); ++j) {
- g->add (p.port(j)->name ());
- }
-
- std::sort (g->ports.begin(), g->ports.end());
+ g->add_bundle (_offer_inputs ? (*i)->bundle_for_inputs() : (*i)->bundle_for_outputs ());
}
}
+
+ /* Bundles created by the session */
+ _session.foreach_bundle (sigc::mem_fun (*this, &PortGroupList::maybe_add_session_bundle));
/* XXX: inserts, sends, plugin inserts? */
@@ -163,9 +158,9 @@ PortGroupList::refresh ()
finding all the ports that we can connect to.
*/
- const char **ports = _session.engine().get_ports ("", _type.to_jack_type(), _offer_inputs ?
- JackPortIsInput : JackPortIsOutput);
- if (ports) {
+ const char **ports = _session.engine().get_ports ("", _type.to_jack_type(), _offer_inputs ?
+ JackPortIsInput : JackPortIsOutput);
+ if (ports) {
int n = 0;
string client_matching_string;
@@ -178,11 +173,11 @@ PortGroupList::refresh ()
if (p.substr(0, strlen ("system:")) == "system:") {
/* system: prefix */
- _system.add (p);
+ _system.add_port (p);
} else {
if (p.substr(0, client_matching_string.length()) != client_matching_string) {
/* other (non-ardour) prefix */
- _other.add (p);
+ _other.add_port (p);
}
}
@@ -198,41 +193,6 @@ PortGroupList::refresh ()
push_back (&_other);
}
-int
-PortGroupList::n_visible_ports () const
-{
- int n = 0;
-
- for (const_iterator i = begin(); i != end(); ++i) {
- if ((*i)->visible) {
- n += (*i)->ports.size();
- }
- }
-
- return n;
-}
-
-std::string
-PortGroupList::get_port_by_index (int n, bool with_prefix) const
-{
- /* XXX: slightly inefficient algorithm */
-
- for (const_iterator i = begin(); i != end(); ++i) {
- for (std::vector<std::string>::const_iterator j = (*i)->ports.begin(); j != (*i)->ports.end(); ++j) {
- if (n == 0) {
- if (with_prefix) {
- return (*i)->prefix + *j;
- } else {
- return *j;
- }
- }
- --n;
- }
- }
-
- return "";
-}
-
void
PortGroupList::set_type (ARDOUR::DataType t)
{
@@ -245,3 +205,10 @@ PortGroupList::set_offer_inputs (bool i)
_offer_inputs = i;
}
+void
+PortGroupList::maybe_add_session_bundle (boost::shared_ptr<ARDOUR::Bundle> b)
+{
+ if (b->ports_are_inputs () == _offer_inputs) {
+ _system.bundles.push_back (b);
+ }
+}