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

Unified Diff: cc/input/single_scrollbar_animation_controller_thinning.h

Issue 2554913002: Prevent overlay scrollbars expand or hover together (Closed)
Patch Set: separate responsibilities of SACT and SSACT Created 4 years 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
Index: cc/input/single_scrollbar_animation_controller_thinning.h
diff --git a/cc/input/single_scrollbar_animation_controller_thinning.h b/cc/input/single_scrollbar_animation_controller_thinning.h
new file mode 100644
index 0000000000000000000000000000000000000000..a240e911e95a608c909f286acdf490df4fa060c0
--- /dev/null
+++ b/cc/input/single_scrollbar_animation_controller_thinning.h
@@ -0,0 +1,103 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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 {
+
+// ScrollbarAnimationControllerThinning for one scrollbar
+class CC_EXPORT SingleScrollbarAnimationControllerThinning {
+ public:
+ static std::unique_ptr<SingleScrollbarAnimationControllerThinning> Create(
+ int scroll_layer_id,
+ ScrollbarOrientation orientation,
+ ScrollbarAnimationControllerClient* client,
+ base::CancelableClosure* delayed_scrollbar_fade,
+ base::TimeDelta thinning_duration);
+
+ ~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_; }
+
+ bool Animate(base::TimeTicks now);
+ void StartAnimation();
+ void StopAnimation();
+
+ bool ShouldFadeOut() const;
+ void UpdateThumbThicknessScale();
+
+ void DidMouseDown();
+ void DidMouseUp();
+ void DidMouseLeave();
+ void DidMouseMoveNear(float distance);
+
+ bool Hidden() const { return hidden_; }
+ void SetHidden(bool hidden) { hidden_ = hidden; }
+
+ private:
+ SingleScrollbarAnimationControllerThinning(
+ int scroll_layer_id,
+ ScrollbarOrientation orientation,
+ ScrollbarAnimationControllerClient* client,
+ base::CancelableClosure* delayed_scrollbar_fade,
+ base::TimeDelta thinning_duration);
+
+ float AnimationProgressAtTime(base::TimeTicks now);
+ void RunAnimationFrame(float progress);
+ const base::TimeDelta& Duration();
+
+ // Describes whether the current animation should INCREASE (thicken)
+ // a bar or DECREASE it (thin).
+ enum AnimationChange { NONE, INCREASE, DECREASE };
+ float ThumbThicknessScaleAt(float progress);
+
+ float AdjustScale(float new_value,
+ float current_value,
+ AnimationChange animation_change,
+ float min_value,
+ float max_value);
+ void ApplyThumbThicknessScale(float thumb_thickness_scale);
+
+ ScrollbarAnimationControllerClient* client_;
+ base::CancelableClosure* delayed_scrollbar_fade_;
+
+ base::TimeTicks last_awaken_time_;
+ bool is_animating_;
+
+ int scroll_layer_id_;
+
+ ScrollbarOrientation orientation_;
+ bool hidden_;
+ 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 thinning_duration_;
+
+ DISALLOW_COPY_AND_ASSIGN(SingleScrollbarAnimationControllerThinning);
+};
+
+} // namespace cc
+
+#endif // CC_INPUT_SINGLE_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_

Powered by Google App Engine
This is Rietveld 408576698