From c2b32631237fad9dd16c4be62304ac4f6b77b409 Mon Sep 17 00:00:00 2001 From: "georgey@chromium.org" Date: Wed, 16 Jun 2010 22:00:04 +0000 Subject: Fix for UI issues on AutoFill dialog on Windows. BUG=46525 TEST=In the bug. Review URL: http://codereview.chromium.org/2802005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50040 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/button/image_button.cc | 5 +++-- views/controls/button/image_button.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'views') diff --git a/views/controls/button/image_button.cc b/views/controls/button/image_button.cc index 1b9029a..c9de83f 100644 --- a/views/controls/button/image_button.cc +++ b/views/controls/button/image_button.cc @@ -19,7 +19,8 @@ static const int kDefaultHeight = 14; // Default button height if no theme. ImageButton::ImageButton(ButtonListener* listener) : CustomButton(listener), h_alignment_(ALIGN_LEFT), - v_alignment_(ALIGN_TOP) { + v_alignment_(ALIGN_TOP), + preferred_size_(kDefaultWidth, kDefaultHeight) { // By default, we request that the gfx::Canvas passed to our View::Paint() // implementation is flipped horizontally so that the button's bitmaps are // mirrored when the UI directionality is right-to-left. @@ -58,7 +59,7 @@ void ImageButton::SetImageAlignment(HorizontalAlignment h_align, gfx::Size ImageButton::GetPreferredSize() { if (!images_[BS_NORMAL].isNull()) return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height()); - return gfx::Size(kDefaultWidth, kDefaultHeight); + return preferred_size_; } void ImageButton::Paint(gfx::Canvas* canvas) { diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h index c99c77f..ffd426b 100644 --- a/views/controls/button/image_button.h +++ b/views/controls/button/image_button.h @@ -50,6 +50,12 @@ class ImageButton : public CustomButton { virtual gfx::Size GetPreferredSize(); virtual void Paint(gfx::Canvas* canvas); + // Sets preferred size, so it could be correctly positioned in layout even if + // it is NULL. + void SetPreferredSize(const gfx::Size& preferred_size) { + preferred_size_ = preferred_size; + } + protected: // Returns the image to paint. This is invoked from paint and returns a value // from images. @@ -65,6 +71,7 @@ class ImageButton : public CustomButton { // Image alignment. HorizontalAlignment h_alignment_; VerticalAlignment v_alignment_; + gfx::Size preferred_size_; DISALLOW_COPY_AND_ASSIGN(ImageButton); }; -- cgit v1.1