| 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_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 5 #ifndef CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| 6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 6 #define CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 13 #include "cc/input/scrollbar.h" | 13 #include "cc/input/scrollbar.h" |
| 14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
| 15 #include "cc/layers/scrollbar_layer_impl_base.h" | 15 #include "cc/layers/scrollbar_layer_impl_base.h" |
| 16 #include "ui/gfx/geometry/vector2d_f.h" | 16 #include "ui/gfx/geometry/vector2d_f.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 class ScrollbarAnimationControllerClient; | 20 class ScrollbarAnimationControllerClient; |
| 21 | 21 |
| 22 // ScrollbarAnimationControllerThinning for one scrollbar | 22 // ScrollbarAnimationControllerThinning for one scrollbar |
| 23 class CC_EXPORT SingleScrollbarAnimationControllerThinning { | 23 class CC_EXPORT SingleScrollbarAnimationControllerThinning { |
| 24 public: | 24 public: |
| 25 static constexpr float kIdleThicknessScale = 0.4f; |
| 26 static constexpr float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; |
| 27 |
| 25 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( | 28 static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create( |
| 26 int scroll_layer_id, | 29 int scroll_layer_id, |
| 27 ScrollbarOrientation orientation, | 30 ScrollbarOrientation orientation, |
| 28 ScrollbarAnimationControllerClient* client, | 31 ScrollbarAnimationControllerClient* client, |
| 29 base::TimeDelta thinning_duration); | 32 base::TimeDelta thinning_duration); |
| 30 | 33 |
| 31 ~SingleScrollbarAnimationControllerThinning() {} | 34 ~SingleScrollbarAnimationControllerThinning() {} |
| 32 | 35 |
| 33 void set_mouse_move_distance_for_test(float distance) { | |
| 34 mouse_move_distance_to_trigger_animation_ = distance; | |
| 35 } | |
| 36 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } | 36 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } |
| 37 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } | 37 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } |
| 38 bool captured() const { return captured_; } | 38 bool captured() const { return captured_; } |
| 39 | 39 |
| 40 bool Animate(base::TimeTicks now); | 40 bool Animate(base::TimeTicks now); |
| 41 void StartAnimation(); | 41 void StartAnimation(); |
| 42 void StopAnimation(); | 42 void StopAnimation(); |
| 43 | 43 |
| 44 void UpdateThumbThicknessScale(); | 44 void UpdateThumbThicknessScale(); |
| 45 | 45 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 bool is_animating_; | 77 bool is_animating_; |
| 78 | 78 |
| 79 int scroll_layer_id_; | 79 int scroll_layer_id_; |
| 80 | 80 |
| 81 ScrollbarOrientation orientation_; | 81 ScrollbarOrientation orientation_; |
| 82 bool captured_; | 82 bool captured_; |
| 83 bool mouse_is_over_scrollbar_; | 83 bool mouse_is_over_scrollbar_; |
| 84 bool mouse_is_near_scrollbar_; | 84 bool mouse_is_near_scrollbar_; |
| 85 // Are we narrowing or thickening the bars. | 85 // Are we narrowing or thickening the bars. |
| 86 AnimationChange thickness_change_; | 86 AnimationChange thickness_change_; |
| 87 // How close should the mouse be to the scrollbar before we thicken it. | |
| 88 float mouse_move_distance_to_trigger_animation_; | |
| 89 | 87 |
| 90 base::TimeDelta thinning_duration_; | 88 base::TimeDelta thinning_duration_; |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); | 90 DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 } // namespace cc | 93 } // namespace cc |
| 96 | 94 |
| 97 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 95 #endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
| OLD | NEW |