Index: ui/events/gesture_detection/snap_scroll_controller.h |
diff --git a/ui/events/gesture_detection/snap_scroll_controller.h b/ui/events/gesture_detection/snap_scroll_controller.h |
index 753c2bcb20103e383fef3a58d64f20900b6f3d8a..049bcd7a3610d2b4f50c44dd9dcc63209b3264a9 100644 |
--- a/ui/events/gesture_detection/snap_scroll_controller.h |
+++ b/ui/events/gesture_detection/snap_scroll_controller.h |
@@ -7,50 +7,42 @@ |
#include "base/basictypes.h" |
#include "ui/events/gesture_detection/gesture_detection_export.h" |
- |
-namespace gfx { |
-class Display; |
-} |
+#include "ui/gfx/geometry/point_f.h" |
+#include "ui/gfx/geometry/size_f.h" |
+#include "ui/gfx/geometry/vector2d_f.h" |
namespace ui { |
class MotionEvent; |
-class ZoomManager; |
// Port of SnapScrollController.java from Chromium |
// Controls the scroll snapping behavior based on scroll updates. |
-class SnapScrollController { |
+class GESTURE_DETECTION_EXPORT SnapScrollController { |
public: |
- explicit SnapScrollController(const gfx::Display& display); |
+ SnapScrollController(float snap_bound, const gfx::SizeF& display_size); |
~SnapScrollController(); |
+ // Sets the snap scroll mode based on the event type. |
+ void SetSnapScrollMode(const MotionEvent& event, |
+ bool is_scale_gesture_detection_in_progress); |
+ |
// Updates the snap scroll mode based on the given X and Y distance to be |
// moved on scroll. If the scroll update is above a threshold, the snapping |
// behavior is reset. |
void UpdateSnapScrollMode(float distance_x, float distance_y); |
- // Sets the snap scroll mode based on the event type. |
- void SetSnapScrollingMode(const MotionEvent& event, |
- bool is_scale_gesture_detection_in_progress); |
- |
- void ResetSnapScrollMode() { snap_scroll_mode_ = SNAP_NONE; } |
- bool IsSnapVertical() const { return snap_scroll_mode_ == SNAP_VERT; } |
- bool IsSnapHorizontal() const { return snap_scroll_mode_ == SNAP_HORIZ; } |
- bool IsSnappingScrolls() const { return snap_scroll_mode_ != SNAP_NONE; } |
+ bool IsSnapVertical() const; |
+ bool IsSnapHorizontal() const; |
+ bool IsSnappingScrolls() const; |
private: |
- enum SnapMode { |
- SNAP_NONE, |
- SNAP_HORIZ, |
- SNAP_VERT |
- }; |
- |
- float channel_distance_; |
- SnapMode snap_scroll_mode_; |
- float first_touch_x_; |
- float first_touch_y_; |
- float distance_x_; |
- float distance_y_; |
+ enum SnapMode { SNAP_NONE, SNAP_PENDING, SNAP_HORIZ, SNAP_VERT }; |
+ |
+ const float snap_bound_; |
+ const float channel_distance_; |
+ SnapMode mode_; |
+ gfx::PointF down_position_; |
+ gfx::Vector2dF accumulated_distance_; |
DISALLOW_COPY_AND_ASSIGN(SnapScrollController); |
}; |