diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-30 21:15:51 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-30 21:15:51 +0000 |
commit | 5e7b4559fefc15e91ccafdb6ea5ba52211d6cef0 (patch) | |
tree | 7cae2c87ce08bcf040a1825b4e2283d0d9d938eb /libs/gtkmm2ext/utils.cc | |
parent | 2cf464cf1daeb2dfdbb8445ff49df67fc85af26c (diff) |
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
Diffstat (limited to 'libs/gtkmm2ext/utils.cc')
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 43 |
1 files changed, 22 insertions, 21 deletions
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<string> copy; + const vector<string>* to_use; + vector<string>::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<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) { + for (vector<string>::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<string>& str cr.clear (); if (set_size) { - vector<string> 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) { |