summaryrefslogtreecommitdiffstats
path: root/views/controls/button/text_button.cc
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls/button/text_button.cc')
-rw-r--r--views/controls/button/text_button.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index c88af99..9d4cf72 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -653,13 +653,7 @@ gfx::Size TextButton::GetPreferredSize() {
void TextButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
TextButtonBase::PaintButton(canvas, mode);
- SkBitmap icon = icon_;
- if (show_multiple_icon_states_) {
- if (has_hover_icon_ && (state() == BS_HOT))
- icon = icon_hover_;
- else if (has_pushed_icon_ && (state() == BS_PUSHED))
- icon = icon_pushed_;
- }
+ const SkBitmap& icon = GetImageToPaint();
if (icon.width() > 0) {
gfx::Rect text_bounds = GetTextBounds();
@@ -702,14 +696,7 @@ void TextButton::GetExtraParams(gfx::NativeTheme::ExtraParams* params) const {
gfx::Rect TextButton::GetTextBounds() const {
int extra_width = 0;
- SkBitmap icon = icon_;
- if (show_multiple_icon_states_) {
- if (has_hover_icon_ && (state() == BS_HOT))
- icon = icon_hover_;
- else if (has_pushed_icon_ && (state() == BS_PUSHED))
- icon = icon_pushed_;
- }
-
+ const SkBitmap& icon = GetImageToPaint();
if (icon.width() > 0)
extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_);
@@ -727,4 +714,14 @@ gfx::Rect TextButton::GetTextBounds() const {
return bounds;
}
+const SkBitmap& TextButton::GetImageToPaint() const {
+ if (show_multiple_icon_states_) {
+ if (has_hover_icon_ && (state() == BS_HOT))
+ return icon_hover_;
+ if (has_pushed_icon_ && (state() == BS_PUSHED))
+ return icon_pushed_;
+ }
+ return icon_;
+}
+
} // namespace views