Chromium Code Reviews| Index: ui/views/animation/toolbar_ink_drop_delegate.cc |
| diff --git a/ui/views/animation/toolbar_ink_drop_delegate.cc b/ui/views/animation/toolbar_ink_drop_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..66a098ab89d62743b49ab1d90c2a19d5e400de35 |
| --- /dev/null |
| +++ b/ui/views/animation/toolbar_ink_drop_delegate.cc |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/events/event.h" |
| +#include "ui/views/animation/ink_drop_animation_controller.h" |
| +#include "ui/views/animation/ink_drop_state.h" |
| +#include "ui/views/animation/toolbar_ink_drop_delegate.h" |
| + |
| +namespace views { |
| + |
| +ToolbarInkDropDelegate::ToolbarInkDropDelegate( |
| + InkDropAnimationController* ink_drop_animation_controller) |
| + : ink_drop_animation_controller_(ink_drop_animation_controller) { |
| +} |
| + |
| +ToolbarInkDropDelegate::~ToolbarInkDropDelegate() { |
| +} |
| + |
| +void ToolbarInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) { |
|
bruthig
2015/11/06 20:29:11
Just re-iterating my quick parting comments from w
varkha
2015/11/06 20:51:50
Maybe. This however allows to refactor what we hav
|
| + views::InkDropState ink_drop_state = views::InkDropState::HIDDEN; |
| + LOG(ERROR) << __FUNCTION__ << " event:" << event->type(); |
| + switch (event->type()) { |
| + case ui::ET_GESTURE_TAP_DOWN: |
| + ink_drop_state = views::InkDropState::ACTION_PENDING; |
| + // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that |
| + // subsequent events for the gesture are sent to |this|. |
| + event->SetHandled(); |
| + break; |
| + case ui::ET_GESTURE_LONG_PRESS: |
| + ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; |
| + break; |
| + case ui::ET_GESTURE_LONG_TAP: |
| + ink_drop_state = views::InkDropState::SLOW_ACTION; |
| + break; |
| + case ui::ET_GESTURE_SCROLL_BEGIN: |
| + case ui::ET_GESTURE_END: |
| + ink_drop_state = views::InkDropState::HIDDEN; |
| + break; |
| + default: |
| + return; |
| + } |
| + |
| + views::InkDropState current_ink_drop_state = |
| + ink_drop_animation_controller_->GetInkDropState(); |
| + |
| + if (ink_drop_state == views::InkDropState::HIDDEN && |
| + (current_ink_drop_state == views::InkDropState::QUICK_ACTION || |
| + current_ink_drop_state == views::InkDropState::SLOW_ACTION || |
| + current_ink_drop_state == views::InkDropState::DEACTIVATED)) { |
| + // These InkDropStates automatically transition to the HIDDEN state so we |
| + // don't make an explicit call. Explicitly animating to HIDDEN in this case |
| + // would prematurely pre-empt these animations. |
| + return; |
| + } |
| + LOG(ERROR) << __FUNCTION__ << " state:" << (int)ink_drop_state; |
| + ink_drop_animation_controller_->AnimateToState(ink_drop_state); |
| +} |
| + |
| +} // namespace views |