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/accessibility/ax_node_data.h" | 7 #include "ui/accessibility/ax_node_data.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 void CustomButton::StateChanged(ButtonState old_state) {} | 441 void CustomButton::StateChanged(ButtonState old_state) {} |
442 | 442 |
443 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { | 443 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { |
444 return event.type() == ui::ET_GESTURE_TAP_DOWN || | 444 return event.type() == ui::ET_GESTURE_TAP_DOWN || |
445 event.type() == ui::ET_GESTURE_TAP || | 445 event.type() == ui::ET_GESTURE_TAP || |
446 (event.IsMouseEvent() && | 446 (event.IsMouseEvent() && |
447 (triggerable_event_flags_ & event.flags()) != 0); | 447 (triggerable_event_flags_ & event.flags()) != 0); |
448 } | 448 } |
449 | 449 |
| 450 bool CustomButton::ShouldUpdateInkDropOnClickCanceled() const { |
| 451 return true; |
| 452 } |
| 453 |
450 bool CustomButton::ShouldEnterPushedState(const ui::Event& event) { | 454 bool CustomButton::ShouldEnterPushedState(const ui::Event& event) { |
451 return IsTriggerableEvent(event); | 455 return IsTriggerableEvent(event); |
452 } | 456 } |
453 | 457 |
454 bool CustomButton::ShouldEnterHoveredState() { | 458 bool CustomButton::ShouldEnterHoveredState() { |
455 if (!visible()) | 459 if (!visible()) |
456 return false; | 460 return false; |
457 | 461 |
458 bool check_mouse_position = true; | 462 bool check_mouse_position = true; |
459 #if defined(USE_AURA) | 463 #if defined(USE_AURA) |
(...skipping 20 matching lines...) Expand all Loading... |
480 | 484 |
481 void CustomButton::NotifyClick(const ui::Event& event) { | 485 void CustomButton::NotifyClick(const ui::Event& event) { |
482 if (has_ink_drop_action_on_click_) { | 486 if (has_ink_drop_action_on_click_) { |
483 AnimateInkDrop(InkDropState::ACTION_TRIGGERED, | 487 AnimateInkDrop(InkDropState::ACTION_TRIGGERED, |
484 ui::LocatedEvent::FromIfValid(&event)); | 488 ui::LocatedEvent::FromIfValid(&event)); |
485 } | 489 } |
486 Button::NotifyClick(event); | 490 Button::NotifyClick(event); |
487 } | 491 } |
488 | 492 |
489 void CustomButton::OnClickCanceled(const ui::Event& event) { | 493 void CustomButton::OnClickCanceled(const ui::Event& event) { |
490 if (GetInkDrop()->GetTargetInkDropState() == | 494 if (ShouldUpdateInkDropOnClickCanceled()) { |
491 views::InkDropState::ACTION_PENDING || | 495 if (GetInkDrop()->GetTargetInkDropState() == |
492 GetInkDrop()->GetTargetInkDropState() == | 496 views::InkDropState::ACTION_PENDING || |
493 views::InkDropState::ALTERNATE_ACTION_PENDING) { | 497 GetInkDrop()->GetTargetInkDropState() == |
494 AnimateInkDrop(views::InkDropState::HIDDEN, | 498 views::InkDropState::ALTERNATE_ACTION_PENDING) { |
495 ui::LocatedEvent::FromIfValid(&event)); | 499 AnimateInkDrop(views::InkDropState::HIDDEN, |
| 500 ui::LocatedEvent::FromIfValid(&event)); |
| 501 } |
496 } | 502 } |
497 Button::OnClickCanceled(event); | 503 Button::OnClickCanceled(event); |
498 } | 504 } |
499 | 505 |
500 } // namespace views | 506 } // namespace views |
OLD | NEW |