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

Side by Side Diff: cc/input/scrollbar_animation_controller_thinning.h

Issue 2442573002: Implement fade-out animation for Aura overlay scrollbars (CC only). (Closed)
Patch Set: Few more fixes Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 6 #define CC_INPUT_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 "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/input/scrollbar_animation_controller.h" 12 #include "cc/input/scrollbar_animation_controller.h"
13 13
14 namespace cc { 14 namespace cc {
15 class LayerImpl; 15 class LayerImpl;
16 16
17 // Scrollbar animation that partially fades and thins after an idle delay, 17 // Scrollbar animation that partially fades and thins after an idle delay,
18 // and reacts to mouse movements. 18 // and reacts to mouse movements.
19 class CC_EXPORT ScrollbarAnimationControllerThinning 19 class CC_EXPORT ScrollbarAnimationControllerThinning
20 : public ScrollbarAnimationController { 20 : public ScrollbarAnimationController {
21 public: 21 public:
22 static std::unique_ptr<ScrollbarAnimationControllerThinning> Create( 22 static std::unique_ptr<ScrollbarAnimationControllerThinning> Create(
23 int scroll_layer_id, 23 int scroll_layer_id,
24 ScrollbarAnimationControllerClient* client, 24 ScrollbarAnimationControllerClient* client,
25 base::TimeDelta delay_before_starting, 25 base::TimeDelta delay_before_starting,
26 base::TimeDelta resize_delay_before_starting, 26 base::TimeDelta resize_delay_before_starting,
27 base::TimeDelta duration); 27 base::TimeDelta fade_duration,
28 base::TimeDelta thinning_duration);
28 29
29 ~ScrollbarAnimationControllerThinning() override; 30 ~ScrollbarAnimationControllerThinning() override;
30 31
31 void set_mouse_move_distance_for_test(float distance) { 32 void set_mouse_move_distance_for_test(float distance) {
32 mouse_move_distance_to_trigger_animation_ = distance; 33 mouse_move_distance_to_trigger_animation_ = distance;
33 } 34 }
34 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } 35 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; }
35 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } 36 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; }
36 37
37 void DidScrollUpdate(bool on_resize) override; 38 void DidScrollUpdate(bool on_resize) override;
38 39
39 void DidCaptureScrollbarBegin() override; 40 void DidCaptureScrollbarBegin() override;
40 void DidCaptureScrollbarEnd() override; 41 void DidCaptureScrollbarEnd() override;
41 void DidMouseMoveOffScrollbar() override; 42 void DidMouseMoveOffScrollbar() override;
42 void DidMouseMoveNear(float distance) override; 43 void DidMouseMoveNear(float distance) override;
43 44
44 protected: 45 protected:
45 ScrollbarAnimationControllerThinning( 46 ScrollbarAnimationControllerThinning(
46 int scroll_layer_id, 47 int scroll_layer_id,
47 ScrollbarAnimationControllerClient* client, 48 ScrollbarAnimationControllerClient* client,
48 base::TimeDelta delay_before_starting, 49 base::TimeDelta delay_before_starting,
49 base::TimeDelta resize_delay_before_starting, 50 base::TimeDelta resize_delay_before_starting,
50 base::TimeDelta duration); 51 base::TimeDelta fade_duration,
52 base::TimeDelta thinning_duration);
51 53
52 void RunAnimationFrame(float progress) override; 54 void RunAnimationFrame(float progress) override;
53 55
54 private: 56 private:
55 // Describes whether the current animation should INCREASE (darken / thicken) 57 // Describes whether the current animation should INCREASE (thicken)
56 // a bar or DECREASE it (lighten / thin). 58 // a bar or DECREASE it (thin).
57 enum AnimationChange { NONE, INCREASE, DECREASE }; 59 enum AnimationChange { NONE, INCREASE, DECREASE };
58 float OpacityAtAnimationProgress(float progress); 60 enum AnimatingProperty { OPACITY, THICKNESS };
59 float ThumbThicknessScaleAtAnimationProgress(float progress); 61 float ThumbThicknessScaleAt(float progress);
60 float AdjustScale(float new_value, 62 float AdjustScale(float new_value,
61 float current_value, 63 float current_value,
62 AnimationChange animation_change, 64 AnimationChange animation_change,
63 float min_value, 65 float min_value,
64 float max_value); 66 float max_value);
65 void ApplyOpacityAndThumbThicknessScale(float opacity, 67 void ApplyOpacity(float opacity);
66 float thumb_thickness_scale); 68 void ApplyThumbThicknessScale(float thumb_thickness_scale);
67 69
70 void SetCurrentAnimatingProperty(AnimatingProperty property);
71
72 bool is_visible_;
aelias_OOO_until_Jul13 2016/10/20 23:40:51 Hmm, I don't generally like "visible" booleans due
bokan 2016/10/21 00:32:30 Done.
68 bool captured_; 73 bool captured_;
69 bool mouse_is_over_scrollbar_; 74 bool mouse_is_over_scrollbar_;
70 bool mouse_is_near_scrollbar_; 75 bool mouse_is_near_scrollbar_;
71 // Are we narrowing or thickening the bars. 76 // Are we narrowing or thickening the bars.
72 AnimationChange thickness_change_; 77 AnimationChange thickness_change_;
73 // Are we darkening or lightening the bars.
74 AnimationChange opacity_change_;
75 // How close should the mouse be to the scrollbar before we thicken it. 78 // How close should the mouse be to the scrollbar before we thicken it.
76 float mouse_move_distance_to_trigger_animation_; 79 float mouse_move_distance_to_trigger_animation_;
77 80
81 base::TimeDelta fade_duration_;
82 base::TimeDelta thinning_duration_;
83
84 AnimatingProperty current_animating_property_;
85
78 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); 86 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning);
79 }; 87 };
80 88
81 } // namespace cc 89 } // namespace cc
82 90
83 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ 91 #endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698