summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-11 22:39:18 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-11 22:39:18 +0000
commit5260b6683833c6d7c014346683b6bfc009f4ae72 (patch)
treeafd3eed25ba8689c173227fe8f133c8e1919a5f8
parent3ca8b36d5f5b9e4b8cd32f7f1c36c4a33a5f63b0 (diff)
downloadchromium_src-5260b6683833c6d7c014346683b6bfc009f4ae72.zip
chromium_src-5260b6683833c6d7c014346683b6bfc009f4ae72.tar.gz
chromium_src-5260b6683833c6d7c014346683b6bfc009f4ae72.tar.bz2
Make LabelButton respect the minimum size of its border. This is useful for
e.g. LabelButtonBorders containing painters with minimum sizes, so the embedder doesn't have to calculate and enforce the minimum size manually. BUG=none TEST=none R=msw@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/64743004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234300 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/controls/button/label_button.cc3
-rw-r--r--ui/views/controls/button/label_button_border.cc11
-rw-r--r--ui/views/controls/button/label_button_border.h3
3 files changed, 17 insertions, 0 deletions
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index 39140ed..4de6843 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -188,6 +188,9 @@ gfx::Size LabelButton::GetPreferredSize() {
const gfx::Insets insets(GetInsets());
size.Enlarge(image_size.width() + insets.width(), insets.height());
+ // Make the size at least as large as the minimum size needed by the border.
+ size.SetToMax(static_cast<LabelButtonBorder*>(border())->GetMinimumSize());
+
// Increase the minimum size monotonically with the preferred size.
size.SetToMax(min_size_);
min_size_ = size;
diff --git a/ui/views/controls/button/label_button_border.cc b/ui/views/controls/button/label_button_border.cc
index fb6ea06..a851199 100644
--- a/ui/views/controls/button/label_button_border.cc
+++ b/ui/views/controls/button/label_button_border.cc
@@ -169,4 +169,15 @@ void LabelButtonBorder::SetPainter(bool focused,
painters_[focused ? 1 : 0][state].reset(painter);
}
+gfx::Size LabelButtonBorder::GetMinimumSize() const {
+ gfx::Size minimum_size;
+ for (int i = 0; i < 2; ++i) {
+ for (int j = 0; j < Button::STATE_COUNT; ++j) {
+ if (painters_[i][j])
+ minimum_size.SetToMax(painters_[i][j]->GetMinimumSize());
+ }
+ }
+ return minimum_size;
+}
+
} // namespace views
diff --git a/ui/views/controls/button/label_button_border.h b/ui/views/controls/button/label_button_border.h
index 048d074..dc81d97 100644
--- a/ui/views/controls/button/label_button_border.h
+++ b/ui/views/controls/button/label_button_border.h
@@ -34,6 +34,9 @@ class VIEWS_EXPORT LabelButtonBorder : public Border {
Painter* GetPainter(bool focused, Button::ButtonState state);
void SetPainter(bool focused, Button::ButtonState state, Painter* painter);
+ // Calls GetMinimumSize() on all painters and returns the largest such size.
+ gfx::Size GetMinimumSize() const;
+
private:
// The painters used for each unfocused or focused button state.
scoped_ptr<Painter> painters_[2][Button::STATE_COUNT];