summaryrefslogtreecommitdiff
path: root/gtk2_ardour/mixer_strip.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-06-21 18:18:54 +0200
committerRobin Gareus <robin@gareus.org>2016-06-21 18:18:54 +0200
commite4ba62e4c40bf8620768f39827c3df1e82976f49 (patch)
treefa8a9e0460cb6bb6f4e598f7eeeeb379524b215a /gtk2_ardour/mixer_strip.cc
parent791cff6f462c6976b099c2694a9b0000aa29842d (diff)
show first word of comment on track's comment-button
Diffstat (limited to 'gtk2_ardour/mixer_strip.cc')
-rw-r--r--gtk2_ardour/mixer_strip.cc46
1 files changed, 24 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)
{