Chromium Code Reviews| 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 // Returns true if the hover layer is visible. | |
| 31 bool IsVisible() const; | |
| 32 | |
| 33 // Fades in the hover visual over the given |duration|. | |
| 34 void FadeIn(const base::TimeDelta& duration); | |
|
sadrul
2015/11/04 19:58:11
TimeDelta is a single int64, and we typically just
bruthig
2015/11/11 21:48:44
Seems like a reasonable abstraction to me :)
| |
| 35 | |
| 36 // Fades out the hover visual over the given |duration|. | |
| 37 void FadeOut(const base::TimeDelta& duration); | |
| 38 | |
| 39 // The root Layer that can be added in to a Layer tree. | |
| 40 ui::Layer* root_layer() { return layer_.get(); } | |
|
sadrul
2015/11/04 19:58:11
Why root_layer() instead of just layer()?
bruthig
2015/11/11 21:48:45
Done.
| |
| 41 | |
| 42 // Sets the |center_point| of the hover layer relative to its parent Layer. | |
| 43 void SetCenterPoint(const gfx::Point& center_point); | |
| 44 | |
| 45 private: | |
| 46 enum HoverAnimationType { FADE_IN, FADE_OUT }; | |
| 47 | |
| 48 // Animates a fade in/out as specified by |animation_type| over the given | |
| 49 // |duration|. | |
| 50 void AnimateFade(HoverAnimationType animation_type, | |
| 51 const base::TimeDelta& duration); | |
| 52 | |
| 53 // The callback that will be invoked when a fade in/out animation is complete. | |
| 54 bool AnimationEndedCallback( | |
| 55 HoverAnimationType animation_type, | |
| 56 const ui::CallbackLayerAnimationObserver& observer); | |
| 57 | |
| 58 // The LayerDelegate that paints the hover |layer_|. | |
| 59 scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_; | |
| 60 | |
| 61 // The visual hover layer that is painted by |layer_delegate_|. | |
| 62 scoped_ptr<ui::Layer> layer_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(InkDropHover); | |
| 65 }; | |
| 66 | |
| 67 } // namespace views | |
| 68 | |
| 69 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ | |
| OLD | NEW |