fix a-eq grid layout
[ardour.git] / gtk2_ardour / ardour_button.cc
index fbc6defdc1b947597a77e221c7baffd0f41458d7..922ba84d2c08ae82739395e7af749440c9bcc899 100644 (file)
@@ -58,7 +58,8 @@ ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element
 ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
 
 ArdourButton::ArdourButton (Element e)
-       : _elements (e)
+       : _sizing_text("")
+       , _elements (e)
        , _icon (Gtkmm2ext::ArdourIcon::NoIcon)
        , _tweaks (Tweaks (0))
        , _char_pixel_width (0)
@@ -95,7 +96,6 @@ ArdourButton::ArdourButton (Element e)
        , _ellipsis (Pango::ELLIPSIZE_NONE)
        , _update_colors (true)
        , _pattern_height (0)
-       , _sizing_text("")
 {
        UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
        /* This is not provided by gtkmm */
@@ -103,7 +103,8 @@ ArdourButton::ArdourButton (Element e)
 }
 
 ArdourButton::ArdourButton (const std::string& str, Element e)
-       : _elements (e)
+       : _sizing_text("")
+       , _elements (e)
        , _tweaks (Tweaks (0))
        , _char_pixel_width (0)
        , _char_pixel_height (0)
@@ -139,7 +140,6 @@ ArdourButton::ArdourButton (const std::string& str, Element e)
        , _ellipsis (Pango::ELLIPSIZE_NONE)
        , _update_colors (true)
        , _pattern_height (0)
-       , _sizing_text("")
 {
        set_text (str);
        UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
@@ -649,7 +649,7 @@ ArdourButton::on_size_request (Gtk::Requisition* req)
                        req->width = req->height;
                if (req->height < req->width)
                        req->height = req->width;
-       } else if (_text_width > 0 && !(_elements & (Menu | Indicator))) {
+       } else if (_sizing_text.empty() && _text_width > 0 && !(_elements & (Menu | Indicator))) {
                // properly centered text for those elements that are centered
                // (no sub-pixel offset)
                if ((req->width - _text_width) & 1) { ++req->width; }
@@ -965,6 +965,11 @@ ArdourButton::on_style_changed (const RefPtr<Gtk::Style>&)
 {
        _update_colors = true;
        CairoWidget::set_dirty ();
+       _char_pixel_width = 0;
+       _char_pixel_height = 0;
+       if (is_realized()) {
+               queue_resize ();
+       }
 }
 
 void