Ian Hickson f162555648 PointerInput refactor
Instead of PointerInputEvent having a "type" field, we now have a
different class for each pointer type.

This has ripple effects throughout the system.

I also did code cleanup in affected files while I was there.
2015-12-04 22:42:38 -08:00

60 lines
1.4 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/gestures.dart';
export 'dart:ui' show Point;
class TestPointer {
TestPointer([ this.pointer = 1 ]);
int pointer;
bool isDown = false;
Point location;
PointerDownEvent down(Point newLocation, { Duration timeStamp: const Duration() }) {
assert(!isDown);
isDown = true;
location = newLocation;
return new PointerDownEvent(
timeStamp: timeStamp,
pointer: pointer,
position: location
);
}
PointerMoveEvent move(Point newLocation, { Duration timeStamp: const Duration() }) {
assert(isDown);
Offset delta = newLocation - location;
location = newLocation;
return new PointerMoveEvent(
timeStamp: timeStamp,
pointer: pointer,
position: newLocation,
delta: delta
);
}
PointerUpEvent up({ Duration timeStamp: const Duration() }) {
assert(isDown);
isDown = false;
return new PointerUpEvent(
timeStamp: timeStamp,
pointer: pointer,
position: location
);
}
PointerCancelEvent cancel({ Duration timeStamp: const Duration() }) {
assert(isDown);
isDown = false;
return new PointerCancelEvent(
timeStamp: timeStamp,
pointer: pointer,
position: location
);
}
}