summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-12-07 13:08:00 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-12-07 13:08:00 +0000
commitbb737997aea86f08ec16e6444f3666ff6a524be2 (patch)
tree6264b4a2b3357707f447878ef84c7911b8f107fa /gtk2_ardour/utils.cc
parent2f837b66f75ad95ff5b6032ca8600bed6ba79fe5 (diff)
move 2 other non-ardour-specific utility functions into gtkmm2ext
git-svn-id: svn://localhost/ardour2/branches/3.0@10932 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc93
1 files changed, 0 insertions, 93 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index f2e774740d..23cceba72e 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -63,99 +63,6 @@ using Gtkmm2ext::Keyboard;
sigc::signal<void> DPIReset;
-int
-pixel_width (const string& str, Pango::FontDescription& font)
-{
- Label foo;
- Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
-
- layout->set_font_description (font);
- layout->set_text (str);
-
- int width, height;
- Gtkmm2ext::get_ink_pixel_size (layout, width, height);
- return width;
-}
-
-string
-fit_to_pixels (const string& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
-{
- Label foo;
- Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
- string::size_type shorter_by = 0;
- string txt;
-
- layout->set_font_description (font);
-
- actual_width = 0;
-
- string ustr = str;
- string::iterator last = ustr.end();
- --last; /* now points at final entry */
-
- txt = ustr;
-
- while (!ustr.empty()) {
-
- layout->set_text (txt);
-
- int width, height;
- Gtkmm2ext::get_ink_pixel_size (layout, width, height);
-
- if (width < pixel_width) {
- actual_width = width;
- break;
- }
-
- ustr.erase (last--);
- shorter_by++;
-
- if (with_ellipses && shorter_by > 3) {
- txt = ustr;
- txt += "...";
- } else {
- txt = ustr;
- }
- }
-
- return txt;
-}
-
-/** Try to fit a string into a given horizontal space by ellipsizing it.
- * @param cr Cairo context in which the text will be plotted.
- * @param name Text.
- * @param avail Available horizontal space.
- * @return (Text, possibly ellipsized) and (horizontal size of text)
- */
-
-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) {
- cairo_text_extents_t ext;
- cairo_text_extents (cr, name.c_str(), &ext);
-
- if (ext.width < avail || name.length() <= 4) {
- 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);
-}
-
/** Add an element to a menu, settings its sensitivity.
* @param m Menu to add to.