OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/controls/button/custom_button.h" | 5 #include "views/controls/button/custom_button.h" |
6 | 6 |
7 #include "app/throb_animation.h" | 7 #include "app/throb_animation.h" |
8 #include "base/keyboard_codes.h" | 8 #include "base/keyboard_codes.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 View::ShowContextMenu(x, y, is_mouse_gesture); | 212 View::ShowContextMenu(x, y, is_mouse_gesture); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void CustomButton::ViewHierarchyChanged(bool is_add, View *parent, | 216 void CustomButton::ViewHierarchyChanged(bool is_add, View *parent, |
217 View *child) { | 217 View *child) { |
218 if (!is_add && state_ != BS_DISABLED) | 218 if (!is_add && state_ != BS_DISABLED) |
219 SetState(BS_NORMAL); | 219 SetState(BS_NORMAL); |
220 } | 220 } |
221 | 221 |
| 222 void CustomButton::SetHotTracked(bool flag) { |
| 223 if (state_ != BS_DISABLED) |
| 224 SetState(flag ? BS_HOT : BS_NORMAL); |
| 225 } |
| 226 |
| 227 bool CustomButton::IsHotTracked() const { |
| 228 return state_ == BS_HOT; |
| 229 } |
| 230 |
| 231 void CustomButton::WillLoseFocus() { |
| 232 if (IsHotTracked()) |
| 233 SetState(BS_NORMAL); |
| 234 } |
| 235 |
222 //////////////////////////////////////////////////////////////////////////////// | 236 //////////////////////////////////////////////////////////////////////////////// |
223 // CustomButton, AnimationDelegate implementation: | 237 // CustomButton, AnimationDelegate implementation: |
224 | 238 |
225 void CustomButton::AnimationProgressed(const Animation* animation) { | 239 void CustomButton::AnimationProgressed(const Animation* animation) { |
226 SchedulePaint(); | 240 SchedulePaint(); |
227 } | 241 } |
228 | 242 |
229 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { | 243 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { |
230 return IsTriggerableEvent(e); | 244 return IsTriggerableEvent(e); |
231 } | 245 } |
(...skipping 11 matching lines...) Expand all Loading... |
243 | 257 |
244 bool CustomButton::IsHighlighted() const { | 258 bool CustomButton::IsHighlighted() const { |
245 return state_ == BS_HOT; | 259 return state_ == BS_HOT; |
246 } | 260 } |
247 | 261 |
248 bool CustomButton::IsPushed() const { | 262 bool CustomButton::IsPushed() const { |
249 return state_ == BS_PUSHED; | 263 return state_ == BS_PUSHED; |
250 } | 264 } |
251 | 265 |
252 } // namespace views | 266 } // namespace views |
OLD | NEW |