summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-03-13 13:01:23 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-03-13 13:01:23 +0000
commite8185a39f29cd9ec89b5827babe7ad3b3561d96a (patch)
treece767a3439c4aed44388be69a3d7ca120795d239 /libs
parent9917f30a180a33ffa9fd70d0b23174d304f4c308 (diff)
remove icky FUDGE-ness code when sizing ComboBoxText's (from an idea by david taht)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4829 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h13
-rw-r--r--libs/gtkmm2ext/utils.cc42
2 files changed, 44 insertions, 11 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index e664f2420d..7f986e738c 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -45,12 +45,21 @@ namespace Gtkmm2ext {
gint vpadding);
void set_size_request_to_display_given_text (Gtk::Widget &w,
- const std::vector<std::string>&,
+ const std::vector<std::string>&,
gint hpadding,
gint vpadding);
void set_popdown_strings (Gtk::ComboBoxText&,
- const std::vector<std::string>&);
+ const std::vector<std::string>&,
+ bool set_size = false,
+ gint hpadding = 0, gint vpadding = 0);
+
+ // Combo's are stupid - they steal space from the entry for the button
+#ifdef GTKOSX
+ static const guint32 COMBO_FUDGE = 38;
+#else
+ static const guint32 COMBO_FUDGE = 24;
+#endif
template<class T> void deferred_delete (void *ptr) {
delete static_cast<T *> (ptr);
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 20c7890162..a61c3d7fb8 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -60,8 +60,8 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *
void
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
- const std::vector<std::string>& strings,
- gint hpadding, gint vpadding)
+ const std::vector<std::string>& strings,
+ gint hpadding, gint vpadding)
{
int width, height;
@@ -69,11 +69,10 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
int height_max = 0;
w.ensure_style ();
- for (vector<string>::const_iterator i = strings.begin();
- i != strings.end(); ++i) {
- get_ink_pixel_size (w.create_pango_layout (*i), width, height);
- width_max = max(width_max,width);
- height_max = max(height_max, height);
+ for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
+ get_ink_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);
}
@@ -86,11 +85,36 @@ Gtkmm2ext::init ()
}
void
-Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
+Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings, bool set_size, gint hpadding, gint vpadding)
{
+ vector<string>::const_iterator i;
+
cr.clear ();
- for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
+ 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);
+ }
+ }
+
+ for (i = strings.begin(); i != strings.end(); ++i) {
cr.append_text (*i);
}
}