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 || |
Peter Kasting
2013/05/13 22:40:35
Nit: Please leave in place parens around all binar
ckocagil
2013/05/14 11:28:27
Done.
| |
127 (state == TextButton::STATE_PRESSED))) { | 128 state == TextButton::STATE_PRESSED || |
128 painter = (state == TextButton::STATE_HOVERED) ? | 129 state == TextButton::STATE_NORMAL && animating)) { |
Peter Kasting
2013/05/13 22:40:35
Nit: Add a comment about why the animating flag me
ckocagil
2013/05/14 11:28:27
Done.
| |
129 hot_painter_.get() : pushed_painter_.get(); | 130 painter = (state == TextButton::STATE_PRESSED) ? |
131 pushed_painter_.get() : hot_painter_.get(); | |
130 } | 132 } |
131 if (painter) { | 133 if (painter && animating) { |
Peter Kasting
2013/05/13 22:40:35
Nit: Don't flatten the old nested conditional this
ckocagil
2013/05/14 11:28:27
Done.
| |
132 if (button->GetAnimation()->is_animating()) { | 134 // TODO(pkasting): Really this should crossfade between states so it could |
133 // TODO(pkasting): Really this should crossfade between states so it could | 135 // handle the case of having a non-NULL |normal_set_|. |
ckocagil
2013/05/12 16:50:46
There doesn't seem to be a |normal_set_| anymore,
msw
2013/05/12 21:40:36
The TODO is still valid, just rename |normal_set_|
ckocagil
2013/05/14 11:28:27
Done.
| |
134 // handle the case of having a non-NULL |normal_set_|. | 136 canvas->SaveLayerAlpha(static_cast<uint8>( |
135 canvas->SaveLayerAlpha(static_cast<uint8>( | 137 button->GetAnimation()->CurrentValueBetween(0, 255))); |
136 button->GetAnimation()->CurrentValueBetween(0, 255))); | 138 painter->Paint(canvas, view.size()); |
137 painter->Paint(canvas, view.size()); | 139 canvas->Restore(); |
138 canvas->Restore(); | 140 } else if (painter) { |
139 } else { | 141 painter->Paint(canvas, view.size()); |
140 painter->Paint(canvas, view.size()); | |
141 } | |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 //////////////////////////////////////////////////////////////////////////////// | 145 //////////////////////////////////////////////////////////////////////////////// |
146 // | 146 // |
147 // TextButtonNativeThemeBorder | 147 // TextButtonNativeThemeBorder |
148 // | 148 // |
149 //////////////////////////////////////////////////////////////////////////////// | 149 //////////////////////////////////////////////////////////////////////////////// |
150 | 150 |
151 TextButtonNativeThemeBorder::TextButtonNativeThemeBorder( | 151 TextButtonNativeThemeBorder::TextButtonNativeThemeBorder( |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 // when not using NativeThemeWin. | 812 // when not using NativeThemeWin. |
813 #if defined(OS_WIN) | 813 #if defined(OS_WIN) |
814 if (GetNativeTheme() == ui::NativeThemeWin::instance()) | 814 if (GetNativeTheme() == ui::NativeThemeWin::instance()) |
815 return; | 815 return; |
816 #endif | 816 #endif |
817 params->button.is_focused = HasFocus() && | 817 params->button.is_focused = HasFocus() && |
818 (focusable() || IsAccessibilityFocusable()); | 818 (focusable() || IsAccessibilityFocusable()); |
819 } | 819 } |
820 | 820 |
821 } // namespace views | 821 } // namespace views |
OLD | NEW |