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

Side by Side Diff: sky/specs/ui.md

Issue 771853002: Specs: flesh out the UI events (touches, mice, stylus...) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | 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 UI Events 1 UI Events
2 ========= 2 =========
3 3
4 Scope
5 -----
6
7 The following input devices are supported by sky:
8 - fingers on multitouch screens
9 - mice, including mouse wheels
10 - styluses on screens
11 - other devices that emulate mice (track pads, track balls)
12 - keyboards
13
14 The following input devices are not supported natively by sky, but can
15 be used by connecting directly to the mojo application servicing the
16 relevant device:
17 - joysticks
18 - track balls that move focus (or raw data from track balls)
19 - raw data from track pads (e.g. multitouch gestures)
20 - raw data from styluses that have their own absolute pads
21 - raw data from mice (e.g. to handle mouse capture in 3D games)
22
23 The following interactions are intended to be easy to handle:
24 - one finger starts panning, another finger is placed on the surface
25 (and ignored), the first finger is lifted, and the second finger
26 continues panning (without the scroll position jumping when the
27 first finger is lifted)
28 - right-clicking doesn't trigger buttons by default
29 - fingers after the first don't trigger buttons by default
30
31 Frameworks are responsible for converting pointer events described
32 below into widget-specific events such as the following:
33 - a click/tap/activation, as distinct from a short drag
34 - a context menu request (e.g. right-click, long-press)
35 - a drag (moving an item)
36 - a pan (scroll)
37 - a zoom/rotation (whether using two finger gestures, or one finger
38 with the double-tap-and-hold gesture)
39 - a double-tap autozoom
40
41 In particular, this means distinguishing whether a finger tap consists
42 of a tap, a drag, or a long-press; it also means distinguishing
43 whether a drag, once established as such, should be treated as a pan
44 or a drag, and deciding whether a secondary touch should begin a
45 zoom/rotation or not.
46
47
4 Pointer events 48 Pointer events
5 -------------- 49 --------------
6 50
7 Each touch or pointer is tracked individually. 51 Each touch or pointer is tracked individually.
8 52
9 New touches and pointers can appear and disappear over time. 53 New touches and pointers can appear and disappear over time.
10 54
11 When a new one enters the system, a 'pointer-added' event is fired at 55 When a new one enters the system, a 'pointer-added' event is fired at
12 the application's document. 56 the application's document.
13 57
14 When it is removed, a 'pointer-removed' event is fired at the 58 When it is removed, a 'pointer-removed' event is fired at the
15 application's document. 59 application's document.
16 60
17 When one switches from "up" to "down", the position of the tap is hit 61 When one switches from "up" to "down", the position of the tap is hit
18 tested and a 'pointer-down' event is fired at the target element under 62 tested and a 'pointer-down' event is fired at the target element under
19 the cursor, if any, or the document otherwise. 63 the cursor, if any, or the document otherwise. The return value, if
64 it's a node, is used as the target of future move and up events until
65 this touch goes up. If there is no return value, the target continues
66 to be the application's document.
67
68 A pointer that is "down" is captured -- all events for that pointer
69 will be routed to the chosen target until the pointer goes up,
70 regardless of whether it's in that target's visible area.
20 71
21 When one moves, if it is "up" then a 'pointer-moved' event is fired at 72 When one moves, if it is "up" then a 'pointer-moved' event is fired at
22 the application's document, otherwise if it is "down" then the event 73 the application's document, otherwise if it is "down" then the event
23 is fired at the element or document that was selected for the 74 is fired at the element or document that was selected for the
24 'pointer-down' event. 75 'pointer-down' event.
25 76
26 When one switches from "down" to "up", a 'pointer-up' event is fired 77 When one switches from "down" to "up", a 'pointer-up' event is fired
27 at the element or document that was selected for the 'pointer-down' 78 at the element or document that was selected for the 'pointer-down'
28 event. 79 event.
29 80
81 When there are no "down" pointers and one switches to "down", if
82 either there are no buttons (touch) or only the primary button is
83 active (mouse, stylus) and this is not an inverted stylus, then this
84 becomes the "primary" pointer. The pointer remains the primary pointer
85 until the corresponding pointer-up event (even if the buttons change).
86 At the time of a pointer-up event, if there is another pointer that is
87 already down and is of the same kind, and that has either no buttons
88 or only its primary button active, then that becomes the new primary
89 pointer.
90
30 91
31 These events all bubble and their data is an object with the following 92 These events all bubble and their data is an object with the following
32 fields: 93 fields:
33 94
34 pointer: an integer assigned to this touch or pointer when it 95 pointer: an integer assigned to this touch or pointer when it
35 enters the system, never reused, increasing monotonically 96 enters the system, never reused, increasing
36 every time a new value is assigned, starting from 1 (if 97 monotonically every time a new value is assigned,
37 the system gets a new tap every microsecond, this will 98 starting from 1 (if the system gets a new tap every
38 cause a problem after 285 years) 99 microsecond, this will cause a problem after 285 years)
39
40 x: x-position relative to the top-left corner of the display,
41 in global layout coordinates
42
43 y: x-position relative to the top-left corner of the display,
44 in global layout coordinates
45 100
46 buttons: a bitfield of the buttons pressed, where 1 is the primary 101 kind: one of 'touch', 'mouse', 'stylus', 'inverted-stylus'
47 button, 2 is the secondary, and subsequent numbers refer
48 to any other buttons
49 102
50 TODO(ianh): add other fields for touches (radius/pressure, angle) 103 x: x-position relative to the top-left corner of the
104 surface of the node on which the event was fired
51 105
52 TODO(ianh): should we use a different way to express buttons? e.g. 106 y: y-position relative to the top-left corner of the
53 create a new touch for the secondary button when it goes down, 107 surface of the node on which the event was fired
54 removing the touch when it goes back up?
55 108
56 TODO(ianh): find a way to avoid the trap everyone always falls into of 109 buttons: a bitfield of the buttons pressed, from the following
57 treating all the buttons as equivalent to a touch (e.g. right-clicking 110 list:
58 a button shouldn't trigger the button). For example, maybe we should 111 1: primary mouse button (not available on stylus)
59 remove 'buttons' and use different event names for the up/down state 112 2: secondary mouse button, primary stylus button
60 changes of non-primary buttons of pointers, like 'pointer-down-2' for 113 3: middle mouse button, secondary stylus button
61 the secondary button, 'pointer-down-3' for the middle mouse button, 114 4: back button
62 and so on. 115 5: forward button
116 additional buttons can be represented by numbers
117 greater than six:
118 n: (n-2)th mouse button, ignoring any buttons that
119 are explicitly back or forward buttons
120 (n-4)th stylus button, again ignoring any
121 explictly back or forward buttons
122
123 down: true if the pointer is down (in pointer-down event or
124 subsequent pointer-move events); false otherwise (in
125 pointer-added, pointer-up, and pointer-removed events,
126 and in pointer-move events that aren't between
127 pointer-down and pointer-up events)
128
129 primary: true if this is a primary pointer/touch (see above)
130
131 obscured: true if the system was rendering another view on top of
132 the sky application at the time of the event (this is
133 intended to enable click-jacking protections)
134
135
136 When primary is true, the following fields are available:
137
138 dx: if primary, then this is the delta from the x-position
139 at the time that the pointer became primary.
140
141 dy: if primary, then this is the delta from the x-position
142 at the time that the pointer became primary.
143
144
145 When down is true:
146
147 pressure: the pressure of the touch as a number ranging from 0.0,
148 indicating a touch with no discernible pressure, to
149 1.0, indicating a touch with "normal" pressure, and
150 possibly beyond, indicating a stronger touch; for
151 devices that do not detect pressure (e.g. mice),
152 returns 1.0
153
154 pressure-min: the minimum value that pressure can return for this
155 pointer
156
157 pressure-max: the maximum value that pressure can return for this
158 pointer
159
160
161 When kind is 'touch', 'stylus', or 'stylus-inverted':
162
163 distance: distance of detected object from surface (e.g. distance
164 of stylus or finger from screen), if supported and down
165 is not true, otherwise 0.0.
166
167 distance-min: the minimum value that distance can return for this
168 pointer (always 0.0)
169
170 distance-max: the maximum value that distance can return for this
171 pointer (0.0 if not supported)
172
173
174 When kind is 'touch', 'stylus', or 'stylus-inverted' and down is true:
175
176 radius-major: the radius of the contact ellipse along the major axis,
177 in pixels
178
179 radius-minor: the radius of the contact ellipse along the major axis,
180 in pixels
181
182 radius-min: the minimum value that could be reported for
183 radius-major or radius-minor for this pointer
184
185 radius-max: the maximum value that could be reported for
186 radius-major or radius-minor for this pointer
187
188
189 When kind is 'touch' and down is true:
190
191 orientation: the angle of the contact ellipse, in radians in the range
192 -pi/2 < orientation <= pi/2
193 ...giving the angle of the major axis of the ellipse with
194 the y-axis (negative angles indicating an orientation
195 along the top-left / bottom-right diagonal, positive
196 angles indicating an orientation along the top-right /
197 bottom-left diagonal, and zero indicating an orientation
198 parallel with the y-axis)
199
200
201 When kind is 'stylus' or 'stylus-inverted':
202
203 orientation: the angle of the stylus, in radians in the range
204 -pi < orientation <= pi
205 ...giving the angle of the axis of the stylus projected
206 onto the screen, relative to the positive y-axis of the
207 screen (thus 0 indicates the stylus, if projected onto
208 the screen, would go from the contact point vertically
209 up in the positive y-axis direction, pi would indicate
210 that the stylus would go down in the negative y-axis
211 direction; pi/4 would indicate that the stylus goes up
212 and to the right, -pi/2 would indicate that the stylus
213 goes to the left, etc)
214
215 tilt: the angle of the stylus, in radians in the range
216 0 <= tilt <= pi/2
217
218 ...giving the angle of the axis of the stylus, relative
219 to the axis perpendicular to the screen (thus 0
220 indicates the stylus is orthogonal to the plane of the
221 screen, while pi/2 indicates that the stylus is flat on
222 the screen)
63 223
64 224
65 Wheel events 225 Wheel events
66 ------------ 226 ------------
67 227
68 When a wheel input device is turned, a 'wheel' event that bubbles is 228 When a wheel input device is turned, a 'wheel' event that bubbles is
69 fired at the application's document, with the following fields: 229 fired at the application's document, with the following fields:
70 230
71 wheel: an integer assigned to this wheel by the system. The same 231 wheel: an integer assigned to this wheel by the system. The same
72 wheel on the same system must always be given the same ID. 232 wheel on the same system must always be given the same ID.
(...skipping 11 matching lines...) Expand all
84 244
85 pointer: the integer assigned to the pointer in its 'pointer-add' 245 pointer: the integer assigned to the pointer in its 'pointer-add'
86 event (see above). 246 event (see above).
87 247
88 x: x-position relative to the top-left corner of the display, 248 x: x-position relative to the top-left corner of the display,
89 in global layout coordinates 249 in global layout coordinates
90 250
91 y: x-position relative to the top-left corner of the display, 251 y: x-position relative to the top-left corner of the display,
92 in global layout coordinates 252 in global layout coordinates
93 253
254 Note: The only wheels that are supported are mouse wheels and physical
255 dials. Track balls are not reported as mouse wheels.
256
94 257
95 Text input events 258 Text input events
96 ----------------- 259 -----------------
97 260
98 TODO(ianh): keyboard events 261 TODO(ianh): keyboard events
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698