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

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

Issue 1937353002: Rename of InkDropAnimationController classes to InkDrop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tdanderson@ comments from patch set 2. Created 4 years, 7 months 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
« no previous file with comments | « ui/views/animation/button_ink_drop_delegate.h ('k') | ui/views/animation/ink_drop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h"
10 #include "ui/views/animation/ink_drop_animation_controller_factory.h" 10 #include "ui/views/animation/ink_drop_factory.h"
11 #include "ui/views/animation/ink_drop_host.h" 11 #include "ui/views/animation/ink_drop_host.h"
12 #include "ui/views/animation/ink_drop_state.h" 12 #include "ui/views/animation/ink_drop_state.h"
13 #include "ui/views/view.h" 13 #include "ui/views/view.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 ButtonInkDropDelegate::ButtonInkDropDelegate(InkDropHost* ink_drop_host, 17 ButtonInkDropDelegate::ButtonInkDropDelegate(InkDropHost* ink_drop_host,
18 View* view) 18 View* view)
19 : target_handler_(new ui::ScopedTargetHandler(view, this)), 19 : target_handler_(new ui::ScopedTargetHandler(view, this)),
20 ink_drop_host_(ink_drop_host), 20 ink_drop_host_(ink_drop_host),
21 ink_drop_animation_controller_( 21 ink_drop_(InkDropFactory::CreateInkDrop(ink_drop_host_)) {}
22 InkDropAnimationControllerFactory::CreateInkDropAnimationController(
23 ink_drop_host_)) {}
24 22
25 ButtonInkDropDelegate::~ButtonInkDropDelegate() { 23 ButtonInkDropDelegate::~ButtonInkDropDelegate() {
26 } 24 }
27 25
28 void ButtonInkDropDelegate::OnAction(InkDropState state) { 26 void ButtonInkDropDelegate::OnAction(InkDropState state) {
29 ink_drop_animation_controller_->AnimateToState(state); 27 ink_drop_->AnimateToState(state);
30 } 28 }
31 29
32 void ButtonInkDropDelegate::SnapToActivated() { 30 void ButtonInkDropDelegate::SnapToActivated() {
33 ink_drop_animation_controller_->SnapToActivated(); 31 ink_drop_->SnapToActivated();
34 } 32 }
35 33
36 void ButtonInkDropDelegate::SetHovered(bool is_hovered) { 34 void ButtonInkDropDelegate::SetHovered(bool is_hovered) {
37 ink_drop_animation_controller_->SetHovered(is_hovered); 35 ink_drop_->SetHovered(is_hovered);
38 } 36 }
39 37
40 //////////////////////////////////////////////////////////////////////////////// 38 ////////////////////////////////////////////////////////////////////////////////
41 // ui::EventHandler: 39 // ui::EventHandler:
42 40
43 void ButtonInkDropDelegate::OnMouseEvent(ui::MouseEvent* event) { 41 void ButtonInkDropDelegate::OnMouseEvent(ui::MouseEvent* event) {
44 switch (event->type()) { 42 switch (event->type()) {
45 case ui::ET_MOUSE_ENTERED: 43 case ui::ET_MOUSE_ENTERED:
46 SetHovered(true); 44 SetHovered(true);
47 break; 45 break;
48 case ui::ET_MOUSE_EXITED: 46 case ui::ET_MOUSE_EXITED:
49 SetHovered(false); 47 SetHovered(false);
50 break; 48 break;
51 default: 49 default:
52 return; 50 return;
53 } 51 }
54 } 52 }
55 53
56 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) { 54 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) {
57 InkDropState current_ink_drop_state = 55 InkDropState current_ink_drop_state = ink_drop_->GetTargetInkDropState();
58 ink_drop_animation_controller_->GetTargetInkDropState();
59 56
60 InkDropState ink_drop_state = InkDropState::HIDDEN; 57 InkDropState ink_drop_state = InkDropState::HIDDEN;
61 switch (event->type()) { 58 switch (event->type()) {
62 case ui::ET_GESTURE_TAP_DOWN: 59 case ui::ET_GESTURE_TAP_DOWN:
63 ink_drop_state = InkDropState::ACTION_PENDING; 60 ink_drop_state = InkDropState::ACTION_PENDING;
64 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that 61 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that
65 // subsequent events for the gesture are sent to |this|. 62 // subsequent events for the gesture are sent to |this|.
66 event->SetHandled(); 63 event->SetHandled();
67 break; 64 break;
68 case ui::ET_GESTURE_LONG_PRESS: 65 case ui::ET_GESTURE_LONG_PRESS:
(...skipping 17 matching lines...) Expand all
86 83
87 if (ink_drop_state == InkDropState::HIDDEN && 84 if (ink_drop_state == InkDropState::HIDDEN &&
88 (current_ink_drop_state == InkDropState::ACTION_TRIGGERED || 85 (current_ink_drop_state == InkDropState::ACTION_TRIGGERED ||
89 current_ink_drop_state == InkDropState::ALTERNATE_ACTION_TRIGGERED || 86 current_ink_drop_state == InkDropState::ALTERNATE_ACTION_TRIGGERED ||
90 current_ink_drop_state == InkDropState::DEACTIVATED)) { 87 current_ink_drop_state == InkDropState::DEACTIVATED)) {
91 // These InkDropStates automatically transition to the HIDDEN state so we 88 // These InkDropStates automatically transition to the HIDDEN state so we
92 // don't make an explicit call. Explicitly animating to HIDDEN in this case 89 // don't make an explicit call. Explicitly animating to HIDDEN in this case
93 // would prematurely pre-empt these animations. 90 // would prematurely pre-empt these animations.
94 return; 91 return;
95 } 92 }
96 ink_drop_animation_controller_->AnimateToState(ink_drop_state); 93 ink_drop_->AnimateToState(ink_drop_state);
97 } 94 }
98 95
99 } // namespace views 96 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/button_ink_drop_delegate.h ('k') | ui/views/animation/ink_drop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698