Chromium Code Reviews| Index: cc/input/single_scrollbar_animation_controller_thinning.h |
| diff --git a/cc/input/scrollbar_animation_controller_thinning.h b/cc/input/single_scrollbar_animation_controller_thinning.h |
| similarity index 55% |
| copy from cc/input/scrollbar_animation_controller_thinning.h |
| copy to cc/input/single_scrollbar_animation_controller_thinning.h |
| index 236e595ea263ec5d9f090d913005b34bfbbcd967..cc8d4bab147f23ec89ea5ec2642f959c263eef3e 100644 |
| --- a/cc/input/scrollbar_animation_controller_thinning.h |
| +++ b/cc/input/single_scrollbar_animation_controller_thinning.h |
| @@ -2,65 +2,74 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| -#define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| +#ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| +#define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| #include <memory> |
| #include "base/macros.h" |
| +#include "base/time/time.h" |
| #include "cc/base/cc_export.h" |
| #include "cc/input/scrollbar_animation_controller.h" |
| +#include "cc/layers/layer_impl.h" |
| +#include "cc/layers/scrollbar_layer_impl_base.h" |
| +#include "ui/gfx/geometry/vector2d_f.h" |
| namespace cc { |
| -// Scrollbar animation that partially fades and thins after an idle delay, |
| -// and reacts to mouse movements. |
| -class CC_EXPORT ScrollbarAnimationControllerThinning |
| - : public ScrollbarAnimationController { |
| +// ScrollbarAnimationControllerThinning for one scrollbar |
| +class CC_EXPORT SingleScrollbarAnimationControllerThinning { |
| public: |
| - static std::unique_ptr<ScrollbarAnimationControllerThinning> Create( |
| + static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( |
| int scroll_layer_id, |
| + ScrollbarOrientation orientation, |
| ScrollbarAnimationControllerClient* client, |
| - base::TimeDelta delay_before_starting, |
| - base::TimeDelta resize_delay_before_starting, |
| + base::CancelableClosure* delayed_scrollbar_fade, |
| base::TimeDelta fade_duration, |
| base::TimeDelta thinning_duration); |
| - ~ScrollbarAnimationControllerThinning() override; |
| + ~SingleScrollbarAnimationControllerThinning() {} |
| void set_mouse_move_distance_for_test(float distance) { |
| mouse_move_distance_to_trigger_animation_ = distance; |
| } |
| bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } |
| bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } |
| + bool captured() const { return captured_; } |
| - void DidScrollUpdate(bool on_resize) override; |
| - void DidScrollEnd() override; |
| + bool Animate(base::TimeTicks now); |
| + void StartAnimation(); |
| + void StopAnimation(); |
| - void DidMouseDown() override; |
| - void DidMouseUp() override; |
| - void DidMouseLeave() override; |
| - void DidMouseMoveNear(float distance) override; |
| - bool ScrollbarsHidden() const override; |
| + void FadeIn(); |
| + bool ShouldFadeOut() const; |
| - protected: |
| - ScrollbarAnimationControllerThinning( |
| + void DidMouseDown(); |
| + void DidMouseUp(); |
| + void DidMouseLeave(); |
| + void DidMouseMoveNear(float distance); |
| + bool ScrollbarsHidden() const; |
| + |
| + const base::TimeDelta& Duration(); |
| + |
| + private: |
| + SingleScrollbarAnimationControllerThinning( |
| int scroll_layer_id, |
| + ScrollbarOrientation orientation, |
| ScrollbarAnimationControllerClient* client, |
| - base::TimeDelta delay_before_starting, |
| - base::TimeDelta resize_delay_before_starting, |
| + base::CancelableClosure* delayed_scrollbar_fade, |
| base::TimeDelta fade_duration, |
| base::TimeDelta thinning_duration); |
| - void RunAnimationFrame(float progress) override; |
| - const base::TimeDelta& Duration() override; |
| + float AnimationProgressAtTime(base::TimeTicks now); |
| + void RunAnimationFrame(float progress); |
| - private: |
| // Describes whether the current animation should INCREASE (thicken) |
| // a bar or DECREASE it (thin). |
| enum AnimationChange { NONE, INCREASE, DECREASE }; |
| enum AnimatingProperty { OPACITY, THICKNESS }; |
| float ThumbThicknessScaleAt(float progress); |
| + |
| float AdjustScale(float new_value, |
| float current_value, |
| AnimationChange animation_change, |
| @@ -71,6 +80,17 @@ class CC_EXPORT ScrollbarAnimationControllerThinning |
| void SetCurrentAnimatingProperty(AnimatingProperty property); |
| + ScrollbarSet Scrollbars() const; |
|
bokan
2016/12/16 14:57:42
This should just return one scrollbar.
|
| + |
| + ScrollbarAnimationControllerClient* client_; |
| + base::CancelableClosure* delayed_scrollbar_fade_; |
| + |
| + base::TimeTicks last_awaken_time_; |
| + bool is_animating_; |
| + |
| + int scroll_layer_id_; |
| + |
| + ScrollbarOrientation orientation_; |
| float opacity_; |
| bool captured_; |
| bool mouse_is_over_scrollbar_; |
| @@ -85,9 +105,9 @@ class CC_EXPORT ScrollbarAnimationControllerThinning |
| AnimatingProperty current_animating_property_; |
| - DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); |
| + DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); |
| }; |
| } // namespace cc |
| -#endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| +#endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |