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

Unified Diff: ui/base/gestures/gesture_types.h

Issue 10837329: gesture: Include velocity in scroll-update gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/gestures/gesture_types.h
diff --git a/ui/base/gestures/gesture_types.h b/ui/base/gestures/gesture_types.h
index 0407954ce92205692eda160c81acba739a385a70..7a78f5dfcb6c41b411465602e4f3c8f1c497be3a 100644
--- a/ui/base/gestures/gesture_types.h
+++ b/ui/base/gestures/gesture_types.h
@@ -13,6 +13,7 @@
namespace ui {
class GestureEvent;
+class GestureSequence;
class TouchEvent;
struct UI_EXPORT GestureEventDetails {
@@ -22,27 +23,31 @@ struct UI_EXPORT GestureEventDetails {
EventType type() const { return type_; }
int touch_points() const { return touch_points_; }
- void set_touch_points(int touch_points) { touch_points_ = touch_points; }
const gfx::Rect& bounding_box() const { return bounding_box_; }
- void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; }
float scroll_x() const {
CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
return data.scroll.x;
}
+
float scroll_y() const {
CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
return data.scroll.y;
}
float velocity_x() const {
- CHECK_EQ(ui::ET_SCROLL_FLING_START, type_);
- return data.velocity.x;
+ CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
+ type_ == ui::ET_SCROLL_FLING_START);
+ return type_ == ui::ET_GESTURE_SCROLL_UPDATE ? data.scroll.velocity_x :
+ data.velocity.x;
}
+
float velocity_y() const {
- CHECK_EQ(ui::ET_SCROLL_FLING_START, type_);
- return data.velocity.y;
+ CHECK(type_ == ui::ET_GESTURE_SCROLL_UPDATE ||
+ type_ == ui::ET_SCROLL_FLING_START);
+ return type_ == ui::ET_GESTURE_SCROLL_UPDATE ? data.scroll.velocity_y :
+ data.velocity.y;
}
int touch_id() const {
@@ -59,14 +64,17 @@ struct UI_EXPORT GestureEventDetails {
CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_);
return data.swipe.left;
}
+
bool swipe_right() const {
CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_);
return data.swipe.right;
}
+
bool swipe_up() const {
CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_);
return data.swipe.up;
}
+
bool swipe_down() const {
CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_);
return data.swipe.down;
@@ -78,11 +86,19 @@ struct UI_EXPORT GestureEventDetails {
}
private:
+ friend class GestureSequence;
rjkroege 2012/08/20 14:52:17 grumble.
sadrul 2012/08/20 15:48:34 This is mostly to allow only GestureSequence to be
+
+ void set_touch_points(int touch_points) { touch_points_ = touch_points; }
+ void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; }
+ void SetScrollVelocity(float velocity_x, float velocity_y);
+
ui::EventType type_;
union {
struct { // SCROLL delta.
float x;
float y;
+ float velocity_x;
+ float velocity_y;
} scroll;
float scale; // PINCH scale.
@@ -102,11 +118,6 @@ struct UI_EXPORT GestureEventDetails {
} swipe;
int tap_count; // TAP repeat count.
-
- struct {
- float delta_x;
- float delta_y;
- } generic;
} data;
int touch_points_; // Number of active touch points in the gesture.

Powered by Google App Engine
This is Rietveld 408576698