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

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

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
« no previous file with comments | « ui/base/gestures/gesture_types.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/base/gestures/gesture_types.h" 5 #include "ui/base/gestures/gesture_types.h"
6 6
7 namespace ui { 7 namespace ui {
8 8
9 GestureEventDetails::GestureEventDetails(ui::EventType type, 9 GestureEventDetails::GestureEventDetails(ui::EventType type,
10 float delta_x, 10 float delta_x,
11 float delta_y) 11 float delta_y)
12 : type_(type), 12 : type_(type),
13 touch_points_(1) { 13 touch_points_(1) {
14 switch (type_) { 14 switch (type_) {
15 case ui::ET_GESTURE_SCROLL_UPDATE: 15 case ui::ET_GESTURE_SCROLL_UPDATE:
16 data.scroll_update.x = delta_x; 16 data.scroll_update.x = delta_x;
17 data.scroll_update.y = delta_y; 17 data.scroll_update.y = delta_y;
18 data.scroll_update.x_ordinal = delta_x;
19 data.scroll_update.y_ordinal = delta_y;
18 break; 20 break;
19 21
20 case ui::ET_SCROLL_FLING_START: 22 case ui::ET_SCROLL_FLING_START:
21 data.fling_velocity.x = delta_x; 23 data.fling_velocity.x = delta_x;
22 data.fling_velocity.y = delta_y; 24 data.fling_velocity.y = delta_y;
25 data.scroll_update.x_ordinal = delta_x;
rjkroege 2013/08/09 22:18:43 should be fling_velocity?
DaveMoore 2013/08/12 20:38:16 Done.
26 data.scroll_update.y_ordinal = delta_y;
23 break; 27 break;
24 28
25 case ui::ET_GESTURE_LONG_PRESS: 29 case ui::ET_GESTURE_LONG_PRESS:
26 data.touch_id = static_cast<int>(delta_x); 30 data.touch_id = static_cast<int>(delta_x);
27 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press."; 31 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press.";
28 break; 32 break;
29 33
30 case ui::ET_GESTURE_TWO_FINGER_TAP: 34 case ui::ET_GESTURE_TWO_FINGER_TAP:
31 data.first_finger_enclosing_rectangle.width = delta_x; 35 data.first_finger_enclosing_rectangle.width = delta_x;
32 data.first_finger_enclosing_rectangle.height = delta_y; 36 data.first_finger_enclosing_rectangle.height = delta_y;
(...skipping 18 matching lines...) Expand all
51 55
52 default: 56 default:
53 if (delta_x != 0.f || delta_y != 0.f) { 57 if (delta_x != 0.f || delta_y != 0.f) {
54 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" 58 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
55 << delta_x << "," << delta_y; 59 << delta_x << "," << delta_y;
56 } 60 }
57 break; 61 break;
58 } 62 }
59 } 63 }
60 64
65 GestureEventDetails::GestureEventDetails(ui::EventType type,
66 float delta_x,
67 float delta_y,
68 float delta_x_ordinal,
69 float delta_y_ordinal)
70 : type_(type),
71 touch_points_(1) {
72 CHECK(type == ui::ET_GESTURE_SCROLL_UPDATE ||
73 type == ui::ET_SCROLL_FLING_START);
74 switch (type_) {
75 case ui::ET_GESTURE_SCROLL_UPDATE:
76 data.scroll_update.x = delta_x;
77 data.scroll_update.y = delta_y;
78 data.scroll_update.x_ordinal = delta_x_ordinal;
79 data.scroll_update.y_ordinal = delta_y_ordinal;
80 break;
81
82 case ui::ET_SCROLL_FLING_START:
83 data.fling_velocity.x = delta_x;
84 data.fling_velocity.y = delta_y;
85 data.scroll_update.x_ordinal = delta_x_ordinal;
rjkroege 2013/08/09 22:18:43 should be fling_velocity here and line below?
DaveMoore 2013/08/12 20:38:16 Done.
86 data.scroll_update.y_ordinal = delta_y_ordinal;
87 break;
88
89 default:
90 break;
91 }
92 }
93
61 void GestureEventDetails::SetScrollVelocity(float velocity_x, 94 void GestureEventDetails::SetScrollVelocity(float velocity_x,
62 float velocity_y) { 95 float velocity_y,
96 float velocity_x_ordinal,
97 float velocity_y_ordinal) {
63 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); 98 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
64 data.scroll_update.velocity_x = velocity_x; 99 data.scroll_update.velocity_x = velocity_x;
65 data.scroll_update.velocity_y = velocity_y; 100 data.scroll_update.velocity_y = velocity_y;
101 data.scroll_update.velocity_x_ordinal = velocity_x_ordinal;
102 data.scroll_update.velocity_y_ordinal = velocity_y_ordinal;
66 } 103 }
67 104
68 } // namespace ui 105 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gestures/gesture_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698