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

Side by Side Diff: ui/views/animation/ink_drop_animation_controller.h

Issue 1280953003: Enhance the material design ripple API so the ripple's state can be controlled by it's owning View. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed minor typo. Created 5 years, 4 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
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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "ui/compositor/layer_tree_owner.h"
10 #include "ui/events/event_handler.h" 11 #include "ui/events/event_handler.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
11 #include "ui/views/views_export.h" 14 #include "ui/views/views_export.h"
12 15
13 namespace ui { 16 namespace ui {
14 class Layer; 17 class Layer;
15 } 18 }
16 19
17 namespace views { 20 namespace views {
18 class AppearAnimationObserver; 21 class AppearAnimationObserver;
19 class InkDropDelegate; 22 class InkDropDelegate;
23 class InkDropHost;
20 class View; 24 class View;
21 25
22 // Controls an animation which can be associated to a ui::Layer backed View. 26 // The different states that the ink drop animation can be animated to.
23 // It sets itself as the pre-target handler for the supplied view, providing 27 enum class InkDropState {
24 // animations for user interactions. The events will not be consumed. 28 // The ink drop is not visible.
25 // 29 HIDDEN,
26 // The supplied views::View will be forced to have a layer, and this controller 30 // The view is being interacted with but the action to be triggered has not
27 // will add child layers to that. 31 // yet been determined.
28 class VIEWS_EXPORT InkDropAnimationController : public ui::EventHandler { 32 ACTION_PENDING,
33 // The quick action for the view has been triggered. e.g. A tap gesture to
34 // click a button.
35 QUICK_ACTION,
36 // The slow action for the view has been triggered. e.g. A long press to bring
37 // up a menu.
38 SLOW_ACTION,
39 // An active state for a view that is no longer being interacted with. e.g. A
40 // pressed button that is showing a menu.
41 ACTIVATED
42 };
43
44 // Base class for an ink drop animation which is hosted by an InkDropHost.
45 class VIEWS_EXPORT InkDropAnimationController {
29 public: 46 public:
30 explicit InkDropAnimationController(View* view); 47 InkDropAnimationController() {}
31 ~InkDropAnimationController() override; 48 virtual ~InkDropAnimationController() {}
49
50 // Animates from the current InkDropState to |state|.
51 virtual void AnimateToState(InkDropState state) = 0;
52
53 // Sets the size of the ink drop.
54 virtual void SetInkDropSize(const gfx::Size& size) = 0;
55
56 // Returns the ink drop bounds.
57 virtual gfx::Rect GetInkDropBounds() const = 0;
58
59 // Sets the bounds for the ink drop. |bounds| are in the coordinate space of
60 // the parent ui::Layer that the ink drop layer is added to.
61 virtual void SetInkDropBounds(const gfx::Rect& bounds) = 0;
32 62
33 private: 63 private:
34 // Starts the animation of a touch event.
35 void AnimateTapDown();
36
37 // Schedules the hide animation of |ink_drop_layer_| for once its current
38 // animation has completed. If |ink_drop_layer_| is not animating, the hide
39 // animation begins immediately.
40 void AnimateHide();
41
42 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_|
43 // until the long press has completed.
44 void AnimateLongPress();
45
46 // Starts the showing animation on |layer|, with a |duration| in milliseconds.
47 void AnimateShow(ui::Layer* layer,
48 AppearAnimationObserver* observer,
49 bool circle,
50 base::TimeDelta duration);
51
52 // Sets the bounds for |layer|.
53 void SetLayerBounds(ui::Layer* layer, bool circle, int width, int height);
54
55 // Initializes |layer| and attaches it to |parent|.
56 void SetupAnimationLayer(ui::Layer* parent,
57 ui::Layer* layer,
58 InkDropDelegate* delegate);
59
60 // ui::EventHandler:
61 void OnGestureEvent(ui::GestureEvent* event) override;
62
63 // The layer for animating a user touch. Added as a child to |view_|'s layer.
64 // It will be stacked underneath.
65 scoped_ptr<ui::Layer> ink_drop_layer_;
66
67 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|.
68 scoped_ptr<InkDropDelegate> ink_drop_delegate_;
69
70 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be
71 // used to automatically trigger a hide animation upon completion.
72 scoped_ptr<AppearAnimationObserver> appear_animation_observer_;
73
74 // The layer for animating a long press. Added as a child to |view_|'s layer.
75 // It will be stacked underneath.
76 scoped_ptr<ui::Layer> long_press_layer_;
77
78 // ui::LayerDelegate responsible for painting to |long_press_layer_|.
79 scoped_ptr<InkDropDelegate> long_press_delegate_;
80
81 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can
82 // be used to automatically trigger a hide animation upon completion.
83 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_;
84
85 // The View for which InkDropAnimationController is a PreTargetHandler.
86 View* view_;
87
88 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationController); 64 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationController);
89 }; 65 };
90 66
91 } // namespace views 67 } // namespace views
92 68
93 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_ 69 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.cc ('k') | ui/views/animation/ink_drop_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698