Chromium Code Reviews| Index: ui/views/animation/ink_drop_hover.h |
| diff --git a/ui/views/animation/ink_drop_hover.h b/ui/views/animation/ink_drop_hover.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..530ff8b14de709848f1fd1ed839143abbc1b31c3 |
| --- /dev/null |
| +++ b/ui/views/animation/ink_drop_hover.h |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ |
| +#define UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| +#include "ui/gfx/geometry/point.h" |
| +#include "ui/gfx/geometry/size.h" |
| +#include "ui/views/views_export.h" |
| + |
| +namespace ui { |
| +class Layer; |
| +class CallbackLayerAnimationObserver; |
| +} // namespace ui |
| + |
| +namespace views { |
| +class RoundedRectangleLayerDelegate; |
| + |
| +// Manages fade in/out animations for a painted Layer that is used to provide |
| +// visual feedback on ui::Views for mouse hover states. |
| +class VIEWS_EXPORT InkDropHover { |
| + public: |
| + InkDropHover(const gfx::Size& size, int corner_radius); |
| + ~InkDropHover(); |
| + |
| + // Fades in the hover visual over the given |duration|. |
| + void FadeIn(const base::TimeDelta& duration); |
| + |
| + // Fades out the hover visual over the given |duration|. |
| + void FadeOut(const base::TimeDelta& duration); |
| + |
| + bool is_hovered() const { return is_hovered_; } |
| + |
| + // The root Layer that can be added in to a Layer tree. |
| + ui::Layer* root_layer() { return layer_.get(); } |
| + |
| + // Sets the |center_point| of the hover layer relative to its parent Layer. |
| + void SetCenterPoint(const gfx::Point& center_point); |
| + |
| + private: |
| + 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.
|
| + |
| + // Animates a fade in/out as specified by |hover_animation| over the given |
| + // |duration|. |
| + void AnimateFade(HoverAnimation hover_animation, |
| + const base::TimeDelta& duration); |
| + |
| + // The callback that will be invoked when a fade in/out animation is started. |
| + void AnimationStartedCallback( |
| + HoverAnimation hover_animation, |
| + const ui::CallbackLayerAnimationObserver& observer); |
| + |
| + // The callback that will be invoked when a fade in/out animation is complete. |
| + bool AnimationEndedCallback( |
| + HoverAnimation hover_animation, |
| + const ui::CallbackLayerAnimationObserver& observer); |
| + |
| + // True when the hover layer is visible. |
| + bool is_hovered_; |
| + |
| + // The LayerDelegate that paints the hover |layer_|. |
| + scoped_ptr<RoundedRectangleLayerDelegate> layer_delegate_; |
| + |
| + // The visual hover layer that is painted by |layer_delegate_|. |
| + scoped_ptr<ui::Layer> layer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InkDropHover); |
| +}; |
| + |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_ANIMATION_INK_DROP_HOVER_H_ |