OLD | NEW |
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 switch (type_) { | 14 switch (type_) { |
14 case ui::ET_GESTURE_SCROLL_UPDATE: | 15 case ui::ET_GESTURE_SCROLL_UPDATE: |
15 data.scroll.x = delta_x; | 16 data.scroll.x = delta_x; |
16 data.scroll.y = delta_y; | 17 data.scroll.y = delta_y; |
17 break; | 18 break; |
18 | 19 |
19 case ui::ET_SCROLL_FLING_START: | 20 case ui::ET_SCROLL_FLING_START: |
20 data.velocity.x = delta_x; | 21 data.velocity.x = delta_x; |
21 data.velocity.y = delta_y; | 22 data.velocity.y = delta_y; |
22 break; | 23 break; |
23 | 24 |
24 case ui::ET_GESTURE_TAP: | 25 case ui::ET_GESTURE_TAP: |
25 data.radius.x = delta_x; | 26 data.radius.x = delta_x; |
26 data.radius.y = delta_y; | 27 data.radius.y = delta_y; |
27 break; | 28 break; |
28 | 29 |
29 case ui::ET_GESTURE_LONG_PRESS: | 30 case ui::ET_GESTURE_LONG_PRESS: |
30 data.touch_id = static_cast<int>(delta_x); | 31 data.touch_id = static_cast<int>(delta_x); |
31 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press."; | 32 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press."; |
32 break; | 33 break; |
33 | 34 |
34 case ui::ET_GESTURE_BEGIN: | 35 case ui::ET_GESTURE_BEGIN: |
35 case ui::ET_GESTURE_END: | 36 case ui::ET_GESTURE_END: |
36 data.touch_points = static_cast<int>(delta_x); | 37 set_touch_points(static_cast<int>(delta_x)); |
37 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for begin/end"; | 38 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for begin/end"; |
38 break; | 39 break; |
39 | 40 |
40 case ui::ET_GESTURE_PINCH_UPDATE: | 41 case ui::ET_GESTURE_PINCH_UPDATE: |
41 data.scale = delta_x; | 42 data.scale = delta_x; |
42 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch"; | 43 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch"; |
43 break; | 44 break; |
44 | 45 |
45 case ui::ET_GESTURE_MULTIFINGER_SWIPE: | 46 case ui::ET_GESTURE_MULTIFINGER_SWIPE: |
46 data.swipe.left = delta_x < 0; | 47 data.swipe.left = delta_x < 0; |
47 data.swipe.right = delta_x > 0; | 48 data.swipe.right = delta_x > 0; |
48 data.swipe.up = delta_y < 0; | 49 data.swipe.up = delta_y < 0; |
49 data.swipe.down = delta_y > 0; | 50 data.swipe.down = delta_y > 0; |
50 break; | 51 break; |
51 | 52 |
52 default: | 53 default: |
53 data.generic.delta_x = delta_x; | 54 data.generic.delta_x = delta_x; |
54 data.generic.delta_y = delta_y; | 55 data.generic.delta_y = delta_y; |
55 if (delta_x != 0.f || delta_y != 0.f) { | 56 if (delta_x != 0.f || delta_y != 0.f) { |
56 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" | 57 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: (" |
57 << delta_x << "," << delta_y; | 58 << delta_x << "," << delta_y; |
58 } | 59 } |
59 break; | 60 break; |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 } // namespace ui | 64 } // namespace ui |
OLD | NEW |