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

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

Issue 1951593002: Add MD Ink Drop to host only when a ripple/hover is active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Replaced unique_ptr with scoped_ptr. 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/ink_drop_animation_observer.h ('k') | ui/views/animation/ink_drop_hover.cc » ('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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_HOVER_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 "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
13 #include "ui/gfx/geometry/point_f.h" 13 #include "ui/gfx/geometry/point_f.h"
14 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/transform.h" 15 #include "ui/gfx/transform.h"
16 #include "ui/views/views_export.h" 16 #include "ui/views/views_export.h"
17 17
18 namespace ui { 18 namespace ui {
19 class Layer; 19 class Layer;
20 class CallbackLayerAnimationObserver; 20 class CallbackLayerAnimationObserver;
21 } // namespace ui 21 } // namespace ui
22 22
23 namespace views { 23 namespace views {
24 namespace test { 24 namespace test {
25 class InkDropHoverTestApi; 25 class InkDropHoverTestApi;
26 } // namespace test 26 } // namespace test
27 27
28 class RoundedRectangleLayerDelegate; 28 class RoundedRectangleLayerDelegate;
29 class InkDropHoverObserver;
29 30
30 // Manages fade in/out animations for a painted Layer that is used to provide 31 // Manages fade in/out animations for a painted Layer that is used to provide
31 // visual feedback on ui::Views for mouse hover states. 32 // visual feedback on ui::Views for mouse hover states.
32 class VIEWS_EXPORT InkDropHover { 33 class VIEWS_EXPORT InkDropHover {
33 public: 34 public:
35 enum AnimationType { FADE_IN, FADE_OUT };
36
34 InkDropHover(const gfx::Size& size, 37 InkDropHover(const gfx::Size& size,
35 int corner_radius, 38 int corner_radius,
36 const gfx::Point& center_point, 39 const gfx::Point& center_point,
37 SkColor color); 40 SkColor color);
38 virtual ~InkDropHover(); 41 virtual ~InkDropHover();
39 42
43 void set_observer(InkDropHoverObserver* observer) { observer_ = observer; }
44
40 void set_explode_size(const gfx::Size& size) { explode_size_ = size; } 45 void set_explode_size(const gfx::Size& size) { explode_size_ = size; }
41 46
42 // Returns true if the hover animation is either in the process of fading 47 // Returns true if the hover animation is either in the process of fading
43 // in or is fully visible. 48 // in or is fully visible.
44 bool IsFadingInOrVisible() const; 49 bool IsFadingInOrVisible() const;
45 50
46 // Fades in the hover visual over the given |duration|. 51 // Fades in the hover visual over the given |duration|.
47 void FadeIn(const base::TimeDelta& duration); 52 void FadeIn(const base::TimeDelta& duration);
48 53
49 // Fades out the hover visual over the given |duration|. If |explode| is true 54 // Fades out the hover visual over the given |duration|. If |explode| is true
50 // then the hover will animate a size increase in addition to the fade out. 55 // then the hover will animate a size increase in addition to the fade out.
51 void FadeOut(const base::TimeDelta& duration, bool explode); 56 void FadeOut(const base::TimeDelta& duration, bool explode);
52 57
53 // The root Layer that can be added in to a Layer tree. 58 // The root Layer that can be added in to a Layer tree.
54 ui::Layer* layer() { return layer_.get(); } 59 ui::Layer* layer() { return layer_.get(); }
55 60
56 // Returns a test api to access internals of this. Default implmentations 61 // Returns a test api to access internals of this. Default implmentations
57 // should return nullptr and test specific subclasses can override to return 62 // should return nullptr and test specific subclasses can override to return
58 // an instance. 63 // an instance.
59 virtual test::InkDropHoverTestApi* GetTestApi(); 64 virtual test::InkDropHoverTestApi* GetTestApi();
60 65
61 private: 66 private:
62 friend class test::InkDropHoverTestApi; 67 friend class test::InkDropHoverTestApi;
63 68
64 enum HoverAnimationType { FADE_IN, FADE_OUT };
65
66 // Animates a fade in/out as specified by |animation_type| combined with a 69 // Animates a fade in/out as specified by |animation_type| combined with a
67 // transformation from the |initial_size| to the |target_size| over the given 70 // transformation from the |initial_size| to the |target_size| over the given
68 // |duration|. 71 // |duration|.
69 void AnimateFade(HoverAnimationType animation_type, 72 void AnimateFade(AnimationType animation_type,
70 const base::TimeDelta& duration, 73 const base::TimeDelta& duration,
71 const gfx::Size& initial_size, 74 const gfx::Size& initial_size,
72 const gfx::Size& target_size); 75 const gfx::Size& target_size);
73 76
74 // Calculates the Transform to apply to |layer_| for the given |size|. 77 // Calculates the Transform to apply to |layer_| for the given |size|.
75 gfx::Transform CalculateTransform(const gfx::Size& size) const; 78 gfx::Transform CalculateTransform(const gfx::Size& size) const;
76 79
80 // The callback that will be invoked when a fade in/out animation is started.
81 void AnimationStartedCallback(
82 AnimationType animation_type,
83 const ui::CallbackLayerAnimationObserver& observer);
84
77 // The callback that will be invoked when a fade in/out animation is complete. 85 // The callback that will be invoked when a fade in/out animation is complete.
78 bool AnimationEndedCallback( 86 bool AnimationEndedCallback(
79 HoverAnimationType animation_type, 87 AnimationType animation_type,
80 const ui::CallbackLayerAnimationObserver& observer); 88 const ui::CallbackLayerAnimationObserver& observer);
81 89
82 // The size of the hover shape when fully faded in. 90 // The size of the hover shape when fully faded in.
83 gfx::Size size_; 91 gfx::Size size_;
84 92
85 // The target size of the hover shape when it expands during a fade out 93 // The target size of the hover shape when it expands during a fade out
86 // animation. 94 // animation.
87 gfx::Size explode_size_; 95 gfx::Size explode_size_;
88 96
89 // The center point of the hover shape in the parent Layer's coordinate space. 97 // The center point of the hover shape in the parent Layer's coordinate space.
90 gfx::PointF center_point_; 98 gfx::PointF center_point_;
91 99
92 // True if the last animation to be initiated was a FADE_IN, and false 100 // True if the last animation to be initiated was a FADE_IN, and false
93 // otherwise. 101 // otherwise.
94 bool last_animation_initiated_was_fade_in_; 102 bool last_animation_initiated_was_fade_in_;
95 103
96 // The LayerDelegate that paints the hover |layer_|. 104 // The LayerDelegate that paints the hover |layer_|.
97 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_; 105 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_;
98 106
99 // The visual hover layer that is painted by |layer_delegate_|. 107 // The visual hover layer that is painted by |layer_delegate_|.
100 scoped_ptr<ui::Layer> layer_; 108 scoped_ptr<ui::Layer> layer_;
101 109
110 InkDropHoverObserver* observer_;
111
102 DISALLOW_COPY_AND_ASSIGN(InkDropHover); 112 DISALLOW_COPY_AND_ASSIGN(InkDropHover);
103 }; 113 };
104 114
105 } // namespace views 115 } // namespace views
106 116
107 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 117 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_observer.h ('k') | ui/views/animation/ink_drop_hover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698