| 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 "views/controls/button/custom_button.h" | 5 #include "views/controls/button/custom_button.h" |
| 6 | 6 |
| 7 #include "ui/base/accessibility/accessible_view_state.h" | 7 #include "ui/base/accessibility/accessible_view_state.h" |
| 8 #include "ui/base/animation/throb_animation.h" | 8 #include "ui/base/animation/throb_animation.h" |
| 9 #include "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
| 10 #include "views/screen.h" | 10 #include "views/screen.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (flag && GetWidget()) { | 84 if (flag && GetWidget()) { |
| 85 GetWidget()->NotifyAccessibilityEvent( | 85 GetWidget()->NotifyAccessibilityEvent( |
| 86 this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 86 this, ui::AccessibilityTypes::EVENT_FOCUS, true); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool CustomButton::IsHotTracked() const { | 90 bool CustomButton::IsHotTracked() const { |
| 91 return state_ == BS_HOT; | 91 return state_ == BS_HOT; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void CustomButton::SetEnabled(bool enabled) { | 94 void CustomButton::OnEnabledChanged() { |
| 95 if (enabled ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) | 95 if (View::IsEnabled() ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 if (enabled) | 98 if (View::IsEnabled()) |
| 99 SetState(IsMouseHovered() ? BS_HOT : BS_NORMAL); | 99 SetState(IsMouseHovered() ? BS_HOT : BS_NORMAL); |
| 100 else | 100 else |
| 101 SetState(BS_DISABLED); | 101 SetState(BS_DISABLED); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool CustomButton::IsEnabled() const { | 104 bool CustomButton::IsEnabled() const { |
| 105 return state_ != BS_DISABLED; | 105 return state_ != BS_DISABLED; |
| 106 } | 106 } |
| 107 | 107 |
| 108 std::string CustomButton::GetClassName() const { | 108 std::string CustomButton::GetClassName() const { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 bool CustomButton::IsFocusable() const { | 281 bool CustomButton::IsFocusable() const { |
| 282 return (state_ != BS_DISABLED) && View::IsFocusable(); | 282 return (state_ != BS_DISABLED) && View::IsFocusable(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void CustomButton::OnBlur() { | 285 void CustomButton::OnBlur() { |
| 286 if (IsHotTracked()) | 286 if (IsHotTracked()) |
| 287 SetState(BS_NORMAL); | 287 SetState(BS_NORMAL); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace views | 290 } // namespace views |
| OLD | NEW |