| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/button/image_button.h" | 5 #include "ui/views/controls/button/image_button.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/base/animation/throb_animation.h" | 8 #include "ui/base/animation/throb_animation.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/skbitmap_operations.h" | 10 #include "ui/gfx/skbitmap_operations.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 preferred_size_(kDefaultWidth, kDefaultHeight) { | 24 preferred_size_(kDefaultWidth, kDefaultHeight) { |
| 25 // By default, we request that the gfx::Canvas passed to our View::OnPaint() | 25 // By default, we request that the gfx::Canvas passed to our View::OnPaint() |
| 26 // implementation is flipped horizontally so that the button's bitmaps are | 26 // implementation is flipped horizontally so that the button's bitmaps are |
| 27 // mirrored when the UI directionality is right-to-left. | 27 // mirrored when the UI directionality is right-to-left. |
| 28 EnableCanvasFlippingForRTLUI(true); | 28 EnableCanvasFlippingForRTLUI(true); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ImageButton::~ImageButton() { | 31 ImageButton::~ImageButton() { |
| 32 } | 32 } |
| 33 | 33 |
| 34 void ImageButton::SetImage(ButtonState aState, const SkBitmap* anImage) { | 34 void ImageButton::SetImage(ButtonState state, const SkBitmap* anImage) { |
| 35 images_[aState] = anImage ? *anImage : SkBitmap(); | 35 images_[state] = anImage ? *anImage : SkBitmap(); |
| 36 PreferredSizeChanged(); | 36 PreferredSizeChanged(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ImageButton::SetBackground(SkColor color, | 39 void ImageButton::SetBackground(SkColor color, |
| 40 const SkBitmap* image, | 40 const SkBitmap* image, |
| 41 const SkBitmap* mask) { | 41 const SkBitmap* mask) { |
| 42 if (!image || !mask) { | 42 if (!image || !mask) { |
| 43 background_image_.reset(); | 43 background_image_.reset(); |
| 44 return; | 44 return; |
| 45 } | 45 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, | 165 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, |
| 166 string16* tooltip) const { | 166 string16* tooltip) const { |
| 167 if (!toggled_ || toggled_tooltip_text_.empty()) | 167 if (!toggled_ || toggled_tooltip_text_.empty()) |
| 168 return Button::GetTooltipText(p, tooltip); | 168 return Button::GetTooltipText(p, tooltip); |
| 169 | 169 |
| 170 *tooltip = toggled_tooltip_text_; | 170 *tooltip = toggled_tooltip_text_; |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace views | 174 } // namespace views |
| OLD | NEW |