diff options
author | Robin Gareus <robin@gareus.org> | 2016-06-21 18:18:54 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-06-21 18:18:54 +0200 |
commit | e4ba62e4c40bf8620768f39827c3df1e82976f49 (patch) | |
tree | fa8a9e0460cb6bb6f4e598f7eeeeb379524b215a /gtk2_ardour | |
parent | 791cff6f462c6976b099c2694a9b0000aa29842d (diff) |
show first word of comment on track's comment-button
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/mixer_strip.cc | 46 | ||||
-rw-r--r-- | gtk2_ardour/mixer_strip.h | 1 |
2 files changed, 25 insertions, 22 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 7bc4839940..d7007184a7 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -263,7 +263,9 @@ MixerStrip::init () group_button.set_name ("mixer strip button"); _comment_button.set_name (X_("mixer strip button")); + _comment_button.set_text_ellipsize (Pango::ELLIPSIZE_END); _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor)); + _comment_button.signal_size_allocate().connect (sigc::mem_fun (*this, &MixerStrip::comment_button_resized)); // TODO implement ArdourKnob::on_size_request properly #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale())) @@ -1487,33 +1489,27 @@ MixerStrip::port_connected_or_disconnected (boost::weak_ptr<Port> wa, boost::wea void MixerStrip::setup_comment_button () { - switch (_width) { + std::string comment = _route->comment(); - case Wide: - if (_route->comment().empty ()) { - _comment_button.set_name ("generic button"); - _comment_button.set_text (_("Comments")); - } else { - _comment_button.set_name ("comment button"); - _comment_button.set_text (_("*Comments*")); - } - break; + set_tooltip (_comment_button, comment.empty() ? _("Click to add/edit comments") : _route->comment()); - case Narrow: - if (_route->comment().empty ()) { - _comment_button.set_name ("generic button"); - _comment_button.set_text (_("Cmt")); - } else { - _comment_button.set_name ("comment button"); - _comment_button.set_text (_("*Cmt*")); - } - break; + if (comment.empty ()) { + _comment_button.set_name ("generic button"); + _comment_button.set_text (_width == Wide ? _("Comments") : _("Cmt")); + return; } - set_tooltip ( - _comment_button, _route->comment().empty() ? _("Click to add/edit comments") : _route->comment() - ); + _comment_button.set_name ("comment button"); + string::size_type pos = comment.find_first_of (" \t\n"); + if (pos != string::npos) { + comment = comment.substr (0, pos); + } + if (comment.empty()) { + _comment_button.set_text (_width == Wide ? _("Comments") : _("Cmt")); + } else { + _comment_button.set_text (comment); + } } bool @@ -1791,6 +1787,12 @@ MixerStrip::name_button_resized (Gtk::Allocation& alloc) name_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE); } +void +MixerStrip::comment_button_resized (Gtk::Allocation& alloc) +{ + _comment_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE); +} + bool MixerStrip::width_button_pressed (GdkEventButton* ev) { diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index 9bffeb419e..0d815c4b3e 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -195,6 +195,7 @@ class MixerStrip : public AxisView, public RouteUI, public Gtk::EventBox void input_button_resized (Gtk::Allocation&); void output_button_resized (Gtk::Allocation&); + void comment_button_resized (Gtk::Allocation&); ArdourButton* midi_input_enable_button; Gtk::HBox input_button_box; |