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

Unified Diff: ui/views/animation/ink_drop_animation_controller_impl.h

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved MouseEntered/Exit() to hover handling in to the ButtonInkDropDelegate. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/animation/ink_drop_animation_controller_impl.h
diff --git a/ui/views/animation/ink_drop_animation_controller_impl.h b/ui/views/animation/ink_drop_animation_controller_impl.h
index c5338835b0d414c75231d1dbd7812ae6da0c7e55..0965451c50d1fb89ec91561fb741b02364a45183 100644
--- a/ui/views/animation/ink_drop_animation_controller_impl.h
+++ b/ui/views/animation/ink_drop_animation_controller_impl.h
@@ -13,9 +13,15 @@
#include "ui/views/animation/ink_drop_animation_observer.h"
#include "ui/views/views_export.h"
+namespace base {
+class Timer;
+} // namespace base
+
namespace views {
class InkDropAnimation;
class InkDropHost;
+class InkDropHover;
+class InkDropAnimationControllerFactoryTest;
// A functional implementation of an InkDropAnimationController.
class VIEWS_EXPORT InkDropAnimationControllerImpl
@@ -30,6 +36,8 @@ class VIEWS_EXPORT InkDropAnimationControllerImpl
// InkDropAnimationController:
InkDropState GetInkDropState() const override;
void AnimateToState(InkDropState ink_drop_state) override;
+ void SetHovered(bool is_hovered) override;
+ bool IsHovered() const override;
gfx::Size GetInkDropLargeSize() const override;
void SetInkDropSize(const gfx::Size& large_size,
int large_corner_radius,
@@ -38,6 +46,12 @@ class VIEWS_EXPORT InkDropAnimationControllerImpl
void SetInkDropCenter(const gfx::Point& center_point) override;
private:
+ friend class InkDropAnimationControllerFactoryTest;
+
+ base::Timer* hover_after_animation_timer_for_test() {
sadrul 2016/01/22 15:23:18 Don't need this since FactoryTest is already a fri
bruthig 2016/01/25 22:39:17 Removed.
+ return hover_after_animation_timer_.get();
+ }
+
// Creates a new InkDropAnimation and sets it to |ink_drop_animation_|. If
// |ink_drop_animation_| wasn't null then it will be destroyed using
// DestroyInkDropAnimation().
@@ -46,12 +60,35 @@ class VIEWS_EXPORT InkDropAnimationControllerImpl
// Destroys the current |ink_drop_animation_|.
void DestroyInkDropAnimation();
+ // Creates a new InkDropHover and sets it to |hover_|. If |hover_| wasn't null
+ // then it will be destroyed using DestroyInkDropHover().
+ void CreateInkDropHover();
+
+ // Destroys the current |hover_|.
+ void DestroyInkDropHover();
+
// views::InkDropAnimationObserver:
void InkDropAnimationStarted(InkDropState ink_drop_state) override;
void InkDropAnimationEnded(InkDropState ink_drop_state,
InkDropAnimationEndedReason reason) override;
- // The host of the ink drop.
+ // Enables or disables the hover state based on |is_hovered| and if an
+ // animation is triggered it will be scheduled to have the given
+ // |animation_duration|.
+ void SetHoveredInternal(bool is_hovered, base::TimeDelta animation_duration);
+
+ // Starts the |hover_after_animation_timer_| timer. This will stop the current
+ // |hover_after_animation_timer_| instance if it exists.
+ void StartHoverAfterAnimationTimer();
+
+ // Stops and destroys the current |hover_after_animation_timer_| instance.
+ void StopHoverAfterAnimationTimer();
+
+ // Callback for when the |hover_after_animation_timer_| fires.
+ void HoverAfterAnimationTimerFired();
+
+ // The host of the ink drop. Used to poll for information such as whether the
+ // hover should be shown or not.
InkDropHost* ink_drop_host_;
// Cached size for the ink drop's large size animations.
@@ -69,10 +106,21 @@ class VIEWS_EXPORT InkDropAnimationControllerImpl
// Cached center point for the ink drop.
gfx::Point ink_drop_center_;
+ // The root Layer that parents the InkDropAnimation layers and the
+ // InkDropHover layers. The |root_layer_| is the one that is added and removed
+ // from the InkDropHost.
+ scoped_ptr<ui::Layer> root_layer_;
+
+ // The current InkDropHover. Lazily created using CreateInkDropHover();
+ scoped_ptr<InkDropHover> hover_;
+
// The current InkDropAnimation. Created on demand using
// CreateInkDropAnimation().
scoped_ptr<InkDropAnimation> ink_drop_animation_;
+ // The timer used to delay the hover fade in after an ink drop animation.
+ scoped_ptr<base::Timer> hover_after_animation_timer_;
sadrul 2016/01/22 15:23:18 Why a scoped_ptr<>?
bruthig 2016/01/25 22:39:17 This was originally done so that the Timer could b
+
DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImpl);
};

Powered by Google App Engine
This is Rietveld 408576698