Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ui/views/animation/toolbar_ink_drop_delegate.cc

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt to refactor ink drop animations Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/events/event.h"
6 #include "ui/views/animation/ink_drop_animation_controller.h"
7 #include "ui/views/animation/ink_drop_state.h"
8 #include "ui/views/animation/toolbar_ink_drop_delegate.h"
9
10 namespace views {
11
12 ToolbarInkDropDelegate::ToolbarInkDropDelegate(
13 InkDropAnimationController* ink_drop_animation_controller)
14 : ink_drop_animation_controller_(ink_drop_animation_controller) {
15 }
16
17 ToolbarInkDropDelegate::~ToolbarInkDropDelegate() {
18 }
19
20 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
21 views::InkDropState ink_drop_state = views::InkDropState::HIDDEN;
22 LOG(ERROR) << __FUNCTION__ << " event:" << event->type();
23 switch (event->type()) {
24 case ui::ET_GESTURE_TAP_DOWN:
25 ink_drop_state = views::InkDropState::ACTION_PENDING;
26 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that
27 // subsequent events for the gesture are sent to |this|.
28 event->SetHandled();
29 break;
30 case ui::ET_GESTURE_LONG_PRESS:
31 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING;
32 break;
33 case ui::ET_GESTURE_LONG_TAP:
34 ink_drop_state = views::InkDropState::SLOW_ACTION;
35 break;
36 case ui::ET_GESTURE_SCROLL_BEGIN:
37 case ui::ET_GESTURE_END:
38 ink_drop_state = views::InkDropState::HIDDEN;
39 break;
40 default:
41 return;
42 }
43
44 views::InkDropState current_ink_drop_state =
45 ink_drop_animation_controller_->GetInkDropState();
46
47 if (ink_drop_state == views::InkDropState::HIDDEN &&
48 (current_ink_drop_state == views::InkDropState::QUICK_ACTION ||
49 current_ink_drop_state == views::InkDropState::SLOW_ACTION ||
50 current_ink_drop_state == views::InkDropState::DEACTIVATED)) {
51 // These InkDropStates automatically transition to the HIDDEN state so we
52 // don't make an explicit call. Explicitly animating to HIDDEN in this case
53 // would prematurely pre-empt these animations.
54 return;
55 }
56 LOG(ERROR) << __FUNCTION__ << " state:" << (int)ink_drop_state;
57 ink_drop_animation_controller_->AnimateToState(ink_drop_state);
58 }
59
60 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698