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

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

Issue 1890243002: Expand the Material Design hover as it fades out when a ripple is triggered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ink_drop_hover_unittest.cc compile error. Created 4 years, 8 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_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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/gfx/geometry/point.h" 13 #include "ui/gfx/geometry/point.h"
14 #include "ui/gfx/geometry/point_f.h"
14 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/geometry/size_f.h"
17 #include "ui/gfx/transform.h"
15 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
16 19
17 namespace ui { 20 namespace ui {
18 class Layer; 21 class Layer;
19 class CallbackLayerAnimationObserver; 22 class CallbackLayerAnimationObserver;
20 } // namespace ui 23 } // namespace ui
21 24
22 namespace views { 25 namespace views {
23 class RoundedRectangleLayerDelegate; 26 class RoundedRectangleLayerDelegate;
24 27
25 // Manages fade in/out animations for a painted Layer that is used to provide 28 // Manages fade in/out animations for a painted Layer that is used to provide
26 // visual feedback on ui::Views for mouse hover states. 29 // visual feedback on ui::Views for mouse hover states.
27 class VIEWS_EXPORT InkDropHover { 30 class VIEWS_EXPORT InkDropHover {
28 public: 31 public:
29 InkDropHover(const gfx::Size& size, 32 InkDropHover(const gfx::Size& size,
30 int corner_radius, 33 int corner_radius,
31 const gfx::Point& center_point, 34 const gfx::Point& center_point,
32 SkColor color); 35 SkColor color);
33 ~InkDropHover(); 36 ~InkDropHover();
34 37
38 void set_explode_size(const gfx::SizeF& size) { explode_size_ = size; }
varkha 2016/04/21 16:16:49 Do you think this class should decide to use Size
varkha 2016/04/21 16:16:49 It may be simpler (less flexible but I don't think
bruthig 2016/04/21 21:14:04 Updated to use Size.
bruthig 2016/04/21 21:14:04 Discussed with varkha@ offline. We will defer dec
39
35 // Returns true if the hover animation is either in the process of fading 40 // Returns true if the hover animation is either in the process of fading
36 // in or is fully visible. 41 // in or is fully visible.
37 bool IsFadingInOrVisible() const; 42 bool IsFadingInOrVisible() const;
38 43
39 // Fades in the hover visual over the given |duration|. 44 // Fades in the hover visual over the given |duration|.
40 void FadeIn(const base::TimeDelta& duration); 45 void FadeIn(const base::TimeDelta& duration);
41 46
42 // Fades out the hover visual over the given |duration|. 47 // Fades out the hover visual over the given |duration|.
varkha 2016/04/21 16:16:49 nit: Document |explode|.
bruthig 2016/04/21 21:14:04 Done.
43 void FadeOut(const base::TimeDelta& duration); 48 void FadeOut(const base::TimeDelta& duration, bool explode);
44 49
45 // The root Layer that can be added in to a Layer tree. 50 // The root Layer that can be added in to a Layer tree.
46 ui::Layer* layer() { return layer_.get(); } 51 ui::Layer* layer() { return layer_.get(); }
47 52
48 private: 53 private:
49 enum HoverAnimationType { FADE_IN, FADE_OUT }; 54 enum HoverAnimationType { FADE_IN, FADE_OUT };
50 55
51 // Animates a fade in/out as specified by |animation_type| over the given 56 // Animates a fade in/out as specified by |animation_type| combined with a
52 // |duration|. 57 // transformation from the |initial_transform| to the |target_transform| over
58 // the given |duration|.
53 void AnimateFade(HoverAnimationType animation_type, 59 void AnimateFade(HoverAnimationType animation_type,
54 const base::TimeDelta& duration); 60 const base::TimeDelta& duration,
61 const gfx::Transform& initial_transform,
62 const gfx::Transform& target_transform);
63
64 // Calculates the Transform to apply to |layer_| for the given |size|.
65 gfx::Transform CalculateTransform(const gfx::SizeF& size) const;
55 66
56 // The callback that will be invoked when a fade in/out animation is complete. 67 // The callback that will be invoked when a fade in/out animation is complete.
57 bool AnimationEndedCallback( 68 bool AnimationEndedCallback(
58 HoverAnimationType animation_type, 69 HoverAnimationType animation_type,
59 const ui::CallbackLayerAnimationObserver& observer); 70 const ui::CallbackLayerAnimationObserver& observer);
60 71
72 // The size of the hover shape when fully faded in.
73 gfx::SizeF size_;
74
75 // The target size of the hover shape when it expands during a fade out
76 // animation.
77 gfx::SizeF explode_size_;
78
79 // The center point of the hover shape in the parent Layer's coordinate space.
80 gfx::PointF center_point_;
81
61 // True if the last animation to be initiated was a FADE_IN, and false 82 // True if the last animation to be initiated was a FADE_IN, and false
62 // otherwise. 83 // otherwise.
63 bool last_animation_initiated_was_fade_in_; 84 bool last_animation_initiated_was_fade_in_;
64 85
65 // The LayerDelegate that paints the hover |layer_|. 86 // The LayerDelegate that paints the hover |layer_|.
66 std::unique_ptr<RoundedRectangleLayerDelegate> layer_delegate_; 87 std::unique_ptr<RoundedRectangleLayerDelegate> layer_delegate_;
67 88
68 // The visual hover layer that is painted by |layer_delegate_|. 89 // The visual hover layer that is painted by |layer_delegate_|.
69 std::unique_ptr<ui::Layer> layer_; 90 std::unique_ptr<ui::Layer> layer_;
70 91
71 DISALLOW_COPY_AND_ASSIGN(InkDropHover); 92 DISALLOW_COPY_AND_ASSIGN(InkDropHover);
72 }; 93 };
73 94
74 } // namespace views 95 } // namespace views
75 96
76 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 97 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698