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

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 (moving more stuff into InkDropDelegate) 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_animation_controller_factory.h"
8 #include "ui/views/animation/ink_drop_host.h"
9 #include "ui/views/animation/ink_drop_state.h"
10 #include "ui/views/animation/toolbar_ink_drop_delegate.h"
11
12 namespace views {
13
14 ToolbarInkDropDelegate::ToolbarInkDropDelegate(InkDropHost* ink_drop_host)
15 : ink_drop_host_(ink_drop_host),
16 ink_drop_animation_controller_(
17 views::InkDropAnimationControllerFactory::
18 CreateInkDropAnimationController(ink_drop_host_)) {}
19
20 ToolbarInkDropDelegate::~ToolbarInkDropDelegate() {}
21
22 void ToolbarInkDropDelegate::SetInkDropSize(int large_size,
23 int large_corner_radius,
24 int small_size,
25 int small_corner_radius) {
26 ink_drop_animation_controller_->SetInkDropSize(
27 gfx::Size(large_size, large_size), large_corner_radius,
28 gfx::Size(small_size, small_size), small_corner_radius);
29 }
30
31 void ToolbarInkDropDelegate::Layout() {
32 ink_drop_animation_controller_->SetInkDropCenter(
33 ink_drop_host_->CalculateInkDropCenter());
34 }
35
36 void ToolbarInkDropDelegate::OnGestureEvent(const ui::GestureEvent& event) {
37 views::InkDropState ink_drop_state = views::InkDropState::HIDDEN;
38 switch (event.type()) {
39 case ui::ET_GESTURE_TAP_DOWN:
40 ink_drop_state = views::InkDropState::ACTION_PENDING;
41 break;
42 case ui::ET_GESTURE_LONG_PRESS:
43 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING;
44 break;
45 case ui::ET_GESTURE_LONG_TAP:
46 ink_drop_state = views::InkDropState::SLOW_ACTION;
47 break;
48 case ui::ET_GESTURE_SCROLL_BEGIN:
49 case ui::ET_GESTURE_END:
50 ink_drop_state = views::InkDropState::HIDDEN;
51 break;
52 default:
53 return;
54 }
55
56 views::InkDropState current_ink_drop_state =
57 ink_drop_animation_controller_->GetInkDropState();
58
59 if (ink_drop_state == views::InkDropState::HIDDEN &&
60 (current_ink_drop_state == views::InkDropState::QUICK_ACTION ||
61 current_ink_drop_state == views::InkDropState::SLOW_ACTION ||
62 current_ink_drop_state == views::InkDropState::DEACTIVATED)) {
63 // These InkDropStates automatically transition to the HIDDEN state so we
64 // don't make an explicit call. Explicitly animating to HIDDEN in this case
65 // would prematurely pre-empt these animations.
66 return;
67 }
68 ink_drop_animation_controller_->AnimateToState(ink_drop_state);
69 }
70
71 void ToolbarInkDropDelegate::OnActionComplete() {
72 ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN);
73 }
74
75 void ToolbarInkDropDelegate::OnActionPending(const ui::Event& event) {
76 ink_drop_animation_controller_->AnimateToState(
77 views::InkDropState::ACTION_PENDING);
78 }
79
80 void ToolbarInkDropDelegate::OnActionQuick() {
81 ink_drop_animation_controller_->AnimateToState(
82 views::InkDropState::QUICK_ACTION);
83 }
84
85 void ToolbarInkDropDelegate::OnActivated() {
86 ink_drop_animation_controller_->AnimateToState(
87 views::InkDropState::ACTIVATED);
88 }
89
90 void ToolbarInkDropDelegate::OnDeactivated() {
91 ink_drop_animation_controller_->AnimateToState(
92 views::InkDropState::DEACTIVATED);
93 }
94
95 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698