summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/port_matrix.cc56
-rw-r--r--gtk2_ardour/port_matrix.h1
-rw-r--r--libs/ardour/ardour/bundle.h1
-rw-r--r--libs/ardour/bundle.cc28
4 files changed, 85 insertions, 1 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 4ffd96e324..7f0d9fb9f3 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -213,6 +213,7 @@ PortMatrix::setup ()
_body->setup ();
setup_scrollbars ();
+ update_tab_highlighting ();
queue_draw ();
}
@@ -777,6 +778,7 @@ PortMatrix::setup_notebooks ()
dummy->show ();
Label* label = manage (new Label ((*i)->name));
label->set_angle (_arrangement == LEFT_TO_BOTTOM ? 90 : -90);
+ label->set_use_markup ();
label->show ();
if (_arrangement == LEFT_TO_BOTTOM) {
_vnotebook.prepend_page (*dummy, *label);
@@ -792,7 +794,10 @@ PortMatrix::setup_notebooks ()
for (PortGroupList::List::const_iterator i = _ports[_column_index].begin(); i != _ports[_column_index].end(); ++i) {
HBox* dummy = manage (new HBox);
dummy->show ();
- _hnotebook.append_page (*dummy, (*i)->name);
+ Label* label = manage (new Label ((*i)->name));
+ label->set_use_markup ();
+ label->show ();
+ _hnotebook.append_page (*dummy, *label);
}
_ignore_notebook_page_selected = false;
@@ -954,6 +959,55 @@ void
PortMatrix::port_connected_or_disconnected ()
{
_body->rebuild_and_draw_grid ();
+ update_tab_highlighting ();
+}
+
+/** Update the highlighting of tab names to reflect which ones
+ * have connections. This is pretty inefficient, unfortunately,
+ * but maybe that doesn't matter too much.
+ */
+void
+PortMatrix::update_tab_highlighting ()
+{
+ for (int i = 0; i < 2; ++i) {
+
+ Gtk::Notebook* notebook = row_index() == i ? &_vnotebook : &_hnotebook;
+
+ PortGroupList const * gl = ports (i);
+ int p = 0;
+ for (PortGroupList::List::const_iterator j = gl->begin(); j != gl->end(); ++j) {
+ bool has_connection = false;
+ PortGroup::BundleList const & bl = (*j)->bundles ();
+ PortGroup::BundleList::const_iterator k = bl.begin ();
+ while (k != bl.end()) {
+ if ((*k)->bundle->connected_to_anything (_session->engine())) {
+ has_connection = true;
+ break;
+ }
+ ++k;
+ }
+
+ /* Find the page index that we should update; this is backwards
+ for the vertical tabs in the LEFT_TO_BOTTOM arrangement.
+ */
+ int page = p;
+ if (i == row_index() && _arrangement == LEFT_TO_BOTTOM) {
+ page = notebook->get_n_pages() - p - 1;
+ }
+
+ Gtk::Label* label = dynamic_cast<Gtk::Label*> (notebook->get_tab_label(*notebook->get_nth_page (page)));
+ string c = label->get_label ();
+ if (c.length() && c[0] == '<' && !has_connection) {
+ /* this label is marked up with <b> but shouldn't be */
+ label->set_markup ((*j)->name);
+ } else if (c.length() && c[0] != '<' && has_connection) {
+ /* this label is not marked up with <b> but should be */
+ label->set_markup (string_compose ("<b>%1</b>", (*j)->name));
+ }
+
+ ++p;
+ }
+ }
}
string
diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h
index be276c0484..5614293e45 100644
--- a/gtk2_ardour/port_matrix.h
+++ b/gtk2_ardour/port_matrix.h
@@ -198,6 +198,7 @@ private:
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);
void port_connected_or_disconnected ();
+ void update_tab_highlighting ();
Gtk::Window* _parent;
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h
index 46b07c48f5..2bf614e75f 100644
--- a/libs/ardour/ardour/bundle.h
+++ b/libs/ardour/ardour/bundle.h
@@ -99,6 +99,7 @@ class Bundle : public PBD::ScopedConnectionList
void connect (boost::shared_ptr<Bundle>, AudioEngine &);
void disconnect (boost::shared_ptr<Bundle>, AudioEngine &);
bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &);
+ bool connected_to_anything (AudioEngine &);
bool has_same_ports (boost::shared_ptr<Bundle>) const;
uint32_t type_channel_to_overall (DataType, uint32_t) const;
uint32_t overall_channel_to_type (DataType, uint32_t) const;
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index dd4bacdff2..6180836bd2 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -440,6 +440,34 @@ Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
return true;
}
+/** This must not be called in code executed as a response to a JACK event,
+ * as it uses jack_port_get_all_connections().
+ * @return true if any of this bundle's channels are connected to anything.
+ */
+bool
+Bundle::connected_to_anything (AudioEngine& engine)
+{
+ for (uint32_t i = 0; i < nchannels().n_total(); ++i) {
+ Bundle::PortList const & ports = channel_ports (i);
+
+ for (uint32_t j = 0; j < ports.size(); ++j) {
+ /* ports[j] may not be an Ardour port, so use JACK directly
+ rather than doing it with Port.
+ */
+ jack_port_t* jp = jack_port_by_name (engine.jack(), ports[j].c_str());
+ if (jp) {
+ const char ** c = jack_port_get_all_connections (engine.jack(), jp);
+ if (c) {
+ jack_free (c);
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
void
Bundle::set_ports_are_inputs ()
{