Chromium Code Reviews| Index: ui/views/animation/ink_drop_impl.h |
| diff --git a/ui/views/animation/ink_drop_impl.h b/ui/views/animation/ink_drop_impl.h |
| index 7f4cca37911e8a6ed6f7a311c5c8038785f9cb52..040e5401219fbbc25d8163d6bdd9686abd406c44 100644 |
| --- a/ui/views/animation/ink_drop_impl.h |
| +++ b/ui/views/animation/ink_drop_impl.h |
| @@ -15,10 +15,6 @@ |
| #include "ui/views/animation/ink_drop_ripple_observer.h" |
| #include "ui/views/views_export.h" |
| -namespace base { |
| -class Timer; |
| -} // namespace base |
| - |
| namespace views { |
| namespace test { |
| class InkDropImplTestApi; |
| @@ -34,11 +30,39 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop, |
| public InkDropRippleObserver, |
| public InkDropHighlightObserver { |
| public: |
| + // The different auto highlight behaviors. |
| + enum class AutoHighlightMode { |
| + // No auto-highlighting is done. The highlight will only be shown/hidden as |
| + // per the hover/focus settings. |
| + NONE, |
| + // The highlight will be hidden when a ripple becomes visible. After the |
| + // ripple is hidden the highlight will be made visible again if the |
| + // hover/focus settings deem it should be. |
| + HIDE_ON_RIPPLE, |
| + // The highlight is made visible when the ripple becomes visible. After the |
| + // ripple is hidden the highlight will be hidden again if the hover/focus |
| + // settings deem it should be. |
| + SHOW_ON_RIPPLE, |
| + }; |
| + |
| // Constructs an ink drop that will attach the ink drop to the given |
| // |ink_drop_host|. |
| explicit InkDropImpl(InkDropHost* ink_drop_host); |
| ~InkDropImpl() override; |
| + void SetShowHighlightOnHover(bool show_highlight_on_hover); |
|
sky
2016/11/02 02:52:11
Do these need to change once a button is created?
bruthig
2016/11/04 18:50:37
Not currently, but having them as configuration me
|
| + |
| + void SetShowHighlightOnFocus(bool show_highlight_on_focus); |
| + |
| + // Auto highlighting is a mechanism to show/hide the highlight based on the |
| + // visibility of the ripple. See the documentation of the AutoHighlightMode |
| + // for more info on the different modes. |
| + // |
| + // This method is intended as a configuration option to be used after |
| + // construction. Behavior is undefined if |this| has already handled any |
| + // InkDrop defined functions. |
| + void SetAutoHighlightMode(AutoHighlightMode auto_highlight_mode); |
| + |
| // InkDrop: |
| InkDropState GetTargetInkDropState() const override; |
| void AnimateToState(InkDropState ink_drop_state) override; |
| @@ -49,6 +73,23 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop, |
| private: |
| friend class test::InkDropImplTestApi; |
| + // Base state classes. |
| + class HighlightState; |
| + |
| + // AutoHighlightMode::NONE |
| + class NoAutoHighlightHiddenState; |
| + class NoAutoHighlightVisibleState; |
| + |
| + // AutoHighlightMode::HIDE_ON_RIPPLE |
| + class HideHighlightOnRippleHiddenState; |
| + class HideHighlightOnRippleVisibleState; |
| + |
| + // AutoHighlightMode::SHOW_ON_RIPPLE states |
| + class ShowHighlightOnRippleHiddenState; |
| + class ShowHighlightOnRippleVisibleState; |
| + |
| + class HighlightStateFactory; |
| + |
| // Destroys |ink_drop_ripple_| if it's targeted to the HIDDEN state. |
| void DestroyHiddenTargetedAnimations(); |
| @@ -99,16 +140,15 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop, |
| base::TimeDelta animation_duration, |
| bool explode); |
| - // Returns true if this ink drop is hovered or focused. |
| + // Returns true if |this| should be hovered based on hover/focus status. |
| bool ShouldHighlight() const; |
| - // Starts the |highlight_after_ripple_timer_| timer. This will stop the |
| - // current |
| - // |highlight_after_ripple_timer_| instance if it exists. |
| - void StartHighlightAfterRippleTimer(); |
| + // Returns true if |this| should be hovered based on focus status. |
| + bool ShouldHighlightBasedOnFocus() const; |
| - // Callback for when the |highlight_after_ripple_timer_| fires. |
| - void HighlightAfterRippleTimerFired(); |
| + // Updates the current |highlight_state_|. Calls Exit()/Enter() on the |
| + // previous/new state to notify them of the transition. |
| + void SetHighlightState(std::unique_ptr<HighlightState> highlight_state); |
| // The host of the ink drop. Used to poll for information such as whether the |
| // highlight should be shown or not. |
| @@ -126,6 +166,12 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop, |
| // CreateInkDropHighlight(); |
| std::unique_ptr<InkDropHighlight> highlight_; |
| + // True denotes the highlight should be shown when this is hovered. |
| + bool show_highlight_on_hover_; |
| + |
| + // True denotes the highlight should be shown when this is focused. |
| + bool show_highlight_on_focus_; |
| + |
| // Tracks the logical hovered state of |this| as manipulated by the public |
| // SetHovered() function. |
| bool is_hovered_; |
| @@ -137,9 +183,13 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop, |
| // The current InkDropRipple. Created on demand using CreateInkDropRipple(). |
| std::unique_ptr<InkDropRipple> ink_drop_ripple_; |
| - // The timer used to delay the highlight fade in after an ink drop ripple |
| - // animation. |
| - std::unique_ptr<base::Timer> highlight_after_ripple_timer_; |
| + // Used by |this| to initialize the starting |highlight_state_| and by the |
| + // current |highlight_state_ to create the next state. |
| + std::unique_ptr<HighlightStateFactory> highlight_state_factory_; |
| + |
| + // The current state object that handles all inputs that affect the visibility |
| + // of the InkDropHighlight. |
| + std::unique_ptr<HighlightState> highlight_state_; |
| DISALLOW_COPY_AND_ASSIGN(InkDropImpl); |
| }; |