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

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

Issue 1298513003: Implemented prototype for new ink drop specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Working prototype. 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_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "ui/gfx/geometry/rect.h" 11 #include "ui/compositor/layer_animator.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/geometry/size_f.h"
14 #include "ui/gfx/transform.h"
12 #include "ui/views/animation/ink_drop_state.h" 15 #include "ui/views/animation/ink_drop_state.h"
13 #include "ui/views/views_export.h" 16 #include "ui/views/views_export.h"
14 17
15 namespace ui { 18 namespace ui {
16 class Layer; 19 class Layer;
20 class LayerDelegate;
17 } // namespace ui 21 } // namespace ui
18 22
19 namespace views { 23 namespace views {
20 class AppearAnimationObserver; 24 class CircleLayerDelegate;
21 class InkDropDelegate; 25 class RectangleLayerDelegate;
22 26
23 // An ink drop animation that animates between the different InkDropStates. 27 // An ink drop animation that animates between the different InkDropStates.
28 // TODO(bruthig): Document me better.
24 class VIEWS_EXPORT InkDropAnimation { 29 class VIEWS_EXPORT InkDropAnimation {
25 public: 30 public:
26 InkDropAnimation(); 31 InkDropAnimation(const gfx::Size& large_size,
32 int large_corner_radius,
33 const gfx::Size& small_size,
34 int small_corner_radius);
27 ~InkDropAnimation(); 35 ~InkDropAnimation();
28 36
29 // The root that can be added in to a Layer tree. 37 // The root that can be added in to a Layer tree.
30 ui::Layer* GetRootLayer(); 38 ui::Layer* GetRootLayer();
31 39
32 // Animates from the current |state_| to |state|. 40 InkDropState ink_drop_state() const { return ink_drop_state_; }
41
42 // Animates from the current |ink_drop_state_| to |state|.
33 void AnimateToState(InkDropState state); 43 void AnimateToState(InkDropState state);
34 44
35 // Set the size of the ink drop. 45 // Sets the origin of the ink drop.
tdanderson 2015/08/19 22:11:19 Is this the origin in terms of where the input eve
bruthig 2015/08/20 20:35:35 Attempted to clarify in comment.
36 void SetInkDropSize(const gfx::Size& size); 46 void SetOrigin(const gfx::Point& origin);
37
38 // Returns the ink drop bounds.
39 gfx::Rect GetInkDropBounds() const;
40
41 // Sets the bounds for the ink drop. |bounds| are in the coordinate space of
42 // the parent ui::Layer that the ink drop layer is added to.
43 void SetInkDropBounds(const gfx::Rect& bounds);
44 47
45 private: 48 private:
46 // Starts the animation of a touch event. 49 // Structure that contains a gfx::Tansform for each of the layers required
47 void AnimateTapDown(); 50 // by the ink drop.
51 struct InkDropTransforms {
52 InkDropTransforms();
53 ~InkDropTransforms();
48 54
49 // Schedules the hide animation of |ink_drop_layer_| for once its current 55 gfx::Transform top_left_circle;
50 // animation has completed. If |ink_drop_layer_| is not animating, the hide 56 gfx::Transform top_right_circle;
51 // animation begins immediately. 57 gfx::Transform bottom_right_circle;
52 void AnimateHide(); 58 gfx::Transform bottom_left_circle;
59 gfx::Transform horizontal_rect;
60 gfx::Transform vertical_rect;
61 };
53 62
54 // Starts the animation of a long press, and cancels hiding |ink_drop_layer_| 63 // TODO(bruthig): Document me.
55 // until the long press has completed. 64 void AnimateToTransforms(
56 void AnimateLongPress(); 65 const InkDropTransforms& transforms,
66 float opacity,
67 base::TimeDelta duration,
68 ui::LayerAnimator::PreemptionStrategy preemption_strategy);
57 69
58 // Starts the showing animation on |layer|, with a |duration| in milliseconds. 70 // TODO(bruthig): Document me.
59 void AnimateShow(ui::Layer* layer, 71 void AnimateToTransform(
60 AppearAnimationObserver* observer, 72 ui::Layer* layer,
61 base::TimeDelta duration); 73 const gfx::Transform& target_transform,
74 base::TimeDelta duration,
75 ui::LayerAnimator::PreemptionStrategy preemption_strategy);
62 76
63 // Sets the bounds for |layer|. 77 // TODO(bruthig): Document me.
64 void SetLayerBounds(ui::Layer* layer); 78 void ResetTransformsToMinSize();
65 79
66 // Initializes |layer|'s properties. 80 // TODO(bruthig): Document me.
67 void SetupAnimationLayer(ui::Layer* layer, InkDropDelegate* delegate); 81 void SetTransforms(const InkDropTransforms& transforms);
68 82
69 // The root layer that parents the animating layers. 83 // TODO(bruthig): Document me.
84 void SetOpacity(float opacity);
85
86 // TODO(bruthig): Document me.
87 InkDropTransforms CalculateCircleTransforms(const gfx::SizeF size) const;
88
89 // TODO(bruthig): Document me.
90 InkDropTransforms CalculateRectTransforms(const gfx::SizeF size,
91 float corner_radius) const;
92
93 // TODO(bruthig): Document me.
94 InkDropTransforms GetCurrentTansforms() const;
95
96 // Creates and configures a new painted layer and adds it to |layer_tree_|.
97 ui::Layer* AddPaintLayer(ui::LayerDelegate* delegate);
98
99 // Size used for large size animations.
100 gfx::Size large_size_;
tdanderson 2015/08/19 22:11:19 I'm not clear from the documentation what "large"
bruthig 2015/09/03 21:21:04 I made an attempt to better explain this with vari
101
102 // Corner radius used for large size animations.
103 int large_corner_radius_;
104
105 // Size used for small size animations.
106 gfx::Size small_size_;
107
108 // Corner radius used for small size animations.
109 int small_corner_radius_;
110
111 // ui::LayerDelegate to paint circles for all the circle layers.
112 scoped_ptr<CircleLayerDelegate> circle_layer_delegate_;
113
114 // ui::LayerDelegate to paint rectangles for all the rectangle layers.
115 scoped_ptr<RectangleLayerDelegate> rect_layer_delegate_;
116
117 // The root layer that parents the animating layers. The root layer is used to
118 // manipulate opacity and origin, and its children are used to manipulate the
119 // different painted shapes that compose the ink drop.
70 scoped_ptr<ui::Layer> root_layer_; 120 scoped_ptr<ui::Layer> root_layer_;
71 121
72 // The layer used for animating a user touch. 122 // The gfx::Transform to apply to the |root_layer_|. This is used to place the
73 scoped_ptr<ui::Layer> ink_drop_layer_; 123 // ink drop to the specified origin.
124 gfx::Transform root_layer_transform_;
74 125
75 // ui::LayerDelegate responsible for painting to |ink_drop_layer_|. 126 // ui::Layers for all of the painted shape layers that compose the ink drop.
76 scoped_ptr<InkDropDelegate> ink_drop_delegate_; 127 scoped_ptr<ui::Layer> top_left_circle_layer_;
128 scoped_ptr<ui::Layer> top_right_circle_layer_;
129 scoped_ptr<ui::Layer> bottom_right_circle_layer_;
130 scoped_ptr<ui::Layer> bottom_left_circle_layer_;
131 scoped_ptr<ui::Layer> horizontal_rect_layer_;
132 scoped_ptr<ui::Layer> vertical_rect_layer_;
77 133
78 // ui::ImplicitAnimationObserver which observes |ink_drop_layer_| and can be 134 // The current ink drop state.
79 // used to automatically trigger a hide animation upon completion. 135 InkDropState ink_drop_state_;
80 scoped_ptr<AppearAnimationObserver> appear_animation_observer_;
81
82 // The layer used for animating a long press.
83 scoped_ptr<ui::Layer> long_press_layer_;
84
85 // ui::LayerDelegate responsible for painting to |long_press_layer_|.
86 scoped_ptr<InkDropDelegate> long_press_delegate_;
87
88 // ui::ImplicitAnimationObserver which observers |long_press_layer_| and can
89 // be used to automatically trigger a hide animation upon completion.
90 scoped_ptr<AppearAnimationObserver> long_press_animation_observer_;
91
92 // The bounds of the ink drop layers. Defined in the coordinate space of the
93 // parent ui::Layer that the ink drop layers were added to.
94 gfx::Rect ink_drop_bounds_;
95 136
96 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation); 137 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation);
97 }; 138 };
98 139
99 } // namespace views 140 } // namespace views
100 141
101 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ 142 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698