OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/button_ink_drop_delegate.h" | 5 #include "ui/views/animation/button_ink_drop_delegate.h" |
6 | 6 |
7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
8 #include "ui/events/scoped_target_handler.h" | 8 #include "ui/events/scoped_target_handler.h" |
9 #include "ui/views/animation/ink_drop_animation_controller.h" | 9 #include "ui/views/animation/ink_drop_animation_controller.h" |
10 #include "ui/views/animation/ink_drop_animation_controller_factory.h" | 10 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 void ButtonInkDropDelegate::OnAction(InkDropState state) { | 42 void ButtonInkDropDelegate::OnAction(InkDropState state) { |
43 ink_drop_animation_controller_->AnimateToState(state); | 43 ink_drop_animation_controller_->AnimateToState(state); |
44 } | 44 } |
45 | 45 |
46 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
47 // ui::EventHandler: | 47 // ui::EventHandler: |
48 | 48 |
49 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) { | 49 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) { |
| 50 InkDropState current_ink_drop_state = |
| 51 ink_drop_animation_controller_->GetInkDropState(); |
| 52 |
50 InkDropState ink_drop_state = InkDropState::HIDDEN; | 53 InkDropState ink_drop_state = InkDropState::HIDDEN; |
51 switch (event->type()) { | 54 switch (event->type()) { |
52 case ui::ET_GESTURE_TAP_DOWN: | 55 case ui::ET_GESTURE_TAP_DOWN: |
53 ink_drop_state = InkDropState::ACTION_PENDING; | 56 ink_drop_state = InkDropState::ACTION_PENDING; |
54 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that | 57 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that |
55 // subsequent events for the gesture are sent to |this|. | 58 // subsequent events for the gesture are sent to |this|. |
56 event->SetHandled(); | 59 event->SetHandled(); |
57 break; | 60 break; |
58 case ui::ET_GESTURE_LONG_PRESS: | 61 case ui::ET_GESTURE_LONG_PRESS: |
59 ink_drop_state = InkDropState::SLOW_ACTION_PENDING; | 62 ink_drop_state = InkDropState::SLOW_ACTION_PENDING; |
60 break; | 63 break; |
61 case ui::ET_GESTURE_LONG_TAP: | 64 case ui::ET_GESTURE_LONG_TAP: |
62 ink_drop_state = InkDropState::SLOW_ACTION; | 65 ink_drop_state = InkDropState::SLOW_ACTION; |
63 break; | 66 break; |
| 67 case ui::ET_GESTURE_END: |
| 68 if (current_ink_drop_state == InkDropState::ACTIVATED) |
| 69 return; |
| 70 // Fall through to ui::ET_GESTURE_SCROLL_BEGIN case. |
64 case ui::ET_GESTURE_SCROLL_BEGIN: | 71 case ui::ET_GESTURE_SCROLL_BEGIN: |
65 case ui::ET_GESTURE_END: | |
66 ink_drop_state = InkDropState::HIDDEN; | 72 ink_drop_state = InkDropState::HIDDEN; |
67 break; | 73 break; |
68 default: | 74 default: |
69 return; | 75 return; |
70 } | 76 } |
71 | 77 |
72 InkDropState current_ink_drop_state = | |
73 ink_drop_animation_controller_->GetInkDropState(); | |
74 | |
75 if (ink_drop_state == InkDropState::HIDDEN && | 78 if (ink_drop_state == InkDropState::HIDDEN && |
76 (current_ink_drop_state == InkDropState::QUICK_ACTION || | 79 (current_ink_drop_state == InkDropState::QUICK_ACTION || |
77 current_ink_drop_state == InkDropState::SLOW_ACTION || | 80 current_ink_drop_state == InkDropState::SLOW_ACTION || |
78 current_ink_drop_state == InkDropState::DEACTIVATED)) { | 81 current_ink_drop_state == InkDropState::DEACTIVATED)) { |
79 // These InkDropStates automatically transition to the HIDDEN state so we | 82 // These InkDropStates automatically transition to the HIDDEN state so we |
80 // don't make an explicit call. Explicitly animating to HIDDEN in this case | 83 // don't make an explicit call. Explicitly animating to HIDDEN in this case |
81 // would prematurely pre-empt these animations. | 84 // would prematurely pre-empt these animations. |
82 return; | 85 return; |
83 } | 86 } |
84 ink_drop_animation_controller_->AnimateToState(ink_drop_state); | 87 ink_drop_animation_controller_->AnimateToState(ink_drop_state); |
85 } | 88 } |
86 | 89 |
87 } // namespace views | 90 } // namespace views |
OLD | NEW |