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

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

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the InkDropAnimationControllerImpl to destroy its timer when not running. Created 4 years, 10 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_animation.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_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 25 matching lines...) Expand all
36 36
37 void ButtonInkDropDelegate::OnLayout() { 37 void ButtonInkDropDelegate::OnLayout() {
38 ink_drop_animation_controller_->SetInkDropCenter( 38 ink_drop_animation_controller_->SetInkDropCenter(
39 ink_drop_host_->CalculateInkDropCenter()); 39 ink_drop_host_->CalculateInkDropCenter());
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 void ButtonInkDropDelegate::SetHovered(bool is_hovered) {
47 ink_drop_animation_controller_->SetHovered(is_hovered);
48 }
49
46 //////////////////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////////////////
47 // ui::EventHandler: 51 // ui::EventHandler:
48 52
53 void ButtonInkDropDelegate::OnMouseEvent(ui::MouseEvent* event) {
54 switch (event->type()) {
55 case ui::ET_MOUSE_ENTERED:
56 case ui::ET_MOUSE_EXITED:
57 SetHovered(ink_drop_host_->ShouldShowInkDropHover());
58 break;
59 default:
60 return;
61 }
62 }
63
49 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) { 64 void ButtonInkDropDelegate::OnGestureEvent(ui::GestureEvent* event) {
50 InkDropState current_ink_drop_state = 65 InkDropState current_ink_drop_state =
51 ink_drop_animation_controller_->GetInkDropState(); 66 ink_drop_animation_controller_->GetInkDropState();
52 67
53 InkDropState ink_drop_state = InkDropState::HIDDEN; 68 InkDropState ink_drop_state = InkDropState::HIDDEN;
54 switch (event->type()) { 69 switch (event->type()) {
55 case ui::ET_GESTURE_TAP_DOWN: 70 case ui::ET_GESTURE_TAP_DOWN:
56 ink_drop_state = InkDropState::ACTION_PENDING; 71 ink_drop_state = InkDropState::ACTION_PENDING;
57 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that 72 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that
58 // subsequent events for the gesture are sent to |this|. 73 // subsequent events for the gesture are sent to |this|.
(...skipping 22 matching lines...) Expand all
81 current_ink_drop_state == InkDropState::DEACTIVATED)) { 96 current_ink_drop_state == InkDropState::DEACTIVATED)) {
82 // These InkDropStates automatically transition to the HIDDEN state so we 97 // These InkDropStates automatically transition to the HIDDEN state so we
83 // don't make an explicit call. Explicitly animating to HIDDEN in this case 98 // don't make an explicit call. Explicitly animating to HIDDEN in this case
84 // would prematurely pre-empt these animations. 99 // would prematurely pre-empt these animations.
85 return; 100 return;
86 } 101 }
87 ink_drop_animation_controller_->AnimateToState(ink_drop_state); 102 ink_drop_animation_controller_->AnimateToState(ink_drop_state);
88 } 103 }
89 104
90 } // namespace views 105 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/button_ink_drop_delegate.h ('k') | ui/views/animation/ink_drop_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698