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

Unified Diff: cc/input/scrollbar_animation_controller_thinning.h

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: bokan comments#31 addressed. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/input/scrollbar_animation_controller.h ('k') | cc/input/scrollbar_animation_controller_thinning.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/input/scrollbar_animation_controller_thinning.h
diff --git a/cc/input/scrollbar_animation_controller_thinning.h b/cc/input/scrollbar_animation_controller_thinning.h
index 236e595ea263ec5d9f090d913005b34bfbbcd967..f3312de16b1a31a148279673206757f9ab8d3f2f 100644
--- a/cc/input/scrollbar_animation_controller_thinning.h
+++ b/cc/input/scrollbar_animation_controller_thinning.h
@@ -10,11 +10,21 @@
#include "base/macros.h"
#include "cc/base/cc_export.h"
#include "cc/input/scrollbar_animation_controller.h"
+#include "cc/input/single_scrollbar_animation_controller_thinning.h"
namespace cc {
-// Scrollbar animation that partially fades and thins after an idle delay,
-// and reacts to mouse movements.
+// This class fade in scrollbars when scroll and fade out after an idle delay.
+// The fade animations works on both scrollbars and is controlled in this class.
+// This class passes the mouse state to each
+// SingleScrollbarAnimationControllerThinning. The thinning animations are
+// independent between vertical/horizontal and are managed by the
+// SingleScrollbarAnimationControllerThinnings.
+
+// TODO(chaopeng) clean up the inheritance hierarchy after
weiliangc 2017/01/24 23:19:57 Is there a reason we are not doing this in this CL
+// ScrollbarAnimationControllerLinearFade merge into
+// ScrollbarAnimationControllerThinning so we can remove the empty overrides and
+// NOTREACHED() checks.
class CC_EXPORT ScrollbarAnimationControllerThinning
: public ScrollbarAnimationController {
public:
@@ -28,22 +38,23 @@ class CC_EXPORT ScrollbarAnimationControllerThinning
~ScrollbarAnimationControllerThinning() override;
- 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_; }
+ void set_mouse_move_distance_for_test(float distance);
+ bool mouse_is_over_scrollbar(ScrollbarOrientation orientation) const;
+ bool mouse_is_near_scrollbar(ScrollbarOrientation orientation) const;
+ bool mouse_is_near_any_scrollbar() const;
+
+ bool Animate(base::TimeTicks now) override;
void DidScrollUpdate(bool on_resize) override;
void DidScrollEnd() override;
-
void DidMouseDown() override;
void DidMouseUp() override;
void DidMouseLeave() override;
- void DidMouseMoveNear(float distance) override;
+ void DidMouseMoveNear(ScrollbarOrientation orientation,
+ float distance) override;
bool ScrollbarsHidden() const override;
- protected:
+ private:
ScrollbarAnimationControllerThinning(
int scroll_layer_id,
ScrollbarAnimationControllerClient* client,
@@ -52,38 +63,21 @@ class CC_EXPORT ScrollbarAnimationControllerThinning
base::TimeDelta fade_duration,
base::TimeDelta thinning_duration);
- void RunAnimationFrame(float progress) override;
- const base::TimeDelta& Duration() override;
+ SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
+ ScrollbarOrientation) const;
- 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,
- float min_value,
- float max_value);
void ApplyOpacity(float opacity);
- void ApplyThumbThicknessScale(float thumb_thickness_scale);
+ bool Captured() const;
+ void RunAnimationFrame(float progress) override;
+ const base::TimeDelta& Duration() override;
- void SetCurrentAnimatingProperty(AnimatingProperty property);
+ std::unique_ptr<SingleScrollbarAnimationControllerThinning>
+ vertical_controller_;
+ std::unique_ptr<SingleScrollbarAnimationControllerThinning>
+ horizontal_controller_;
float opacity_;
- bool captured_;
- bool mouse_is_over_scrollbar_;
- bool mouse_is_near_scrollbar_;
- // Are we narrowing or thickening the bars.
- AnimationChange thickness_change_;
- // How close should the mouse be to the scrollbar before we thicken it.
- float mouse_move_distance_to_trigger_animation_;
-
base::TimeDelta fade_duration_;
- base::TimeDelta thinning_duration_;
-
- AnimatingProperty current_animating_property_;
DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning);
};
« no previous file with comments | « cc/input/scrollbar_animation_controller.h ('k') | cc/input/scrollbar_animation_controller_thinning.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698