summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/bundle_manager.cc109
-rw-r--r--gtk2_ardour/bundle_manager.h14
-rw-r--r--gtk2_ardour/global_port_matrix.h12
-rw-r--r--gtk2_ardour/io_selector.cc35
-rw-r--r--gtk2_ardour/io_selector.h13
-rw-r--r--gtk2_ardour/port_group.cc48
-rw-r--r--gtk2_ardour/port_group.h6
-rw-r--r--gtk2_ardour/port_matrix.cc182
-rw-r--r--gtk2_ardour/port_matrix.h18
-rw-r--r--gtk2_ardour/session_option_editor.cc11
-rw-r--r--libs/ardour/io.cc2
11 files changed, 271 insertions, 179 deletions
diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc
index 8fd7c05973..52415de4ee 100644
--- a/gtk2_ardour/bundle_manager.cc
+++ b/gtk2_ardour/bundle_manager.cc
@@ -30,8 +30,11 @@
#include "bundle_manager.h"
#include "i18n.h"
+using namespace std;
+using namespace ARDOUR;
+
BundleEditorMatrix::BundleEditorMatrix (
- ARDOUR::Session& session, boost::shared_ptr<ARDOUR::Bundle> bundle
+ Session& session, boost::shared_ptr<Bundle> bundle
)
: PortMatrix (session, bundle->type()),
_bundle (bundle)
@@ -55,10 +58,10 @@ BundleEditorMatrix::setup_ports (int dim)
}
void
-BundleEditorMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
+BundleEditorMatrix::set_state (BundleChannel c[2], bool s)
{
- ARDOUR::Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
- for (ARDOUR::Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
+ Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
+ for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
if (s) {
c[OURS].bundle->add_port_to_channel (c[OURS].channel, *i);
} else {
@@ -68,10 +71,10 @@ BundleEditorMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
}
PortMatrixNode::State
-BundleEditorMatrix::get_state (ARDOUR::BundleChannel c[2]) const
+BundleEditorMatrix::get_state (BundleChannel c[2]) const
{
- ARDOUR::Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
- for (ARDOUR::Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
+ Bundle::PortList const& pl = c[OTHER].bundle->channel_ports (c[OTHER].channel);
+ for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
if (!c[OURS].bundle->port_attached_to_channel (c[OURS].channel, *i)) {
return PortMatrixNode::NOT_ASSOCIATED;
}
@@ -80,35 +83,67 @@ BundleEditorMatrix::get_state (ARDOUR::BundleChannel c[2]) const
return PortMatrixNode::ASSOCIATED;
}
-std::string
-BundleEditorMatrix::add_channel_name () const
+bool
+BundleEditorMatrix::can_add_channel (boost::shared_ptr<Bundle> b) const
{
- return _bundle->name ();
+ if (b == _bundle) {
+ return true;
+ }
+
+ return PortMatrix::can_add_channel (b);
}
void
-BundleEditorMatrix::add_channel ()
+BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b)
{
- NameChannelDialog d;
- d.set_position (Gtk::WIN_POS_MOUSE);
+ if (b == _bundle) {
+
+ NameChannelDialog d;
+ d.set_position (Gtk::WIN_POS_MOUSE);
+
+ if (d.run () != Gtk::RESPONSE_ACCEPT) {
+ return;
+ }
+
+ _bundle->add_channel (d.get_name());
+ setup_ports (OURS);
+
+ } else {
+
+ PortMatrix::add_channel (b);
+
+ }
+}
- if (d.run () != Gtk::RESPONSE_ACCEPT) {
- return;
+bool
+BundleEditorMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
+{
+ if (b == _bundle) {
+ return true;
}
- _bundle->add_channel (d.get_name());
- setup_ports (OURS);
+ return PortMatrix::can_remove_channels (b);
}
void
-BundleEditorMatrix::remove_channel (ARDOUR::BundleChannel bc)
+BundleEditorMatrix::remove_channel (BundleChannel bc)
{
bc.bundle->remove_channel (bc.channel);
setup_ports (OURS);
}
+bool
+BundleEditorMatrix::can_rename_channels (boost::shared_ptr<Bundle> b) const
+{
+ if (b == _bundle) {
+ return true;
+ }
+
+ return PortMatrix::can_rename_channels (b);
+}
+
void
-BundleEditorMatrix::rename_channel (ARDOUR::BundleChannel bc)
+BundleEditorMatrix::rename_channel (BundleChannel bc)
{
NameChannelDialog d (bc.bundle, bc.channel);
d.set_position (Gtk::WIN_POS_MOUSE);
@@ -126,7 +161,7 @@ BundleEditorMatrix::list_is_global (int dim) const
return (dim == OTHER);
}
-BundleEditor::BundleEditor (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::UserBundle> bundle, bool add)
+BundleEditor::BundleEditor (Session& session, boost::shared_ptr<UserBundle> bundle, bool add)
: ArdourDialog (_("Edit Bundle")), _matrix (session, bundle), _bundle (bundle)
{
Gtk::Table* t = new Gtk::Table (3, 2);
@@ -170,10 +205,10 @@ BundleEditor::BundleEditor (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::
_type.append_text (_("MIDI"));
switch (bundle->type ()) {
- case ARDOUR::DataType::AUDIO:
+ case DataType::AUDIO:
_type.set_active_text (_("Audio"));
break;
- case ARDOUR::DataType::MIDI:
+ case DataType::MIDI:
_type.set_active_text (_("MIDI"));
break;
}
@@ -212,8 +247,8 @@ BundleEditor::type_changed ()
{
_bundle->remove_ports_from_channels ();
- ARDOUR::DataType const t = _type.get_active_text() == _("Audio") ?
- ARDOUR::DataType::AUDIO : ARDOUR::DataType::MIDI;
+ DataType const t = _type.get_active_text() == _("Audio") ?
+ DataType::AUDIO : DataType::MIDI;
_bundle->set_type (t);
_matrix.set_type (t);
@@ -227,7 +262,7 @@ BundleEditor::on_map ()
}
-BundleManager::BundleManager (ARDOUR::Session& session)
+BundleManager::BundleManager (Session& session)
: ArdourDialog (_("Bundle manager")), _session (session), edit_button (_("Edit")), delete_button (_("Delete"))
{
_list_model = Gtk::ListStore::create (_list_model_columns);
@@ -235,8 +270,8 @@ BundleManager::BundleManager (ARDOUR::Session& session)
_tree_view.append_column (_("Name"), _list_model_columns.name);
_tree_view.set_headers_visible (false);
- boost::shared_ptr<ARDOUR::BundleList> bundles = _session.bundles ();
- for (ARDOUR::BundleList::iterator i = bundles->begin(); i != bundles->end(); ++i) {
+ boost::shared_ptr<BundleList> bundles = _session.bundles ();
+ for (BundleList::iterator i = bundles->begin(); i != bundles->end(); ++i) {
add_bundle (*i);
}
@@ -286,7 +321,7 @@ BundleManager::set_button_sensitivity ()
void
BundleManager::new_clicked ()
{
- boost::shared_ptr<ARDOUR::UserBundle> b (new ARDOUR::UserBundle (""));
+ boost::shared_ptr<UserBundle> b (new UserBundle (""));
/* Start off with a single channel */
b->add_channel ("");
@@ -304,7 +339,7 @@ BundleManager::edit_clicked ()
{
Gtk::TreeModel::iterator i = _tree_view.get_selection()->get_selected();
if (i) {
- boost::shared_ptr<ARDOUR::UserBundle> b = (*i)[_list_model_columns.bundle];
+ boost::shared_ptr<UserBundle> b = (*i)[_list_model_columns.bundle];
BundleEditor e (_session, b, false);
if (e.run () == Gtk::RESPONSE_ACCEPT) {
_session.set_dirty ();
@@ -317,16 +352,16 @@ BundleManager::delete_clicked ()
{
Gtk::TreeModel::iterator i = _tree_view.get_selection()->get_selected();
if (i) {
- boost::shared_ptr<ARDOUR::UserBundle> b = (*i)[_list_model_columns.bundle];
+ boost::shared_ptr<UserBundle> b = (*i)[_list_model_columns.bundle];
_session.remove_bundle (b);
_list_model->erase (i);
}
}
void
-BundleManager::add_bundle (boost::shared_ptr<ARDOUR::Bundle> b)
+BundleManager::add_bundle (boost::shared_ptr<Bundle> b)
{
- boost::shared_ptr<ARDOUR::UserBundle> u = boost::dynamic_pointer_cast<ARDOUR::UserBundle> (b);
+ boost::shared_ptr<UserBundle> u = boost::dynamic_pointer_cast<UserBundle> (b);
if (u == 0) {
return;
}
@@ -339,15 +374,15 @@ BundleManager::add_bundle (boost::shared_ptr<ARDOUR::Bundle> b)
}
void
-BundleManager::bundle_changed (ARDOUR::Bundle::Change c, boost::shared_ptr<ARDOUR::UserBundle> b)
+BundleManager::bundle_changed (Bundle::Change c, boost::shared_ptr<UserBundle> b)
{
- if ((c & ARDOUR::Bundle::NameChanged) == 0) {
+ if ((c & Bundle::NameChanged) == 0) {
return;
}
Gtk::TreeModel::iterator i = _list_model->children().begin ();
while (i != _list_model->children().end()) {
- boost::shared_ptr<ARDOUR::UserBundle> t = (*i)[_list_model_columns.bundle];
+ boost::shared_ptr<UserBundle> t = (*i)[_list_model_columns.bundle];
if (t == b) {
break;
}
@@ -367,7 +402,7 @@ NameChannelDialog::NameChannelDialog ()
setup ();
}
-NameChannelDialog::NameChannelDialog (boost::shared_ptr<ARDOUR::Bundle> b, uint32_t c)
+NameChannelDialog::NameChannelDialog (boost::shared_ptr<Bundle> b, uint32_t c)
: ArdourDialog (_("Rename channel")),
_bundle (b),
_channel (c),
@@ -398,7 +433,7 @@ NameChannelDialog::setup ()
set_default_response (Gtk::RESPONSE_ACCEPT);
}
-std::string
+string
NameChannelDialog::get_name () const
{
return _name.get_text ();
diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h
index e7ce049da5..d8e60e9cc9 100644
--- a/gtk2_ardour/bundle_manager.h
+++ b/gtk2_ardour/bundle_manager.h
@@ -39,15 +39,13 @@ class BundleEditorMatrix : public PortMatrix
void set_state (ARDOUR::BundleChannel c[2], bool s);
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
- std::string add_channel_name () const;
- void add_channel ();
- bool can_remove_channels (int d) const {
- return d == OURS;
- }
+
+ bool can_add_channel (boost::shared_ptr<ARDOUR::Bundle>) const;
+
+ void add_channel (boost::shared_ptr<ARDOUR::Bundle>);
+ bool can_remove_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
void remove_channel (ARDOUR::BundleChannel);
- bool can_rename_channels (int d) const {
- return d == OURS;
- }
+ bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const;
void rename_channel (ARDOUR::BundleChannel);
void setup_ports (int);
bool list_is_global (int) const;
diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h
index 4f3bedd1fd..d88ad12faa 100644
--- a/gtk2_ardour/global_port_matrix.h
+++ b/gtk2_ardour/global_port_matrix.h
@@ -36,17 +36,13 @@ public:
void set_state (ARDOUR::BundleChannel c[2], bool);
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
- bool can_remove_channels (int d) const {
- return false;
- }
- void remove_channel (ARDOUR::BundleChannel) {}
- bool can_rename_channels (int d) const {
- return false;
- }
-
std::string disassociation_verb () const {
return _("Disconnect");
}
+
+ std::string channel_noun () const {
+ return _("port");
+ }
bool list_is_global (int) const {
return true;
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc
index eab6ff9865..31ba681790 100644
--- a/gtk2_ardour/io_selector.cc
+++ b/gtk2_ardour/io_selector.cc
@@ -75,7 +75,7 @@ IOSelector::setup_ports (int dim)
} else {
_port_group->clear ();
- _port_group->add_bundle (_io->bundle ());
+ _port_group->add_bundle (_io->bundle (), _io);
}
_ports[dim].resume_signals ();
@@ -145,39 +145,6 @@ IOSelector::n_io_ports () const
}
}
-string
-IOSelector::add_channel_name () const
-{
- return _io->name ();
-}
-
-void
-IOSelector::add_channel ()
-{
- // The IO selector only works for single typed IOs
- const ARDOUR::DataType t = _io->default_type ();
-
- try {
- _io->add_port ("", this);
- }
-
- catch (AudioEngine::PortRegistrationFailure& err) {
- MessageDialog msg (_("There are no more JACK ports available."));
- msg.run ();
- }
-}
-
-void
-IOSelector::remove_channel (ARDOUR::BundleChannel bc)
-{
- Port* f = _session.engine().get_port_by_name (bc.bundle->channel_ports(bc.channel)[0]);
- if (!f) {
- return;
- }
-
- _io->remove_port (f, this);
-}
-
bool
IOSelector::list_is_global (int dim) const
{
diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h
index 3f4eb2155a..6a87ffaf55 100644
--- a/gtk2_ardour/io_selector.h
+++ b/gtk2_ardour/io_selector.h
@@ -36,19 +36,6 @@ class IOSelector : public PortMatrix
void set_state (ARDOUR::BundleChannel c[2], bool);
PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const;
- std::string add_channel_name () const;
-
- void add_channel ();
-
- bool can_remove_channels (int d) const {
- return d == _ours;
- }
-
- void remove_channel (ARDOUR::BundleChannel);
- bool can_rename_channels (int d) const {
- return false;
- }
-
std::string disassociation_verb () const {
return _("Disconnect");
}
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 544d0e527e..187cdef19a 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -50,16 +50,23 @@ PortGroup::PortGroup (std::string const & n)
}
+void
+PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
+{
+ add_bundle (b, boost::shared_ptr<IO> ());
+}
+
/** Add a bundle to a group.
* @param b Bundle.
*/
void
-PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
+PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io)
{
assert (b.get());
BundleRecord r;
r.bundle = b;
+ r.io = io;
r.has_colour = false;
r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed));
@@ -73,12 +80,13 @@ PortGroup::add_bundle (boost::shared_ptr<Bundle> b)
* @param c Colour to represent the group with.
*/
void
-PortGroup::add_bundle (boost::shared_ptr<Bundle> b, Gdk::Color c)
+PortGroup::add_bundle (boost::shared_ptr<Bundle> b, boost::shared_ptr<IO> io, Gdk::Color c)
{
assert (b.get());
BundleRecord r;
r.bundle = b;
+ r.io = io;
r.colour = c;
r.has_colour = true;
r.changed_connection = b->Changed.connect (sigc::mem_fun (*this, &PortGroup::bundle_changed));
@@ -157,6 +165,22 @@ PortGroup::total_channels () const
return n;
}
+boost::shared_ptr<IO>
+PortGroup::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
+{
+ BundleList::const_iterator i = _bundles.begin ();
+ while (i != _bundles.end() && i->bundle != b) {
+ ++i;
+ }
+
+ if (i == _bundles.end()) {
+ return boost::shared_ptr<IO> ();
+ }
+
+ return i->io;
+}
+
+
/** PortGroupList constructor.
*/
PortGroupList::PortGroupList ()
@@ -250,9 +274,9 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs)
TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->get());
if (tv) {
- g->add_bundle (rb, tv->color ());
+ g->add_bundle (rb, io, tv->color ());
} else {
- g->add_bundle (rb);
+ g->add_bundle (rb, io);
}
}
}
@@ -493,6 +517,22 @@ PortGroupList::resume_signals ()
_signals_suspended = false;
}
+boost::shared_ptr<IO>
+PortGroupList::io_from_bundle (boost::shared_ptr<ARDOUR::Bundle> b) const
+{
+ List::const_iterator i = _groups.begin ();
+ while (i != _groups.end()) {
+ boost::shared_ptr<IO> io = (*i)->io_from_bundle (b);
+ if (io) {
+ return io;
+ }
+ ++i;
+ }
+
+ return boost::shared_ptr<IO> ();
+}
+
+
RouteBundle::RouteBundle (boost::shared_ptr<Bundle> r)
: _route (r)
{
diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h
index 22dee8de5e..dbdcfc06ca 100644
--- a/gtk2_ardour/port_group.h
+++ b/gtk2_ardour/port_group.h
@@ -50,11 +50,13 @@ public:
PortGroup (std::string const & n);
void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
- void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, Gdk::Color);
+ void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO> io);
+ void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO>, Gdk::Color);
void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
void clear ();
uint32_t total_channels () const;
+ boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
std::string name; ///< name for the group
@@ -74,6 +76,7 @@ public:
struct BundleRecord {
boost::shared_ptr<ARDOUR::Bundle> bundle;
+ boost::shared_ptr<ARDOUR::IO> io;
Gdk::Color colour;
bool has_colour;
sigc::connection changed_connection;
@@ -110,6 +113,7 @@ class PortGroupList : public sigc::trackable
uint32_t size () const {
return _groups.size();
}
+ boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
void suspend_signals ();
void resume_signals ();
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 4aed9d5ef4..a415cf5e91 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -36,12 +36,13 @@
using namespace std;
using namespace sigc;
using namespace Gtk;
+using namespace ARDOUR;
/** PortMatrix constructor.
* @param session Our session.
* @param type Port type that we are handling.
*/
-PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type)
+PortMatrix::PortMatrix (Session& session, DataType type)
: Table (2, 2),
_session (session),
_type (type),
@@ -95,8 +96,8 @@ PortMatrix::reconnect_to_routes ()
}
_route_connections.clear ();
- boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
- for (ARDOUR::RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
+ boost::shared_ptr<RouteList> routes = _session.get_routes ();
+ for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
_route_connections.push_back (
(*i)->processors_changed.connect (mem_fun (*this, &PortMatrix::setup_global_ports))
);
@@ -127,7 +128,7 @@ PortMatrix::setup ()
}
void
-PortMatrix::set_type (ARDOUR::DataType t)
+PortMatrix::set_type (DataType t)
{
_type = t;
_ports[0].set_type (_type);
@@ -178,9 +179,9 @@ PortMatrix::disassociate_all ()
for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
for (uint32_t l = 0; l < k->bundle->nchannels(); ++l) {
- ARDOUR::BundleChannel c[2] = {
- ARDOUR::BundleChannel (i->bundle, j),
- ARDOUR::BundleChannel (k->bundle, l)
+ BundleChannel c[2] = {
+ BundleChannel (i->bundle, j),
+ BundleChannel (k->bundle, l)
};
if (get_state (c) == PortMatrixNode::ASSOCIATED) {
@@ -240,8 +241,8 @@ PortMatrix::rows () const
void
PortMatrix::popup_menu (
- pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel> column,
- pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel> row,
+ pair<boost::shared_ptr<PortGroup>, BundleChannel> column,
+ pair<boost::shared_ptr<PortGroup>, BundleChannel> row,
uint32_t t
)
{
@@ -258,48 +259,30 @@ PortMatrix::popup_menu (
pg[_column_index] = column.first;
pg[_row_index] = row.first;
- ARDOUR::BundleChannel bc[2];
+ BundleChannel bc[2];
bc[_column_index] = column.second;
bc[_row_index] = row.second;
char buf [64];
- std::string const n = add_channel_name ();
- if (!n.empty()) {
- snprintf (buf, sizeof (buf), _("Add %s to '%s'"), channel_noun().c_str(), n.c_str());
- items.push_back (MenuElem (buf, mem_fun (*this, &PortMatrix::add_channel)));
- }
-
- for (int dim = 0; dim < 2; ++dim) {
- if (pg[dim]) {
+ for (int dim = 0; dim < 2; ++dim) {
- boost::weak_ptr<PortGroup> wp (pg[dim]);
-
- if (pg[dim]->visible()) {
- if (dim == 0) {
- snprintf (buf, sizeof (buf), _("Hide '%s' sources"), pg[dim]->name.c_str());
- } else {
- snprintf (buf, sizeof (buf), _("Hide '%s' destinations"), pg[dim]->name.c_str());
- }
+ if (bc[dim].bundle) {
- items.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::hide_group), wp)));
- } else {
- if (dim == 0) {
- snprintf (buf, sizeof (buf), _("Show '%s' sources"), pg[dim]->name.c_str());
- } else {
- snprintf (buf, sizeof (buf), _("Show '%s' destinations"), pg[dim]->name.c_str());
- }
- items.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::show_group), wp)));
- }
- }
+ Menu* m = manage (new Menu);
+ MenuList& sub = m->items ();
- if (bc[dim].bundle) {
- boost::weak_ptr<ARDOUR::Bundle> w (bc[dim].bundle);
+ boost::weak_ptr<Bundle> w (bc[dim].bundle);
- if (can_remove_channels (dim)) {
+ if (can_add_channel (bc[dim].bundle)) {
+ snprintf (buf, sizeof (buf), _("Add %s"), channel_noun().c_str());
+ sub.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::add_channel_proxy), w)));
+ }
+
+ if (can_remove_channels (bc[dim].bundle)) {
snprintf (buf, sizeof (buf), _("Remove '%s'"), bc[dim].bundle->channel_name (bc[dim].channel).c_str());
- items.push_back (
+ sub.push_back (
MenuElem (
buf,
bind (mem_fun (*this, &PortMatrix::remove_channel_proxy), w, bc[dim].channel)
@@ -307,9 +290,9 @@ PortMatrix::popup_menu (
);
}
- if (can_rename_channels (dim)) {
+ if (can_rename_channels (bc[dim].bundle)) {
snprintf (buf, sizeof (buf), _("Rename '%s'..."), bc[dim].bundle->channel_name (bc[dim].channel).c_str());
- items.push_back (
+ sub.push_back (
MenuElem (
buf,
bind (mem_fun (*this, &PortMatrix::rename_channel_proxy), w, bc[dim].channel)
@@ -318,20 +301,48 @@ PortMatrix::popup_menu (
}
if (_show_only_bundles) {
- snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), bc[dim].bundle->name().c_str());
+ snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
} else {
snprintf (
- buf, sizeof (buf), _("%s all from '%s/%s'"),
+ buf, sizeof (buf), _("%s all from '%s'"),
disassociation_verb().c_str(),
- bc[dim].bundle->name().c_str(),
bc[dim].bundle->channel_name (bc[dim].channel).c_str()
);
}
- items.push_back (
+ sub.push_back (
MenuElem (buf, bind (mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim))
);
+
+
+ items.push_back (MenuElem (bc[dim].bundle->name().c_str(), *m));
+ }
+ }
+
+ items.push_back (SeparatorElem ());
+
+ for (int dim = 0; dim < 2; ++dim) {
+
+ if (pg[dim]) {
+
+ boost::weak_ptr<PortGroup> wp (pg[dim]);
+ if (pg[dim]->visible()) {
+ if (dim == 0) {
+ snprintf (buf, sizeof (buf), _("Hide '%s' sources"), pg[dim]->name.c_str());
+ } else {
+ snprintf (buf, sizeof (buf), _("Hide '%s' destinations"), pg[dim]->name.c_str());
+ }
+
+ items.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::hide_group), wp)));
+ } else {
+ if (dim == 0) {
+ snprintf (buf, sizeof (buf), _("Show '%s' sources"), pg[dim]->name.c_str());
+ } else {
+ snprintf (buf, sizeof (buf), _("Show '%s' destinations"), pg[dim]->name.c_str());
+ }
+ items.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::show_group), wp)));
+ }
}
}
@@ -348,32 +359,32 @@ PortMatrix::popup_menu (
}
void
-PortMatrix::remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle> b, uint32_t c)
+PortMatrix::remove_channel_proxy (boost::weak_ptr<Bundle> b, uint32_t c)
{
- boost::shared_ptr<ARDOUR::Bundle> sb = b.lock ();
+ boost::shared_ptr<Bundle> sb = b.lock ();
if (!sb) {
return;
}
- remove_channel (ARDOUR::BundleChannel (sb, c));
+ remove_channel (BundleChannel (sb, c));
}
void
-PortMatrix::rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle> b, uint32_t c)
+PortMatrix::rename_channel_proxy (boost::weak_ptr<Bundle> b, uint32_t c)
{
- boost::shared_ptr<ARDOUR::Bundle> sb = b.lock ();
+ boost::shared_ptr<Bundle> sb = b.lock ();
if (!sb) {
return;
}
- rename_channel (ARDOUR::BundleChannel (sb, c));
+ rename_channel (BundleChannel (sb, c));
}
void
-PortMatrix::disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle> bundle, uint32_t channel, int dim)
+PortMatrix::disassociate_all_on_channel (boost::weak_ptr<Bundle> bundle, uint32_t channel, int dim)
{
- boost::shared_ptr<ARDOUR::Bundle> sb = bundle.lock ();
+ boost::shared_ptr<Bundle> sb = bundle.lock ();
if (!sb) {
return;
}
@@ -383,9 +394,9 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<ARDOUR::Bundle> bundle,
for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) {
- ARDOUR::BundleChannel c[2];
- c[dim] = ARDOUR::BundleChannel (sb, channel);
- c[1-dim] = ARDOUR::BundleChannel (i->bundle, j);
+ BundleChannel c[2];
+ c[dim] = BundleChannel (sb, channel);
+ c[1-dim] = BundleChannel (i->bundle, j);
if (get_state (c) == PortMatrixNode::ASSOCIATED) {
set_state (c, false);
@@ -488,3 +499,60 @@ PortMatrix::on_scroll_event (GdkEventScroll* ev)
return true;
}
+
+boost::shared_ptr<IO>
+PortMatrix::io_from_bundle (boost::shared_ptr<Bundle> b) const
+{
+ boost::shared_ptr<IO> io = _ports[0].io_from_bundle (b);
+ if (!io) {
+ io = _ports[1].io_from_bundle (b);
+ }
+
+ return io;
+}
+
+bool
+PortMatrix::can_add_channel (boost::shared_ptr<Bundle> b) const
+{
+ return io_from_bundle (b);
+}
+
+void
+PortMatrix::add_channel (boost::shared_ptr<Bundle> b)
+{
+ boost::shared_ptr<IO> io = io_from_bundle (b);
+
+ if (io) {
+ io->add_port ("", this, _type);
+ }
+}
+
+bool
+PortMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
+{
+ return io_from_bundle (b);
+}
+
+void
+PortMatrix::remove_channel (ARDOUR::BundleChannel b)
+{
+ boost::shared_ptr<IO> io = io_from_bundle (b.bundle);
+
+ if (io) {
+ Port* p = io->nth (b.channel);
+ if (p) {
+ io->remove_port (p, this);
+ }
+ }
+}
+
+void
+PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w)
+{
+ boost::shared_ptr<Bundle> b = w.lock ();
+ if (!b) {
+ return;
+ }
+
+ add_channel (b);
+}
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index 6117e971db..15035fa594 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -125,15 +125,13 @@ public:
virtual PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const = 0;
virtual bool list_is_global (int) const = 0;
- /** If adding a channel is allowed in this situation, return the name of the
- * thing that it would be added to.
- * @return Name.
- */
- virtual std::string add_channel_name () const { return ""; }
- virtual void add_channel () {}
- virtual bool can_remove_channels (int) const = 0;
- virtual void remove_channel (ARDOUR::BundleChannel) = 0;
- virtual bool can_rename_channels (int) const = 0;
+ virtual bool can_add_channel (boost::shared_ptr<ARDOUR::Bundle>) const;
+ 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 bool can_rename_channels (boost::shared_ptr<ARDOUR::Bundle>) const {
+ return false;
+ }
virtual void rename_channel (ARDOUR::BundleChannel) {}
virtual std::string disassociation_verb () const = 0;
virtual std::string channel_noun () const { return _("channel"); }
@@ -163,6 +161,7 @@ private:
void routes_changed ();
void reconnect_to_routes ();
void select_arrangement ();
+ void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>);
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);
@@ -171,6 +170,7 @@ private:
void show_group (boost::weak_ptr<PortGroup>);
void toggle_show_only_bundles ();
bool on_scroll_event (GdkEventScroll *);
+ boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
/// port type that we are working with
ARDOUR::DataType _type;
diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc
index cf7e856def..b23bccd37a 100644
--- a/gtk2_ardour/session_option_editor.cc
+++ b/gtk2_ardour/session_option_editor.cc
@@ -88,19 +88,16 @@ public:
return PortMatrixNode::NOT_ASSOCIATED;
}
- bool list_is_global (int dim) const
- {
+ bool list_is_global (int dim) const {
return (dim == OTHER);
}
- bool can_remove_channels (int) const {
+ bool can_remove_channels (boost::shared_ptr<Bundle>) const {
return false;
}
+
void remove_channel (ARDOUR::BundleChannel) {}
- bool can_rename_channels (int) const {
- return false;
- }
-
+
std::string disassociation_verb () const {
return _("Disassociate");
}
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 8c14466b00..4fb3f915c4 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -260,7 +260,7 @@ IO::remove_port (Port* port, void* src)
PortCountChanged (n_ports()); /* EMIT SIGNAL */
}
- if (change == ConfigurationChanged) {
+ if (change & ConfigurationChanged) {
setup_bundles ();
}