OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/text_button.h" | 5 #include "ui/views/controls/button/text_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 TextButtonDefaultBorder::~TextButtonDefaultBorder() { | 112 TextButtonDefaultBorder::~TextButtonDefaultBorder() { |
113 } | 113 } |
114 | 114 |
115 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
116 // | 116 // |
117 // TextButtonDefaultBorder - painting | 117 // TextButtonDefaultBorder - painting |
118 // | 118 // |
119 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
120 void TextButtonDefaultBorder::Paint(const View& view, gfx::Canvas* canvas) { | 120 void TextButtonDefaultBorder::Paint(const View& view, gfx::Canvas* canvas) { |
121 const TextButton* button = static_cast<const TextButton*>(&view); | 121 const TextButton* button = static_cast<const TextButton*>(&view); |
122 int state = button->state(); | 122 const int state = button->state(); |
123 const bool animating = button->GetAnimation()->is_animating(); | |
123 | 124 |
124 Painter* painter = normal_painter_.get(); | 125 Painter* painter = normal_painter_.get(); |
125 if (button->show_multiple_icon_states() && | 126 if (button->show_multiple_icon_states() && |
126 ((state == TextButton::STATE_HOVERED) || | 127 ((state == TextButton::STATE_HOVERED) || |
127 (state == TextButton::STATE_PRESSED))) { | 128 (state == TextButton::STATE_PRESSED) || |
128 painter = (state == TextButton::STATE_HOVERED) ? | 129 ((state == TextButton::STATE_NORMAL) && animating))) { |
129 hot_painter_.get() : pushed_painter_.get(); | 130 // Also use the hot painter when we're STATE_NORMAL and |animating|. This is |
131 // to allow subclasses to have things like the bookmark throb animation. | |
Peter Kasting
2013/05/15 01:18:48
Nit: It would be nice to go even further to explai
ckocagil
2013/05/26 21:45:46
Done(?)
| |
132 painter = (state == TextButton::STATE_PRESSED) ? | |
133 pushed_painter_.get() : hot_painter_.get(); | |
130 } | 134 } |
131 if (painter) { | 135 if (painter) { |
132 if (button->GetAnimation()->is_animating()) { | 136 if (animating) { |
133 // TODO(pkasting): Really this should crossfade between states so it could | 137 // TODO(pkasting): Really this should crossfade between states so it could |
134 // handle the case of having a non-NULL |normal_set_|. | 138 // handle the case of having a non-NULL |normal_painter_|. |
135 canvas->SaveLayerAlpha(static_cast<uint8>( | 139 canvas->SaveLayerAlpha(static_cast<uint8>( |
136 button->GetAnimation()->CurrentValueBetween(0, 255))); | 140 button->GetAnimation()->CurrentValueBetween(0, 255))); |
137 painter->Paint(canvas, view.size()); | 141 painter->Paint(canvas, view.size()); |
138 canvas->Restore(); | 142 canvas->Restore(); |
139 } else { | 143 } else { |
140 painter->Paint(canvas, view.size()); | 144 painter->Paint(canvas, view.size()); |
141 } | 145 } |
142 } | 146 } |
143 } | 147 } |
144 | 148 |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 // when not using NativeThemeWin. | 816 // when not using NativeThemeWin. |
813 #if defined(OS_WIN) | 817 #if defined(OS_WIN) |
814 if (GetNativeTheme() == ui::NativeThemeWin::instance()) | 818 if (GetNativeTheme() == ui::NativeThemeWin::instance()) |
815 return; | 819 return; |
816 #endif | 820 #endif |
817 params->button.is_focused = HasFocus() && | 821 params->button.is_focused = HasFocus() && |
818 (focusable() || IsAccessibilityFocusable()); | 822 (focusable() || IsAccessibilityFocusable()); |
819 } | 823 } |
820 | 824 |
821 } // namespace views | 825 } // namespace views |
OLD | NEW |