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

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

Issue 1913243002: Enabled tests to control material design ink drop animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. 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 <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/point_f.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 #include "ui/views/views_export.h" 17 #include "ui/views/views_export.h"
18 18
19 namespace ui { 19 namespace ui {
20 class Layer; 20 class Layer;
21 class CallbackLayerAnimationObserver; 21 class CallbackLayerAnimationObserver;
22 } // namespace ui 22 } // namespace ui
23 23
24 namespace views { 24 namespace views {
25 namespace test {
26 class InkDropHoverTestApi;
27 } // namespace test
28
25 class RoundedRectangleLayerDelegate; 29 class RoundedRectangleLayerDelegate;
26 30
27 // 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
28 // visual feedback on ui::Views for mouse hover states. 32 // visual feedback on ui::Views for mouse hover states.
29 class VIEWS_EXPORT InkDropHover { 33 class VIEWS_EXPORT InkDropHover {
30 public: 34 public:
31 InkDropHover(const gfx::Size& size, 35 InkDropHover(const gfx::Size& size,
32 int corner_radius, 36 int corner_radius,
33 const gfx::Point& center_point, 37 const gfx::Point& center_point,
34 SkColor color); 38 SkColor color);
35 ~InkDropHover(); 39 virtual ~InkDropHover();
36 40
37 void set_explode_size(const gfx::Size& size) { explode_size_ = size; } 41 void set_explode_size(const gfx::Size& size) { explode_size_ = size; }
38 42
39 // Returns true if the hover animation is either in the process of fading 43 // Returns true if the hover animation is either in the process of fading
40 // in or is fully visible. 44 // in or is fully visible.
41 bool IsFadingInOrVisible() const; 45 bool IsFadingInOrVisible() const;
42 46
43 // Fades in the hover visual over the given |duration|. 47 // Fades in the hover visual over the given |duration|.
44 void FadeIn(const base::TimeDelta& duration); 48 void FadeIn(const base::TimeDelta& duration);
45 49
46 // Fades out the hover visual over the given |duration|. If |explode| is true 50 // Fades out the hover visual over the given |duration|. If |explode| is true
47 // then the hover will animate a size increase in addition to the fade out. 51 // then the hover will animate a size increase in addition to the fade out.
48 void FadeOut(const base::TimeDelta& duration, bool explode); 52 void FadeOut(const base::TimeDelta& duration, bool explode);
49 53
50 // The root Layer that can be added in to a Layer tree. 54 // The root Layer that can be added in to a Layer tree.
51 ui::Layer* layer() { return layer_.get(); } 55 ui::Layer* layer() { return layer_.get(); }
52 56
57 // Returns a test api to access internals of this. Default implmentations
58 // should return nullptr and test specific subclasses can override to return
59 // an instance.
60 virtual test::InkDropHoverTestApi* GetTestApi();
61
53 private: 62 private:
63 friend class test::InkDropHoverTestApi;
64
54 enum HoverAnimationType { FADE_IN, FADE_OUT }; 65 enum HoverAnimationType { FADE_IN, FADE_OUT };
55 66
56 // Animates a fade in/out as specified by |animation_type| combined with a 67 // Animates a fade in/out as specified by |animation_type| combined with a
57 // transformation from the |initial_size| to the |target_size| over the given 68 // transformation from the |initial_size| to the |target_size| over the given
58 // |duration|. 69 // |duration|.
59 void AnimateFade(HoverAnimationType animation_type, 70 void AnimateFade(HoverAnimationType animation_type,
60 const base::TimeDelta& duration, 71 const base::TimeDelta& duration,
61 const gfx::Size& initial_size, 72 const gfx::Size& initial_size,
62 const gfx::Size& target_size); 73 const gfx::Size& target_size);
63 74
(...skipping 24 matching lines...) Expand all
88 99
89 // The visual hover layer that is painted by |layer_delegate_|. 100 // The visual hover layer that is painted by |layer_delegate_|.
90 std::unique_ptr<ui::Layer> layer_; 101 std::unique_ptr<ui::Layer> layer_;
91 102
92 DISALLOW_COPY_AND_ASSIGN(InkDropHover); 103 DISALLOW_COPY_AND_ASSIGN(InkDropHover);
93 }; 104 };
94 105
95 } // namespace views 106 } // namespace views
96 107
97 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ 108 #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