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
3 // found in the LICENSE file.
5 #include "ui/events/gestures/gesture_types.h"
9 GestureEventDetails::GestureEventDetails(ui::EventType type,
15 case ui::ET_GESTURE_SCROLL_UPDATE:
16 data.scroll_update.x = delta_x;
17 data.scroll_update.y = delta_y;
18 data.scroll_update.x_ordinal = delta_x;
19 data.scroll_update.y_ordinal = delta_y;
22 case ui::ET_SCROLL_FLING_START:
23 data.fling_velocity.x = delta_x;
24 data.fling_velocity.y = delta_y;
25 data.fling_velocity.x_ordinal = delta_x;
26 data.fling_velocity.y_ordinal = delta_y;
29 case ui::ET_GESTURE_LONG_PRESS:
30 data.touch_id = static_cast<int>(delta_x);
31 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press.";
34 case ui::ET_GESTURE_TWO_FINGER_TAP:
35 data.first_finger_enclosing_rectangle.width = delta_x;
36 data.first_finger_enclosing_rectangle.height = delta_y;
39 case ui::ET_GESTURE_PINCH_UPDATE:
41 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
44 case ui::ET_GESTURE_MULTIFINGER_SWIPE:
45 data.swipe.left = delta_x < 0;
46 data.swipe.right = delta_x > 0;
47 data.swipe.up = delta_y < 0;
48 data.swipe.down = delta_y > 0;
51 case ui::ET_GESTURE_TAP:
52 data.tap_count = static_cast<int>(delta_x);
53 CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for tap.";
57 if (delta_x != 0.f || delta_y != 0.f) {
58 DLOG(WARNING) << "A gesture event (" << type << ") had unknown data: ("
59 << delta_x << "," << delta_y;
65 GestureEventDetails::GestureEventDetails(ui::EventType type,
68 float delta_x_ordinal,
69 float delta_y_ordinal)
72 CHECK(type == ui::ET_GESTURE_SCROLL_UPDATE ||
73 type == ui::ET_SCROLL_FLING_START);
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;
82 case ui::ET_SCROLL_FLING_START:
83 data.fling_velocity.x = delta_x;
84 data.fling_velocity.y = delta_y;
85 data.fling_velocity.x_ordinal = delta_x_ordinal;
86 data.fling_velocity.y_ordinal = delta_y_ordinal;
94 void GestureEventDetails::SetScrollVelocity(float velocity_x,
96 float velocity_x_ordinal,
97 float velocity_y_ordinal) {
98 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
99 data.scroll_update.velocity_x = velocity_x;
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;