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

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

Issue 1944043002: Enabled tests to control material design ink drop animations. (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
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 {
25 class InkDropHoverTestApi;
26 } // namespace test
27
24 class RoundedRectangleLayerDelegate; 28 class RoundedRectangleLayerDelegate;
25 29
26 // Manages fade in/out animations for a painted Layer that is used to provide 30 // Manages fade in/out animations for a painted Layer that is used to provide
27 // visual feedback on ui::Views for mouse hover states. 31 // visual feedback on ui::Views for mouse hover states.
28 class VIEWS_EXPORT InkDropHover { 32 class VIEWS_EXPORT InkDropHover {
29 public: 33 public:
30 InkDropHover(const gfx::Size& size, 34 InkDropHover(const gfx::Size& size,
31 int corner_radius, 35 int corner_radius,
32 const gfx::Point& center_point, 36 const gfx::Point& center_point,
33 SkColor color); 37 SkColor color);
34 ~InkDropHover(); 38 virtual ~InkDropHover();
35 39
36 void set_explode_size(const gfx::Size& size) { explode_size_ = size; } 40 void set_explode_size(const gfx::Size& size) { explode_size_ = size; }
37 41
38 // Returns true if the hover animation is either in the process of fading 42 // Returns true if the hover animation is either in the process of fading
39 // in or is fully visible. 43 // in or is fully visible.
40 bool IsFadingInOrVisible() const; 44 bool IsFadingInOrVisible() const;
41 45
42 // Fades in the hover visual over the given |duration|. 46 // Fades in the hover visual over the given |duration|.
43 void FadeIn(const base::TimeDelta& duration); 47 void FadeIn(const base::TimeDelta& duration);
44 48
45 // Fades out the hover visual over the given |duration|. If |explode| is true 49 // Fades out the hover visual over the given |duration|. If |explode| is true
46 // then the hover will animate a size increase in addition to the fade out. 50 // then the hover will animate a size increase in addition to the fade out.
47 void FadeOut(const base::TimeDelta& duration, bool explode); 51 void FadeOut(const base::TimeDelta& duration, bool explode);
48 52
49 // The root Layer that can be added in to a Layer tree. 53 // The root Layer that can be added in to a Layer tree.
50 ui::Layer* layer() { return layer_.get(); } 54 ui::Layer* layer() { return layer_.get(); }
51 55
56 // Returns a test api to access internals of this. Default implmentations
57 // should return nullptr and test specific subclasses can override to return
58 // an instance.
59 virtual test::InkDropHoverTestApi* GetTestApi();
60
52 private: 61 private:
62 friend class test::InkDropHoverTestApi;
63
53 enum HoverAnimationType { FADE_IN, FADE_OUT }; 64 enum HoverAnimationType { FADE_IN, FADE_OUT };
54 65
55 // Animates a fade in/out as specified by |animation_type| combined with a 66 // Animates a fade in/out as specified by |animation_type| combined with a
56 // transformation from the |initial_size| to the |target_size| over the given 67 // transformation from the |initial_size| to the |target_size| over the given
57 // |duration|. 68 // |duration|.
58 void AnimateFade(HoverAnimationType animation_type, 69 void AnimateFade(HoverAnimationType animation_type,
59 const base::TimeDelta& duration, 70 const base::TimeDelta& duration,
60 const gfx::Size& initial_size, 71 const gfx::Size& initial_size,
61 const gfx::Size& target_size); 72 const gfx::Size& target_size);
62 73
(...skipping 24 matching lines...) Expand all
87 98
88 // The visual hover layer that is painted by |layer_delegate_|. 99 // The visual hover layer that is painted by |layer_delegate_|.
89 scoped_ptr<ui::Layer> layer_; 100 scoped_ptr<ui::Layer> layer_;
90 101
91 DISALLOW_COPY_AND_ASSIGN(InkDropHover); 102 DISALLOW_COPY_AND_ASSIGN(InkDropHover);
92 }; 103 };
93 104
94 } // namespace views 105 } // namespace views
95 106
96 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 107 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_impl_unittest.cc ('k') | ui/views/animation/ink_drop_hover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698