diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-12-14 16:21:43 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-12-14 16:21:43 +0000 |
commit | 0d6c5f78e9b7986afb220c559015da53a36e4e03 (patch) | |
tree | 59d81d0cee6884a7f6208af5012863e8da86ffe1 /gtk2_ardour/utils.cc | |
parent | b7f645cbe633cf1235c5bc28df7f93254b3a15f0 (diff) |
fix for crash when loading a session after running another, caused by not checking for _view != 0 in route_time_axis.cc; make fit_to_pixels() more useful and use it to truncate redirect and redirect parameters names in track control area
git-svn-id: svn://localhost/ardour2/trunk@1212 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r-- | gtk2_ardour/utils.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 389d43d2f2..887494829e 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -46,11 +46,13 @@ using namespace Glib; using namespace PBD; ustring -fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width) +fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses) { Label foo; Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (""); - + ustring::size_type shorter_by = 0; + ustring txt; + layout->set_font_description (font); actual_width = 0; @@ -59,9 +61,11 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font ustring::iterator last = ustr.end(); --last; /* now points at final entry */ + txt = ustr; + while (!ustr.empty()) { - layout->set_text (ustr); + layout->set_text (txt); int width, height; Gtkmm2ext::get_ink_pixel_size (layout, width, height); @@ -72,9 +76,17 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font } ustr.erase (last--); + shorter_by++; + + if (with_ellipses && shorter_by > 3) { + txt = ustr; + txt += "..."; + } else { + txt = ustr; + } } - return ustr; + return txt; } gint |