| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 5 #ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| 6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 12 #include "cc/input/scrollbar_animation_controller.h" | 13 #include "cc/input/scrollbar_animation_controller.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 // Scrollbar animation that partially fades and thins after an idle delay, | 17 using std::vector; |
| 17 // and reacts to mouse movements. | 18 |
| 18 class CC_EXPORT ScrollbarAnimationControllerThinning | 19 // ScrollbarAnimationControllerThinning for one scrollbar |
| 20 class CC_EXPORT SingleScrollbarAnimationControllerThinning |
| 19 : public ScrollbarAnimationController { | 21 : public ScrollbarAnimationController { |
| 20 public: | 22 public: |
| 21 static std::unique_ptr<ScrollbarAnimationControllerThinning> Create( | 23 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( |
| 22 int scroll_layer_id, | 24 int scroll_layer_id, |
| 25 ScrollbarOrientation orientation, |
| 23 ScrollbarAnimationControllerClient* client, | 26 ScrollbarAnimationControllerClient* client, |
| 24 base::TimeDelta delay_before_starting, | 27 base::TimeDelta delay_before_starting, |
| 25 base::TimeDelta resize_delay_before_starting, | 28 base::TimeDelta resize_delay_before_starting, |
| 26 base::TimeDelta fade_duration, | 29 base::TimeDelta fade_duration, |
| 27 base::TimeDelta thinning_duration); | 30 base::TimeDelta thinning_duration); |
| 28 | 31 |
| 29 ~ScrollbarAnimationControllerThinning() override; | 32 ~SingleScrollbarAnimationControllerThinning() override {} |
| 30 | 33 |
| 31 void set_mouse_move_distance_for_test(float distance) { | 34 void set_mouse_move_distance_for_test(float distance) { |
| 32 mouse_move_distance_to_trigger_animation_ = distance; | 35 mouse_move_distance_to_trigger_animation_ = distance; |
| 33 } | 36 } |
| 37 ScrollbarOrientation orientation() const { return orientation_; } |
| 34 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } | 38 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } |
| 35 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } | 39 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } |
| 36 | 40 |
| 37 void DidScrollUpdate(bool on_resize) override; | 41 void DidScrollUpdate(bool on_resize) override; |
| 38 | 42 |
| 39 void DidMouseDown() override; | 43 void DidMouseDown() override; |
| 40 void DidMouseUp() override; | 44 void DidMouseUp() override; |
| 41 void DidMouseLeave() override; | 45 void DidMouseLeave() override; |
| 42 void DidMouseMoveNear(float distance) override; | |
| 43 bool ScrollbarsHidden() const override; | 46 bool ScrollbarsHidden() const override; |
| 47 void RunAnimationFrame(float progress) override; |
| 48 const base::TimeDelta& Duration() override; |
| 49 void DidMouseMoveNear(vector<DistanceToScrollbar>) override; |
| 44 | 50 |
| 45 protected: | 51 protected: |
| 46 ScrollbarAnimationControllerThinning( | 52 SingleScrollbarAnimationControllerThinning( |
| 47 int scroll_layer_id, | 53 int scroll_layer_id, |
| 54 ScrollbarOrientation orientation, |
| 48 ScrollbarAnimationControllerClient* client, | 55 ScrollbarAnimationControllerClient* client, |
| 49 base::TimeDelta delay_before_starting, | 56 base::TimeDelta delay_before_starting, |
| 50 base::TimeDelta resize_delay_before_starting, | 57 base::TimeDelta resize_delay_before_starting, |
| 51 base::TimeDelta fade_duration, | 58 base::TimeDelta fade_duration, |
| 52 base::TimeDelta thinning_duration); | 59 base::TimeDelta thinning_duration); |
| 53 | 60 |
| 54 void RunAnimationFrame(float progress) override; | |
| 55 const base::TimeDelta& Duration() override; | |
| 56 | |
| 57 private: | 61 private: |
| 58 // Describes whether the current animation should INCREASE (thicken) | 62 // Describes whether the current animation should INCREASE (thicken) |
| 59 // a bar or DECREASE it (thin). | 63 // a bar or DECREASE it (thin). |
| 60 enum AnimationChange { NONE, INCREASE, DECREASE }; | 64 enum AnimationChange { NONE, INCREASE, DECREASE }; |
| 61 enum AnimatingProperty { OPACITY, THICKNESS }; | 65 enum AnimatingProperty { OPACITY, THICKNESS }; |
| 62 float ThumbThicknessScaleAt(float progress); | 66 float ThumbThicknessScaleAt(float progress); |
| 63 float AdjustScale(float new_value, | 67 float AdjustScale(float new_value, |
| 64 float current_value, | 68 float current_value, |
| 65 AnimationChange animation_change, | 69 AnimationChange animation_change, |
| 66 float min_value, | 70 float min_value, |
| 67 float max_value); | 71 float max_value); |
| 68 void ApplyOpacity(float opacity); | 72 void ApplyOpacity(float opacity); |
| 69 void ApplyThumbThicknessScale(float thumb_thickness_scale); | 73 void ApplyThumbThicknessScale(float thumb_thickness_scale); |
| 70 | 74 |
| 71 void SetCurrentAnimatingProperty(AnimatingProperty property); | 75 void SetCurrentAnimatingProperty(AnimatingProperty property); |
| 72 | 76 |
| 77 ScrollbarOrientation orientation_; |
| 73 float opacity_; | 78 float opacity_; |
| 74 bool captured_; | 79 bool captured_; |
| 75 bool mouse_is_over_scrollbar_; | 80 bool mouse_is_over_scrollbar_; |
| 76 bool mouse_is_near_scrollbar_; | 81 bool mouse_is_near_scrollbar_; |
| 77 // Are we narrowing or thickening the bars. | 82 // Are we narrowing or thickening the bars. |
| 78 AnimationChange thickness_change_; | 83 AnimationChange thickness_change_; |
| 79 // How close should the mouse be to the scrollbar before we thicken it. | 84 // How close should the mouse be to the scrollbar before we thicken it. |
| 80 float mouse_move_distance_to_trigger_animation_; | 85 float mouse_move_distance_to_trigger_animation_; |
| 81 | 86 |
| 82 base::TimeDelta fade_duration_; | 87 base::TimeDelta fade_duration_; |
| 83 base::TimeDelta thinning_duration_; | 88 base::TimeDelta thinning_duration_; |
| 84 | 89 |
| 85 AnimatingProperty current_animating_property_; | 90 AnimatingProperty current_animating_property_; |
| 86 | 91 |
| 87 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); | 92 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 } // namespace cc | 95 } // namespace cc |
| 91 | 96 |
| 92 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 97 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| OLD | NEW |