Move Point to Offset (#9277)

* Manually fix every use of Point.x and Point.y

Some of these were moved to dx/dy, but not all.

* Manually convert uses of the old gradient API

* Remove old reference to Point.

* Mechanical changes

I applied the following at the root of the Flutter repository:

git ls-files -z | xargs -0 sed -i 's/\bPoint[.]origin\b/Offset.zero/g'
git ls-files -z | xargs -0 sed -i 's/\bPoint[.]lerp\b/Offset.lerp/g'
git ls-files -z | xargs -0 sed -i 's/\bnew Point\b/new Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bconst Point\b/const Offset/g'
git ls-files -z | xargs -0 sed -i 's/\bstatic Point /static Offset /g'
git ls-files -z | xargs -0 sed -i 's/\bfinal Point /final Offset /g'
git ls-files -z | xargs -0 sed -i 's/^\( *\)Point /\1Offset /g'
git ls-files -z | xargs -0 sed -i 's/ui[.]Point\b/ui.Offset/g'
git ls-files -z | xargs -0 sed -i 's/(Point\b/(Offset/g'
git ls-files -z | xargs -0 sed -i 's/\([[{,]\) Point\b/\1 Offset/g'
git ls-files -z | xargs -0 sed -i 's/@required Point\b/@required Offset/g'
git ls-files -z | xargs -0 sed -i 's/<Point>/<Offset>/g'
git ls-files -z | xargs -0 sed -i 's/[.]toOffset()//g'
git ls-files -z | xargs -0 sed -i 's/[.]toPoint()//g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point, /show /g'
git ls-files -z | xargs -0 sed -i 's/\bshow Point;/show Offset;/g'

* Mechanical changes - dartdocs

I applied the following at the root of the Flutter repository:

git ls-files -z | xargs -0 sed -i 's/\ba \[Point\]/an [Offset]/g'
git ls-files -z | xargs -0 sed -i 's/\[Point\]/[Offset]/g'

* Further improvements and a test

* Fix minor errors from rebasing...

* Roll engine
This commit is contained in:
Ian Hickson 2017-04-12 15:06:12 -07:00 committed by GitHub
parent 7b0b5c5760
commit bf017b79b3
182 changed files with 2374 additions and 2389 deletions

View file

@ -1 +1 @@
059ab3a47165d98cb1d7ac5e2a2e4b50abf39832
bcc8779cb88c0474f94277efa0ab7c83f14a0a9b

View file

@ -53,12 +53,12 @@ Future<Null> main() async {
while (wallClockWatch.elapsed < kBenchmarkTime) {
cpuWatch.reset();
if (drawerIsOpen) {
await tester.tapAt(const Point(780.0, 250.0)); // Close drawer
await tester.tapAt(const Offset(780.0, 250.0)); // Close drawer
await tester.pump();
totalCloseIterationCount += 1;
totalCloseFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
} else {
await tester.tapAt(const Point(20.0, 50.0)); // Open drawer
await tester.tapAt(const Offset(20.0, 50.0)); // Open drawer
await tester.pump();
totalOpenIterationCount += 1;
totalOpenFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;

View file

@ -31,7 +31,7 @@ Future<Null> main() async {
stocks.main();
await tester.pump(); // Start startup animation
await tester.pump(const Duration(seconds: 1)); // Complete startup animation
await tester.tapAt(const Point(20.0, 40.0)); // Open drawer
await tester.tapAt(const Offset(20.0, 40.0)); // Open drawer
await tester.pump(); // Start drawer animation
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation

View file

@ -30,7 +30,7 @@ Future<Null> main() async {
stocks.main();
await tester.pump(); // Start startup animation
await tester.pump(const Duration(seconds: 1)); // Complete startup animation
await tester.tapAt(const Point(20.0, 40.0)); // Open drawer
await tester.tapAt(const Offset(20.0, 40.0)); // Open drawer
await tester.pump(); // Start drawer animation
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation

View file

@ -163,7 +163,7 @@ class DashOutlineCirclePainter extends CustomPainter {
..style = PaintingStyle.stroke
..strokeWidth = radius / 10.0;
final Path path = new Path();
final Rect box = Point.origin & size;
final Rect box = Offset.zero & size;
for (double theta = 0.0; theta < math.PI * 2.0; theta += deltaTheta)
path.addArc(box, theta + startOffset, segmentArc);
canvas.drawPath(path, paint);

View file

@ -54,7 +54,7 @@ class _PointDemoPainter extends CustomPainter {
final MaterialPointArcTween arc;
Animation<double> _repaint;
void drawPoint(Canvas canvas, Point point, Color color) {
void drawPoint(Canvas canvas, Offset point, Color color) {
final Paint paint = new Paint()
..color = color.withOpacity(0.25)
..style = PaintingStyle.fill;
@ -93,7 +93,7 @@ class _PointDemoPainter extends CustomPainter {
}
@override
bool hitTest(Point position) {
bool hitTest(Offset position) {
return (arc.begin - position).distanceSquared < _kTargetSlop
|| (arc.end - position).distanceSquared < _kTargetSlop;
}
@ -117,8 +117,8 @@ class _PointDemoState extends State<_PointDemo> {
CurvedAnimation _animation;
_DragTarget _dragTarget;
Size _screenSize;
Point _begin;
Point _end;
Offset _begin;
Offset _end;
@override
void initState() {
@ -132,7 +132,7 @@ class _PointDemoState extends State<_PointDemo> {
super.dispose();
}
Drag _handleOnStart(Point position) {
Drag _handleOnStart(Offset position) {
// TODO(hansmuller): allow the user to drag both points at the same time.
if (_dragTarget != null)
return new _IgnoreDrag();
@ -181,8 +181,8 @@ class _PointDemoState extends State<_PointDemo> {
final Size screenSize = MediaQuery.of(context).size;
if (_screenSize == null || _screenSize != screenSize) {
_screenSize = screenSize;
_begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2);
_end = new Point(screenSize.width * 0.1, screenSize.height * 0.4);
_begin = new Offset(screenSize.width * 0.5, screenSize.height * 0.2);
_end = new Offset(screenSize.width * 0.1, screenSize.height * 0.4);
}
final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
@ -229,7 +229,7 @@ class _RectangleDemoPainter extends CustomPainter {
final MaterialRectArcTween arc;
Animation<double> _repaint;
void drawPoint(Canvas canvas, Point p, Color color) {
void drawPoint(Canvas canvas, Offset p, Color color) {
final Paint paint = new Paint()
..color = color.withOpacity(0.25)
..style = PaintingStyle.fill;
@ -258,7 +258,7 @@ class _RectangleDemoPainter extends CustomPainter {
}
@override
bool hitTest(Point position) {
bool hitTest(Offset position) {
return (arc.begin.center - position).distanceSquared < _kTargetSlop
|| (arc.end.center - position).distanceSquared < _kTargetSlop;
}
@ -297,7 +297,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
super.dispose();
}
Drag _handleOnStart(Point position) {
Drag _handleOnStart(Offset position) {
// TODO(hansmuller): allow the user to drag both points at the same time.
if (_dragTarget != null)
return new _IgnoreDrag();

View file

@ -33,19 +33,19 @@ class _MarkerPainter extends CustomPainter {
void paint(Canvas canvas, _) {
final Paint paint = new Paint()..color = const Color(0x8000FF00);
final double r = size / 2.0;
canvas.drawCircle(new Point(r, r), r, paint);
canvas.drawCircle(new Offset(r, r), r, paint);
paint
..color = const Color(0xFFFFFFFF)
..style = PaintingStyle.stroke
..strokeWidth = 1.0;
if (type == MarkerType.topLeft) {
canvas.drawLine(new Point(r, r), new Point(r + r - 1.0, r), paint);
canvas.drawLine(new Point(r, r), new Point(r, r + r - 1.0), paint);
canvas.drawLine(new Offset(r, r), new Offset(r + r - 1.0, r), paint);
canvas.drawLine(new Offset(r, r), new Offset(r, r + r - 1.0), paint);
}
if (type == MarkerType.bottomRight) {
canvas.drawLine(new Point(r, r), new Point(1.0, r), paint);
canvas.drawLine(new Point(r, r), new Point(r, 1.0), paint);
canvas.drawLine(new Offset(r, r), new Offset(1.0, r), paint);
canvas.drawLine(new Offset(r, r), new Offset(r, 1.0), paint);
}
}
@ -64,15 +64,15 @@ class Marker extends StatelessWidget {
this.size: 40.0,
}) : super(key: key);
final Point position;
final Offset position;
final double size;
final MarkerType type;
@override
Widget build(BuildContext context) {
return new Positioned(
left: position.x - size / 2.0,
top: position.y - size / 2.0,
left: position.dx - size / 2.0,
top: position.dy - size / 2.0,
width: size,
height: size,
child: new IgnorePointer(
@ -92,7 +92,7 @@ class OverlayGeometryApp extends StatefulWidget {
OverlayGeometryAppState createState() => new OverlayGeometryAppState();
}
typedef void CardTapCallback(GlobalKey targetKey, Point globalPosition);
typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition);
class CardBuilder extends SliverChildDelegate {
CardBuilder({ this.cardModels, this.onTapUp });
@ -134,7 +134,7 @@ class CardBuilder extends SliverChildDelegate {
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
List<CardModel> cardModels;
Map<MarkerType, Point> markers = <MarkerType, Point>{};
Map<MarkerType, Offset> markers = <MarkerType, Offset>{};
double markersScrollOffset = 0.0;
@override
@ -157,21 +157,21 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
final double dy = markersScrollOffset - notification.metrics.extentBefore;
markersScrollOffset = notification.metrics.extentBefore;
for (MarkerType type in markers.keys) {
final Point oldPosition = markers[type];
markers[type] = new Point(oldPosition.x, oldPosition.y + dy);
final Offset oldPosition = markers[type];
markers[type] = oldPosition.translate(0.0, dy);
}
});
}
return false;
}
void handleTapUp(GlobalKey target, Point globalPosition) {
void handleTapUp(GlobalKey target, Offset globalPosition) {
setState(() {
markers[MarkerType.touch] = globalPosition;
final RenderBox box = target.currentContext.findRenderObject();
markers[MarkerType.topLeft] = box.localToGlobal(const Point(0.0, 0.0));
markers[MarkerType.topLeft] = box.localToGlobal(const Offset(0.0, 0.0));
final Size size = box.size;
markers[MarkerType.bottomRight] = box.localToGlobal(new Point(size.width, size.height));
markers[MarkerType.bottomRight] = box.localToGlobal(new Offset(size.width, size.height));
final ScrollableState scrollable = Scrollable.of(target.currentContext);
markersScrollOffset = scrollable.position.pixels;
});

View file

@ -178,8 +178,8 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
return Rect.lerp(begin, end, tColumnToRow);
}
Point _interpolatePoint(Point begin, Point end) {
return Point.lerp(begin, end, tColumnToRow);
Offset _interpolatePoint(Offset begin, Offset end) {
return Offset.lerp(begin, end, tColumnToRow);
}
@override
@ -220,30 +220,30 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
cardRect.left + 0.5, cardRect.top, cardRect.width - 1.0, cardRect.height
);
layoutChild(cardId, new BoxConstraints.tight(insetRect.size));
positionChild(cardId, insetRect.topLeft.toOffset());
positionChild(cardId, insetRect.topLeft);
}
// Layout the title for index.
final Size titleSize = layoutChild('title$index', new BoxConstraints.loose(cardRect.size));
final double columnTitleY = columnCardRect.centerLeft.y - titleSize.height / 2.0;
final double rowTitleY = rowCardRect.centerLeft.y - titleSize.height / 2.0;
final double columnTitleY = columnCardRect.centerLeft.dy - titleSize.height / 2.0;
final double rowTitleY = rowCardRect.centerLeft.dy - titleSize.height / 2.0;
final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0;
final Point columnTitleOrigin = new Point(columnTitleX, columnTitleY);
final Point rowTitleOrigin = new Point(centeredRowTitleX, rowTitleY);
final Point titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin);
positionChild('title$index', titleOrigin.toOffset() + offset);
final Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY);
final Offset rowTitleOrigin = new Offset(centeredRowTitleX, rowTitleY);
final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin);
positionChild('title$index', titleOrigin + offset);
// Layout the selection indicator for index.
final Size indicatorSize = layoutChild('indicator$index', new BoxConstraints.loose(cardRect.size));
final double columnIndicatorX = cardRect.centerRight.x - indicatorSize.width - 16.0;
final double columnIndicatorY = cardRect.bottomRight.y - indicatorSize.height - 16.0;
final Point columnIndicatorOrigin = new Point(columnIndicatorX, columnIndicatorY);
final double columnIndicatorX = cardRect.centerRight.dx - indicatorSize.width - 16.0;
final double columnIndicatorY = cardRect.bottomRight.dy - indicatorSize.height - 16.0;
final Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY);
final Rect titleRect = new Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0;
final double rowIndicatorY = titleRect.bottomCenter.y + 16.0;
final Point rowIndicatorOrigin = new Point(centeredRowIndicatorX, rowIndicatorY);
final Point indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
positionChild('indicator$index', indicatorOrigin.toOffset() + offset);
final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0;
final Offset rowIndicatorOrigin = new Offset(centeredRowIndicatorX, rowIndicatorY);
final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
positionChild('indicator$index', indicatorOrigin + offset);
columnCardY += columnCardHeight;
rowCardX += rowCardWidth;
@ -434,7 +434,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
behavior: HitTestBehavior.opaque,
child: new SectionCard(section: allSections[index]),
onTapUp: (TapUpDetails details) {
final double xOffset = details.globalPosition.x;
final double xOffset = details.globalPosition.dx;
setState(() {
_maybeScroll(midScrollOffset, index, xOffset);
});

View file

@ -90,7 +90,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
void _handleOnScaleStart(ScaleStartDetails details) {
setState(() {
_previousScale = _scale;
_normalizedOffset = (details.focalPoint.toOffset() - _offset) / _scale;
_normalizedOffset = (details.focalPoint - _offset) / _scale;
// The fling animation stops if an input gesture starts.
_controller.stop();
});
@ -100,7 +100,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
setState(() {
_scale = (_previousScale * details.scale).clamp(1.0, 4.0);
// Ensure that image location under the focal point stays in the same place despite scaling.
_offset = _clampOffset(details.focalPoint.toOffset() - _normalizedOffset * _scale);
_offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale);
});
}
@ -109,7 +109,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
if (magnitude < _kMinFlingVelocity)
return;
final Offset direction = details.velocity.pixelsPerSecond / magnitude;
final double distance = (Point.origin & context.size).shortestSide;
final double distance = (Offset.zero & context.size).shortestSide;
_flingAnimation = new Tween<Offset>(
begin: _offset,
end: _clampOffset(_offset + direction * distance)

View file

@ -20,7 +20,7 @@ void main() {
// Scroll the Buttons demo into view so that a tap will succeed
final Point allDemosOrigin = tester.getTopRight(find.text('Demos'));
final Offset allDemosOrigin = tester.getTopRight(find.text('Demos'));
final Finder button = find.text('Buttons');
while (button.evaluate().isEmpty) {
await tester.dragFrom(allDemosOrigin, const Offset(0.0, -100.0));

View file

@ -77,8 +77,8 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
await tester.pump(const Duration(milliseconds: 400));
// Scroll the demo around a bit.
await tester.flingFrom(const Point(400.0, 300.0), const Offset(-100.0, 0.0), 500.0);
await tester.flingFrom(const Point(400.0, 300.0), const Offset(0.0, -100.0), 500.0);
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(-100.0, 0.0), 500.0);
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, -100.0), 500.0);
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
await tester.pump(const Duration(milliseconds: 200));
@ -90,15 +90,15 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView?.debugLayer?.toStringDeep());
// Scroll the demo around a bit more.
await tester.flingFrom(const Point(400.0, 300.0), const Offset(-200.0, 0.0), 500.0);
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(-200.0, 0.0), 500.0);
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 400));
await tester.flingFrom(const Point(400.0, 300.0), const Offset(100.0, 0.0), 500.0);
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(100.0, 0.0), 500.0);
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
await tester.flingFrom(const Point(400.0, 300.0), const Offset(0.0, 400.0), 1000.0);
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, 400.0), 1000.0);
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));

View file

@ -26,24 +26,24 @@ ui.Picture paint(ui.Rect paintBounds) {
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
final ui.Size size = paintBounds.size;
final ui.Point mid = size.center(ui.Point.origin);
final ui.Offset mid = size.center(ui.Offset.zero);
final double radius = size.shortestSide / 2.0;
final double devicePixelRatio = ui.window.devicePixelRatio;
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
canvas.save();
canvas.translate(-mid.x/2.0, logicalSize.height*2.0);
canvas.clipRect(
new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
canvas.translate(-mid.dx / 2.0, logicalSize.height * 2.0);
canvas.clipRect(new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
canvas.translate(mid.x, mid.y);
canvas.translate(mid.dx, mid.dy);
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
canvas.rotate(math.PI/4.0);
final ui.Gradient yellowBlue = new ui.Gradient.linear(
<ui.Point>[new ui.Point(-radius, -radius), const ui.Point(0.0, 0.0)],
<ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)]
new ui.Offset(-radius, -radius),
const ui.Offset(0.0, 0.0),
<ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)],
);
canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius),
new ui.Paint()..shader = yellowBlue);
@ -57,11 +57,11 @@ ui.Picture paint(ui.Rect paintBounds) {
]);
canvas.transform(scaleMatrix);
paint.color = const ui.Color.fromARGB(128, 0, 255, 0);
canvas.drawCircle(ui.Point.origin, radius, paint);
canvas.drawCircle(ui.Offset.zero, radius, paint);
canvas.restore();
paint.color = const ui.Color.fromARGB(128, 255, 0, 0);
canvas.drawCircle(const ui.Point(150.0, 300.0), radius, paint);
canvas.drawCircle(const ui.Offset(150.0, 300.0), radius, paint);
// When we're done issuing painting commands, we end the recording an receive
// a Picture, which is an immutable record of the commands we've issued. You
@ -85,7 +85,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
}
void beginFrame(Duration timeStamp) {
final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Picture picture = paint(paintBounds);
final ui.Scene scene = composite(picture, paintBounds);
ui.window.render(scene);

View file

@ -16,7 +16,7 @@ void beginFrame(Duration timeStamp) {
final ui.Paragraph paragraph = paragraphBuilder.build()
..layout(new ui.ParagraphConstraints(width: logicalSize.width));
final ui.Rect physicalBounds = ui.Point.origin & (logicalSize * devicePixelRatio);
final ui.Rect physicalBounds = ui.Offset.zero & (logicalSize * devicePixelRatio);
final ui.PictureRecorder recorder = new ui.PictureRecorder();
final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds);
canvas.scale(devicePixelRatio, devicePixelRatio);

View file

@ -19,7 +19,7 @@ void beginFrame(Duration timeStamp) {
// PAINT
final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.PictureRecorder recorder = new ui.PictureRecorder();
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);

View file

@ -44,7 +44,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
}
void beginFrame(Duration timeStamp) {
final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Picture picture = paint(paintBounds);
final ui.Scene scene = composite(picture, paintBounds);
ui.window.render(scene);

View file

@ -26,7 +26,7 @@ ui.Picture paint(ui.Rect paintBounds) {
// The commands draw a circle in the center of the screen.
final ui.Size size = paintBounds.size;
canvas.drawCircle(
size.center(ui.Point.origin),
size.center(ui.Offset.zero),
size.shortestSide * 0.45,
new ui.Paint()..color = color
);
@ -67,7 +67,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
}
void beginFrame(Duration timeStamp) {
final ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio);
// First, record a picture with our painting commands.
final ui.Picture picture = paint(paintBounds);
// Second, include that picture in a scene graph.

View file

@ -525,22 +525,22 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
if (child != null) {
final Rect bounds = offset & size;
// we move the offset to the center of the circle for the RenderSectors
context.paintChild(child, bounds.center.toOffset());
context.paintChild(child, bounds.center);
}
}
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (child == null)
return false;
double x = position.x;
double y = position.y;
double x = position.dx;
double y = position.dy;
// translate to our origin
x -= size.width/2.0;
y -= size.height/2.0;
x -= size.width / 2.0;
y -= size.height / 2.0;
// convert to radius/theta
final double radius = math.sqrt(x*x+y*y);
final double theta = (math.atan2(x, -y) - math.PI/2.0) % kTwoPi;
final double radius = math.sqrt(x * x + y * y);
final double theta = (math.atan2(x, -y) - math.PI / 2.0) % kTwoPi;
if (radius < innerRadius)
return false;
if (radius >= innerRadius + child.deltaRadius)

View file

@ -23,7 +23,7 @@ class Dot {
Dot({ Color color }) : _paint = new Paint()..color = color;
final Paint _paint;
Point position = Point.origin;
Offset position = Offset.zero;
double radius = 0.0;
void update(PointerEvent event) {
@ -58,7 +58,7 @@ class RenderDots extends RenderBox {
/// Makes this render object hittable so that it receives pointer events.
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
/// Processes pointer events by mutating state and invalidating its previous
/// painting commands.

View file

@ -10,9 +10,9 @@ class RenderDots extends RenderConstrainedBox {
// Makes this render box hittable so that we'll get pointer events.
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
final Map<int, Point> _dots = <int, Point>{};
final Map<int, Offset> _dots = <int, Offset>{};
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
@ -31,7 +31,7 @@ class RenderDots extends RenderConstrainedBox {
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
final Paint paint = new Paint()..color = const Color(0xFF00FF00);
for (Point point in _dots.values)
for (Offset point in _dots.values)
canvas.drawCircle(point, 50.0, paint);
super.paint(context, offset);

View file

@ -27,18 +27,16 @@ class _GesturePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint();
final Offset center = (size.center(Offset.zero) * zoom + offset);
final double radius = size.width / 2.0 * zoom;
final Gradient gradient = new RadialGradient(
colors: forward ? <Color>[swatch.shade50, swatch.shade900]
: <Color>[swatch.shade900, swatch.shade50]
);
final Paint paint = new Paint()
..shader = gradient.createShader(new Rect.fromLTWH(
center.x - radius,
center.y - radius,
radius * 2.0,
radius * 2.0
..shader = gradient.createShader(new Rect.fromCircle(
center: center,
radius: radius,
));
canvas.drawCircle(center, radius, paint);
}
@ -63,7 +61,7 @@ class GestureDemo extends StatefulWidget {
class _GestureDemoState extends State<GestureDemo> {
Point _startingFocalPoint;
Offset _startingFocalPoint;
Offset _previousOffset;
Offset _offset = Offset.zero;
@ -92,8 +90,8 @@ class _GestureDemoState extends State<GestureDemo> {
_zoom = (_previousZoom * details.scale);
// Ensure that item under the focal point stays in the same place despite zooming
final Offset normalizedOffset = (_startingFocalPoint.toOffset() - _previousOffset) / _previousZoom;
_offset = details.focalPoint.toOffset() - normalizedOffset * _zoom;
final Offset normalizedOffset = (_startingFocalPoint - _previousOffset) / _previousZoom;
_offset = details.focalPoint - normalizedOffset * _zoom;
});
}

View file

@ -42,7 +42,7 @@ class StockArrowPainter extends CustomPainter {
// Draw a circle that circumscribes the arrow.
paint.style = PaintingStyle.stroke;
canvas.drawCircle(new Point(centerX, centerY), r, paint);
canvas.drawCircle(new Offset(centerX, centerY), r, paint);
}
@override

View file

@ -61,8 +61,8 @@ void main() {
expect(find.text('Account Balance'), findsNothing);
// drag the drawer out
final Point left = new Point(0.0, ui.window.physicalSize.height / 2.0);
final Point right = new Point(ui.window.physicalSize.width, left.y);
final Offset left = new Offset(0.0, ui.window.physicalSize.height / 2.0);
final Offset right = new Offset(ui.window.physicalSize.width, left.dy);
final TestGesture gesture = await tester.startGesture(left);
await tester.pump();
await gesture.moveTo(right);

View file

@ -272,12 +272,12 @@ class _CupertinoButtonBarPainter extends CustomPainter {
final Paint paint = new Paint()
..color = _kButtonDividerColor;
canvas.drawLine(Point.origin, new Point(size.width, 0.0), paint);
canvas.drawLine(Offset.zero, new Offset(size.width, 0.0), paint);
for (int i = 1; i < count; ++i) {
// TODO(abarth): Hide the divider when one of the adjacent buttons is
// highlighted.
final double x = size.width * i / count;
canvas.drawLine(new Point(x, 0.0), new Point(x, size.height), paint);
canvas.drawLine(new Offset(x, 0.0), new Offset(x, size.height), paint);
}
}

View file

@ -281,8 +281,8 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
}
@override
bool hitTestSelf(Point position) {
return (position.x - _thumbCenter).abs() < CupertinoThumbPainter.radius + _kPadding;
bool hitTestSelf(Offset position) {
return (position.dx - _thumbCenter).abs() < CupertinoThumbPainter.radius + _kPadding;
}
@override
@ -319,7 +319,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
canvas.drawRRect(new RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0, 1.0), paint);
}
final Point thumbCenter = new Point(trackActive, trackCenter);
final Offset thumbCenter = new Offset(trackActive, trackCenter);
_thumbPainter.paint(canvas, new Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius));
}

View file

@ -321,7 +321,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {

View file

@ -83,7 +83,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
/// Determine which [HitTestTarget] objects are located at a given position.
@override // from HitTestable
void hitTest(HitTestResult result, Point position) {
void hitTest(HitTestResult result, Offset position) {
result.add(new HitTestEntry(this));
}

View file

@ -28,7 +28,7 @@ class _PointerState {
_down = false;
}
Point lastPosition;
Offset lastPosition;
}
/// Converts from engine pointer data to framework pointer events.
@ -36,7 +36,7 @@ class PointerEventConverter {
// Map from platform pointer identifiers to PointerEvent pointer identifiers.
static final Map<int, _PointerState> _pointers = <int, _PointerState>{};
static _PointerState _ensureStateForPointer(ui.PointerData datum, Point position) {
static _PointerState _ensureStateForPointer(ui.PointerData datum, Offset position) {
return _pointers.putIfAbsent(
datum.device,
() => new _PointerState(position)
@ -46,7 +46,7 @@ class PointerEventConverter {
/// Expand the given packet of pointer data into a sequence of framework pointer events.
static Iterable<PointerEvent> expand(Iterable<ui.PointerData> data, double devicePixelRatio) sync* {
for (ui.PointerData datum in data) {
final Point position = new Point(datum.physicalX, datum.physicalY) / devicePixelRatio;
final Offset position = new Offset(datum.physicalX, datum.physicalY) / devicePixelRatio;
final Duration timeStamp = datum.timeStamp;
final PointerDeviceKind kind = datum.kind;
assert(datum.change != null);

View file

@ -28,14 +28,14 @@ class DragDownDetails {
/// Creates details for a [GestureDragDownCallback].
///
/// The [globalPosition] argument must not be null.
DragDownDetails({ this.globalPosition: Point.origin }) {
DragDownDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen.
///
/// Defaults to the origin if not specified in the constructor.
final Point globalPosition;
final Offset globalPosition;
@override
String toString() => '$runtimeType($globalPosition)';
@ -61,14 +61,14 @@ class DragStartDetails {
/// Creates details for a [GestureDragStartCallback].
///
/// The [globalPosition] argument must not be null.
DragStartDetails({ this.globalPosition: Point.origin }) {
DragStartDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen.
///
/// Defaults to the origin if not specified in the constructor.
final Point globalPosition;
final Offset globalPosition;
@override
String toString() => '$runtimeType($globalPosition)';
@ -131,7 +131,7 @@ class DragUpdateDetails {
final double primaryDelta;
/// The pointer's global position when it triggered this update.
final Point globalPosition;
final Offset globalPosition;
@override
String toString() => '$runtimeType($delta)';
@ -270,7 +270,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
double maxFlingVelocity;
_DragState _state = _DragState.ready;
Point _initialPosition;
Offset _initialPosition;
Offset _pendingDragOffset;
bool _isFlingGesture(VelocityEstimate estimate);

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show Point, Offset, PointerDeviceKind;
import 'dart:ui' show Offset, PointerDeviceKind;
import 'package:flutter/foundation.dart';
export 'dart:ui' show Point, Offset, PointerDeviceKind;
export 'dart:ui' show Offset, PointerDeviceKind;
/// The bit of [PointerEvent.buttons] that corresponds to the primary mouse button.
///
@ -77,7 +77,7 @@ abstract class PointerEvent {
this.pointer: 0,
this.kind: PointerDeviceKind.touch,
this.device: 0,
this.position: Point.origin,
this.position: Offset.zero,
this.delta: Offset.zero,
this.buttons: 0,
this.down: false,
@ -109,7 +109,7 @@ abstract class PointerEvent {
/// Coordinate of the position of the pointer, in logical pixels in the global
/// coordinate space.
final Point position;
final Offset position;
/// Distance in logical pixels that the pointer moved since the last
/// PointerMoveEvent. Always 0.0 for down, up, and cancel events.
@ -257,7 +257,7 @@ class PointerAddedEvent extends PointerEvent {
Duration timeStamp: Duration.ZERO,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
bool obscured: false,
double pressureMin: 1.0,
double pressureMax: 1.0,
@ -331,7 +331,7 @@ class PointerHoverEvent extends PointerEvent {
Duration timeStamp: Duration.ZERO,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
Offset delta: Offset.zero,
int buttons: 0,
bool obscured: false,
@ -377,7 +377,7 @@ class PointerDownEvent extends PointerEvent {
int pointer: 0,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
int buttons: 0,
bool obscured: false,
double pressure: 1.0,
@ -429,7 +429,7 @@ class PointerMoveEvent extends PointerEvent {
int pointer: 0,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
Offset delta: Offset.zero,
int buttons: 0,
bool obscured: false,
@ -477,7 +477,7 @@ class PointerUpEvent extends PointerEvent {
int pointer: 0,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
int buttons: 0,
bool obscured: false,
double pressureMin: 1.0,
@ -518,7 +518,7 @@ class PointerCancelEvent extends PointerEvent {
int pointer: 0,
PointerDeviceKind kind: PointerDeviceKind.touch,
int device: 0,
Point position: Point.origin,
Offset position: Offset.zero,
int buttons: 0,
bool obscured: false,
double pressureMin: 1.0,

View file

@ -10,7 +10,7 @@ abstract class HitTestable { // ignore: one_member_abstracts
///
/// If this given position hits this object, consider adding a [HitTestEntry]
/// to the given hit test result.
void hitTest(HitTestResult result, Point position);
void hitTest(HitTestResult result, Offset position);
}
/// An object that can dispatch events.

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' show Point, Offset;
import 'dart:ui' show Offset;
import 'package:flutter/foundation.dart';
@ -16,7 +16,7 @@ import 'recognizer.dart';
import 'velocity_tracker.dart';
/// Signature for when [MultiDragGestureRecognizer] recognizes the start of a drag gesture.
typedef Drag GestureMultiDragStartCallback(Point position);
typedef Drag GestureMultiDragStartCallback(Offset position);
/// Interface for receiving updates about drags from a [MultiDragGestureRecognizer].
abstract class Drag {
@ -49,7 +49,7 @@ abstract class MultiDragPointerState {
}
/// The global coordinates of the pointer when the pointer contacted the screen.
final Point initialPosition;
final Offset initialPosition;
final VelocityTracker _velocityTracker = new VelocityTracker();
Drag _client;
@ -251,10 +251,10 @@ abstract class MultiDragGestureRecognizer<T extends MultiDragPointerState> exten
final T state = _pointers[pointer];
if (state == null)
return; // We might already have canceled this drag if the up comes before the accept.
state.accepted((Point initialPosition) => _startDrag(initialPosition, pointer));
state.accepted((Offset initialPosition) => _startDrag(initialPosition, pointer));
}
Drag _startDrag(Point initialPosition, int pointer) {
Drag _startDrag(Offset initialPosition, int pointer) {
assert(_pointers != null);
final T state = _pointers[pointer];
assert(state != null);
@ -303,7 +303,7 @@ abstract class MultiDragGestureRecognizer<T extends MultiDragPointerState> exten
}
class _ImmediatePointerState extends MultiDragPointerState {
_ImmediatePointerState(Point initialPosition) : super(initialPosition);
_ImmediatePointerState(Offset initialPosition) : super(initialPosition);
@override
void checkForResolutionAfterMove() {
@ -340,7 +340,7 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im
class _HorizontalPointerState extends MultiDragPointerState {
_HorizontalPointerState(Point initialPosition) : super(initialPosition);
_HorizontalPointerState(Offset initialPosition) : super(initialPosition);
@override
void checkForResolutionAfterMove() {
@ -377,7 +377,7 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H
class _VerticalPointerState extends MultiDragPointerState {
_VerticalPointerState(Point initialPosition) : super(initialPosition);
_VerticalPointerState(Offset initialPosition) : super(initialPosition);
@override
void checkForResolutionAfterMove() {
@ -413,7 +413,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver
}
class _DelayedPointerState extends MultiDragPointerState {
_DelayedPointerState(Point initialPosition, Duration delay) : super(initialPosition) {
_DelayedPointerState(Offset initialPosition, Duration delay) : super(initialPosition) {
assert(delay != null);
_timer = new Timer(delay, _delayPassed);
}

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' show Point, Offset;
import 'dart:ui' show Offset;
import 'arena.dart';
import 'binding.dart';
@ -41,7 +41,7 @@ class _TapTracker {
final int pointer;
final GestureArenaEntry entry;
final Point _initialPosition;
final Offset _initialPosition;
bool _isTrackingPointer = false;
@ -249,8 +249,8 @@ class _TapGesture extends _TapTracker {
bool _wonArena = false;
Timer _timer;
Point _lastPosition;
Point _finalPosition;
Offset _lastPosition;
Offset _finalPosition;
void handleEvent(PointerEvent event) {
assert(event.pointer == pointer);
@ -374,7 +374,7 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
invokeCallback<Null>('onTapCancel', () => onTapCancel(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
}
void _dispatchTap(int pointer, Point globalPosition) {
void _dispatchTap(int pointer, Offset globalPosition) {
assert(_gestureMap.containsKey(pointer));
_gestureMap.remove(pointer);
if (onTapUp != null)
@ -383,7 +383,7 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
invokeCallback<Null>('onTap', () => onTap(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
}
void _dispatchLongTap(int pointer, Point lastPosition) {
void _dispatchLongTap(int pointer, Offset lastPosition) {
assert(_gestureMap.containsKey(pointer));
if (onLongTapDown != null)
invokeCallback<Null>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504

View file

@ -4,7 +4,7 @@
import 'dart:async';
import 'dart:collection';
import 'dart:ui' show Point, Offset;
import 'dart:ui' show Offset;
import 'package:flutter/foundation.dart';
@ -232,7 +232,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
int primaryPointer;
/// The global location at which the primary pointer contacted the screen.
Point initialPosition;
Offset initialPosition;
Timer _timer;

View file

@ -32,13 +32,13 @@ class ScaleStartDetails {
/// Creates details for [GestureScaleStartCallback].
///
/// The [focalPoint] argument must not be null.
ScaleStartDetails({ this.focalPoint: Point.origin }) {
ScaleStartDetails({ this.focalPoint: Offset.zero }) {
assert(focalPoint != null);
}
/// The initial focal point of the pointers in contact with the screen.
/// Reported in global coordinates.
final Point focalPoint;
final Offset focalPoint;
@override
String toString() => 'ScaleStartDetails(focalPoint: $focalPoint)';
@ -50,14 +50,14 @@ class ScaleUpdateDetails {
///
/// The [focalPoint] and [scale] arguments must not be null. The [scale]
/// argument must be greater than or equal to zero.
ScaleUpdateDetails({ this.focalPoint: Point.origin, this.scale: 1.0 }) {
ScaleUpdateDetails({ this.focalPoint: Offset.zero, this.scale: 1.0 }) {
assert(focalPoint != null);
assert(scale != null && scale >= 0.0);
}
/// The focal point of the pointers in contact with the screen. Reported in
/// global coordinates.
final Point focalPoint;
final Offset focalPoint;
/// The scale implied by the pointers in contact with the screen. A value
/// greater than or equal to zero.
@ -121,11 +121,11 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
_ScaleState _state = _ScaleState.ready;
Point _initialFocalPoint;
Point _currentFocalPoint;
Offset _initialFocalPoint;
Offset _currentFocalPoint;
double _initialSpan;
double _currentSpan;
Map<int, Point> _pointerLocations;
Map<int, Offset> _pointerLocations;
final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
double get _scaleFactor => _initialSpan > 0.0 ? _currentSpan / _initialSpan : 1.0;
@ -138,7 +138,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
_state = _ScaleState.possible;
_initialSpan = 0.0;
_currentSpan = 0.0;
_pointerLocations = <int, Point>{};
_pointerLocations = <int, Offset>{};
}
}
@ -172,10 +172,10 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
final int count = _pointerLocations.keys.length;
// Compute the focal point
Point focalPoint = Point.origin;
Offset focalPoint = Offset.zero;
for (int pointer in _pointerLocations.keys)
focalPoint += _pointerLocations[pointer].toOffset();
_currentFocalPoint = count > 0 ? new Point(focalPoint.x / count, focalPoint.y / count) : Point.origin;
focalPoint += _pointerLocations[pointer];
_currentFocalPoint = count > 0 ? focalPoint / count.toDouble() : Offset.zero;
// Span is the average deviation from focal point
double totalDeviation = 0.0;

View file

@ -12,12 +12,12 @@ class TapDownDetails {
/// Creates details for a [GestureTapDownCallback].
///
/// The [globalPosition] argument must not be null.
TapDownDetails({ this.globalPosition: Point.origin }) {
TapDownDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen.
final Point globalPosition;
final Offset globalPosition;
}
/// Signature for when a pointer that might cause a tap has contacted the
@ -32,12 +32,12 @@ class TapUpDetails {
/// Creates details for a [GestureTapUpCallback].
///
/// The [globalPosition] argument must not be null.
TapUpDetails({ this.globalPosition: Point.origin }) {
TapUpDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen.
final Point globalPosition;
final Offset globalPosition;
}
/// Signature for when a pointer that will trigger a tap has stopped contacting
@ -85,7 +85,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
bool _sentTapDown = false;
bool _wonArenaForPrimaryPointer = false;
Point _finalPosition;
Offset _finalPosition;
@override
void handlePrimaryPointer(PointerEvent event) {

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show Point, Offset;
import 'dart:ui' show Offset;
import 'lsq_solver.dart';
export 'dart:ui' show Point, Offset;
export 'dart:ui' show Offset;
/// A velocity in two dimensions.
class Velocity {
@ -119,7 +119,7 @@ class _PointAtTime {
const _PointAtTime(this.point, this.time);
final Duration time;
final Point point;
final Offset point;
@override
String toString() => '_PointAtTime($point at $time)';
@ -148,7 +148,7 @@ class VelocityTracker {
int _index = 0;
/// Adds a position as the given time to the tracker.
void addPosition(Duration time, Point position) {
void addPosition(Duration time, Offset position) {
_index += 1;
if (_index == _kHistorySize)
_index = 0;
@ -186,9 +186,9 @@ class VelocityTracker {
break;
oldestSample = sample;
final Point position = sample.point;
x.add(position.x);
y.add(position.y);
final Offset position = sample.point;
x.add(position.dx);
y.add(position.dy);
w.add(1.0);
time.add(-age);
index = (index == 0 ? _kHistorySize : index) - 1;

View file

@ -13,7 +13,7 @@ import 'package:flutter/painting.dart';
// vertical or horizontal.
const double _kOnAxisDelta = 2.0;
/// A [Tween] that animates a [Point] along a circular arc.
/// A [Tween] that animates an [Offset] along a circular arc.
///
/// The arc's radius is related to the bounding box that contains the [begin]
/// and [end] points. If the bounding box is taller than it is wide, then the
@ -27,14 +27,14 @@ const double _kOnAxisDelta = 2.0;
/// See also:
///
/// * [MaterialRectArcTween]
class MaterialPointArcTween extends Tween<Point> {
/// Creates a [Tween] for animating [Point]s along a circular arc.
class MaterialPointArcTween extends Tween<Offset> {
/// Creates a [Tween] for animating [Offset]s along a circular arc.
///
/// The [begin] and [end] points are required, cannot be null, and are
/// immutable.
MaterialPointArcTween({
@required Point begin,
@required Point end
@required Offset begin,
@required Offset end
}) : super(begin: begin, end: end) {
assert(begin != null);
assert(end != null);
@ -43,43 +43,43 @@ class MaterialPointArcTween extends Tween<Point> {
final double deltaX = delta.dx.abs();
final double deltaY = delta.dy.abs();
final double distanceFromAtoB = delta.distance;
final Point c = new Point(end.x, begin.y);
final Offset c = new Offset(end.dx, begin.dy);
double sweepAngle() => 2.0 * math.asin(distanceFromAtoB / (2.0 * _radius));
if (deltaX > _kOnAxisDelta && deltaY > _kOnAxisDelta) {
if (deltaX < deltaY) {
_radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0;
_center = new Point(end.x + _radius * (begin.x - end.x).sign, end.y);
if (begin.x < end.x) {
_beginAngle = sweepAngle() * (begin.y - end.y).sign;
_center = new Offset(end.dx + _radius * (begin.dx - end.dx).sign, end.dy);
if (begin.dx < end.dx) {
_beginAngle = sweepAngle() * (begin.dy - end.dy).sign;
_endAngle = 0.0;
} else {
_beginAngle = math.PI + sweepAngle() * (end.y - begin.y).sign;
_beginAngle = math.PI + sweepAngle() * (end.dy - begin.dy).sign;
_endAngle = math.PI;
}
} else {
_radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0;
_center = new Point(begin.x, begin.y + (end.y - begin.y).sign * _radius);
if (begin.y < end.y) {
_center = new Offset(begin.dx, begin.dy + (end.dy - begin.dy).sign * _radius);
if (begin.dy < end.dy) {
_beginAngle = -math.PI / 2.0;
_endAngle = _beginAngle + sweepAngle() * (end.x - begin.x).sign;
_endAngle = _beginAngle + sweepAngle() * (end.dx - begin.dx).sign;
} else {
_beginAngle = math.PI / 2.0;
_endAngle = _beginAngle + sweepAngle() * (begin.x - end.x).sign;
_endAngle = _beginAngle + sweepAngle() * (begin.dx - end.dx).sign;
}
}
}
}
Point _center;
Offset _center;
double _radius;
double _beginAngle;
double _endAngle;
/// The center of the circular arc, null if [begin] and [end] are horiztonally or
/// vertically aligned.
Point get center => _center;
Offset get center => _center;
/// The radius of the circular arc, null if begin and end are horiztonally or
/// vertically aligned.
@ -96,24 +96,24 @@ class MaterialPointArcTween extends Tween<Point> {
/// Setting the arc's [begin] parameter is not supported. Construct a new arc instead.
@override
set begin(Point value) {
set begin(Offset value) {
assert(false); // not supported
}
/// Setting the arc's [end] parameter is not supported. Construct a new arc instead.
@override
set end(Point value) {
set end(Offset value) {
assert(false); // not supported
}
@override
Point lerp(double t) {
Offset lerp(double t) {
if (t == 0.0)
return begin;
if (t == 1.0)
return end;
if (_beginAngle == null || _endAngle == null)
return Point.lerp(begin, end, t);
return Offset.lerp(begin, end, t);
final double angle = lerpDouble(_beginAngle, _endAngle, t);
final double x = math.cos(angle) * _radius;
final double y = math.sin(angle) * _radius;
@ -186,7 +186,7 @@ T _maxBy<T>(Iterable<T> input, _KeyFunc<T> keyFunc) {
///
/// See also:
///
/// * [MaterialPointArcTween]. the analogue for [Point] interporation.
/// * [MaterialPointArcTween]. the analogue for [Offset] interporation.
/// * [RectTween], which does a linear rectangle interpolation.
class MaterialRectArcTween extends RectTween {
/// Creates a [Tween] for animating [Rect]s along a circular arc.
@ -215,14 +215,14 @@ class MaterialRectArcTween extends RectTween {
MaterialPointArcTween _beginArc;
MaterialPointArcTween _endArc;
Point _cornerFor(Rect rect, _CornerId id) {
Offset _cornerFor(Rect rect, _CornerId id) {
switch (id) {
case _CornerId.topLeft: return rect.topLeft;
case _CornerId.topRight: return rect.topRight;
case _CornerId.bottomLeft: return rect.bottomLeft;
case _CornerId.bottomRight: return rect.bottomRight;
}
return Point.origin;
return Offset.zero;
}
double _diagonalSupport(Offset centersVector, _Diagonal diagonal) {

View file

@ -571,7 +571,7 @@ class _RadialPainter extends CustomPainter {
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.height);
canvas.clipRect(rect);
final double navWidth = math.min(bottomNavMaxWidth, size.width);
final Point center = new Point(
final Offset center = new Offset(
(size.width - navWidth) / 2.0 + circle.offset.dx * navWidth,
circle.offset.dy * size.height
);

View file

@ -172,7 +172,7 @@ class _RenderCheckbox extends RenderToggleable {
final double offsetX = offset.dx + (size.width - _kEdgeSize) / 2.0;
final double offsetY = offset.dy + (size.height - _kEdgeSize) / 2.0;
paintRadialReaction(canvas, offset, size.center(Point.origin));
paintRadialReaction(canvas, offset, size.center(Offset.zero));
final double t = position.value;
@ -203,14 +203,14 @@ class _RenderCheckbox extends RenderToggleable {
..style = PaintingStyle.stroke
..strokeWidth = _kStrokeWidth;
final Path path = new Path();
final Point start = const Point(_kEdgeSize * 0.15, _kEdgeSize * 0.45);
final Point mid = const Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7);
final Point end = const Point(_kEdgeSize * 0.85, _kEdgeSize * 0.25);
final Point drawStart = Point.lerp(start, mid, 1.0 - value);
final Point drawEnd = Point.lerp(mid, end, value);
path.moveTo(offsetX + drawStart.x, offsetY + drawStart.y);
path.lineTo(offsetX + mid.x, offsetY + mid.y);
path.lineTo(offsetX + drawEnd.x, offsetY + drawEnd.y);
final Offset start = const Offset(_kEdgeSize * 0.15, _kEdgeSize * 0.45);
final Offset mid = const Offset(_kEdgeSize * 0.4, _kEdgeSize * 0.7);
final Offset end = const Offset(_kEdgeSize * 0.85, _kEdgeSize * 0.25);
final Offset drawStart = Offset.lerp(start, mid, 1.0 - value);
final Offset drawEnd = Offset.lerp(mid, end, value);
path.moveTo(offsetX + drawStart.dx, offsetY + drawStart.dy);
path.lineTo(offsetX + mid.dx, offsetY + mid.dy);
path.lineTo(offsetX + drawEnd.dx, offsetY + drawEnd.dy);
canvas.drawPath(path, paint);
}
}

View file

@ -62,7 +62,7 @@ class _DropdownMenuPainter extends CustomPainter {
final Rect rect = new Rect.fromLTRB(0.0, top.evaluate(resize), size.width, bottom.evaluate(resize));
_painter.paint(canvas, rect.topLeft.toOffset(), new ImageConfiguration(size: rect.size));
_painter.paint(canvas, rect.topLeft, new ImageConfiguration(size: rect.size));
}
@override
@ -231,7 +231,7 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
top = bottom - childSize.height;
}
assert(() {
final Rect container = Point.origin & size;
final Rect container = Offset.zero & size;
if (container.intersect(buttonRect) == buttonRect) {
// If the button was entirely on-screen, then verify
// that the menu is also on-screen.
@ -499,7 +499,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> {
void _handleTap() {
final RenderBox itemBox = context.findRenderObject();
final Rect itemRect = itemBox.localToGlobal(Point.origin) & itemBox.size;
final Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
Navigator.push(context, new _DropdownRoute<T>(
items: widget.items,
buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect),

View file

@ -131,7 +131,7 @@ class InkHighlight extends InkFeature {
void paintFeature(Canvas canvas, Matrix4 transform) {
final Paint paint = new Paint()..color = color.withAlpha(_alpha.value);
final Offset originOffset = MatrixUtils.getAsTranslation(transform);
final Rect rect = (_rectCallback != null ? _rectCallback() : Point.origin & referenceBox.size);
final Rect rect = (_rectCallback != null ? _rectCallback() : Offset.zero & referenceBox.size);
if (originOffset == null) {
canvas.save();
canvas.transform(transform.storage);

View file

@ -22,11 +22,11 @@ RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, Rec
return rectCallback;
}
if (containedInkWell)
return () => Point.origin & referenceBox.size;
return () => Offset.zero & referenceBox.size;
return null;
}
double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Point position) {
double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Offset position) {
if (containedInkWell) {
final Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
return _getSplashRadiusForPoistionInSize(size, position);
@ -34,11 +34,11 @@ double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallb
return Material.defaultSplashRadius;
}
double _getSplashRadiusForPoistionInSize(Size bounds, Point position) {
final double d1 = (position - bounds.topLeft(Point.origin)).distance;
final double d2 = (position - bounds.topRight(Point.origin)).distance;
final double d3 = (position - bounds.bottomLeft(Point.origin)).distance;
final double d4 = (position - bounds.bottomRight(Point.origin)).distance;
double _getSplashRadiusForPoistionInSize(Size bounds, Offset position) {
final double d1 = (position - bounds.topLeft(Offset.zero)).distance;
final double d2 = (position - bounds.topRight(Offset.zero)).distance;
final double d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
final double d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return math.max(math.max(d1, d2), math.max(d3, d4)).ceilToDouble();
}
@ -76,7 +76,7 @@ class InkSplash extends InkFeature {
InkSplash({
@required MaterialInkController controller,
@required RenderBox referenceBox,
Point position,
Offset position,
Color color,
bool containedInkWell: false,
RectCallback rectCallback,
@ -109,7 +109,7 @@ class InkSplash extends InkFeature {
controller.addInkFeature(this);
}
final Point _position;
final Offset _position;
final BorderRadius _borderRadius;
final double _targetRadius;
final RectCallback _clipCallback;
@ -185,9 +185,9 @@ class InkSplash extends InkFeature {
@override
void paintFeature(Canvas canvas, Matrix4 transform) {
final Paint paint = new Paint()..color = _color.withAlpha(_alpha.value);
Point center = _position;
Offset center = _position;
if (_repositionToReferenceBox)
center = Point.lerp(center, referenceBox.size.center(Point.origin), _radiusController.value);
center = Offset.lerp(center, referenceBox.size.center(Offset.zero), _radiusController.value);
final Offset originOffset = MatrixUtils.getAsTranslation(transform);
if (originOffset == null) {
canvas.save();

View file

@ -340,7 +340,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void paint(PaintingContext context, Offset offset) {
@ -348,7 +348,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
final Canvas canvas = context.canvas;
canvas.save();
canvas.translate(offset.dx, offset.dy);
canvas.clipRect(Point.origin & size);
canvas.clipRect(Offset.zero & size);
for (InkFeature inkFeature in _inkFeatures)
inkFeature._paint(canvas);
canvas.restore();

View file

@ -524,15 +524,17 @@ class PopupMenuButton<T> extends StatefulWidget {
class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
void showButtonMenu() {
final RenderBox renderBox = context.findRenderObject();
final Point topLeft = renderBox.localToGlobal(Point.origin);
final Offset topLeft = renderBox.localToGlobal(Offset.zero);
showMenu<T>(
context: context,
elevation: widget.elevation,
items: widget.itemBuilder(context),
initialValue: widget.initialValue,
position: new RelativeRect.fromLTRB(
topLeft.x, topLeft.y + (widget.initialValue != null ? renderBox.size.height / 2.0 : 0.0),
0.0, 0.0
topLeft.dx,
topLeft.dy + (widget.initialValue != null ? renderBox.size.height / 2.0 : 0.0),
0.0,
0.0,
)
)
.then<Null>((T newValue) {

View file

@ -89,18 +89,18 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
final Paint paint = new Paint()
..color = backgroundColor
..style = PaintingStyle.fill;
canvas.drawRect(Point.origin & size, paint);
canvas.drawRect(Offset.zero & size, paint);
paint.color = valueColor;
if (value != null) {
final double width = value.clamp(0.0, 1.0) * size.width;
canvas.drawRect(Point.origin & new Size(width, size.height), paint);
canvas.drawRect(Offset.zero & new Size(width, size.height), paint);
} else {
final double startX = size.width * (1.5 * animationValue - 0.5);
final double endX = startX + 0.5 * size.width;
final double x = startX.clamp(0.0, size.width);
final double width = endX.clamp(0.0, size.width) - x;
canvas.drawRect(new Point(x, 0.0) & new Size(width, size.height), paint);
canvas.drawRect(new Offset(x, 0.0) & new Size(width, size.height), paint);
}
}
@ -239,7 +239,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
if (value == null) // Indeterminate
paint.strokeCap = StrokeCap.square;
canvas.drawArc(Point.origin & size, arcStart, arcSweep, false, paint);
canvas.drawArc(Offset.zero & size, arcStart, arcSweep, false, paint);
}
@override

View file

@ -190,9 +190,9 @@ class _RenderRadio extends RenderToggleable {
void paint(PaintingContext context, Offset offset) {
final Canvas canvas = context.canvas;
paintRadialReaction(canvas, offset, const Point(kRadialReactionRadius, kRadialReactionRadius));
paintRadialReaction(canvas, offset, const Offset(kRadialReactionRadius, kRadialReactionRadius));
final Point center = (offset & size).center;
final Offset center = (offset & size).center;
final Color radioColor = onChanged != null ? activeColor : inactiveColor;
// Outer circle

View file

@ -143,13 +143,13 @@ class _ScrollbarController extends ChangeNotifier {
Paint get _paint => new Paint()..color = color.withOpacity(_opacity.value);
void _paintVerticalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
final Point thumbOrigin = new Point(size.width - _kThumbGirth, thumbOffset);
final Offset thumbOrigin = new Offset(size.width - _kThumbGirth, thumbOffset);
final Size thumbSize = new Size(_kThumbGirth, thumbExtent);
canvas.drawRect(thumbOrigin & thumbSize, _paint);
}
void _paintHorizontalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
final Point thumbOrigin = new Point(thumbOffset, size.height - _kThumbGirth);
final Offset thumbOrigin = new Offset(thumbOffset, size.height - _kThumbGirth);
final Size thumbSize = new Size(thumbExtent, _kThumbGirth);
canvas.drawRect(thumbOrigin & thumbSize, _paint);
}

View file

@ -389,8 +389,8 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
bool get isInteractive => onChanged != null;
double _getValueFromGlobalPosition(Point globalPosition) {
return (globalToLocal(globalPosition).x - _kReactionRadius) / _trackLength;
double _getValueFromGlobalPosition(Offset globalPosition) {
return (globalToLocal(globalPosition).dx - _kReactionRadius) / _trackLength;
}
double _discretize(double value) {
@ -430,7 +430,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
@ -461,7 +461,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
final Paint primaryPaint = new Paint()..color = enabled ? _activeColor : _kInactiveTrackColor;
final Paint trackPaint = new Paint()..color = _kTrackColorTween.evaluate(_reaction);
final Point thumbCenter = new Point(trackActive, trackCenter);
final Offset thumbCenter = new Offset(trackActive, trackCenter);
final double thumbRadius = enabled ? _kThumbRadiusTween.evaluate(_reaction) : _kDisabledThumbRadius;
if (enabled) {
@ -495,22 +495,22 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
}
if (label != null) {
final Point center = new Point(trackActive, _kLabelBalloonCenterTween.evaluate(_reaction) + trackCenter);
final Offset center = new Offset(trackActive, _kLabelBalloonCenterTween.evaluate(_reaction) + trackCenter);
final double radius = _kLabelBalloonRadiusTween.evaluate(_reaction);
final Point tip = new Point(trackActive, _kLabelBalloonTipTween.evaluate(_reaction) + trackCenter);
final Offset tip = new Offset(trackActive, _kLabelBalloonTipTween.evaluate(_reaction) + trackCenter);
final double tipAttachment = _kLabelBalloonTipAttachmentRatio * radius;
canvas.drawCircle(center, radius, primaryPaint);
final Path path = new Path()
..moveTo(tip.x, tip.y)
..lineTo(center.x - tipAttachment, center.y + tipAttachment)
..lineTo(center.x + tipAttachment, center.y + tipAttachment)
..moveTo(tip.dx, tip.dy)
..lineTo(center.dx - tipAttachment, center.dy + tipAttachment)
..lineTo(center.dx + tipAttachment, center.dy + tipAttachment)
..close();
canvas.drawPath(path, primaryPaint);
_labelPainter.layout();
final Offset labelOffset = new Offset(
center.x - _labelPainter.width / 2.0,
center.y - _labelPainter.height / 2.0
center.dx - _labelPainter.width / 2.0,
center.dy - _labelPainter.height / 2.0
);
_labelPainter.paint(canvas, labelOffset);
return;

View file

@ -652,7 +652,7 @@ class _TrianglePainter extends CustomPainter {
final Color color;
@override
bool hitTest(Point point) => true; // Hitting the rectangle is fine enough.
bool hitTest(Offset point) => true; // Hitting the rectangle is fine enough.
@override
bool shouldRepaint(_TrianglePainter oldPainter) {
@ -664,10 +664,10 @@ class _TrianglePainter extends CustomPainter {
final double base = size.width;
final double halfBase = size.width / 2.0;
final double height = size.height;
final List<Point> points = <Point>[
new Point(0.0, height),
new Point(base, height),
new Point(halfBase, 0.0),
final List<Offset> points = <Offset>[
new Offset(0.0, height),
new Offset(base, height),
new Offset(halfBase, 0.0),
];
canvas.drawPath(

View file

@ -365,7 +365,7 @@ class _RenderSwitch extends RenderToggleable {
final RRect trackRRect = new RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius));
canvas.drawRRect(trackRRect, paint);
final Point thumbPosition = new Point(
final Offset thumbPosition = new Offset(
kRadialReactionRadius + currentPosition * _trackInnerLength,
size.height / 2.0
);
@ -389,7 +389,7 @@ class _RenderSwitch extends RenderToggleable {
final double radius = _kThumbRadius - inset;
thumbPainter.paint(
canvas,
thumbPosition.toOffset() + offset - new Offset(radius, radius),
thumbPosition + offset - new Offset(radius, radius),
configuration.copyWith(size: new Size.fromRadius(radius))
);
} finally {

View file

@ -92,7 +92,7 @@ class _TextSelectionToolbar extends StatelessWidget {
class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate {
_TextSelectionToolbarLayout(this.position);
final Point position;
final Offset position;
@override
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
@ -101,8 +101,8 @@ class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate {
@override
Offset getPositionForChild(Size size, Size childSize) {
double x = position.x - childSize.width/2.0;
double y = position.y - childSize.height;
double x = position.dx - childSize.width / 2.0;
double y = position.dy - childSize.height;
if (x < _kToolbarScreenPadding)
x = _kToolbarScreenPadding;
@ -133,7 +133,7 @@ class _TextSelectionHandlePainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final Paint paint = new Paint()..color = color;
final double radius = size.width/2.0;
canvas.drawCircle(new Point(radius, radius), radius, paint);
canvas.drawCircle(new Offset(radius, radius), radius, paint);
canvas.drawRect(new Rect.fromLTWH(0.0, 0.0, radius, radius), paint);
}
@ -150,7 +150,7 @@ class _MaterialTextSelectionControls extends TextSelectionControls {
/// Builder for material-style copy/paste text selection toolbar.
@override
Widget buildToolbar(
BuildContext context, Point position, TextSelectionDelegate delegate) {
BuildContext context, Offset position, TextSelectionDelegate delegate) {
final Size screenSize = MediaQuery.of(context).size;
return new ConstrainedBox(
constraints: new BoxConstraints.loose(screenSize),

View file

@ -393,7 +393,7 @@ class _DialPainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final double radius = size.shortestSide / 2.0;
final Offset center = new Offset(size.width / 2.0, size.height / 2.0);
final Point centerPoint = center.toPoint();
final Offset centerPoint = center;
canvas.drawCircle(centerPoint, radius, new Paint()..color = backgroundColor);
const double labelPadding = 24.0;
@ -418,7 +418,7 @@ class _DialPainter extends CustomPainter {
final Paint selectorPaint = new Paint()
..color = accentColor;
final Point focusedPoint = getOffsetForTheta(theta).toPoint();
final Offset focusedPoint = getOffsetForTheta(theta);
final double focusedRadius = labelPadding - 4.0;
canvas.drawCircle(centerPoint, 4.0, selectorPaint);
canvas.drawCircle(focusedPoint, focusedRadius, selectorPaint);
@ -549,15 +549,15 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
});
}
Point _position;
Point _center;
Offset _position;
Offset _center;
void _handlePanStart(DragStartDetails details) {
assert(!_dragging);
_dragging = true;
final RenderBox box = context.findRenderObject();
_position = box.globalToLocal(details.globalPosition);
_center = box.size.center(Point.origin);
_center = box.size.center(Offset.zero);
_updateThetaForPan();
_notifyOnChangedIfNeeded();
}

View file

@ -191,7 +191,7 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
bool get isInteractive => onChanged != null;
TapGestureRecognizer _tap;
Point _downPosition;
Offset _downPosition;
@override
void attach(PipelineOwner owner) {
@ -257,7 +257,7 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
@ -272,11 +272,11 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
/// origin is the center point of the reaction (usually distinct from the
/// point at which the user interacted with the control, which is handled
/// automatically).
void paintRadialReaction(Canvas canvas, Offset offset, Point origin) {
void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) {
if (!_reaction.isDismissed) {
// TODO(abarth): We should have a different reaction color when position is zero.
final Paint reactionPaint = new Paint()..color = activeColor.withAlpha(kRadialReactionAlpha);
final Point center = Point.lerp(_downPosition ?? origin, origin, _reaction.value);
final Offset center = Offset.lerp(_downPosition ?? origin, origin, _reaction.value);
final double radius = _kRadialReactionRadiusTween.evaluate(_reaction);
canvas.drawCircle(center + offset, radius, reactionPaint);
}

View file

@ -119,7 +119,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
return; // Already visible.
}
final RenderBox box = context.findRenderObject();
final Point target = box.localToGlobal(box.size.center(Point.origin));
final Offset target = box.localToGlobal(box.size.center(Offset.zero));
// We create this widget outside of the overlay entry's builder to prevent
// updated values from happening to leak into the overlay when the overlay
// rebuilds.
@ -195,7 +195,7 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
this.preferBelow
});
final Point target;
final Offset target;
final double verticalOffset;
final bool preferBelow;
@ -205,16 +205,16 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
@override
Offset getPositionForChild(Size size, Size childSize) {
// VERTICAL DIRECTION
final bool fitsBelow = target.y + verticalOffset + childSize.height <= size.height - _kScreenEdgeMargin;
final bool fitsAbove = target.y - verticalOffset - childSize.height >= _kScreenEdgeMargin;
final bool fitsBelow = target.dy + verticalOffset + childSize.height <= size.height - _kScreenEdgeMargin;
final bool fitsAbove = target.dy - verticalOffset - childSize.height >= _kScreenEdgeMargin;
final bool tooltipBelow = preferBelow ? fitsBelow || !fitsAbove : !(fitsAbove || !fitsBelow);
double y;
if (tooltipBelow)
y = math.min(target.y + verticalOffset, size.height - _kScreenEdgeMargin);
y = math.min(target.dy + verticalOffset, size.height - _kScreenEdgeMargin);
else
y = math.max(target.y - verticalOffset - childSize.height, _kScreenEdgeMargin);
y = math.max(target.dy - verticalOffset - childSize.height, _kScreenEdgeMargin);
// HORIZONTAL DIRECTION
final double normalizedTargetX = target.x.clamp(_kScreenEdgeMargin, size.width - _kScreenEdgeMargin);
final double normalizedTargetX = target.dx.clamp(_kScreenEdgeMargin, size.width - _kScreenEdgeMargin);
double x;
if (normalizedTargetX < _kScreenEdgeMargin + childSize.width / 2.0) {
x = _kScreenEdgeMargin;
@ -250,7 +250,7 @@ class _TooltipOverlay extends StatelessWidget {
final double height;
final EdgeInsets padding;
final Animation<double> animation;
final Point target;
final Offset target;
final double verticalOffset;
final bool preferBelow;

View file

@ -18,7 +18,6 @@ export 'dart:ui' show
PaintingStyle,
Path,
PathFillType,
Point,
Radius,
RRect,
RSTransform,

View file

@ -89,7 +89,7 @@ class FittedSizes {
/// ```dart
/// final Size imageSize = new Size(image.width.toDouble(), image.height.toDouble());
/// final FittedSizes sizes = applyBoxFit(fit, imageSize, outputRect.size);
/// final Rect inputSubrect = FractionalOffset.center.inscribe(sizes.source, Point.origin & imageSize);
/// final Rect inputSubrect = FractionalOffset.center.inscribe(sizes.source, Offset.zero & imageSize);
/// final Rect outputSubrect = FractionalOffset.center.inscribe(sizes.destination, outputRect);
/// canvas.drawImageRect(image, inputSubrect, outputSubrect, paint);
/// ```

View file

@ -668,8 +668,9 @@ class LinearGradient extends Gradient {
@override
Shader createShader(Rect rect) {
return new ui.Gradient.linear(
<Point>[begin.withinRect(rect), end.withinRect(rect)],
colors, stops, tileMode
begin.withinRect(rect),
end.withinRect(rect),
colors, stops, tileMode,
);
}
@ -938,7 +939,7 @@ void paintImage({
}
final double dx = (outputSize.width - destinationSize.width) * (alignment?.dx ?? 0.5);
final double dy = (outputSize.height - destinationSize.height) * (alignment?.dy ?? 0.5);
final Point destinationPosition = rect.topLeft + new Offset(dx, dy);
final Offset destinationPosition = rect.topLeft.translate(dx, dy);
final Rect destinationRect = destinationPosition & destinationSize;
if (repeat != ImageRepeat.noRepeat) {
canvas.save();
@ -946,7 +947,7 @@ void paintImage({
}
if (centerSlice == null) {
final Rect sourceRect = (alignment ?? FractionalOffset.center).inscribe(
fittedSizes.source, Point.origin & inputSize
fittedSizes.source, Offset.zero & inputSize
);
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
canvas.drawImageRect(image, sourceRect, tileRect, paint);
@ -1228,19 +1229,19 @@ class BoxDecoration extends Decoration {
}
@override
bool hitTest(Size size, Point position) {
bool hitTest(Size size, Offset position) {
assert(shape != null);
assert((Point.origin & size).contains(position));
assert((Offset.zero & size).contains(position));
switch (shape) {
case BoxShape.rectangle:
if (borderRadius != null) {
final RRect bounds = borderRadius.toRRect(Point.origin & size);
final RRect bounds = borderRadius.toRRect(Offset.zero & size);
return bounds.contains(position);
}
return true;
case BoxShape.circle:
// Circles are inscribed into our smallest dimension.
final Point center = size.center(Point.origin);
final Offset center = size.center(Offset.zero);
final double distance = (position - center).distance;
return distance <= math.min(size.width, size.height) / 2.0;
}
@ -1292,7 +1293,7 @@ class _BoxDecorationPainter extends BoxPainter {
switch (_decoration.shape) {
case BoxShape.circle:
assert(_decoration.borderRadius == null);
final Point center = rect.center;
final Offset center = rect.center;
final double radius = rect.shortestSide / 2.0;
canvas.drawCircle(center, radius, paint);
break;

View file

@ -10,7 +10,7 @@ import 'edge_insets.dart';
export 'package:flutter/services.dart' show ImageConfiguration;
export 'basic_types.dart' show Point, Offset, Size;
export 'basic_types.dart' show Offset, Size;
export 'edge_insets.dart' show EdgeInsets;
// This group of classes is intended for painting in cartesian coordinates.
@ -71,7 +71,7 @@ abstract class Decoration {
/// if the decoration only draws a circle, this function might
/// return true if the point was inside the circle and false
/// otherwise.
bool hitTest(Size size, Point position) => true;
bool hitTest(Size size, Offset position) => true;
/// Returns a [BoxPainter] that will paint this decoration.
///

View file

@ -174,7 +174,7 @@ class FlutterLogoDecoration extends Decoration {
@override
// TODO(ianh): better hit testing
bool hitTest(Size size, Point position) => true;
bool hitTest(Size size, Offset position) => true;
@override
BoxPainter createBoxPainter([VoidCallback onChanged]) {
@ -275,10 +275,8 @@ class _FlutterLogoPainter extends BoxPainter {
..color = _config.darkColor;
final ui.Gradient triangleGradient = new ui.Gradient.linear(
const <Point>[
const Point(87.2623 + 37.9092, 28.8384 + 123.4389),
const Point(42.9205 + 37.9092, 35.0952 + 123.4389),
],
const Offset(87.2623 + 37.9092, 28.8384 + 123.4389),
const Offset(42.9205 + 37.9092, 35.0952 + 123.4389),
<Color>[
const Color(0xBFFFFFFF),
const Color(0xBFFCFCFC),
@ -290,17 +288,15 @@ class _FlutterLogoPainter extends BoxPainter {
const Color(0xBF6E6E6E),
const Color(0xBF616161),
],
<double>[ 0.2690, 0.4093, 0.4972, 0.5708, 0.6364, 0.6968, 0.7533, 0.8058, 0.8219 ]
<double>[ 0.2690, 0.4093, 0.4972, 0.5708, 0.6364, 0.6968, 0.7533, 0.8058, 0.8219 ],
);
final Paint trianglePaint = new Paint()
..shader = triangleGradient
..blendMode = BlendMode.multiply;
final ui.Gradient rectangleGradient = new ui.Gradient.linear(
const <Point>[
const Point(62.3643 + 37.9092, 40.135 + 123.4389),
const Point(54.0376 + 37.9092, 31.8083 + 123.4389),
],
const Offset(62.3643 + 37.9092, 40.135 + 123.4389),
const Offset(54.0376 + 37.9092, 31.8083 + 123.4389),
<Color>[
const Color(0x80FFFFFF),
const Color(0x80FCFCFC),
@ -440,11 +436,11 @@ class _FlutterLogoPainter extends BoxPainter {
);
canvas.save();
if (_config._position < 1.0) {
final Point center = logoSquare.center;
final Offset center = logoSquare.center;
final Path path = new Path()
..moveTo(center.x, center.y)
..lineTo(center.x + rect.width, center.y - rect.width)
..lineTo(center.x + rect.width, center.y + rect.width)
..moveTo(center.dx, center.dy)
..lineTo(center.dx + rect.width, center.dy - rect.width)
..lineTo(center.dx + rect.width, center.dy + rect.width)
..close();
canvas.clipPath(path);
}
@ -462,7 +458,7 @@ class _FlutterLogoPainter extends BoxPainter {
canvas.save();
}
canvas.translate(
logoTargetSquare.center.x - (_textBoundingRect.width * scale / 2.0),
logoTargetSquare.center.dx - (_textBoundingRect.width * scale / 2.0),
logoTargetSquare.bottom
);
canvas.scale(scale, scale);
@ -471,7 +467,8 @@ class _FlutterLogoPainter extends BoxPainter {
canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint()
..blendMode = BlendMode.modulate
..shader = new ui.Gradient.linear(
<Point>[new Point(_textBoundingRect.width * -0.5, 0.0), new Point(_textBoundingRect.width * 1.5, 0.0)],
new Offset(_textBoundingRect.width * -0.5, 0.0),
new Offset(_textBoundingRect.width * 1.5, 0.0),
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF), const Color(0x00FFFFFF), const Color(0x00FFFFFF)],
<double>[ 0.0, math.max(0.0, _config._position.abs() - 0.1), math.min(_config._position.abs() + 0.1, 1.0), 1.0 ],
)

View file

@ -103,8 +103,8 @@ class FractionalOffset {
}
/// Returns the point that is this fraction within the given rect.
Point withinRect(Rect rect) {
return new Point(rect.left + dx * rect.width, rect.top + dy * rect.height);
Offset withinRect(Rect rect) {
return new Offset(rect.left + dx * rect.width, rect.top + dy * rect.height);
}
/// Returns a rect of the given size, centered at this fraction of the given rect.

View file

@ -94,10 +94,10 @@ class MatrixUtils {
///
/// This function assumes the given point has a z-coordinate of 0.0. The
/// z-coordinate of the result is ignored.
static Point transformPoint(Matrix4 transform, Point point) {
final Vector3 position3 = new Vector3(point.x, point.y, 0.0);
static Offset transformPoint(Matrix4 transform, Offset point) {
final Vector3 position3 = new Vector3(point.dx, point.dy, 0.0);
final Vector3 transformed3 = transform.perspectiveTransform(position3);
return new Point(transformed3.x, transformed3.y);
return new Offset(transformed3.x, transformed3.y);
}
/// Returns a rect that bounds the result of applying the given matrix as a
@ -107,15 +107,15 @@ class MatrixUtils {
/// The transformed rect is then projected back into the plane with z equals
/// 0.0 before computing its bounding rect.
static Rect transformRect(Matrix4 transform, Rect rect) {
final Point point1 = transformPoint(transform, rect.topLeft);
final Point point2 = transformPoint(transform, rect.topRight);
final Point point3 = transformPoint(transform, rect.bottomLeft);
final Point point4 = transformPoint(transform, rect.bottomRight);
final Offset point1 = transformPoint(transform, rect.topLeft);
final Offset point2 = transformPoint(transform, rect.topRight);
final Offset point3 = transformPoint(transform, rect.bottomLeft);
final Offset point4 = transformPoint(transform, rect.bottomRight);
return new Rect.fromLTRB(
_min4(point1.x, point2.x, point3.x, point4.x),
_min4(point1.y, point2.y, point3.y, point4.y),
_max4(point1.x, point2.x, point3.x, point4.x),
_max4(point1.y, point2.y, point3.y, point4.y)
_min4(point1.dx, point2.dx, point3.dx, point4.dx),
_min4(point1.dy, point2.dy, point3.dy, point4.dy),
_max4(point1.dx, point2.dx, point3.dx, point4.dx),
_max4(point1.dy, point2.dy, point3.dy, point4.dy)
);
}

View file

@ -153,7 +153,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
@override
void paint(PaintingContext context, Offset offset) {
if (child != null && _hasVisualOverflow) {
final Rect rect = Point.origin & size;
final Rect rect = Offset.zero & size;
context.pushClipRect(needsCompositing, offset, rect, super.paint);
} else {
super.paint(context, offset);

View file

@ -243,7 +243,7 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
}
@override
void hitTest(HitTestResult result, Point position) {
void hitTest(HitTestResult result, Offset position) {
assert(renderView != null);
renderView.hitTest(result, position: position);
// This super call is safe since it will be bound to a mixed-in declaration.

View file

@ -242,7 +242,7 @@ class RenderListBody extends RenderBox
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return defaultHitTestChildren(result, position: position);
}

View file

@ -509,7 +509,7 @@ class BoxHitTestEntry extends HitTestEntry {
RenderBox get target => super.target;
/// The position of the hit test in the local coordinates of [target].
final Point localPosition;
final Offset localPosition;
@override
String toString() => '${target.runtimeType}#${target.hashCode}@$localPosition';
@ -899,7 +899,7 @@ class _IntrinsicDimensionsCacheEntry {
/// [hitTestChildren]. When implementing hit testing, you can either override
/// these latter two methods, or ignore them and just override [hitTest].
///
/// The [hitTest] method itself is given a [Point], and must return true if the
/// The [hitTest] method itself is given an [Offset], and must return true if the
/// object or one of its children has absorbed the hit (preventing objects below
/// this one from being hit), or false if the hit can continue to other objects
/// below this one.
@ -1424,7 +1424,7 @@ abstract class RenderBox extends RenderObject {
}
@override
Rect get semanticBounds => Point.origin & size;
Rect get semanticBounds => Offset.zero & size;
@override
void debugResetSize() {
@ -1691,7 +1691,7 @@ abstract class RenderBox extends RenderObject {
/// called. For example, a render object might be a child of a [RenderOpacity]
/// object, which calls [hitTest] on its children when its opacity is zero
/// even through it does not [paint] its children.
bool hitTest(HitTestResult result, { @required Point position }) {
bool hitTest(HitTestResult result, { @required Offset position }) {
assert(() {
if (!hasSize) {
if (debugNeedsLayout) {
@ -1719,8 +1719,7 @@ abstract class RenderBox extends RenderObject {
}
return true;
});
if (position.x >= 0.0 && position.x < _size.width &&
position.y >= 0.0 && position.y < _size.height) {
if (_size.contains(position)) {
if (hitTestChildren(result, position: position) || hitTestSelf(position)) {
result.add(new BoxHitTestEntry(this, position));
return true;
@ -1735,7 +1734,7 @@ abstract class RenderBox extends RenderObject {
/// Used by [hitTest]. If you override [hitTest] and do not call this
/// function, then you don't need to implement this function.
@protected
bool hitTestSelf(Point position) => false;
bool hitTestSelf(Offset position) => false;
/// Override this method to check whether any children are located at the
/// given position.
@ -1747,7 +1746,7 @@ abstract class RenderBox extends RenderObject {
/// Used by [hitTest]. If you override [hitTest] and do not call this
/// function, then you don't need to implement this function.
@protected
bool hitTestChildren(HitTestResult result, { Point position }) => false;
bool hitTestChildren(HitTestResult result, { Offset position }) => false;
/// Multiply the transform from the parent's coordinate system to this box's
/// coordinate system into the given transform.
@ -1808,16 +1807,16 @@ abstract class RenderBox extends RenderObject {
/// coordinate system for this box.
///
/// If the transform from global coordinates to local coordinates is
/// degenerate, this function returns [Point.origin].
/// degenerate, this function returns [Offset.zero].
///
/// If `ancestor` is non-null, this function converts the given point from the
/// coordinate system of `ancestor` (which must be an ancestor of this render
/// object) instead of from the global coordinate system.
Point globalToLocal(Point point, { RenderObject ancestor }) {
Offset globalToLocal(Offset point, { RenderObject ancestor }) {
final Matrix4 transform = getTransformTo(ancestor);
final double det = transform.invert();
if (det == 0.0)
return Point.origin;
return Offset.zero;
return MatrixUtils.transformPoint(transform, point);
}
@ -1827,7 +1826,7 @@ abstract class RenderBox extends RenderObject {
/// If `ancestor` is non-null, this function converts the given point to the
/// coordinate system of `ancestor` (which must be an ancestor of this render
/// object) instead of to the global coordinate system.
Point localToGlobal(Point point, { RenderObject ancestor }) {
Offset localToGlobal(Offset point, { RenderObject ancestor }) {
return MatrixUtils.transformPoint(getTransformTo(ancestor), point);
}
@ -1845,7 +1844,7 @@ abstract class RenderBox extends RenderObject {
///
/// The returned paint bounds are in the local coordinate system of this box.
@override
Rect get paintBounds => Point.origin & size;
Rect get paintBounds => Offset.zero & size;
/// Override this method to handle pointer events that hit this render object.
///
@ -2039,14 +2038,12 @@ abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare
///
/// Stops walking once after the first child reports that it contains the
/// given point. Returns whether any children contain the given point.
bool defaultHitTestChildren(HitTestResult result, { Point position }) {
bool defaultHitTestChildren(HitTestResult result, { Offset position }) {
// the x, y parameters have the top left of the node's box as the origin
ChildType child = lastChild;
while (child != null) {
final ParentDataType childParentData = child.parentData;
final Point transformed = new Point(position.x - childParentData.offset.dx,
position.y - childParentData.offset.dy);
if (child.hitTest(result, position: transformed))
if (child.hitTest(result, position: position - childParentData.offset))
return true;
child = childParentData.previousSibling;
}

View file

@ -344,7 +344,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return defaultHitTestChildren(result, position: position);
}
}

View file

@ -36,7 +36,7 @@ class TextSelectionPoint {
}
/// Screen coordinates of the lower left or lower right corner of the selection.
final Point point;
final Offset point;
/// Direction of the text at this edge of the selection.
final TextDirection direction;
@ -271,12 +271,12 @@ class RenderEditable extends RenderBox {
if (selection.isCollapsed) {
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
final Offset caretOffset = _textPainter.getOffsetForCaret(selection.extent, _caretPrototype);
final Point start = new Point(0.0, _preferredLineHeight) + caretOffset + paintOffset;
final Offset start = new Offset(0.0, _preferredLineHeight) + caretOffset + paintOffset;
return <TextSelectionPoint>[new TextSelectionPoint(localToGlobal(start), null)];
} else {
final List<ui.TextBox> boxes = _textPainter.getBoxesForSelection(selection);
final Point start = new Point(boxes.first.start, boxes.first.bottom) + paintOffset;
final Point end = new Point(boxes.last.end, boxes.last.bottom) + paintOffset;
final Offset start = new Offset(boxes.first.start, boxes.first.bottom) + paintOffset;
final Offset end = new Offset(boxes.last.end, boxes.last.bottom) + paintOffset;
return <TextSelectionPoint>[
new TextSelectionPoint(localToGlobal(start), boxes.first.direction),
new TextSelectionPoint(localToGlobal(end), boxes.last.direction),
@ -285,9 +285,9 @@ class RenderEditable extends RenderBox {
}
/// Returns the position in the text for the given global coordinate.
TextPosition getPositionForPoint(Point globalPosition) {
TextPosition getPositionForPoint(Offset globalPosition) {
globalPosition += -_paintOffset;
return _textPainter.getPositionForOffset(globalToLocal(globalPosition).toOffset());
return _textPainter.getPositionForOffset(globalToLocal(globalPosition));
}
/// Returns the Rect in local coordinates for the caret at the given text
@ -311,7 +311,7 @@ class RenderEditable extends RenderBox {
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
TapGestureRecognizer _tap;
LongPressGestureRecognizer _longPress;
@ -325,18 +325,18 @@ class RenderEditable extends RenderBox {
}
}
Point _lastTapDownPosition;
Point _longPressPosition;
Offset _lastTapDownPosition;
Offset _longPressPosition;
void _handleTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition + -_paintOffset;
}
void _handleTap() {
assert(_lastTapDownPosition != null);
final Point globalPosition = _lastTapDownPosition;
final Offset globalPosition = _lastTapDownPosition;
_lastTapDownPosition = null;
if (onSelectionChanged != null) {
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition).toOffset());
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition));
onSelectionChanged(new TextSelection.fromPosition(position), this, false);
}
}
@ -348,10 +348,10 @@ class RenderEditable extends RenderBox {
}
void _handleLongPress() {
final Point globalPosition = _longPressPosition;
final Offset globalPosition = _longPressPosition;
_longPressPosition = null;
if (onSelectionChanged != null) {
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition).toOffset());
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition));
onSelectionChanged(_selectWordAtOffset(position), this, true);
}
}
@ -419,13 +419,13 @@ class RenderEditable extends RenderBox {
@override
void paint(PaintingContext context, Offset offset) {
if (_hasVisualOverflow)
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintContents);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents);
else
_paintContents(context, offset);
}
@override
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Point.origin & size : null;
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
@override
void debugFillDescription(List<String> description) {

View file

@ -73,7 +73,7 @@ class RenderErrorBox extends RenderBox {
bool get sizedByParent => true;
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void performResize() {

View file

@ -681,7 +681,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return defaultHitTestChildren(result, position: position);
}
@ -693,7 +693,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
// We have overflow. Clip it.
context.pushClipRect(needsCompositing, offset, Point.origin & size, defaultPaint);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
assert(() {
// In debug mode, if you have overflow, we highlight where the
@ -729,7 +729,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
@override
Rect describeApproximatePaintClip(RenderObject child) => _overflow > 0.0 ? Point.origin & size : null;
Rect describeApproximatePaintClip(RenderObject child) => _overflow > 0.0 ? Offset.zero & size : null;
@override
String toString() {

View file

@ -364,11 +364,11 @@ class RenderFlow extends RenderBox
@override
void paint(PaintingContext context, Offset offset) {
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintWithDelegate);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintWithDelegate);
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
final List<RenderBox> children = getChildrenAsList();
for (int i = _lastPaintOrder.length - 1; i >= 0; --i) {
final int childIndex = _lastPaintOrder[i];
@ -386,7 +386,7 @@ class RenderFlow extends RenderBox
// on screen and cannot be hit.
continue;
}
final Point childPosition = MatrixUtils.transformPoint(inverse, position);
final Offset childPosition = MatrixUtils.transformPoint(inverse, position);
if (child.hitTest(result, position: childPosition))
return true;
}

View file

@ -216,7 +216,7 @@ class RenderImage extends RenderBox {
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void performLayout() {

View file

@ -1249,7 +1249,7 @@ class PipelineOwner {
///
/// The general behaviour of your hit-testing method should be similar to the
/// behavior described for [RenderBox]. The main difference is that the input
/// need not be a [Point]. You are also allowed to use a different subclass of
/// need not be an [Offset]. You are also allowed to use a different subclass of
/// [HitTestEntry] when adding entries to the [HitTestResult]. When the
/// [handleEvent] method is called, the same object that was added to the
/// [HitTestResult] will be passed in, so it can be used to track information
@ -2480,7 +2480,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
// (with the signature being whatever passes for coordinates for this
// particular class):
//
// bool hitTest(HitTestResult result, { Point position }) {
// bool hitTest(HitTestResult result, { Offset position }) {
// // If the given position is not inside this node, then return false.
// // Otherwise:
// // For each child that intersects the position, in z-order starting from

View file

@ -172,7 +172,7 @@ class RenderParagraph extends RenderBox {
}
@override
bool hitTestSelf(Point position) => true;
bool hitTestSelf(Offset position) => true;
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
@ -180,7 +180,7 @@ class RenderParagraph extends RenderBox {
if (event is! PointerDownEvent)
return;
_layoutTextWithConstraints(constraints);
final Offset offset = entry.localPosition.toOffset();
final Offset offset = entry.localPosition;
final TextPosition position = _textPainter.getPositionForOffset(offset);
final TextSpan span = _textPainter.text.getSpanForPosition(position);
span?.recognizer?.addPointer(event);
@ -222,15 +222,17 @@ class RenderParagraph extends RenderBox {
final double fadeStart = fadeEnd - fadeSizePainter.width;
// TODO(abarth): This shader has an LTR bias.
_overflowShader = new ui.Gradient.linear(
<Point>[new Point(fadeStart, 0.0), new Point(fadeEnd, 0.0)],
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)]
new Offset(fadeStart, 0.0),
new Offset(fadeEnd, 0.0),
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)],
);
} else {
final double fadeEnd = size.height;
final double fadeStart = fadeEnd - fadeSizePainter.height / 2.0;
_overflowShader = new ui.Gradient.linear(
<Point>[new Point(0.0, fadeStart), new Point(0.0, fadeEnd)],
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)]
new Offset(0.0, fadeStart),
new Offset(0.0, fadeEnd),
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)],
);
}
break;
@ -279,7 +281,7 @@ class RenderParagraph extends RenderBox {
final Paint paint = new Paint()
..blendMode = BlendMode.modulate
..shader = _overflowShader;
canvas.drawRect(Point.origin & size, paint);
canvas.drawRect(Offset.zero & size, paint);
}
canvas.restore();
}

View file

@ -105,7 +105,7 @@ abstract class RenderProxyBoxMixin implements RenderBox, RenderObjectWithChildMi
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return child?.hitTest(result, position: position) ?? false;
}
@ -150,10 +150,9 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox {
HitTestBehavior behavior;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
bool hitTarget = false;
if (position.x >= 0.0 && position.x < size.width &&
position.y >= 0.0 && position.y < size.height) {
if (size.contains(position)) {
hitTarget = hitTestChildren(result, position: position) || hitTestSelf(position);
if (hitTarget || behavior == HitTestBehavior.translucent)
result.add(new BoxHitTestEntry(this, position));
@ -162,7 +161,7 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox {
}
@override
bool hitTestSelf(Point position) => behavior == HitTestBehavior.opaque;
bool hitTestSelf(Offset position) => behavior == HitTestBehavior.opaque;
@override
void debugFillDescription(List<String> description) {
@ -821,7 +820,7 @@ class RenderShaderMask extends RenderProxyBox {
void paint(PaintingContext context, Offset offset) {
if (child != null) {
assert(needsCompositing);
final Rect rect = Point.origin & size;
final Rect rect = Offset.zero & size;
context.pushShaderMask(offset, _shaderCallback(rect), rect, _blendMode, super.paint);
}
}
@ -908,7 +907,7 @@ abstract class CustomClipper<T> {
/// the RenderObject. If getClip returns a shape that is roughly the
/// same size as the RenderObject (e.g. it's a rounded rectangle
/// with very small arcs in the corners), then this may be adequate.
Rect getApproximateClipRect(Size size) => Point.origin & size;
Rect getApproximateClipRect(Size size) => Offset.zero & size;
/// Called whenever a new instance of the custom clipper delegate class is
/// provided to the clip object, or any time that a new clip object is created
@ -989,7 +988,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
@override
Rect describeApproximatePaintClip(RenderObject child) {
return _clipper?.getApproximateClipRect(size) ?? Point.origin & size;
return _clipper?.getApproximateClipRect(size) ?? Offset.zero & size;
}
}
@ -1009,10 +1008,10 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
}) : super(child: child, clipper: clipper);
@override
Rect get _defaultClip => Point.origin & size;
Rect get _defaultClip => Offset.zero & size;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (_clipper != null) {
_updateClip();
assert(_clip != null);
@ -1068,10 +1067,10 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
}
@override
RRect get _defaultClip => _borderRadius.toRRect(Point.origin & size);
RRect get _defaultClip => _borderRadius.toRRect(Offset.zero & size);
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (_clipper != null) {
_updateClip();
assert(_clip != null);
@ -1117,16 +1116,16 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
}
@override
Rect get _defaultClip => Point.origin & size;
Rect get _defaultClip => Offset.zero & size;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
_updateClip();
assert(_clip != null);
final Point center = _clip.center;
final Offset center = _clip.center;
// convert the position to an offset from the center of the unit circle
final Offset offset = new Offset((position.x - center.x) / _clip.width,
(position.y - center.y) / _clip.height);
final Offset offset = new Offset((position.dx - center.dx) / _clip.width,
(position.dy - center.dy) / _clip.height);
// check if the point is outside the unit circle
if (offset.distanceSquared > 0.25) // x^2 + y^2 > r^2
return false;
@ -1166,10 +1165,10 @@ class RenderClipPath extends _RenderCustomClip<Path> {
}) : super(child: child, clipper: clipper);
@override
Path get _defaultClip => new Path()..addRect(Point.origin & size);
Path get _defaultClip => new Path()..addRect(Offset.zero & size);
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (_clipper != null) {
_updateClip();
assert(_clip != null);
@ -1183,7 +1182,7 @@ class RenderClipPath extends _RenderCustomClip<Path> {
void paint(PaintingContext context, Offset offset) {
if (child != null) {
_updateClip();
context.pushClipPath(needsCompositing, offset, Point.origin & size, _clip, super.paint);
context.pushClipPath(needsCompositing, offset, Offset.zero & size, _clip, super.paint);
}
}
}
@ -1260,15 +1259,15 @@ class RenderPhysicalModel extends _RenderCustomClip<RRect> {
@override
RRect get _defaultClip {
if (_shape == BoxShape.rectangle) {
return _borderRadius.toRRect(Point.origin & size);
return _borderRadius.toRRect(Offset.zero & size);
} else {
final Rect rect = Point.origin & size;
final Rect rect = Offset.zero & size;
return new RRect.fromRectXY(rect, rect.width / 2, rect.height / 2);
}
}
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (_clipper != null) {
_updateClip();
assert(_clip != null);
@ -1368,7 +1367,7 @@ class RenderDecoratedBox extends RenderProxyBox {
}
@override
bool hitTestSelf(Point position) {
bool hitTestSelf(Offset position) {
return _decoration.hitTest(size, position);
}
@ -1543,7 +1542,7 @@ class RenderTransform extends RenderProxyBox {
}
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (transformHitTests) {
Matrix4 inverse;
try {
@ -1660,8 +1659,8 @@ class RenderFittedBox extends RenderProxyBox {
final FittedSizes sizes = applyBoxFit(_fit, childSize, size);
final double scaleX = sizes.destination.width / sizes.source.width;
final double scaleY = sizes.destination.height / sizes.source.height;
final Rect sourceRect = _alignment.inscribe(sizes.source, Point.origin & childSize);
final Rect destinationRect = _alignment.inscribe(sizes.destination, Point.origin & size);
final Rect sourceRect = _alignment.inscribe(sizes.source, Offset.zero & childSize);
final Rect destinationRect = _alignment.inscribe(sizes.destination, Offset.zero & size);
_hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.width;
_transform = new Matrix4.translationValues(destinationRect.left, destinationRect.top, 0.0)
..scale(scaleX, scaleY, 1.0)
@ -1684,14 +1683,14 @@ class RenderFittedBox extends RenderProxyBox {
_updatePaintData();
if (child != null) {
if (_hasVisualOverflow)
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintChildWithTransform);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintChildWithTransform);
else
_paintChildWithTransform(context, offset);
}
}
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
_updatePaintData();
Matrix4 inverse;
try {
@ -1758,10 +1757,10 @@ class RenderFractionalTranslation extends RenderProxyBox {
bool transformHitTests;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
assert(!debugNeedsLayout);
if (transformHitTests)
position = new Point(position.x - translation.dx * size.width, position.y - translation.dy * size.height);
position = new Offset(position.dx - translation.dx * size.width, position.dy - translation.dy * size.height);
return super.hitTest(result, position: position);
}
@ -1882,7 +1881,7 @@ abstract class CustomPainter {
/// image that should be considered a "hit", false if it corresponds to a
/// point that should be considered outside the painted image, and null to use
/// the default behavior.
bool hitTest(Point position) => null;
bool hitTest(Offset position) => null;
@override
String toString() => '$runtimeType#$hashCode';
@ -2024,14 +2023,14 @@ class RenderCustomPaint extends RenderProxyBox {
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
if (_foregroundPainter != null && (_foregroundPainter.hitTest(position) ?? false))
return true;
return super.hitTestChildren(result, position: position);
}
@override
bool hitTestSelf(Point position) {
bool hitTestSelf(Offset position) {
return _painter != null && (_painter.hitTest(position) ?? true);
}
@ -2361,7 +2360,7 @@ class RenderIgnorePointer extends RenderProxyBox {
bool get _effectiveIgnoringSemantics => ignoringSemantics == null ? ignoring : ignoringSemantics;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
return ignoring ? false : super.hitTest(result, position: position);
}
@ -2465,7 +2464,7 @@ class RenderOffstage extends RenderProxyBox {
}
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
return !offstage && super.hitTest(result, position: position);
}
@ -2521,7 +2520,7 @@ class RenderAbsorbPointer extends RenderProxyBox {
bool absorbing;
@override
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
return absorbing ? true : super.hitTest(result, position: position);
}
@ -2674,7 +2673,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
final double primaryDelta = size.width * -scrollFactor;
onHorizontalDragUpdate(new DragUpdateDetails(
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
globalPosition: localToGlobal(size.center(Point.origin)),
globalPosition: localToGlobal(size.center(Offset.zero)),
));
}
break;
@ -2683,7 +2682,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
final double primaryDelta = size.width * scrollFactor;
onHorizontalDragUpdate(new DragUpdateDetails(
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
globalPosition: localToGlobal(size.center(Point.origin)),
globalPosition: localToGlobal(size.center(Offset.zero)),
));
}
break;
@ -2692,7 +2691,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
final double primaryDelta = size.height * -scrollFactor;
onVerticalDragUpdate(new DragUpdateDetails(
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
globalPosition: localToGlobal(size.center(Point.origin)),
globalPosition: localToGlobal(size.center(Offset.zero)),
));
}
break;
@ -2701,7 +2700,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
final double primaryDelta = size.height * scrollFactor;
onVerticalDragUpdate(new DragUpdateDetails(
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
globalPosition: localToGlobal(size.center(Point.origin)),
globalPosition: localToGlobal(size.center(Offset.zero)),
));
}
break;

View file

@ -90,7 +90,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
assert(_paintTransform != null || debugNeedsLayout || child == null);
if (child == null || _paintTransform == null)
return false;

View file

@ -716,7 +716,7 @@ class SemanticsOwner extends ChangeNotifier {
handler?.performAction(action);
}
SemanticsActionHandler _getSemanticsActionHandlerForPosition(SemanticsNode node, Point position, SemanticsAction action) {
SemanticsActionHandler _getSemanticsActionHandlerForPosition(SemanticsNode node, Offset position, SemanticsAction action) {
if (node.transform != null) {
final Matrix4 inverse = new Matrix4.identity();
if (inverse.copyInverse(node.transform) == 0.0)
@ -750,7 +750,7 @@ class SemanticsOwner extends ChangeNotifier {
///
/// If the [SemanticsNode] has not indicated that it can perform the action,
/// this function does nothing.
void performActionAt(Point position, SemanticsAction action) {
void performActionAt(Offset position, SemanticsAction action) {
assert(action != null);
final SemanticsNode node = rootSemanticsNode;
if (node == null)

View file

@ -70,12 +70,10 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
if (child != null) {
final BoxParentData childParentData = child.parentData;
final Point childPosition = new Point(position.x - childParentData.offset.dx,
position.y - childParentData.offset.dy);
return child.hitTest(result, position: childPosition);
return child.hitTest(result, position: position - childParentData.offset);
}
return false;
}

View file

@ -1014,13 +1014,13 @@ abstract class RenderSliver extends RenderObject {
return null;
}
void _debugDrawArrow(Canvas canvas, Paint paint, Point p0, Point p1, GrowthDirection direction) {
void _debugDrawArrow(Canvas canvas, Paint paint, Offset p0, Offset p1, GrowthDirection direction) {
assert(() {
if (p0 == p1)
return true;
assert(p0.x == p1.x || p0.y == p1.y); // must be axis-aligned
assert(p0.dx == p1.dx || p0.dy == p1.dy); // must be axis-aligned
final double d = (p1 - p0).distance * 0.2;
Point temp;
Offset temp;
double dx1, dx2, dy1, dy2;
switch (direction) {
case GrowthDirection.forward:
@ -1033,18 +1033,18 @@ abstract class RenderSliver extends RenderObject {
dx1 = dx2 = dy1 = dy2 = -d;
break;
}
if (p0.x == p1.x) {
if (p0.dx == p1.dx) {
dx2 = -dx2;
} else {
dy2 = -dy2;
}
canvas.drawPath(
new Path()
..moveTo(p0.x, p0.y)
..lineTo(p1.x, p1.y)
..moveTo(p1.x - dx1, p1.y - dy1)
..lineTo(p1.x, p1.y)
..lineTo(p1.x - dx2, p1.y - dy2),
..moveTo(p0.dx, p0.dy)
..lineTo(p1.dx, p1.dy)
..moveTo(p1.dx - dx1, p1.dy - dy1)
..lineTo(p1.dx, p1.dy)
..lineTo(p1.dx - dx2, p1.dy - dy2),
paint
);
return true;
@ -1065,50 +1065,50 @@ abstract class RenderSliver extends RenderObject {
final double padding = math.max(2.0, strokeWidth);
final Canvas canvas = context.canvas;
canvas.drawCircle(
offset.translate(padding, padding).toPoint(),
offset.translate(padding, padding),
padding * 0.5,
paint,
);
switch (constraints.axis) {
case Axis.vertical:
canvas.drawLine(
offset.toPoint(),
offset.translate(constraints.crossAxisExtent, 0.0).toPoint(),
offset,
offset.translate(constraints.crossAxisExtent, 0.0),
paint,
);
_debugDrawArrow(
canvas,
paint,
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, padding).toPoint(),
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, arrowExtent - padding).toPoint(),
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, padding),
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, arrowExtent - padding),
constraints.normalizedGrowthDirection,
);
_debugDrawArrow(
canvas,
paint,
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, padding).toPoint(),
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, arrowExtent - padding).toPoint(),
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, padding),
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, arrowExtent - padding),
constraints.normalizedGrowthDirection,
);
break;
case Axis.horizontal:
canvas.drawLine(
offset.toPoint(),
offset.translate(0.0, constraints.crossAxisExtent).toPoint(),
offset,
offset.translate(0.0, constraints.crossAxisExtent),
paint,
);
_debugDrawArrow(
canvas,
paint,
offset.translate(padding, constraints.crossAxisExtent * 1.0 / 4.0).toPoint(),
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 1.0 / 4.0).toPoint(),
offset.translate(padding, constraints.crossAxisExtent * 1.0 / 4.0),
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 1.0 / 4.0),
constraints.normalizedGrowthDirection,
);
_debugDrawArrow(
canvas,
paint,
offset.translate(padding, constraints.crossAxisExtent * 3.0 / 4.0).toPoint(),
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 3.0 / 4.0).toPoint(),
offset.translate(padding, constraints.crossAxisExtent * 3.0 / 4.0),
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 3.0 / 4.0),
constraints.normalizedGrowthDirection,
);
break;
@ -1177,11 +1177,11 @@ abstract class RenderSliverHelpers implements RenderSliver {
case Axis.horizontal:
if (!rightWayUp)
absolutePosition = child.size.width - absolutePosition;
return child.hitTest(result, position: new Point(absolutePosition, absoluteCrossAxisPosition));
return child.hitTest(result, position: new Offset(absolutePosition, absoluteCrossAxisPosition));
case Axis.vertical:
if (!rightWayUp)
absolutePosition = child.size.height - absolutePosition;
return child.hitTest(result, position: new Point(absoluteCrossAxisPosition, absolutePosition));
return child.hitTest(result, position: new Offset(absoluteCrossAxisPosition, absolutePosition));
}
return false;
}

View file

@ -420,7 +420,7 @@ class RenderStack extends RenderBox
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return defaultHitTestChildren(result, position: position);
}
@ -436,14 +436,14 @@ class RenderStack extends RenderBox
@override
void paint(PaintingContext context, Offset offset) {
if (_overflow == Overflow.clip && _hasVisualOverflow) {
context.pushClipRect(needsCompositing, offset, Point.origin & size, paintStack);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack);
} else {
paintStack(context, offset);
}
}
@override
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Point.origin & size : null;
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
@override
void debugFillDescription(List<String> description) {
@ -496,15 +496,13 @@ class RenderIndexedStack extends RenderStack {
}
@override
bool hitTestChildren(HitTestResult result, { @required Point position }) {
bool hitTestChildren(HitTestResult result, { @required Offset position }) {
if (firstChild == null || index == null)
return false;
assert(position != null);
final RenderBox child = _childAtIndex();
final StackParentData childParentData = child.parentData;
final Point transformed = new Point(position.x - childParentData.offset.dx,
position.y - childParentData.offset.dy);
return child.hitTest(result, position: transformed);
return child.hitTest(result, position: position - childParentData.offset);
}
@override

View file

@ -1196,15 +1196,13 @@ class RenderTable extends RenderBox {
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
assert(_children.length == rows * columns);
for (int index = _children.length - 1; index >= 0; index -= 1) {
final RenderBox child = _children[index];
if (child != null) {
final BoxParentData childParentData = child.parentData;
final Point transformed = new Point(position.x - childParentData.offset.dx,
position.y - childParentData.offset.dy);
if (child.hitTest(result, position: transformed))
if (child.hitTest(result, position: position - childParentData.offset))
return true;
}
}

View file

@ -126,7 +126,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
/// given hit test result.
///
/// The [position] argument is in the coordinate system of the render view.
bool hitTest(HitTestResult result, { Point position }) {
bool hitTest(HitTestResult result, { Offset position }) {
if (child != null)
child.hitTest(result, position: position);
result.add(new HitTestEntry(this));
@ -164,10 +164,10 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
}
@override
Rect get paintBounds => Point.origin & size;
Rect get paintBounds => Offset.zero & size;
@override
Rect get semanticBounds => Point.origin & size;
Rect get semanticBounds => Offset.zero & size;
@override
void debugFillDescription(List<String> description) {

View file

@ -223,7 +223,7 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
if (firstChild == null)
return;
if (hasVisualOverflow) {
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintContents);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents);
} else {
_paintContents(context, offset);
}
@ -265,16 +265,16 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
double mainAxisPosition, crossAxisPosition;
switch (axis) {
case Axis.vertical:
mainAxisPosition = position.y;
crossAxisPosition = position.x;
mainAxisPosition = position.dy;
crossAxisPosition = position.dx;
break;
case Axis.horizontal:
mainAxisPosition = position.x;
crossAxisPosition = position.y;
mainAxisPosition = position.dx;
crossAxisPosition = position.dy;
break;
}
assert(mainAxisPosition != null);

View file

@ -560,7 +560,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return defaultHitTestChildren(result, position: position);
}
@ -569,7 +569,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
// TODO(ianh): move the debug flex overflow paint logic somewhere common so
// it can be reused here
if (_hasVisualOverflow)
context.pushClipRect(needsCompositing, offset, Point.origin & size, defaultPaint);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
else
defaultPaint(context, offset);
}

View file

@ -99,7 +99,7 @@ class BannerPainter extends CustomPainter {
..drawRect(_kRect, _paintBanner);
final double width = _kOffset * 2.0;
_textPainter.layout(minWidth: width, maxWidth: width);
_textPainter.paint(canvas, _kRect.topLeft.toOffset() + new Offset(0.0, (_kRect.height - _textPainter.height) / 2.0));
_textPainter.paint(canvas, _kRect.topLeft + new Offset(0.0, (_kRect.height - _textPainter.height) / 2.0));
}
@override
@ -111,7 +111,7 @@ class BannerPainter extends CustomPainter {
}
@override
bool hitTest(Point position) => false;
bool hitTest(Offset position) => false;
double _translationX(double width) {
assert(location != null);

View file

@ -234,7 +234,7 @@ class LongPressDraggable<T> extends Draggable<T> {
@override
DelayedMultiDragGestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) {
return new DelayedMultiDragGestureRecognizer()
..onStart = (Point position) {
..onStart = (Offset position) {
final Drag result = onStart(position);
if (result != null)
HapticFeedback.vibrate();
@ -281,17 +281,17 @@ class _DraggableState<T> extends State<Draggable<T>> {
_recognizer.addPointer(event);
}
_DragAvatar<T> _startDrag(Point position) {
_DragAvatar<T> _startDrag(Offset position) {
if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags)
return null;
Point dragStartPoint;
Offset dragStartPoint;
switch (widget.dragAnchor) {
case DragAnchor.child:
final RenderBox renderObject = context.findRenderObject();
dragStartPoint = renderObject.globalToLocal(position);
break;
case DragAnchor.pointer:
dragStartPoint = Point.origin;
dragStartPoint = Offset.zero;
break;
}
setState(() {
@ -439,8 +439,8 @@ class _DragAvatar<T> extends Drag {
_DragAvatar({
@required this.overlayState,
this.data,
Point initialPosition,
this.dragStartPoint: Point.origin,
Offset initialPosition,
this.dragStartPoint: Offset.zero,
this.feedback,
this.feedbackOffset: Offset.zero,
this.onDragEnd
@ -455,7 +455,7 @@ class _DragAvatar<T> extends Drag {
}
final T data;
final Point dragStartPoint;
final Offset dragStartPoint;
final Widget feedback;
final Offset feedbackOffset;
final _OnDragEnd onDragEnd;
@ -463,7 +463,7 @@ class _DragAvatar<T> extends Drag {
_DragTargetState<T> _activeTarget;
final List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
Point _position;
Offset _position;
Offset _lastOffset;
OverlayEntry _entry;
@ -483,7 +483,7 @@ class _DragAvatar<T> extends Drag {
finishDrag(_DragEndKind.canceled);
}
void updateDrag(Point globalPosition) {
void updateDrag(Offset globalPosition) {
_lastOffset = globalPosition - dragStartPoint;
_entry.markNeedsBuild();
final HitTestResult result = new HitTestResult();
@ -558,10 +558,10 @@ class _DragAvatar<T> extends Drag {
Widget _build(BuildContext context) {
final RenderBox box = overlayState.context.findRenderObject();
final Point overlayTopLeft = box.localToGlobal(Point.origin);
final Offset overlayTopLeft = box.localToGlobal(Offset.zero);
return new Positioned(
left: _lastOffset.dx - overlayTopLeft.x,
top: _lastOffset.dy - overlayTopLeft.y,
left: _lastOffset.dx - overlayTopLeft.dx,
top: _lastOffset.dy - overlayTopLeft.dy,
child: new IgnorePointer(
child: feedback
)

View file

@ -27,11 +27,11 @@ class _GridPaperPainter extends CustomPainter {
final double allDivisions = (divisions * subDivisions).toDouble();
for (double x = 0.0; x <= size.width; x += interval / allDivisions) {
linePaint.strokeWidth = (x % interval == 0.0) ? 1.0 : (x % (interval / subDivisions) == 0.0) ? 0.5: 0.25;
canvas.drawLine(new Point(x, 0.0), new Point(x, size.height), linePaint);
canvas.drawLine(new Offset(x, 0.0), new Offset(x, size.height), linePaint);
}
for (double y = 0.0; y <= size.height; y += interval / allDivisions) {
linePaint.strokeWidth = (y % interval == 0.0) ? 1.0 : (y % (interval / subDivisions) == 0.0) ? 0.5: 0.25;
canvas.drawLine(new Point(0.0, y), new Point(size.width, y), linePaint);
canvas.drawLine(new Offset(0.0, y), new Offset(size.width, y), linePaint);
}
}
@ -44,7 +44,7 @@ class _GridPaperPainter extends CustomPainter {
}
@override
bool hitTest(Point position) => false;
bool hitTest(Offset position) => false;
}
/// A widget that draws a rectilinear grid of 1px wide lines.

View file

@ -31,7 +31,7 @@ enum _HeroFlightType {
Rect _globalRect(BuildContext context) {
final RenderBox box = context.findRenderObject();
assert(box != null && box.hasSize);
return MatrixUtils.transformRect(box.getTransformTo(null), Point.origin & box.size);
return MatrixUtils.transformRect(box.getTransformTo(null), Offset.zero & box.size);
}
/// A widget that marks its child as being a candidate for hero animations.
@ -250,7 +250,7 @@ class _HeroFlight {
// The toHero has been laid out. If it's no longer where the hero animation is
// supposed to end up (heroRect.end) then recreate the heroRect tween.
final RenderBox routeBox = manifest.toRoute.subtreeContext?.findRenderObject();
final Point heroOriginEnd = toHeroBox.localToGlobal(Point.origin, ancestor: routeBox);
final Offset heroOriginEnd = toHeroBox.localToGlobal(Offset.zero, ancestor: routeBox);
if (heroOriginEnd != heroRect.end.topLeft) {
final Rect heroRectEnd = heroOriginEnd & heroRect.end.size;
heroRect = _doCreateRectTween(heroRect.begin, heroRectEnd);

View file

@ -214,7 +214,7 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin<Ren
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
return child?.hitTest(result, position: position) ?? false;
}

View file

@ -165,13 +165,13 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
assert(renderer != null);
assert(renderer.hasSize);
final Size size = renderer.size;
final Point position = renderer.globalToLocal(notification.dragDetails.globalPosition);
final Offset position = renderer.globalToLocal(notification.dragDetails.globalPosition);
switch (notification.axis) {
case Axis.horizontal:
controller.pull(notification.overscroll.abs(), size.width, position.y.clamp(0.0, size.height), size.height);
controller.pull(notification.overscroll.abs(), size.width, position.dy.clamp(0.0, size.height), size.height);
break;
case Axis.vertical:
controller.pull(notification.overscroll.abs(), size.height, position.x.clamp(0.0, size.width), size.width);
controller.pull(notification.overscroll.abs(), size.height, position.dx.clamp(0.0, size.width), size.width);
break;
}
}
@ -423,7 +423,7 @@ class _GlowController extends ChangeNotifier {
final double height = math.min(size.height, size.width * _kWidthToHeightFactor);
final double scaleY = _glowSize.value * baseGlowScale;
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, height);
final Point center = new Point((size.width / 2.0) * (0.5 + _displacement), height - radius);
final Offset center = new Offset((size.width / 2.0) * (0.5 + _displacement), height - radius);
final Paint paint = new Paint()..color = color.withOpacity(_glowOpacity.value);
canvas.save();
canvas.scale(1.0, scaleY);

View file

@ -68,7 +68,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
});
}
Point _lastPointerDownLocation;
Offset _lastPointerDownLocation;
void _handlePointerDown(PointerDownEvent event) {
setState(() {
_lastPointerDownLocation = event.position;
@ -115,7 +115,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
});
}
void _performAction(Point position, SemanticsAction action) {
void _performAction(Offset position, SemanticsAction action) {
_pipelineOwner.semanticsOwner?.performActionAt(position, action);
}
@ -241,7 +241,7 @@ void _paintMessage(Canvas canvas, SemanticsNode node) {
..text = new TextSpan(style: _messageStyle, text: message)
..layout(maxWidth: rect.width);
textPainter.paint(canvas, FractionalOffset.center.inscribe(textPainter.size, rect).topLeft.toOffset());
textPainter.paint(canvas, FractionalOffset.center.inscribe(textPainter.size, rect).topLeft);
canvas.restore();
}
@ -297,7 +297,7 @@ class _SemanticsDebuggerPainter extends CustomPainter {
final PipelineOwner owner;
final int generation;
final Point pointerPosition;
final Offset pointerPosition;
SemanticsNode get _rootSemanticsNode {
return owner.semanticsOwner?.rootSemanticsNode;

View file

@ -351,7 +351,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
}
if (_shouldClipAtPaintOffset(paintOffset)) {
context.pushClipRect(needsCompositing, offset, Point.origin & size, paintContents);
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintContents);
} else {
paintContents(context, offset);
}
@ -367,14 +367,14 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
@override
Rect describeApproximatePaintClip(RenderObject child) {
if (child != null && _shouldClipAtPaintOffset(_paintOffset))
return Point.origin & size;
return Offset.zero & size;
return null;
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
bool hitTestChildren(HitTestResult result, { Offset position }) {
if (child != null) {
final Point transformed = position + -_paintOffset;
final Offset transformed = position + -_paintOffset;
return child.hitTest(result, position: transformed);
}
return false;

View file

@ -74,7 +74,7 @@ abstract class TextSelectionControls {
///
/// Typically displays buttons for copying and pasting text.
// TODO(mpcomplete): A single position is probably insufficient.
Widget buildToolbar(BuildContext context, Point position, TextSelectionDelegate delegate);
Widget buildToolbar(BuildContext context, Offset position, TextSelectionDelegate delegate);
/// Returns the size of the selection handle.
Size get handleSize;
@ -237,11 +237,11 @@ class TextSelectionOverlay implements TextSelectionDelegate {
// Find the horizontal midpoint, just above the selected text.
final List<TextSelectionPoint> endpoints = renderObject.getEndpointsForSelection(_selection);
final Point midpoint = new Point(
final Offset midpoint = new Offset(
(endpoints.length == 1) ?
endpoints[0].point.x :
(endpoints[0].point.x + endpoints[1].point.x) / 2.0,
endpoints[0].point.y - renderObject.size.height
endpoints[0].point.dx :
(endpoints[0].point.dx + endpoints[1].point.dx) / 2.0,
endpoints[0].point.dy - renderObject.size.height
);
return new FadeTransition(
@ -318,7 +318,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
}
class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {
Point _dragPosition;
Offset _dragPosition;
void _handleDragStart(DragStartDetails details) {
_dragPosition = details.globalPosition + new Offset(0.0, -widget.selectionControls.handleSize.height);
@ -362,7 +362,7 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay
@override
Widget build(BuildContext context) {
final List<TextSelectionPoint> endpoints = widget.renderObject.getEndpointsForSelection(widget.selection);
Point point;
Offset point;
TextSelectionHandleType type;
switch (widget.position) {
@ -386,8 +386,8 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay
child: new Stack(
children: <Widget>[
new Positioned(
left: point.x,
top: point.y,
left: point.dx,
top: point.dy,
child: widget.selectionControls.buildHandle(context, type)
)
]

View file

@ -133,7 +133,7 @@ void main() {
)));
// Keep a "down" gesture on the button
final Point center = tester.getCenter(find.byType(CupertinoButton));
final Offset center = tester.getCenter(find.byType(CupertinoButton));
await tester.startGesture(center);
await tester.pumpAndSettle();
@ -154,7 +154,7 @@ void main() {
)));
// Keep a "down" gesture on the button
final Point center = tester.getCenter(find.byType(CupertinoButton));
final Offset center = tester.getCenter(find.byType(CupertinoButton));
await tester.startGesture(center);
await tester.pumpAndSettle();

View file

@ -66,7 +66,7 @@ void main() {
);
expect(value, equals(0.0));
final Point topLeft = tester.getTopLeft(find.byKey(sliderKey));
final Offset topLeft = tester.getTopLeft(find.byKey(sliderKey));
const double unit = CupertinoThumbPainter.radius;
const double delta = 3.0 * unit;
await tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));

View file

@ -29,61 +29,61 @@ void main() {
// Down/up pair 1: normal tap sequence
const PointerDownEvent down1 = const PointerDownEvent(
pointer: 1,
position: const Point(10.0, 10.0)
position: const Offset(10.0, 10.0)
);
const PointerUpEvent up1 = const PointerUpEvent(
pointer: 1,
position: const Point(11.0, 9.0)
position: const Offset(11.0, 9.0)
);
// Down/up pair 2: normal tap sequence close to pair 1
const PointerDownEvent down2 = const PointerDownEvent(
pointer: 2,
position: const Point(12.0, 12.0)
position: const Offset(12.0, 12.0)
);
const PointerUpEvent up2 = const PointerUpEvent(
pointer: 2,
position: const Point(13.0, 11.0)
position: const Offset(13.0, 11.0)
);
// Down/up pair 3: normal tap sequence far away from pair 1
const PointerDownEvent down3 = const PointerDownEvent(
pointer: 3,
position: const Point(130.0, 130.0)
position: const Offset(130.0, 130.0)
);
const PointerUpEvent up3 = const PointerUpEvent(
pointer: 3,
position: const Point(131.0, 129.0)
position: const Offset(131.0, 129.0)
);
// Down/move/up sequence 4: intervening motion
const PointerDownEvent down4 = const PointerDownEvent(
pointer: 4,
position: const Point(10.0, 10.0)
position: const Offset(10.0, 10.0)
);
const PointerMoveEvent move4 = const PointerMoveEvent(
pointer: 4,
position: const Point(25.0, 25.0)
position: const Offset(25.0, 25.0)
);
const PointerUpEvent up4 = const PointerUpEvent(
pointer: 4,
position: const Point(25.0, 25.0)
position: const Offset(25.0, 25.0)
);
// Down/up pair 5: normal tap sequence identical to pair 1 with different pointer
const PointerDownEvent down5 = const PointerDownEvent(
pointer: 5,
position: const Point(10.0, 10.0)
position: const Offset(10.0, 10.0)
);
const PointerUpEvent up5 = const PointerUpEvent(
pointer: 5,
position: const Point(11.0, 9.0)
position: const Offset(11.0, 9.0)
);
testGesture('Should recognize double tap', (GestureTester tester) {

View file

@ -35,7 +35,7 @@ void main() {
};
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0));
pan.addPointer(down);
tap.addPointer(down);
tester.closeArena(5);
@ -50,7 +50,7 @@ void main() {
expect(didEndPan, isFalse);
expect(didTap, isFalse);
tester.route(pointer.move(const Point(20.0, 20.0)));
tester.route(pointer.move(const Offset(20.0, 20.0)));
expect(didStartPan, isTrue);
didStartPan = false;
expect(updatedScrollDelta, const Offset(10.0, 10.0));
@ -58,7 +58,7 @@ void main() {
expect(didEndPan, isFalse);
expect(didTap, isFalse);
tester.route(pointer.move(const Point(20.0, 25.0)));
tester.route(pointer.move(const Offset(20.0, 25.0)));
expect(didStartPan, isFalse);
expect(updatedScrollDelta, const Offset(0.0, 5.0));
updatedScrollDelta = null;
@ -95,7 +95,7 @@ void main() {
};
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0));
drag.addPointer(down);
tester.closeArena(5);
expect(didStartDrag, isFalse);
@ -107,14 +107,14 @@ void main() {
expect(updatedDelta, isNull);
expect(didEndDrag, isFalse);
tester.route(pointer.move(const Point(20.0, 25.0)));
tester.route(pointer.move(const Offset(20.0, 25.0)));
expect(didStartDrag, isTrue);
didStartDrag = false;
expect(updatedDelta, 10.0);
updatedDelta = null;
expect(didEndDrag, isFalse);
tester.route(pointer.move(const Point(20.0, 25.0)));
tester.route(pointer.move(const Offset(20.0, 25.0)));
expect(didStartDrag, isFalse);
expect(updatedDelta, 0.0);
updatedDelta = null;
@ -140,21 +140,21 @@ void main() {
};
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 25.0), timeStamp: const Duration(milliseconds: 10));
final PointerDownEvent down = pointer.down(const Offset(10.0, 25.0), timeStamp: const Duration(milliseconds: 10));
drag.addPointer(down);
tester.closeArena(5);
tester.route(down);
tester.route(pointer.move(const Point(20.0, 25.0), timeStamp: const Duration(milliseconds: 10)));
tester.route(pointer.move(const Point(30.0, 25.0), timeStamp: const Duration(milliseconds: 11)));
tester.route(pointer.move(const Point(40.0, 25.0), timeStamp: const Duration(milliseconds: 12)));
tester.route(pointer.move(const Point(50.0, 25.0), timeStamp: const Duration(milliseconds: 13)));
tester.route(pointer.move(const Point(60.0, 25.0), timeStamp: const Duration(milliseconds: 14)));
tester.route(pointer.move(const Point(70.0, 25.0), timeStamp: const Duration(milliseconds: 15)));
tester.route(pointer.move(const Point(80.0, 25.0), timeStamp: const Duration(milliseconds: 16)));
tester.route(pointer.move(const Point(90.0, 25.0), timeStamp: const Duration(milliseconds: 17)));
tester.route(pointer.move(const Point(100.0, 25.0), timeStamp: const Duration(milliseconds: 18)));
tester.route(pointer.move(const Point(110.0, 25.0), timeStamp: const Duration(milliseconds: 19)));
tester.route(pointer.move(const Point(120.0, 25.0), timeStamp: const Duration(milliseconds: 20)));
tester.route(pointer.move(const Offset(20.0, 25.0), timeStamp: const Duration(milliseconds: 10)));
tester.route(pointer.move(const Offset(30.0, 25.0), timeStamp: const Duration(milliseconds: 11)));
tester.route(pointer.move(const Offset(40.0, 25.0), timeStamp: const Duration(milliseconds: 12)));
tester.route(pointer.move(const Offset(50.0, 25.0), timeStamp: const Duration(milliseconds: 13)));
tester.route(pointer.move(const Offset(60.0, 25.0), timeStamp: const Duration(milliseconds: 14)));
tester.route(pointer.move(const Offset(70.0, 25.0), timeStamp: const Duration(milliseconds: 15)));
tester.route(pointer.move(const Offset(80.0, 25.0), timeStamp: const Duration(milliseconds: 16)));
tester.route(pointer.move(const Offset(90.0, 25.0), timeStamp: const Duration(milliseconds: 17)));
tester.route(pointer.move(const Offset(100.0, 25.0), timeStamp: const Duration(milliseconds: 18)));
tester.route(pointer.move(const Offset(110.0, 25.0), timeStamp: const Duration(milliseconds: 19)));
tester.route(pointer.move(const Offset(120.0, 25.0), timeStamp: const Duration(milliseconds: 20)));
tester.route(pointer.up(timeStamp: const Duration(milliseconds: 20)));
expect(velocity.pixelsPerSecond.dx, inInclusiveRange(0.99 * kMaxFlingVelocity, kMaxFlingVelocity));
expect(velocity.pixelsPerSecond.dy, moreOrLessEquals(0.0));
@ -166,7 +166,7 @@ void main() {
testGesture('Drag details', (GestureTester tester) {
expect(new DragDownDetails(), hasOneLineDescription);
expect(new DragStartDetails(), hasOneLineDescription);
expect(new DragUpdateDetails(globalPosition: Point.origin), hasOneLineDescription);
expect(new DragUpdateDetails(globalPosition: Offset.zero), hasOneLineDescription);
expect(new DragEndDetails(), hasOneLineDescription);
});
}

View file

@ -9,12 +9,12 @@ import 'gesture_tester.dart';
const PointerDownEvent down = const PointerDownEvent(
pointer: 5,
position: const Point(10.0, 10.0)
position: const Offset(10.0, 10.0)
);
const PointerUpEvent up = const PointerUpEvent(
pointer: 5,
position: const Point(11.0, 9.0)
position: const Offset(11.0, 9.0)
);
void main() {

View file

@ -17,23 +17,23 @@ void main() {
final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer();
bool didStartDrag = false;
drag.onStart = (Point position) {
drag.onStart = (Offset position) {
didStartDrag = true;
return new TestDrag();
};
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0));
drag.addPointer(down);
tester.closeArena(5);
expect(didStartDrag, isFalse);
tester.async.flushMicrotasks();
expect(didStartDrag, isFalse);
tester.route(pointer.move(const Point(20.0, 20.0)));
tester.route(pointer.move(const Offset(20.0, 20.0)));
expect(didStartDrag, isFalse);
tester.async.elapse(kLongPressTimeout * 2);
expect(didStartDrag, isFalse);
tester.route(pointer.move(const Point(30.0, 30.0)));
tester.route(pointer.move(const Offset(30.0, 30.0)));
expect(didStartDrag, isFalse);
drag.dispose();
});

View file

@ -26,7 +26,7 @@ void main() {
final TestPointer pointer5 = new TestPointer(5);
final PointerDownEvent down5 = pointer5.down(const Point(10.0, 10.0));
final PointerDownEvent down5 = pointer5.down(const Offset(10.0, 10.0));
tap.addPointer(down5);
tester.closeArena(5);
expect(log, <String>['tap-down 5']);
@ -35,7 +35,7 @@ void main() {
expect(log, isEmpty);
final TestPointer pointer6 = new TestPointer(6);
final PointerDownEvent down6 = pointer6.down(const Point(15.0, 15.0));
final PointerDownEvent down6 = pointer6.down(const Offset(15.0, 15.0));
tap.addPointer(down6);
tester.closeArena(6);
expect(log, <String>['tap-down 6']);
@ -43,10 +43,10 @@ void main() {
tester.route(down6);
expect(log, isEmpty);
tester.route(pointer5.move(const Point(11.0, 12.0)));
tester.route(pointer5.move(const Offset(11.0, 12.0)));
expect(log, isEmpty);
tester.route(pointer6.move(const Point(14.0, 13.0)));
tester.route(pointer6.move(const Offset(14.0, 13.0)));
expect(log, isEmpty);
tester.route(pointer5.up());
@ -60,7 +60,7 @@ void main() {
expect(log, <String>['long-tap-down 6']);
log.clear();
tester.route(pointer6.move(const Point(4.0, 3.0)));
tester.route(pointer6.move(const Offset(4.0, 3.0)));
expect(log, <String>['tap-cancel 6']);
log.clear();

Some files were not shown because too many files have changed in this diff Show more