From 0272c4f74941f96b8f0bd1c0c3f46649758ab9ce Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 11 Mar 2015 19:45:02 +0100 Subject: [PATCH] renice connection button labels * pango ellipsize text * use pretty-names if available --- gtk2_ardour/mixer_strip.cc | 69 ++++++++++++++++++++++++++++++-------- gtk2_ardour/mixer_strip.h | 3 ++ 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index a1e0ebe91c..423b0044d5 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -316,9 +316,14 @@ MixerStrip::init () input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false); input_button.signal_button_release_event().connect (sigc::mem_fun(*this, &MixerStrip::input_release), false); + input_button.signal_size_allocate().connect (sigc::mem_fun (*this, &MixerStrip::input_button_resized)); + + input_button.set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE); + output_button.set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE); output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false); output_button.signal_button_release_event().connect (sigc::mem_fun(*this, &MixerStrip::output_release), false); + output_button.signal_size_allocate().connect (sigc::mem_fun (*this, &MixerStrip::output_button_resized)); number_label.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::number_button_button_press), false); @@ -1148,7 +1153,6 @@ MixerStrip::update_io_button (boost::shared_ptr route, Width widt uint32_t other_connection_count = 0; ostringstream label; - string label_string; bool have_label = false; bool each_io_has_one_connection = true; @@ -1193,12 +1197,20 @@ MixerStrip::update_io_button (boost::shared_ptr route, Width widt if (!port_connections.empty()) { for (vector::iterator i = port_connections.begin(); i != port_connections.end(); ++i) { + string pn = ""; string& connection_name (*i); + if (connection_name.find("system:") == 0) { + pn = AudioEngine::instance()->get_pretty_name_by_name (connection_name); + } + if (io_connection_count == 0) { - tooltip << endl << Glib::Markup::escape_text(port->name().substr(port->name().find("/") + 1)) << " -> " << Glib::Markup::escape_text(connection_name); + tooltip << endl << Glib::Markup::escape_text(port->name().substr(port->name().find("/") + 1)) + << " -> " + << Glib::Markup::escape_text( pn.empty() ? connection_name : pn ); } else { - tooltip << ", " << Glib::Markup::escape_text(connection_name); + tooltip << ", " + << Glib::Markup::escape_text( pn.empty() ? connection_name : pn ); } if (connection_name.find("ardour:") == 0) { @@ -1213,6 +1225,32 @@ MixerStrip::update_io_button (boost::shared_ptr route, Width widt if (connection_name.find(ardour_track_name) == 0) { ++ardour_connection_count; } + } else if (!pn.empty()) { + if (system_ports.empty()) { + system_ports += pn; + } else { + system_ports += "/" + pn; + } + if (connection_name.find("system:") == 0) { + ++system_connection_count; + } + } else if (connection_name.find("system:midi_") == 0) { + if (for_input) { + // "system:midi_capture_123" -> "123" + system_port = connection_name.substr(20); + } else { + // "system:midi_playback_123" -> "123" + system_port = connection_name.substr(21); + } + + if (system_ports.empty()) { + system_ports += system_port; + } else { + system_ports += "/" + system_port; + } + + ++system_connection_count; + } else if (connection_name.find("system:") == 0) { if (for_input) { // "system:capture_123" -> "123" @@ -1296,19 +1334,10 @@ MixerStrip::update_io_button (boost::shared_ptr route, Width widt } } - switch (width) { - case Wide: - label_string = label.str().substr(0, 7); - break; - case Narrow: - label_string = label.str().substr(0, 3); - break; - } - if (for_input) { - input_button.set_text (label_string); + input_button.set_text (label.str()); } else { - output_button.set_text (label_string); + output_button.set_text (label.str()); } } @@ -1625,6 +1654,18 @@ MixerStrip::name_changed () } } +void +MixerStrip::input_button_resized (Gtk::Allocation& alloc) +{ + input_button.set_layout_ellisize_width (alloc.get_width() * PANGO_SCALE); +} + +void +MixerStrip::output_button_resized (Gtk::Allocation& alloc) +{ + output_button.set_layout_ellisize_width (alloc.get_width() * PANGO_SCALE); +} + void MixerStrip::name_button_resized (Gtk::Allocation& alloc) { diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index bd3c3a289b..46f5abd82f 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -183,6 +183,9 @@ class MixerStrip : public RouteUI, public Gtk::EventBox ArdourButton input_button; ArdourButton output_button; + void input_button_resized (Gtk::Allocation&); + void output_button_resized (Gtk::Allocation&); + ArdourButton* midi_input_enable_button; Gtk::HBox input_button_box; -- 2.30.2