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

Side by Side Diff: ui/base/gestures/gesture_types.h

Issue 22354005: Add support for maintaining ordinal values through GestureRecognizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix to fling Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BASE_GESTURES_GESTURE_TYPES_H_ 5 #ifndef UI_BASE_GESTURES_GESTURE_TYPES_H_
6 #define UI_BASE_GESTURES_GESTURE_TYPES_H_ 6 #define UI_BASE_GESTURES_GESTURE_TYPES_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/base/events/event_constants.h" 9 #include "ui/base/events/event_constants.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 class GestureEvent; 14 class GestureEvent;
15 class TouchEvent; 15 class TouchEvent;
16 16
17 struct UI_EXPORT GestureEventDetails { 17 struct UI_EXPORT GestureEventDetails {
18 public: 18 public:
19 GestureEventDetails(EventType type, float delta_x, float delta_y); 19 GestureEventDetails(EventType type, float delta_x, float delta_y);
20 GestureEventDetails(EventType type,
21 float delta_x, float delta_y,
22 float delta_x_ordinal, float delta_y_ordinal);
20 23
21 EventType type() const { return type_; } 24 EventType type() const { return type_; }
22 25
23 int touch_points() const { return touch_points_; } 26 int touch_points() const { return touch_points_; }
24 void set_touch_points(int touch_points) { touch_points_ = touch_points; } 27 void set_touch_points(int touch_points) { touch_points_ = touch_points; }
25 28
26 const gfx::Rect& bounding_box() const { return bounding_box_; } 29 const gfx::Rect& bounding_box() const { return bounding_box_; }
27 void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; } 30 void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; }
28 31
29 void SetScrollVelocity(float velocity_x, float velocity_y); 32 void SetScrollVelocity(float velocity_x, float velocity_y,
33 float velocity_x_ordinal, float velocity_y_ordinal);
30 34
31 float scroll_x() const { 35 float scroll_x() const {
32 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); 36 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
33 return data.scroll_update.x; 37 return data.scroll_update.x;
34 } 38 }
35 39
36 float scroll_y() const { 40 float scroll_y() const {
37 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); 41 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
38 return data.scroll_update.y; 42 return data.scroll_update.y;
39 } 43 }
40 44
41 float velocity_x() const { 45 float velocity_x() const {
42 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE || 46 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
43 type_ == ui::ET_SCROLL_FLING_START); 47 type_ == ui::ET_SCROLL_FLING_START);
44 return type_ == ui::ET_SCROLL_FLING_START ? data.fling_velocity.x : 48 return type_ == ui::ET_SCROLL_FLING_START ? data.fling_velocity.x :
45 data.scroll_update.velocity_x; 49 data.scroll_update.velocity_x;
46 } 50 }
47 51
48 float velocity_y() const { 52 float velocity_y() const {
49 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE || 53 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
50 type_ == ui::ET_SCROLL_FLING_START); 54 type_ == ui::ET_SCROLL_FLING_START);
51 return type_ == ui::ET_SCROLL_FLING_START ? data.fling_velocity.y : 55 return type_ == ui::ET_SCROLL_FLING_START ? data.fling_velocity.y :
52 data.scroll_update.velocity_y; 56 data.scroll_update.velocity_y;
53 } 57 }
54 58
59 // *_ordinal values are unmodified by rail based clamping.
60 float scroll_x_ordinal() const {
61 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
62 return data.scroll_update.x_ordinal;
63 }
64
65 float scroll_y_ordinal() const {
66 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
67 return data.scroll_update.y_ordinal;
68 }
69
70 float velocity_x_ordinal() const {
71 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
72 type_ == ui::ET_SCROLL_FLING_START);
73 return type_ == ui::ET_SCROLL_FLING_START ?
74 data.fling_velocity.x_ordinal :
75 data.scroll_update.velocity_x_ordinal;
76 }
77
78 float velocity_y_ordinal() const {
79 CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
80 type_ == ui::ET_SCROLL_FLING_START);
81 return type_ == ui::ET_SCROLL_FLING_START ?
82 data.fling_velocity.y_ordinal :
83 data.scroll_update.velocity_y_ordinal;
84 }
85
55 int touch_id() const { 86 int touch_id() const {
56 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_); 87 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_);
57 return data.touch_id; 88 return data.touch_id;
58 } 89 }
59 90
60 float first_finger_width() const { 91 float first_finger_width() const {
61 CHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_); 92 CHECK_EQ(ui::ET_GESTURE_TWO_FINGER_TAP, type_);
62 return data.first_finger_enclosing_rectangle.width; 93 return data.first_finger_enclosing_rectangle.width;
63 } 94 }
64 95
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 129 }
99 130
100 private: 131 private:
101 ui::EventType type_; 132 ui::EventType type_;
102 union { 133 union {
103 struct { // SCROLL delta. 134 struct { // SCROLL delta.
104 float x; 135 float x;
105 float y; 136 float y;
106 float velocity_x; 137 float velocity_x;
107 float velocity_y; 138 float velocity_y;
139 float x_ordinal;
140 float y_ordinal;
141 float velocity_x_ordinal;
142 float velocity_y_ordinal;
108 } scroll_update; 143 } scroll_update;
109 144
110 float scale; // PINCH scale. 145 float scale; // PINCH scale.
111 146
112 struct { // FLING velocity. 147 struct { // FLING velocity.
113 float x; 148 float x;
114 float y; 149 float y;
150 float x_ordinal;
151 float y_ordinal;
115 } fling_velocity; 152 } fling_velocity;
116 153
117 int touch_id; // LONG_PRESS touch-id. 154 int touch_id; // LONG_PRESS touch-id.
118 155
119 // Dimensions of the first finger's enclosing rectangle for TWO_FINGER_TAP. 156 // Dimensions of the first finger's enclosing rectangle for TWO_FINGER_TAP.
120 struct { 157 struct {
121 float width; 158 float width;
122 float height; 159 float height;
123 } first_finger_enclosing_rectangle; 160 } first_finger_enclosing_rectangle;
124 161
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 virtual ~GestureEventHelper() { 205 virtual ~GestureEventHelper() {
169 } 206 }
170 207
171 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; 208 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0;
172 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; 209 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0;
173 }; 210 };
174 211
175 } // namespace ui 212 } // namespace ui
176 213
177 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ 214 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698