OLD | NEW |
1 Gestures | 1 Gestures |
2 ======== | 2 ======== |
3 | 3 |
4 ```dart | 4 ```dart |
5 SKY MODULE | 5 SKY MODULE |
6 <!-- part of dart:sky --> | 6 <!-- part of dart:sky --> |
7 | 7 |
8 <script> | 8 <script> |
9 abstract class GestureEvent extends Event { | 9 abstract class GestureEvent extends Event { |
10 Gesture _gesture; | 10 Gesture _gesture; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return new PointerState(gestures: source.gestures, chosen: source.chosen); | 163 return new PointerState(gestures: source.gestures, chosen: source.chosen); |
164 } | 164 } |
165 @nonnull List<@nonnull Gesture> gestures; | 165 @nonnull List<@nonnull Gesture> gestures; |
166 @nonnull bool chosen = false; | 166 @nonnull bool chosen = false; |
167 } | 167 } |
168 | 168 |
169 class GestureManager { | 169 class GestureManager { |
170 GestureManager(this.target) { | 170 GestureManager(this.target) { |
171 target.events.where((event) => event is PointerDownEvent).listen(_handler); | 171 target.events.where((event) => event is PointerDownEvent).listen(_handler); |
172 } | 172 } |
173 final @nonnull EventTarget target; // usually the ApplicationDocument object | 173 final @nonnull EventTarget target; // usually the ApplicationRoot object |
174 | 174 |
175 Map<@nonnull int, @nonnull PointerState> _pointers = new SplayTreeMap<int, Poi
nterState>(); | 175 Map<@nonnull int, @nonnull PointerState> _pointers = new SplayTreeMap<int, Poi
nterState>(); |
176 | 176 |
177 void addGesture(@nonnull PointerEvent event, @nonnull Gesture gesture) { | 177 void addGesture(@nonnull PointerEvent event, @nonnull Gesture gesture) { |
178 assert(gesture.active); | 178 assert(gesture.active); |
179 var pointer = event.pointer; | 179 var pointer = event.pointer; |
180 if (_pointers.containsKey(pointer)) { | 180 if (_pointers.containsKey(pointer)) { |
181 assert(!_pointers[pointer].gestures.contains(gesture)); | 181 assert(!_pointers[pointer].gestures.contains(gesture)); |
182 if (_pointers[pointer].chosen) | 182 if (_pointers[pointer].chosen) |
183 cancelGesture(gesture); | 183 cancelGesture(gesture); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // fling-end: cancel(), or after fling or fling-cancel (prechoose) | 421 // fling-end: cancel(), or after fling or fling-cancel (prechoose) |
422 } | 422 } |
423 | 423 |
424 class FlingLeftGesture : FlingGesture { } | 424 class FlingLeftGesture : FlingGesture { } |
425 class FlingRightGesture : FlingGesture { } | 425 class FlingRightGesture : FlingGesture { } |
426 class FlingUpGesture : FlingGesture { } | 426 class FlingUpGesture : FlingGesture { } |
427 class FlingDownGesture : FlingGesture { } | 427 class FlingDownGesture : FlingGesture { } |
428 | 428 |
429 </script> | 429 </script> |
430 ``` | 430 ``` |
OLD | NEW |