diff options
author | Carl Hetherington <carl@carlh.net> | 2009-06-20 13:41:55 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-06-20 13:41:55 +0000 |
commit | b895b677bf29cca95fe0626616d7495113386b04 (patch) | |
tree | 41f6e065356445cc769c797aa11e4226e0babe05 /gtk2_ardour/utils.cc | |
parent | 379b19cfdc1c05d93249c902d9a8dd7e5a7737d8 (diff) |
Optional tabs down the LHS of the editor window to indicate edit group membership.
git-svn-id: svn://localhost/ardour2/branches/3.0@5220 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r-- | gtk2_ardour/utils.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index f5490c025a..dc410136d7 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -113,11 +113,43 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font return txt; } +std::pair<std::string, double> +fit_to_pixels (cairo_t* cr, std::string name, double avail) +{ + /* XXX hopefully there exists a more efficient way of doing this */ + + bool abbreviated = false; + uint32_t width = 0; + + while (1) { + if (name.length() <= 4) { + break; + } + + cairo_text_extents_t ext; + cairo_text_extents (cr, name.c_str(), &ext); + if (ext.width < avail) { + width = ext.width; + break; + } + + if (abbreviated) { + name = name.substr (0, name.length() - 4) + "..."; + } else { + name = name.substr (0, name.length() - 3) + "..."; + abbreviated = true; + } + } + + return std::make_pair (name, width); +} + + gint just_hide_it (GdkEventAny *ev, Gtk::Window *win) { win->hide (); - return TRUE; + return 0; } /* xpm2rgb copied from nixieclock, which bore the legend: |