From 5e7b4559fefc15e91ccafdb6ea5ba52211d6cef0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 30 Dec 2010 21:15:51 +0000 Subject: resize all editor comboboxes when DPI is reset. involved a minor refactoring of some code and the spreading of the awful COMBO_FUDGE+10 hack git-svn-id: svn://localhost/ardour2/branches/3.0@8398 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/gtkmm2ext/utils.cc | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'libs/gtkmm2ext/utils.cc') diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index cded38786e..afff784ae8 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -82,12 +82,32 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, int width_max = 0; int height_max = 0; w.ensure_style (); + vector copy; + const vector* to_use; + vector::const_iterator i; + + for (i = strings.begin(); i != strings.end(); ++i) { + if ((*i).find_first_of ("gy") != string::npos) { + /* contains a descender */ + break; + } + } + + if (i == strings.end()) { + /* make a copy of the strings then add one that has a descener */ + copy = strings; + copy.push_back ("g"); + to_use = © + } else { + to_use = &strings; + } - for (vector::const_iterator i = strings.begin(); i != strings.end(); ++i) { + for (vector::const_iterator i = to_use->begin(); i != to_use->end(); ++i) { get_pixel_size (w.create_pango_layout (*i), width, height); width_max = max(width_max,width); height_max = max(height_max, height); } + w.set_size_request(width_max + hpadding, height_max + vpadding); } @@ -207,26 +227,7 @@ Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector& str cr.clear (); if (set_size) { - vector copy; - - for (i = strings.begin(); i != strings.end(); ++i) { - if ((*i).find_first_of ("gy") != string::npos) { - /* contains a descender */ - break; - } - } - - if (i == strings.end()) { - - /* make a copy of the strings then add one that has a descener */ - - copy = strings; - copy.push_back ("g"); - set_size_request_to_display_given_text (cr, copy, COMBO_FUDGE+10+hpadding, 15+vpadding); - - } else { - set_size_request_to_display_given_text (cr, strings, COMBO_FUDGE+10+hpadding, 15+vpadding); - } + set_size_request_to_display_given_text (cr, strings, COMBO_FUDGE+10+hpadding, 15+vpadding); } for (i = strings.begin(); i != strings.end(); ++i) { -- cgit v1.2.3