From fa1e12b682e66ef6eb30de9aaad7ac919eb10634 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 21 May 2012 21:50:29 +0000 Subject: Slightly hacky improvement to embolden the labels of connection matrix tabs when they have connections. git-svn-id: svn://localhost/ardour2/branches/3.0@12371 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_matrix.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'gtk2_ardour/port_matrix.cc') 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 (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 but shouldn't be */ + label->set_markup ((*j)->name); + } else if (c.length() && c[0] != '<' && has_connection) { + /* this label is not marked up with but should be */ + label->set_markup (string_compose ("%1", (*j)->name)); + } + + ++p; + } + } } string -- cgit v1.2.3