renice connection button labels
authorRobin Gareus <robin@gareus.org>
Wed, 11 Mar 2015 18:45:02 +0000 (19:45 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 11 Mar 2015 19:06:41 +0000 (20:06 +0100)
* pango ellipsize text
* use pretty-names if available

gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h

index a1e0ebe91cafdaeb1ba448d08093364613ae155b..423b0044d590ee8ad769c417d28f653b38ff005f 100644 (file)
@@ -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<ARDOUR::Route> 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<ARDOUR::Route> route, Width widt
 
                if (!port_connections.empty()) {
                        for (vector<string>::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<ARDOUR::Route> 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<ARDOUR::Route> 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)
 {
index bd3c3a289b6b3cc3093be06c8eab95b8c1482db8..46f5abd82f3e18929d633bfa88c44b24077df6af 100644 (file)
@@ -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;