Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: views/controls/button/custom_button.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(bool enabled) {
95 if (enabled ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) 95 if (enabled ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED))
96 return; 96 return;
97 97
98 if (enabled) 98 if (enabled)
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 {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698