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/custom_button.h" | 5 #include "ui/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/event.h" | 9 #include "ui/base/event.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 is_throbbing_(false), | 288 is_throbbing_(false), |
289 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), | 289 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), |
290 request_focus_on_press_(true) { | 290 request_focus_on_press_(true) { |
291 hover_animation_.reset(new ui::ThrobAnimation(this)); | 291 hover_animation_.reset(new ui::ThrobAnimation(this)); |
292 hover_animation_->SetSlideDuration(kHoverFadeDurationMs); | 292 hover_animation_->SetSlideDuration(kHoverFadeDurationMs); |
293 } | 293 } |
294 | 294 |
295 void CustomButton::StateChanged() { | 295 void CustomButton::StateChanged() { |
296 } | 296 } |
297 | 297 |
298 bool CustomButton::IsTriggerableEvent(const Event& event) { | 298 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { |
299 return event.type() == ui::ET_GESTURE_TAP_DOWN || | 299 return event.type() == ui::ET_GESTURE_TAP_DOWN || |
300 event.type() == ui::ET_GESTURE_TAP || | 300 event.type() == ui::ET_GESTURE_TAP || |
301 (event.IsMouseEvent() && | 301 (event.IsMouseEvent() && |
302 (triggerable_event_flags_ & event.flags()) != 0); | 302 (triggerable_event_flags_ & event.flags()) != 0); |
303 } | 303 } |
304 | 304 |
305 bool CustomButton::ShouldEnterPushedState(const Event& event) { | 305 bool CustomButton::ShouldEnterPushedState(const ui::Event& event) { |
306 return IsTriggerableEvent(event); | 306 return IsTriggerableEvent(event); |
307 } | 307 } |
308 | 308 |
309 //////////////////////////////////////////////////////////////////////////////// | 309 //////////////////////////////////////////////////////////////////////////////// |
310 // CustomButton, View overrides (protected): | 310 // CustomButton, View overrides (protected): |
311 | 311 |
312 void CustomButton::ViewHierarchyChanged(bool is_add, View *parent, | 312 void CustomButton::ViewHierarchyChanged(bool is_add, View *parent, |
313 View *child) { | 313 View *child) { |
314 if (!is_add && state_ != BS_DISABLED) | 314 if (!is_add && state_ != BS_DISABLED) |
315 SetState(BS_NORMAL); | 315 SetState(BS_NORMAL); |
316 } | 316 } |
317 | 317 |
318 void CustomButton::OnBlur() { | 318 void CustomButton::OnBlur() { |
319 if (IsHotTracked()) | 319 if (IsHotTracked()) |
320 SetState(BS_NORMAL); | 320 SetState(BS_NORMAL); |
321 } | 321 } |
322 | 322 |
323 } // namespace views | 323 } // namespace views |
OLD | NEW |