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
This commit is contained in:
Carl Hetherington 2012-05-21 21:50:29 +00:00
parent 451a03d68a
commit fa1e12b682
4 changed files with 85 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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 ()
{