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

Side by Side Diff: ui/android/view_client.h

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: comments Created 3 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef UI_ANDROID_VIEW_CLIENT_H_
6 #define UI_ANDROID_VIEW_CLIENT_H_
7
8 #include <jni.h>
9
10 #include "ui/android/ui_android_export.h"
11
12 namespace ui {
13
14 // Container of motion event data. Used when traversing views along their
15 // hierarchy. Actual motion event object will be constructed right before
16 // it is used in the |ViewClient| implementation to avoid creating multiple
17 // |MotionEventAndroid| instances.
18 struct MotionEventData {
boliu 2017/02/28 22:44:54 so why do we need a new struct if MotionEventAndro
Jinsuk Kim 2017/03/02 04:08:35 Because - MEA creates and assigns a unique id for
aelias_OOO_until_Jul13 2017/03/02 04:17:42 I tend to agree with Bo.
aelias_OOO_until_Jul13 2017/03/02 04:21:46 In the long run, C++ touch handles could be child
Jinsuk Kim 2017/03/03 06:29:21 Thanks for the input. Done. Added another ctor to
Jinsuk Kim 2017/03/03 06:29:21 Acknowledged. Left a TODO in rwhva about removing
19 MotionEventData(float dip_scale,
20 jobject jevent,
21 long time_ms,
22 int android_action,
23 int pointer_count,
24 int history_size,
25 int action_index,
26 float pos_x0,
27 float pos_y0,
28 float pos_x1,
29 float pos_y1,
30 int pointer_id_0,
31 int pointer_id_1,
32 float touch_major_0,
33 float touch_major_1,
34 float touch_minor_0,
35 float touch_minor_1,
36 float orientation_0,
37 float orientation_1,
38 float tilt_0,
39 float tilt_1,
40 float raw_pos_x,
41 float raw_pos_y,
42 float pressure,
43 int android_tool_type_0,
44 int android_tool_type_1,
45 int android_action_button,
46 int android_button_state,
47 int android_meta_state,
48 bool is_touch_handle_event);
49
50 MotionEventData(const MotionEventData& other);
51
52 // Returns a new |MotionEventData| object whose position is offset
53 // by a given delta.
54 MotionEventData Offset(float delta_x, float delta_y) const;
55
56 static MotionEventData ForTouch(float dip_scale,
57 jobject jevent,
58 long time,
59 int action,
60 int pointer_count,
61 int history_size,
62 int action_index,
63 float pos_x0,
64 float pos_y0,
65 float pos_x1,
66 float pos_y1,
67 int pointer_id_0,
68 int pointer_id_1,
69 float touch_major_0,
70 float touch_major_1,
71 float touch_minor_0,
72 float touch_minor_1,
73 float orientation_0,
74 float orientation_1,
75 float tilt_0,
76 float tilt_1,
77 float raw_pos_x,
78 float raw_pos_y,
79 int tool_type_0,
80 int tool_type_1,
81 int button_state,
82 int meta_state,
83 bool is_touch_handle_event);
84
85 static MotionEventData ForMouse(float dip_scale,
86 long time_ms,
87 int android_action,
88 float pos_x,
89 float pos_y,
90 int pointer_id,
91 float orientation,
92 float pressure,
93 float tilt,
94 int android_tool_type,
95 int android_action_button,
96 int android_button_state,
97 int android_meta_state);
98
99 float GetX() const { return pos_x_0 / dip_scale; }
100 float GetY() const { return pos_y_0 / dip_scale; }
101
102 const float dip_scale;
103 const jobject jevent;
104 const long time_ms;
105 const int android_action;
106 const int pointer_count;
107 const int history_size;
108 const int action_index;
109
110 const float pos_x_0; // in pixel unit
111 const float pos_y_0;
112 const float pos_x_1;
113 const float pos_y_1;
114
115 const int pointer_id_0;
116 const int pointer_id_1;
117 const float touch_major_0;
118 const float touch_major_1;
119 const float touch_minor_0;
120 const float touch_minor_1;
121 const float orientation_0;
122 const float orientation_1;
123 const float tilt_0;
124 const float tilt_1;
125 const float raw_pos_x;
126 const float raw_pos_y;
127 const float pressure;
128 const int android_tool_type_0;
129 const int android_tool_type_1;
130 const int android_action_button;
131 const int android_button_state;
132 const int android_meta_state;
133 const bool is_touch_handle_event;
134 };
135
136 // Client interface used to forward events from Java to native views.
137 // Calls are dispatched to its children along the hierarchy of ViewAndroid.
138 // Use bool return type to stop propagating the call i.e. overriden method
139 // should return true to indicate that the event was handled and stop
140 // the processing.
141 class UI_ANDROID_EXPORT ViewClient {
142 public:
143 virtual bool OnTouchEvent(const MotionEventData& m);
144 virtual bool OnMouseEvent(const MotionEventData& m);
145 };
146
147 } // namespace ui
148
149 #endif // UI_ANDROID_VIEW_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698