X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fui%2Fviews%2Fcontrols%2Fbutton%2Fimage_button.cc;h=1079d5e209b3effa2f44cad0eab34d03e717b6c6;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=ecbd4a1072443854e379004fe4214be65fd1846b;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ui/views/controls/button/image_button.cc b/src/ui/views/controls/button/image_button.cc index ecbd4a1..1079d5e 100644 --- a/src/ui/views/controls/button/image_button.cc +++ b/src/ui/views/controls/button/image_button.cc @@ -15,8 +15,11 @@ namespace views { -static const int kDefaultWidth = 16; // Default button width if no theme. -static const int kDefaultHeight = 14; // Default button height if no theme. +// Default button size if no image is set. This is ignored if there is an image, +// and exists for historical reasons (any number of clients could depend on this +// behaviour). +static const int kDefaultWidth = 16; +static const int kDefaultHeight = 14; const char ImageButton::kViewClassName[] = "ImageButton"; @@ -27,7 +30,6 @@ ImageButton::ImageButton(ButtonListener* listener) : CustomButton(listener), h_alignment_(ALIGN_LEFT), v_alignment_(ALIGN_TOP), - preferred_size_(kDefaultWidth, kDefaultHeight), draw_image_mirrored_(false), focus_painter_(Painter::CreateDashedFocusPainter()) { // By default, we request that the gfx::Canvas passed to our View::OnPaint() @@ -71,16 +73,26 @@ void ImageButton::SetFocusPainter(scoped_ptr focus_painter) { focus_painter_ = focus_painter.Pass(); } +void ImageButton::SetMinimumImageSize(const gfx::Size& size) { + if (minimum_image_size_ == size) + return; + + minimum_image_size_ = size; + PreferredSizeChanged(); +} + //////////////////////////////////////////////////////////////////////////////// // ImageButton, View overrides: gfx::Size ImageButton::GetPreferredSize() const { - gfx::Size size = preferred_size_; + gfx::Size size(kDefaultWidth, kDefaultHeight); if (!images_[STATE_NORMAL].isNull()) { size = gfx::Size(images_[STATE_NORMAL].width(), images_[STATE_NORMAL].height()); } + size.SetToMax(minimum_image_size_); + gfx::Insets insets = GetInsets(); size.Enlarge(insets.width(), insets.height()); return size;