OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/animation/throb_animation.h" | 7 #include "ui/base/animation/throb_animation.h" |
8 #include "ui/base/keycodes/keyboard_codes.h" | 8 #include "ui/base/keycodes/keyboard_codes.h" |
9 #include "views/screen.h" | 9 #include "views/screen.h" |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
132 // CustomButton, View overrides (protected): | 132 // CustomButton, View overrides (protected): |
133 | 133 |
134 bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { | 134 bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { |
135 if (!enabled_) | 135 if (!enabled_) |
136 return false; | 136 return false; |
137 | 137 |
138 SetState(BS_NORMAL); | 138 SetState(BS_NORMAL); |
139 KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.GetKeyCode(), | 139 KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.GetKeyCode(), |
140 accelerator.modifiers(), 0, 0); | 140 accelerator.modifiers()); |
141 NotifyClick(key_event); | 141 NotifyClick(key_event); |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 bool CustomButton::OnMousePressed(const MouseEvent& e) { | 145 bool CustomButton::OnMousePressed(const MouseEvent& e) { |
146 if (state_ != BS_DISABLED) { | 146 if (state_ != BS_DISABLED) { |
147 if (ShouldEnterPushedState(e) && HitTest(e.location())) | 147 if (ShouldEnterPushedState(e) && HitTest(e.location())) |
148 SetState(BS_PUSHED); | 148 SetState(BS_PUSHED); |
149 if (request_focus_on_press_) | 149 if (request_focus_on_press_) |
150 RequestFocus(); | 150 RequestFocus(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 void CustomButton::AnimationProgressed(const ui::Animation* animation) { | 267 void CustomButton::AnimationProgressed(const ui::Animation* animation) { |
268 SchedulePaint(); | 268 SchedulePaint(); |
269 } | 269 } |
270 | 270 |
271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { | 271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { |
272 return IsTriggerableEvent(e); | 272 return IsTriggerableEvent(e); |
273 } | 273 } |
274 | 274 |
275 } // namespace views | 275 } // namespace views |
OLD | NEW |