new PBD::ControllableDescriptor class to encapsulate parsing of binding URIs and...
[ardour.git] / libs / gtkmm2ext / utils.cc
index adcaaaaeb5ac1ac946bf969868c412a8b59f90ad..3a021bbe7bb94304fcec4322453d47b8a5e5596d 100644 (file)
@@ -59,8 +59,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;
@@ -68,11 +68,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);
 }
@@ -85,11 +84,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);
        }
 }