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

Side by Side Diff: samples/swarm/swarm_ui_lib/touch/TouchHandler.dart

Issue 12493003: Exposing Point & Rect types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Sync to ToT Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of touch; 5 part of touch;
6 6
7 /** 7 /**
8 * Touch Handler. Class that handles all touch events and 8 * Touch Handler. Class that handles all touch events and
9 * uses them to interpret higher level gestures and behaviors. TouchEvent is a 9 * uses them to interpret higher level gestures and behaviors. TouchEvent is a
10 * built in mobile safari type: 10 * built in mobile safari type:
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 /** 232 /**
233 * Touch end handler. 233 * Touch end handler.
234 */ 234 */
235 void _onEnd(int timeStamp, [TouchEvent e = null]) { 235 void _onEnd(int timeStamp, [TouchEvent e = null]) {
236 _touching = false; 236 _touching = false;
237 _touchable.onTouchEnd(); 237 _touchable.onTouchEnd();
238 if (!_tracking || _draggable == null) { 238 if (!_tracking || _draggable == null) {
239 return; 239 return;
240 } 240 }
241 Touch touch = _getLastTouch(); 241 Touch touch = _getLastTouch();
242 int clientX = touch.clientX; 242 int clientX = touch.client.x;
243 int clientY = touch.clientY; 243 int clientY = touch.client.y;
244 if (_dragging) { 244 if (_dragging) {
245 _endTime = timeStamp; 245 _endTime = timeStamp;
246 _endTouchX = clientX; 246 _endTouchX = clientX;
247 _endTouchY = clientY; 247 _endTouchY = clientY;
248 _recentTouchesX = _removeOldTouches(_recentTouchesX, timeStamp); 248 _recentTouchesX = _removeOldTouches(_recentTouchesX, timeStamp);
249 _recentTouchesY = _removeOldTouches(_recentTouchesY, timeStamp); 249 _recentTouchesY = _removeOldTouches(_recentTouchesY, timeStamp);
250 _draggable.onDragEnd(); 250 _draggable.onDragEnd();
251 if (e != null) { 251 if (e != null) {
252 e.preventDefault(); 252 e.preventDefault();
253 } 253 }
254 ClickBuster.preventGhostClick(_startTouchX, _startTouchY); 254 ClickBuster.preventGhostClick(_startTouchX, _startTouchY);
255 } 255 }
256 _endTracking(); 256 _endTracking();
257 } 257 }
258 258
259 /** 259 /**
260 * Touch move handler. 260 * Touch move handler.
261 */ 261 */
262 void _onMove(TouchEvent e) { 262 void _onMove(TouchEvent e) {
263 if (!_tracking || _draggable == null) { 263 if (!_tracking || _draggable == null) {
264 return; 264 return;
265 } 265 }
266 final touch = e.touches[0]; 266 final touch = e.touches[0];
267 int clientX = touch.clientX; 267 int clientX = touch.client.x;
268 int clientY = touch.clientY; 268 int clientY = touch.client.y;
269 int moveX = _lastTouchX - clientX; 269 int moveX = _lastTouchX - clientX;
270 int moveY = _lastTouchY - clientY; 270 int moveY = _lastTouchY - clientY;
271 _totalMoveX += moveX.abs(); 271 _totalMoveX += moveX.abs();
272 _totalMoveY += moveY.abs(); 272 _totalMoveY += moveY.abs();
273 _lastTouchX = clientX; 273 _lastTouchX = clientX;
274 _lastTouchY = clientY; 274 _lastTouchY = clientY;
275 if (!_dragging && 275 if (!_dragging &&
276 ((_totalMoveY > _MIN_TRACKING_FOR_DRAG && _draggable.verticalEnabled) || 276 ((_totalMoveY > _MIN_TRACKING_FOR_DRAG && _draggable.verticalEnabled) ||
277 (_totalMoveX > _MIN_TRACKING_FOR_DRAG && 277 (_totalMoveX > _MIN_TRACKING_FOR_DRAG &&
278 _draggable.horizontalEnabled))) { 278 _draggable.horizontalEnabled))) {
(...skipping 30 matching lines...) Expand all
309 */ 309 */
310 void _onStart(TouchEvent e) { 310 void _onStart(TouchEvent e) {
311 if (_touching) { 311 if (_touching) {
312 return; 312 return;
313 } 313 }
314 _touching = true; 314 _touching = true;
315 if (!_touchable.onTouchStart(e) || _draggable == null) { 315 if (!_touchable.onTouchStart(e) || _draggable == null) {
316 return; 316 return;
317 } 317 }
318 final touch = e.touches[0]; 318 final touch = e.touches[0];
319 _startTouchX = _lastTouchX = touch.clientX; 319 _startTouchX = _lastTouchX = touch.client.x;
320 _startTouchY = _lastTouchY = touch.clientY; 320 _startTouchY = _lastTouchY = touch.client.y;
321 _startTime = e.timeStamp; 321 _startTime = e.timeStamp;
322 // TODO(jacobr): why don't we just clear the lists? 322 // TODO(jacobr): why don't we just clear the lists?
323 _recentTouchesX = new List<int>(); 323 _recentTouchesX = new List<int>();
324 _recentTouchesY = new List<int>(); 324 _recentTouchesY = new List<int>();
325 _recentTouchesX.add(touch.clientX); 325 _recentTouchesX.add(touch.client.x);
326 _recentTouchesX.add(e.timeStamp); 326 _recentTouchesX.add(e.timeStamp);
327 _recentTouchesY.add(touch.clientY); 327 _recentTouchesY.add(touch.client.y);
328 _recentTouchesY.add(e.timeStamp); 328 _recentTouchesY.add(e.timeStamp);
329 _lastEvent = e; 329 _lastEvent = e;
330 _beginTracking(); 330 _beginTracking();
331 } 331 }
332 332
333 /** 333 /**
334 * Filters the provided recent touches list to remove all touches older than 334 * Filters the provided recent touches list to remove all touches older than
335 * the max tracking time or the 5th most recent touch. 335 * the max tracking time or the 5th most recent touch.
336 * [recentTouches] specifies a list of tuples where the first item is the x 336 * [recentTouches] specifies a list of tuples where the first item is the x
337 * or y component of the recent touch and the second item is the touch time 337 * or y component of the recent touch and the second item is the touch time
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 /** 385 /**
386 * Call this method to enable drag behavior on a draggable delegate. 386 * Call this method to enable drag behavior on a draggable delegate.
387 * The [draggable] object can be the same as the [_touchable] object, they are 387 * The [draggable] object can be the same as the [_touchable] object, they are
388 * assigned to different members to allow for strong typing with interfaces. 388 * assigned to different members to allow for strong typing with interfaces.
389 */ 389 */
390 void setDraggable(Draggable draggable) { 390 void setDraggable(Draggable draggable) {
391 _draggable = draggable; 391 _draggable = draggable;
392 } 392 }
393 } 393 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/touch/Scrollbar.dart ('k') | samples/swarm/swarm_ui_lib/touch/TouchUtil.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698