OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ | |
6 #define UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | |
11 #include "ui/gfx/geometry/point.h" | |
12 #include "ui/gfx/geometry/size.h" | |
13 #include "ui/views/views_export.h" | |
14 | |
15 namespace ui { | |
16 class Layer; | |
17 class CallbackLayerAnimationObserver; | |
18 } // namespace ui | |
19 | |
20 namespace views { | |
21 class RoundedRectangleLayerDelegate; | |
22 | |
23 // Manages fade in/out animations for a painted Layer that is used to provide | |
24 // visual feedback on ui::Views for mouse hover states. | |
25 class VIEWS_EXPORT InkDropHover { | |
26 public: | |
27 InkDropHover(const gfx::Size& size, int corner_radius); | |
28 ~InkDropHover(); | |
29 | |
30 // Fades in the hover visual over the given |duration|. | |
31 void FadeIn(const base::TimeDelta& duration); | |
32 | |
33 // Fades out the hover visual over the given |duration|. | |
34 void FadeOut(const base::TimeDelta& duration); | |
35 | |
36 bool is_hovered() const { return is_hovered_; } | |
37 | |
38 // The root Layer that can be added in to a Layer tree. | |
39 ui::Layer* root_layer() { return layer_.get(); } | |
40 | |
41 // Sets the |center_point| of the hover layer relative to its parent Layer. | |
42 void SetCenterPoint(const gfx::Point& center_point); | |
43 | |
44 private: | |
45 enum HoverAnimation { FADE_IN, FADE_OUT }; | |
tdanderson
2015/10/15 14:46:54
nit: I would prefer a name such as HoverAnimationT
bruthig
2015/10/15 21:49:29
Done.
| |
46 | |
47 // Animates a fade in/out as specified by |hover_animation| over the given | |
48 // |duration|. | |
49 void AnimateFade(HoverAnimation hover_animation, | |
50 const base::TimeDelta& duration); | |
51 | |
52 // The callback that will be invoked when a fade in/out animation is started. | |
53 void AnimationStartedCallback( | |
54 HoverAnimation hover_animation, | |
55 const ui::CallbackLayerAnimationObserver& observer); | |
56 | |
57 // The callback that will be invoked when a fade in/out animation is complete. | |
58 bool AnimationEndedCallback( | |
59 HoverAnimation hover_animation, | |
60 const ui::CallbackLayerAnimationObserver& observer); | |
61 | |
62 // True when the hover layer is visible. | |
63 bool is_hovered_; | |
64 | |
65 // The LayerDelegate that paints the hover |layer_|. | |
66 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_; | |
67 | |
68 // The visual hover layer that is painted by |layer_delegate_|. | |
69 scoped_ptr<ui::Layer> layer_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(InkDropHover); | |
72 }; | |
73 | |
74 } // namespace views | |
75 | |
76 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ | |
OLD | NEW |