Index: ui/views/controls/button/label_button.h |
diff --git a/ui/views/controls/button/label_button.h b/ui/views/controls/button/label_button.h |
index bceaf715654a99e288ae0f677d463a2c16a5d6de..f23fece415c7838dfe7dc4a722a7f8158f84aab8 100644 |
--- a/ui/views/controls/button/label_button.h |
+++ b/ui/views/controls/button/label_button.h |
@@ -66,8 +66,14 @@ class VIEWS_EXPORT LabelButton : public CustomButton, |
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); |
// Call set_min_size(gfx::Size()) to clear the monotonically increasing size. |
- void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; } |
- void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } |
+ void set_min_size(const gfx::Size& min_size) { |
msw
2014/07/21 16:28:26
Rename these (SetMinSize, SetMaxSize) and define t
noms (inactive)
2014/07/21 17:18:51
Done.
|
+ min_size_ = min_size; |
+ ResetCachedSize(); |
+ } |
+ void set_max_size(const gfx::Size& max_size) { |
+ max_size_ = max_size; |
+ ResetCachedSize(); |
+ } |
// Get or set the option to handle the return key; false by default. |
bool is_default() const { return is_default_; } |
@@ -144,6 +150,9 @@ class VIEWS_EXPORT LabelButton : public CustomButton, |
virtual ui::NativeTheme::State GetForegroundThemeState( |
ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
+ // Resets |button_size_| and marks |button_size_valid_| as false. |
+ void ResetCachedSize(); |
+ |
// The image and label shown in the button. |
ImageView* image_; |
Label* label_; |
@@ -164,6 +173,10 @@ class VIEWS_EXPORT LabelButton : public CustomButton, |
// |max_size_| may be set to clamp the preferred size. |
gfx::Size max_size_; |
+ // Cache the last computed preferred size. |
+ mutable gfx::Size button_size_; |
+ mutable bool button_size_valid_; |
+ |
// Flag indicating default handling of the return key via an accelerator. |
// Whether or not the button appears or behaves as the default button in its |
// current context; |