1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_GESTURE_DETECTION_SNAP_SCROLL_CONTROLLER_H_
6 #define UI_EVENTS_GESTURE_DETECTION_SNAP_SCROLL_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "ui/events/gesture_detection/gesture_detection_export.h"
20 // Port of SnapScrollController.java from Chromium
21 // Controls the scroll snapping behavior based on scroll updates.
22 class SnapScrollController
{
24 explicit SnapScrollController(const gfx::Display
& display
);
25 ~SnapScrollController();
27 // Updates the snap scroll mode based on the given X and Y distance to be
28 // moved on scroll. If the scroll update is above a threshold, the snapping
30 void UpdateSnapScrollMode(float distance_x
, float distance_y
);
32 // Sets the snap scroll mode based on the event type.
33 void SetSnapScrollingMode(const MotionEvent
& event
,
34 bool is_scale_gesture_detection_in_progress
);
36 void ResetSnapScrollMode() { snap_scroll_mode_
= SNAP_NONE
; }
37 bool IsSnapVertical() const { return snap_scroll_mode_
== SNAP_VERT
; }
38 bool IsSnapHorizontal() const { return snap_scroll_mode_
== SNAP_HORIZ
; }
39 bool IsSnappingScrolls() const { return snap_scroll_mode_
!= SNAP_NONE
; }
48 float channel_distance_
;
49 SnapMode snap_scroll_mode_
;
55 DISALLOW_COPY_AND_ASSIGN(SnapScrollController
);
60 #endif // UI_EVENTS_GESTURE_DETECTION_SNAP_SCROLL_CONTROLLER_H_