OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "ui/events/gesture_detection/gesture_detection_export.h" | 10 #include "ui/events/gesture_detection/gesture_detection_export.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 ~Config(); | 25 ~Config(); |
26 GestureDetector::Config gesture_detector_config; | 26 GestureDetector::Config gesture_detector_config; |
27 bool quick_scale_enabled; | 27 bool quick_scale_enabled; |
28 int min_scaling_touch_major; | 28 int min_scaling_touch_major; |
29 int min_scaling_span; | 29 int min_scaling_span; |
30 }; | 30 }; |
31 | 31 |
32 class ScaleGestureListener { | 32 class ScaleGestureListener { |
33 public: | 33 public: |
34 virtual ~ScaleGestureListener() {} | 34 virtual ~ScaleGestureListener() {} |
35 virtual bool OnScale(const ScaleGestureDetector& detector) = 0; | 35 virtual bool OnScale(const ScaleGestureDetector& detector, |
36 virtual bool OnScaleBegin(const ScaleGestureDetector& detector) = 0; | 36 const MotionEvent& e) = 0; |
37 virtual void OnScaleEnd(const ScaleGestureDetector& detector) = 0; | 37 virtual bool OnScaleBegin(const ScaleGestureDetector& detector, |
| 38 const MotionEvent& e) = 0; |
| 39 virtual void OnScaleEnd(const ScaleGestureDetector& detector, |
| 40 const MotionEvent& e) = 0; |
38 }; | 41 }; |
39 | 42 |
40 // A convenience class to extend when you only want to listen for a subset of | 43 // A convenience class to extend when you only want to listen for a subset of |
41 // scaling-related events. This implements all methods in | 44 // scaling-related events. This implements all methods in |
42 // |ScaleGestureListener| but does nothing. | 45 // |ScaleGestureListener| but does nothing. |
43 // |OnScale()| returns false so that a subclass can retrieve the accumulated | 46 // |OnScale()| returns false so that a subclass can retrieve the accumulated |
44 // scale factor in an overridden |OnScaleEnd()|. | 47 // scale factor in an overridden |OnScaleEnd()|. |
45 // |OnScaleBegin() returns true. | 48 // |OnScaleBegin() returns true. |
46 class SimpleScaleGestureListener : public ScaleGestureListener { | 49 class SimpleScaleGestureListener : public ScaleGestureListener { |
47 public: | 50 public: |
48 // ScaleGestureListener implementation. | 51 // ScaleGestureListener implementation. |
49 virtual bool OnScale(const ScaleGestureDetector&) OVERRIDE; | 52 virtual bool OnScale(const ScaleGestureDetector&, |
50 virtual bool OnScaleBegin(const ScaleGestureDetector&) OVERRIDE; | 53 const MotionEvent&) OVERRIDE; |
51 virtual void OnScaleEnd(const ScaleGestureDetector&) OVERRIDE; | 54 virtual bool OnScaleBegin(const ScaleGestureDetector&, |
| 55 const MotionEvent&) OVERRIDE; |
| 56 virtual void OnScaleEnd(const ScaleGestureDetector&, |
| 57 const MotionEvent&) OVERRIDE; |
52 }; | 58 }; |
53 | 59 |
54 ScaleGestureDetector(const Config& config, ScaleGestureListener* listener); | 60 ScaleGestureDetector(const Config& config, ScaleGestureListener* listener); |
55 virtual ~ScaleGestureDetector(); | 61 virtual ~ScaleGestureDetector(); |
56 | 62 |
57 // Accepts MotionEvents and dispatches events to a |ScaleGestureListener| | 63 // Accepts MotionEvents and dispatches events to a |ScaleGestureListener| |
58 // when appropriate. | 64 // when appropriate. |
59 // | 65 // |
60 // Note: Applications should pass a complete and consistent event stream to | 66 // Note: Applications should pass a complete and consistent event stream to |
61 // this method. A complete and consistent event stream involves all | 67 // this method. A complete and consistent event stream involves all |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 bool event_before_or_above_starting_gesture_event_; | 137 bool event_before_or_above_starting_gesture_event_; |
132 | 138 |
133 scoped_ptr<GestureDetector> gesture_detector_; | 139 scoped_ptr<GestureDetector> gesture_detector_; |
134 | 140 |
135 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); | 141 DISALLOW_COPY_AND_ASSIGN(ScaleGestureDetector); |
136 }; | 142 }; |
137 | 143 |
138 } // namespace ui | 144 } // namespace ui |
139 | 145 |
140 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ | 146 #endif // UI_EVENTS_GESTURE_DETECTION_SCALE_GESTURE_DETECTOR_H_ |
OLD | NEW |