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

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

Issue 1682893002: Color the ink drop ripple and hover effects based on theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests Created 4 years, 10 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 "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 "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/geometry/size.h"
13 #include "ui/views/views_export.h" 14 #include "ui/views/views_export.h"
14 15
15 namespace ui { 16 namespace ui {
16 class Layer; 17 class Layer;
17 class CallbackLayerAnimationObserver; 18 class CallbackLayerAnimationObserver;
18 } // namespace ui 19 } // namespace ui
19 20
20 namespace views { 21 namespace views {
21 class RoundedRectangleLayerDelegate; 22 class RoundedRectangleLayerDelegate;
22 23
23 // Manages fade in/out animations for a painted Layer that is used to provide 24 // 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 // visual feedback on ui::Views for mouse hover states.
25 class VIEWS_EXPORT InkDropHover { 26 class VIEWS_EXPORT InkDropHover {
26 public: 27 public:
27 InkDropHover(const gfx::Size& size, int corner_radius); 28 InkDropHover(SkColor color, const gfx::Size& size, int corner_radius);
28 ~InkDropHover(); 29 ~InkDropHover();
29 30
30 // Returns true if the hover layer is visible. 31 // Returns true if the hover layer is visible.
31 bool IsVisible() const; 32 bool IsVisible() const;
32 33
33 // Fades in the hover visual over the given |duration|. 34 // Fades in the hover visual over the given |duration|.
34 void FadeIn(const base::TimeDelta& duration); 35 void FadeIn(const base::TimeDelta& duration);
35 36
36 // Fades out the hover visual over the given |duration|. 37 // Fades out the hover visual over the given |duration|.
37 void FadeOut(const base::TimeDelta& duration); 38 void FadeOut(const base::TimeDelta& duration);
38 39
39 // The root Layer that can be added in to a Layer tree. 40 // The root Layer that can be added in to a Layer tree.
40 ui::Layer* layer() { return layer_.get(); } 41 ui::Layer* layer() { return layer_.get(); }
41 42
43 // Returns the color used to draw this hover effect.
44 SkColor GetColor() const;
45
42 // Sets the |center_point| of the hover layer relative to its parent Layer. 46 // Sets the |center_point| of the hover layer relative to its parent Layer.
43 void SetCenterPoint(const gfx::Point& center_point); 47 void SetCenterPoint(const gfx::Point& center_point);
44 48
45 private: 49 private:
46 enum HoverAnimationType { FADE_IN, FADE_OUT }; 50 enum HoverAnimationType { FADE_IN, FADE_OUT };
47 51
48 // Animates a fade in/out as specified by |animation_type| over the given 52 // Animates a fade in/out as specified by |animation_type| over the given
49 // |duration|. 53 // |duration|.
50 void AnimateFade(HoverAnimationType animation_type, 54 void AnimateFade(HoverAnimationType animation_type,
51 const base::TimeDelta& duration); 55 const base::TimeDelta& duration);
52 56
53 // The callback that will be invoked when a fade in/out animation is complete. 57 // The callback that will be invoked when a fade in/out animation is complete.
54 bool AnimationEndedCallback( 58 bool AnimationEndedCallback(
55 HoverAnimationType animation_type, 59 HoverAnimationType animation_type,
56 const ui::CallbackLayerAnimationObserver& observer); 60 const ui::CallbackLayerAnimationObserver& observer);
57 61
58 // The LayerDelegate that paints the hover |layer_|. 62 // The LayerDelegate that paints the hover |layer_|.
59 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_; 63 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_;
60 64
61 // The visual hover layer that is painted by |layer_delegate_|. 65 // The visual hover layer that is painted by |layer_delegate_|.
62 scoped_ptr<ui::Layer> layer_; 66 scoped_ptr<ui::Layer> layer_;
63 67
64 DISALLOW_COPY_AND_ASSIGN(InkDropHover); 68 DISALLOW_COPY_AND_ASSIGN(InkDropHover);
65 }; 69 };
66 70
67 } // namespace views 71 } // namespace views
68 72
69 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 73 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698