mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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:
parent
7b0b5c5760
commit
bf017b79b3
@ -1 +1 @@
|
|||||||
059ab3a47165d98cb1d7ac5e2a2e4b50abf39832
|
bcc8779cb88c0474f94277efa0ab7c83f14a0a9b
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -53,12 +53,12 @@ Future<Null> main() async {
|
|||||||
while (wallClockWatch.elapsed < kBenchmarkTime) {
|
while (wallClockWatch.elapsed < kBenchmarkTime) {
|
||||||
cpuWatch.reset();
|
cpuWatch.reset();
|
||||||
if (drawerIsOpen) {
|
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();
|
await tester.pump();
|
||||||
totalCloseIterationCount += 1;
|
totalCloseIterationCount += 1;
|
||||||
totalCloseFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
|
totalCloseFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
|
||||||
} else {
|
} 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();
|
await tester.pump();
|
||||||
totalOpenIterationCount += 1;
|
totalOpenIterationCount += 1;
|
||||||
totalOpenFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
|
totalOpenFrameElapsedMicroseconds += cpuWatch.elapsedMicroseconds;
|
||||||
|
@ -31,7 +31,7 @@ Future<Null> main() async {
|
|||||||
stocks.main();
|
stocks.main();
|
||||||
await tester.pump(); // Start startup animation
|
await tester.pump(); // Start startup animation
|
||||||
await tester.pump(const Duration(seconds: 1)); // Complete 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(); // Start drawer animation
|
||||||
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ Future<Null> main() async {
|
|||||||
stocks.main();
|
stocks.main();
|
||||||
await tester.pump(); // Start startup animation
|
await tester.pump(); // Start startup animation
|
||||||
await tester.pump(const Duration(seconds: 1)); // Complete 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(); // Start drawer animation
|
||||||
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class DashOutlineCirclePainter extends CustomPainter {
|
|||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = radius / 10.0;
|
..strokeWidth = radius / 10.0;
|
||||||
final Path path = new Path();
|
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)
|
for (double theta = 0.0; theta < math.PI * 2.0; theta += deltaTheta)
|
||||||
path.addArc(box, theta + startOffset, segmentArc);
|
path.addArc(box, theta + startOffset, segmentArc);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
|
@ -54,7 +54,7 @@ class _PointDemoPainter extends CustomPainter {
|
|||||||
final MaterialPointArcTween arc;
|
final MaterialPointArcTween arc;
|
||||||
Animation<double> _repaint;
|
Animation<double> _repaint;
|
||||||
|
|
||||||
void drawPoint(Canvas canvas, Point point, Color color) {
|
void drawPoint(Canvas canvas, Offset point, Color color) {
|
||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..color = color.withOpacity(0.25)
|
..color = color.withOpacity(0.25)
|
||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
@ -93,7 +93,7 @@ class _PointDemoPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Point position) {
|
bool hitTest(Offset position) {
|
||||||
return (arc.begin - position).distanceSquared < _kTargetSlop
|
return (arc.begin - position).distanceSquared < _kTargetSlop
|
||||||
|| (arc.end - position).distanceSquared < _kTargetSlop;
|
|| (arc.end - position).distanceSquared < _kTargetSlop;
|
||||||
}
|
}
|
||||||
@ -117,8 +117,8 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
CurvedAnimation _animation;
|
CurvedAnimation _animation;
|
||||||
_DragTarget _dragTarget;
|
_DragTarget _dragTarget;
|
||||||
Size _screenSize;
|
Size _screenSize;
|
||||||
Point _begin;
|
Offset _begin;
|
||||||
Point _end;
|
Offset _end;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -132,7 +132,7 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Drag _handleOnStart(Point position) {
|
Drag _handleOnStart(Offset position) {
|
||||||
// TODO(hansmuller): allow the user to drag both points at the same time.
|
// TODO(hansmuller): allow the user to drag both points at the same time.
|
||||||
if (_dragTarget != null)
|
if (_dragTarget != null)
|
||||||
return new _IgnoreDrag();
|
return new _IgnoreDrag();
|
||||||
@ -181,8 +181,8 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
final Size screenSize = MediaQuery.of(context).size;
|
final Size screenSize = MediaQuery.of(context).size;
|
||||||
if (_screenSize == null || _screenSize != screenSize) {
|
if (_screenSize == null || _screenSize != screenSize) {
|
||||||
_screenSize = screenSize;
|
_screenSize = screenSize;
|
||||||
_begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2);
|
_begin = new Offset(screenSize.width * 0.5, screenSize.height * 0.2);
|
||||||
_end = new Point(screenSize.width * 0.1, screenSize.height * 0.4);
|
_end = new Offset(screenSize.width * 0.1, screenSize.height * 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
|
final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
|
||||||
@ -229,7 +229,7 @@ class _RectangleDemoPainter extends CustomPainter {
|
|||||||
final MaterialRectArcTween arc;
|
final MaterialRectArcTween arc;
|
||||||
Animation<double> _repaint;
|
Animation<double> _repaint;
|
||||||
|
|
||||||
void drawPoint(Canvas canvas, Point p, Color color) {
|
void drawPoint(Canvas canvas, Offset p, Color color) {
|
||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..color = color.withOpacity(0.25)
|
..color = color.withOpacity(0.25)
|
||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
@ -258,7 +258,7 @@ class _RectangleDemoPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Point position) {
|
bool hitTest(Offset position) {
|
||||||
return (arc.begin.center - position).distanceSquared < _kTargetSlop
|
return (arc.begin.center - position).distanceSquared < _kTargetSlop
|
||||||
|| (arc.end.center - position).distanceSquared < _kTargetSlop;
|
|| (arc.end.center - position).distanceSquared < _kTargetSlop;
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Drag _handleOnStart(Point position) {
|
Drag _handleOnStart(Offset position) {
|
||||||
// TODO(hansmuller): allow the user to drag both points at the same time.
|
// TODO(hansmuller): allow the user to drag both points at the same time.
|
||||||
if (_dragTarget != null)
|
if (_dragTarget != null)
|
||||||
return new _IgnoreDrag();
|
return new _IgnoreDrag();
|
||||||
|
@ -33,19 +33,19 @@ class _MarkerPainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, _) {
|
void paint(Canvas canvas, _) {
|
||||||
final Paint paint = new Paint()..color = const Color(0x8000FF00);
|
final Paint paint = new Paint()..color = const Color(0x8000FF00);
|
||||||
final double r = size / 2.0;
|
final double r = size / 2.0;
|
||||||
canvas.drawCircle(new Point(r, r), r, paint);
|
canvas.drawCircle(new Offset(r, r), r, paint);
|
||||||
|
|
||||||
paint
|
paint
|
||||||
..color = const Color(0xFFFFFFFF)
|
..color = const Color(0xFFFFFFFF)
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.0;
|
..strokeWidth = 1.0;
|
||||||
if (type == MarkerType.topLeft) {
|
if (type == MarkerType.topLeft) {
|
||||||
canvas.drawLine(new Point(r, r), new Point(r + r - 1.0, r), paint);
|
canvas.drawLine(new Offset(r, r), new Offset(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 + r - 1.0), paint);
|
||||||
}
|
}
|
||||||
if (type == MarkerType.bottomRight) {
|
if (type == MarkerType.bottomRight) {
|
||||||
canvas.drawLine(new Point(r, r), new Point(1.0, r), paint);
|
canvas.drawLine(new Offset(r, r), new Offset(1.0, r), paint);
|
||||||
canvas.drawLine(new Point(r, r), new Point(r, 1.0), 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,
|
this.size: 40.0,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Point position;
|
final Offset position;
|
||||||
final double size;
|
final double size;
|
||||||
final MarkerType type;
|
final MarkerType type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Positioned(
|
return new Positioned(
|
||||||
left: position.x - size / 2.0,
|
left: position.dx - size / 2.0,
|
||||||
top: position.y - size / 2.0,
|
top: position.dy - size / 2.0,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
child: new IgnorePointer(
|
child: new IgnorePointer(
|
||||||
@ -92,7 +92,7 @@ class OverlayGeometryApp extends StatefulWidget {
|
|||||||
OverlayGeometryAppState createState() => new OverlayGeometryAppState();
|
OverlayGeometryAppState createState() => new OverlayGeometryAppState();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void CardTapCallback(GlobalKey targetKey, Point globalPosition);
|
typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition);
|
||||||
|
|
||||||
class CardBuilder extends SliverChildDelegate {
|
class CardBuilder extends SliverChildDelegate {
|
||||||
CardBuilder({ this.cardModels, this.onTapUp });
|
CardBuilder({ this.cardModels, this.onTapUp });
|
||||||
@ -134,7 +134,7 @@ class CardBuilder extends SliverChildDelegate {
|
|||||||
|
|
||||||
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||||
List<CardModel> cardModels;
|
List<CardModel> cardModels;
|
||||||
Map<MarkerType, Point> markers = <MarkerType, Point>{};
|
Map<MarkerType, Offset> markers = <MarkerType, Offset>{};
|
||||||
double markersScrollOffset = 0.0;
|
double markersScrollOffset = 0.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -157,21 +157,21 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
|||||||
final double dy = markersScrollOffset - notification.metrics.extentBefore;
|
final double dy = markersScrollOffset - notification.metrics.extentBefore;
|
||||||
markersScrollOffset = notification.metrics.extentBefore;
|
markersScrollOffset = notification.metrics.extentBefore;
|
||||||
for (MarkerType type in markers.keys) {
|
for (MarkerType type in markers.keys) {
|
||||||
final Point oldPosition = markers[type];
|
final Offset oldPosition = markers[type];
|
||||||
markers[type] = new Point(oldPosition.x, oldPosition.y + dy);
|
markers[type] = oldPosition.translate(0.0, dy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleTapUp(GlobalKey target, Point globalPosition) {
|
void handleTapUp(GlobalKey target, Offset globalPosition) {
|
||||||
setState(() {
|
setState(() {
|
||||||
markers[MarkerType.touch] = globalPosition;
|
markers[MarkerType.touch] = globalPosition;
|
||||||
final RenderBox box = target.currentContext.findRenderObject();
|
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;
|
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);
|
final ScrollableState scrollable = Scrollable.of(target.currentContext);
|
||||||
markersScrollOffset = scrollable.position.pixels;
|
markersScrollOffset = scrollable.position.pixels;
|
||||||
});
|
});
|
||||||
|
@ -178,8 +178,8 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
|
|||||||
return Rect.lerp(begin, end, tColumnToRow);
|
return Rect.lerp(begin, end, tColumnToRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point _interpolatePoint(Point begin, Point end) {
|
Offset _interpolatePoint(Offset begin, Offset end) {
|
||||||
return Point.lerp(begin, end, tColumnToRow);
|
return Offset.lerp(begin, end, tColumnToRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -220,30 +220,30 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
|
|||||||
cardRect.left + 0.5, cardRect.top, cardRect.width - 1.0, cardRect.height
|
cardRect.left + 0.5, cardRect.top, cardRect.width - 1.0, cardRect.height
|
||||||
);
|
);
|
||||||
layoutChild(cardId, new BoxConstraints.tight(insetRect.size));
|
layoutChild(cardId, new BoxConstraints.tight(insetRect.size));
|
||||||
positionChild(cardId, insetRect.topLeft.toOffset());
|
positionChild(cardId, insetRect.topLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout the title for index.
|
// Layout the title for index.
|
||||||
final Size titleSize = layoutChild('title$index', new BoxConstraints.loose(cardRect.size));
|
final Size titleSize = layoutChild('title$index', new BoxConstraints.loose(cardRect.size));
|
||||||
final double columnTitleY = columnCardRect.centerLeft.y - titleSize.height / 2.0;
|
final double columnTitleY = columnCardRect.centerLeft.dy - titleSize.height / 2.0;
|
||||||
final double rowTitleY = rowCardRect.centerLeft.y - titleSize.height / 2.0;
|
final double rowTitleY = rowCardRect.centerLeft.dy - titleSize.height / 2.0;
|
||||||
final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0;
|
final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0;
|
||||||
final Point columnTitleOrigin = new Point(columnTitleX, columnTitleY);
|
final Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY);
|
||||||
final Point rowTitleOrigin = new Point(centeredRowTitleX, rowTitleY);
|
final Offset rowTitleOrigin = new Offset(centeredRowTitleX, rowTitleY);
|
||||||
final Point titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin);
|
final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin);
|
||||||
positionChild('title$index', titleOrigin.toOffset() + offset);
|
positionChild('title$index', titleOrigin + offset);
|
||||||
|
|
||||||
// Layout the selection indicator for index.
|
// Layout the selection indicator for index.
|
||||||
final Size indicatorSize = layoutChild('indicator$index', new BoxConstraints.loose(cardRect.size));
|
final Size indicatorSize = layoutChild('indicator$index', new BoxConstraints.loose(cardRect.size));
|
||||||
final double columnIndicatorX = cardRect.centerRight.x - indicatorSize.width - 16.0;
|
final double columnIndicatorX = cardRect.centerRight.dx - indicatorSize.width - 16.0;
|
||||||
final double columnIndicatorY = cardRect.bottomRight.y - indicatorSize.height - 16.0;
|
final double columnIndicatorY = cardRect.bottomRight.dy - indicatorSize.height - 16.0;
|
||||||
final Point columnIndicatorOrigin = new Point(columnIndicatorX, columnIndicatorY);
|
final Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY);
|
||||||
final Rect titleRect = new Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
|
final Rect titleRect = new Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
|
||||||
final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0;
|
final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0;
|
||||||
final double rowIndicatorY = titleRect.bottomCenter.y + 16.0;
|
final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0;
|
||||||
final Point rowIndicatorOrigin = new Point(centeredRowIndicatorX, rowIndicatorY);
|
final Offset rowIndicatorOrigin = new Offset(centeredRowIndicatorX, rowIndicatorY);
|
||||||
final Point indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
|
final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
|
||||||
positionChild('indicator$index', indicatorOrigin.toOffset() + offset);
|
positionChild('indicator$index', indicatorOrigin + offset);
|
||||||
|
|
||||||
columnCardY += columnCardHeight;
|
columnCardY += columnCardHeight;
|
||||||
rowCardX += rowCardWidth;
|
rowCardX += rowCardWidth;
|
||||||
@ -434,7 +434,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
|||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
child: new SectionCard(section: allSections[index]),
|
child: new SectionCard(section: allSections[index]),
|
||||||
onTapUp: (TapUpDetails details) {
|
onTapUp: (TapUpDetails details) {
|
||||||
final double xOffset = details.globalPosition.x;
|
final double xOffset = details.globalPosition.dx;
|
||||||
setState(() {
|
setState(() {
|
||||||
_maybeScroll(midScrollOffset, index, xOffset);
|
_maybeScroll(midScrollOffset, index, xOffset);
|
||||||
});
|
});
|
||||||
|
@ -90,7 +90,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
|||||||
void _handleOnScaleStart(ScaleStartDetails details) {
|
void _handleOnScaleStart(ScaleStartDetails details) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_previousScale = _scale;
|
_previousScale = _scale;
|
||||||
_normalizedOffset = (details.focalPoint.toOffset() - _offset) / _scale;
|
_normalizedOffset = (details.focalPoint - _offset) / _scale;
|
||||||
// The fling animation stops if an input gesture starts.
|
// The fling animation stops if an input gesture starts.
|
||||||
_controller.stop();
|
_controller.stop();
|
||||||
});
|
});
|
||||||
@ -100,7 +100,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
|||||||
setState(() {
|
setState(() {
|
||||||
_scale = (_previousScale * details.scale).clamp(1.0, 4.0);
|
_scale = (_previousScale * details.scale).clamp(1.0, 4.0);
|
||||||
// Ensure that image location under the focal point stays in the same place despite scaling.
|
// 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)
|
if (magnitude < _kMinFlingVelocity)
|
||||||
return;
|
return;
|
||||||
final Offset direction = details.velocity.pixelsPerSecond / magnitude;
|
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>(
|
_flingAnimation = new Tween<Offset>(
|
||||||
begin: _offset,
|
begin: _offset,
|
||||||
end: _clampOffset(_offset + direction * distance)
|
end: _clampOffset(_offset + direction * distance)
|
||||||
|
@ -20,7 +20,7 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
// Scroll the Buttons demo into view so that a tap will succeed
|
// 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');
|
final Finder button = find.text('Buttons');
|
||||||
while (button.evaluate().isEmpty) {
|
while (button.evaluate().isEmpty) {
|
||||||
await tester.dragFrom(allDemosOrigin, const Offset(0.0, -100.0));
|
await tester.dragFrom(allDemosOrigin, const Offset(0.0, -100.0));
|
||||||
|
@ -77,8 +77,8 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
|
|||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
|
|
||||||
// Scroll the demo around a bit.
|
// 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 Offset(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(0.0, -100.0), 500.0);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(milliseconds: 50));
|
await tester.pump(const Duration(milliseconds: 50));
|
||||||
await tester.pump(const Duration(milliseconds: 200));
|
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());
|
verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView?.debugLayer?.toStringDeep());
|
||||||
|
|
||||||
// Scroll the demo around a bit more.
|
// 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();
|
||||||
await tester.pump(const Duration(milliseconds: 50));
|
await tester.pump(const Duration(milliseconds: 50));
|
||||||
await tester.pump(const Duration(milliseconds: 200));
|
await tester.pump(const Duration(milliseconds: 200));
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
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();
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
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();
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
|
|
||||||
|
@ -26,24 +26,24 @@ ui.Picture paint(ui.Rect paintBounds) {
|
|||||||
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
|
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
|
||||||
|
|
||||||
final ui.Size size = paintBounds.size;
|
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 radius = size.shortestSide / 2.0;
|
||||||
|
|
||||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||||
|
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(-mid.x/2.0, logicalSize.height*2.0);
|
canvas.translate(-mid.dx / 2.0, logicalSize.height * 2.0);
|
||||||
canvas.clipRect(
|
canvas.clipRect(new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
|
||||||
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);
|
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
|
||||||
canvas.rotate(math.PI/4.0);
|
canvas.rotate(math.PI/4.0);
|
||||||
|
|
||||||
final ui.Gradient yellowBlue = new ui.Gradient.linear(
|
final ui.Gradient yellowBlue = new ui.Gradient.linear(
|
||||||
<ui.Point>[new ui.Point(-radius, -radius), const ui.Point(0.0, 0.0)],
|
new ui.Offset(-radius, -radius),
|
||||||
<ui.Color>[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)]
|
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),
|
canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||||
new ui.Paint()..shader = yellowBlue);
|
new ui.Paint()..shader = yellowBlue);
|
||||||
@ -57,11 +57,11 @@ ui.Picture paint(ui.Rect paintBounds) {
|
|||||||
]);
|
]);
|
||||||
canvas.transform(scaleMatrix);
|
canvas.transform(scaleMatrix);
|
||||||
paint.color = const ui.Color.fromARGB(128, 0, 255, 0);
|
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();
|
canvas.restore();
|
||||||
|
|
||||||
paint.color = const ui.Color.fromARGB(128, 255, 0, 0);
|
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
|
// 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
|
// 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) {
|
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.Picture picture = paint(paintBounds);
|
||||||
final ui.Scene scene = composite(picture, paintBounds);
|
final ui.Scene scene = composite(picture, paintBounds);
|
||||||
ui.window.render(scene);
|
ui.window.render(scene);
|
||||||
|
@ -16,7 +16,7 @@ void beginFrame(Duration timeStamp) {
|
|||||||
final ui.Paragraph paragraph = paragraphBuilder.build()
|
final ui.Paragraph paragraph = paragraphBuilder.build()
|
||||||
..layout(new ui.ParagraphConstraints(width: logicalSize.width));
|
..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.PictureRecorder recorder = new ui.PictureRecorder();
|
||||||
final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds);
|
final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds);
|
||||||
canvas.scale(devicePixelRatio, devicePixelRatio);
|
canvas.scale(devicePixelRatio, devicePixelRatio);
|
||||||
|
@ -19,7 +19,7 @@ void beginFrame(Duration timeStamp) {
|
|||||||
|
|
||||||
// PAINT
|
// 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.PictureRecorder recorder = new ui.PictureRecorder();
|
||||||
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||||
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
||||||
|
@ -44,7 +44,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
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.Picture picture = paint(paintBounds);
|
||||||
final ui.Scene scene = composite(picture, paintBounds);
|
final ui.Scene scene = composite(picture, paintBounds);
|
||||||
ui.window.render(scene);
|
ui.window.render(scene);
|
||||||
|
@ -26,7 +26,7 @@ ui.Picture paint(ui.Rect paintBounds) {
|
|||||||
// The commands draw a circle in the center of the screen.
|
// The commands draw a circle in the center of the screen.
|
||||||
final ui.Size size = paintBounds.size;
|
final ui.Size size = paintBounds.size;
|
||||||
canvas.drawCircle(
|
canvas.drawCircle(
|
||||||
size.center(ui.Point.origin),
|
size.center(ui.Offset.zero),
|
||||||
size.shortestSide * 0.45,
|
size.shortestSide * 0.45,
|
||||||
new ui.Paint()..color = color
|
new ui.Paint()..color = color
|
||||||
);
|
);
|
||||||
@ -67,7 +67,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
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.
|
// First, record a picture with our painting commands.
|
||||||
final ui.Picture picture = paint(paintBounds);
|
final ui.Picture picture = paint(paintBounds);
|
||||||
// Second, include that picture in a scene graph.
|
// Second, include that picture in a scene graph.
|
||||||
|
@ -525,22 +525,22 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
|
|||||||
if (child != null) {
|
if (child != null) {
|
||||||
final Rect bounds = offset & size;
|
final Rect bounds = offset & size;
|
||||||
// we move the offset to the center of the circle for the RenderSectors
|
// 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
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (child == null)
|
if (child == null)
|
||||||
return false;
|
return false;
|
||||||
double x = position.x;
|
double x = position.dx;
|
||||||
double y = position.y;
|
double y = position.dy;
|
||||||
// translate to our origin
|
// translate to our origin
|
||||||
x -= size.width/2.0;
|
x -= size.width / 2.0;
|
||||||
y -= size.height/2.0;
|
y -= size.height / 2.0;
|
||||||
// convert to radius/theta
|
// convert to radius/theta
|
||||||
final double radius = math.sqrt(x*x+y*y);
|
final double radius = math.sqrt(x * x + y * y);
|
||||||
final double theta = (math.atan2(x, -y) - math.PI/2.0) % kTwoPi;
|
final double theta = (math.atan2(x, -y) - math.PI / 2.0) % kTwoPi;
|
||||||
if (radius < innerRadius)
|
if (radius < innerRadius)
|
||||||
return false;
|
return false;
|
||||||
if (radius >= innerRadius + child.deltaRadius)
|
if (radius >= innerRadius + child.deltaRadius)
|
||||||
|
@ -23,7 +23,7 @@ class Dot {
|
|||||||
Dot({ Color color }) : _paint = new Paint()..color = color;
|
Dot({ Color color }) : _paint = new Paint()..color = color;
|
||||||
|
|
||||||
final Paint _paint;
|
final Paint _paint;
|
||||||
Point position = Point.origin;
|
Offset position = Offset.zero;
|
||||||
double radius = 0.0;
|
double radius = 0.0;
|
||||||
|
|
||||||
void update(PointerEvent event) {
|
void update(PointerEvent event) {
|
||||||
@ -58,7 +58,7 @@ class RenderDots extends RenderBox {
|
|||||||
|
|
||||||
/// Makes this render object hittable so that it receives pointer events.
|
/// Makes this render object hittable so that it receives pointer events.
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
/// Processes pointer events by mutating state and invalidating its previous
|
/// Processes pointer events by mutating state and invalidating its previous
|
||||||
/// painting commands.
|
/// painting commands.
|
||||||
|
@ -10,9 +10,9 @@ class RenderDots extends RenderConstrainedBox {
|
|||||||
|
|
||||||
// Makes this render box hittable so that we'll get pointer events.
|
// Makes this render box hittable so that we'll get pointer events.
|
||||||
@override
|
@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
|
@override
|
||||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
||||||
@ -31,7 +31,7 @@ class RenderDots extends RenderConstrainedBox {
|
|||||||
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
|
canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF));
|
||||||
|
|
||||||
final Paint paint = new Paint()..color = const Color(0xFF00FF00);
|
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);
|
canvas.drawCircle(point, 50.0, paint);
|
||||||
|
|
||||||
super.paint(context, offset);
|
super.paint(context, offset);
|
||||||
|
@ -27,18 +27,16 @@ class _GesturePainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
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 double radius = size.width / 2.0 * zoom;
|
||||||
final Gradient gradient = new RadialGradient(
|
final Gradient gradient = new RadialGradient(
|
||||||
colors: forward ? <Color>[swatch.shade50, swatch.shade900]
|
colors: forward ? <Color>[swatch.shade50, swatch.shade900]
|
||||||
: <Color>[swatch.shade900, swatch.shade50]
|
: <Color>[swatch.shade900, swatch.shade50]
|
||||||
);
|
);
|
||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..shader = gradient.createShader(new Rect.fromLTWH(
|
..shader = gradient.createShader(new Rect.fromCircle(
|
||||||
center.x - radius,
|
center: center,
|
||||||
center.y - radius,
|
radius: radius,
|
||||||
radius * 2.0,
|
|
||||||
radius * 2.0
|
|
||||||
));
|
));
|
||||||
canvas.drawCircle(center, radius, paint);
|
canvas.drawCircle(center, radius, paint);
|
||||||
}
|
}
|
||||||
@ -63,7 +61,7 @@ class GestureDemo extends StatefulWidget {
|
|||||||
|
|
||||||
class _GestureDemoState extends State<GestureDemo> {
|
class _GestureDemoState extends State<GestureDemo> {
|
||||||
|
|
||||||
Point _startingFocalPoint;
|
Offset _startingFocalPoint;
|
||||||
|
|
||||||
Offset _previousOffset;
|
Offset _previousOffset;
|
||||||
Offset _offset = Offset.zero;
|
Offset _offset = Offset.zero;
|
||||||
@ -92,8 +90,8 @@ class _GestureDemoState extends State<GestureDemo> {
|
|||||||
_zoom = (_previousZoom * details.scale);
|
_zoom = (_previousZoom * details.scale);
|
||||||
|
|
||||||
// Ensure that item under the focal point stays in the same place despite zooming
|
// Ensure that item under the focal point stays in the same place despite zooming
|
||||||
final Offset normalizedOffset = (_startingFocalPoint.toOffset() - _previousOffset) / _previousZoom;
|
final Offset normalizedOffset = (_startingFocalPoint - _previousOffset) / _previousZoom;
|
||||||
_offset = details.focalPoint.toOffset() - normalizedOffset * _zoom;
|
_offset = details.focalPoint - normalizedOffset * _zoom;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class StockArrowPainter extends CustomPainter {
|
|||||||
|
|
||||||
// Draw a circle that circumscribes the arrow.
|
// Draw a circle that circumscribes the arrow.
|
||||||
paint.style = PaintingStyle.stroke;
|
paint.style = PaintingStyle.stroke;
|
||||||
canvas.drawCircle(new Point(centerX, centerY), r, paint);
|
canvas.drawCircle(new Offset(centerX, centerY), r, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -61,8 +61,8 @@ void main() {
|
|||||||
expect(find.text('Account Balance'), findsNothing);
|
expect(find.text('Account Balance'), findsNothing);
|
||||||
|
|
||||||
// drag the drawer out
|
// drag the drawer out
|
||||||
final Point left = new Point(0.0, ui.window.physicalSize.height / 2.0);
|
final Offset left = new Offset(0.0, ui.window.physicalSize.height / 2.0);
|
||||||
final Point right = new Point(ui.window.physicalSize.width, left.y);
|
final Offset right = new Offset(ui.window.physicalSize.width, left.dy);
|
||||||
final TestGesture gesture = await tester.startGesture(left);
|
final TestGesture gesture = await tester.startGesture(left);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await gesture.moveTo(right);
|
await gesture.moveTo(right);
|
||||||
|
@ -272,12 +272,12 @@ class _CupertinoButtonBarPainter extends CustomPainter {
|
|||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..color = _kButtonDividerColor;
|
..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) {
|
for (int i = 1; i < count; ++i) {
|
||||||
// TODO(abarth): Hide the divider when one of the adjacent buttons is
|
// TODO(abarth): Hide the divider when one of the adjacent buttons is
|
||||||
// highlighted.
|
// highlighted.
|
||||||
final double x = size.width * i / count;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) {
|
bool hitTestSelf(Offset position) {
|
||||||
return (position.x - _thumbCenter).abs() < CupertinoThumbPainter.radius + _kPadding;
|
return (position.dx - _thumbCenter).abs() < CupertinoThumbPainter.radius + _kPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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);
|
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));
|
_thumbPainter.paint(canvas, new Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
||||||
|
@ -83,7 +83,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
|
|||||||
|
|
||||||
/// Determine which [HitTestTarget] objects are located at a given position.
|
/// Determine which [HitTestTarget] objects are located at a given position.
|
||||||
@override // from HitTestable
|
@override // from HitTestable
|
||||||
void hitTest(HitTestResult result, Point position) {
|
void hitTest(HitTestResult result, Offset position) {
|
||||||
result.add(new HitTestEntry(this));
|
result.add(new HitTestEntry(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class _PointerState {
|
|||||||
_down = false;
|
_down = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point lastPosition;
|
Offset lastPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts from engine pointer data to framework pointer events.
|
/// Converts from engine pointer data to framework pointer events.
|
||||||
@ -36,7 +36,7 @@ class PointerEventConverter {
|
|||||||
// Map from platform pointer identifiers to PointerEvent pointer identifiers.
|
// Map from platform pointer identifiers to PointerEvent pointer identifiers.
|
||||||
static final Map<int, _PointerState> _pointers = <int, _PointerState>{};
|
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(
|
return _pointers.putIfAbsent(
|
||||||
datum.device,
|
datum.device,
|
||||||
() => new _PointerState(position)
|
() => new _PointerState(position)
|
||||||
@ -46,7 +46,7 @@ class PointerEventConverter {
|
|||||||
/// Expand the given packet of pointer data into a sequence of framework pointer events.
|
/// 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* {
|
static Iterable<PointerEvent> expand(Iterable<ui.PointerData> data, double devicePixelRatio) sync* {
|
||||||
for (ui.PointerData datum in data) {
|
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 Duration timeStamp = datum.timeStamp;
|
||||||
final PointerDeviceKind kind = datum.kind;
|
final PointerDeviceKind kind = datum.kind;
|
||||||
assert(datum.change != null);
|
assert(datum.change != null);
|
||||||
|
@ -28,14 +28,14 @@ class DragDownDetails {
|
|||||||
/// Creates details for a [GestureDragDownCallback].
|
/// Creates details for a [GestureDragDownCallback].
|
||||||
///
|
///
|
||||||
/// The [globalPosition] argument must not be null.
|
/// The [globalPosition] argument must not be null.
|
||||||
DragDownDetails({ this.globalPosition: Point.origin }) {
|
DragDownDetails({ this.globalPosition: Offset.zero }) {
|
||||||
assert(globalPosition != null);
|
assert(globalPosition != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The global position at which the pointer contacted the screen.
|
/// The global position at which the pointer contacted the screen.
|
||||||
///
|
///
|
||||||
/// Defaults to the origin if not specified in the constructor.
|
/// Defaults to the origin if not specified in the constructor.
|
||||||
final Point globalPosition;
|
final Offset globalPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($globalPosition)';
|
String toString() => '$runtimeType($globalPosition)';
|
||||||
@ -61,14 +61,14 @@ class DragStartDetails {
|
|||||||
/// Creates details for a [GestureDragStartCallback].
|
/// Creates details for a [GestureDragStartCallback].
|
||||||
///
|
///
|
||||||
/// The [globalPosition] argument must not be null.
|
/// The [globalPosition] argument must not be null.
|
||||||
DragStartDetails({ this.globalPosition: Point.origin }) {
|
DragStartDetails({ this.globalPosition: Offset.zero }) {
|
||||||
assert(globalPosition != null);
|
assert(globalPosition != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The global position at which the pointer contacted the screen.
|
/// The global position at which the pointer contacted the screen.
|
||||||
///
|
///
|
||||||
/// Defaults to the origin if not specified in the constructor.
|
/// Defaults to the origin if not specified in the constructor.
|
||||||
final Point globalPosition;
|
final Offset globalPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($globalPosition)';
|
String toString() => '$runtimeType($globalPosition)';
|
||||||
@ -131,7 +131,7 @@ class DragUpdateDetails {
|
|||||||
final double primaryDelta;
|
final double primaryDelta;
|
||||||
|
|
||||||
/// The pointer's global position when it triggered this update.
|
/// The pointer's global position when it triggered this update.
|
||||||
final Point globalPosition;
|
final Offset globalPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($delta)';
|
String toString() => '$runtimeType($delta)';
|
||||||
@ -270,7 +270,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
|||||||
double maxFlingVelocity;
|
double maxFlingVelocity;
|
||||||
|
|
||||||
_DragState _state = _DragState.ready;
|
_DragState _state = _DragState.ready;
|
||||||
Point _initialPosition;
|
Offset _initialPosition;
|
||||||
Offset _pendingDragOffset;
|
Offset _pendingDragOffset;
|
||||||
|
|
||||||
bool _isFlingGesture(VelocityEstimate estimate);
|
bool _isFlingGesture(VelocityEstimate estimate);
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:ui' show Point, Offset, PointerDeviceKind;
|
import 'dart:ui' show Offset, PointerDeviceKind;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
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.
|
/// The bit of [PointerEvent.buttons] that corresponds to the primary mouse button.
|
||||||
///
|
///
|
||||||
@ -77,7 +77,7 @@ abstract class PointerEvent {
|
|||||||
this.pointer: 0,
|
this.pointer: 0,
|
||||||
this.kind: PointerDeviceKind.touch,
|
this.kind: PointerDeviceKind.touch,
|
||||||
this.device: 0,
|
this.device: 0,
|
||||||
this.position: Point.origin,
|
this.position: Offset.zero,
|
||||||
this.delta: Offset.zero,
|
this.delta: Offset.zero,
|
||||||
this.buttons: 0,
|
this.buttons: 0,
|
||||||
this.down: false,
|
this.down: false,
|
||||||
@ -109,7 +109,7 @@ abstract class PointerEvent {
|
|||||||
|
|
||||||
/// Coordinate of the position of the pointer, in logical pixels in the global
|
/// Coordinate of the position of the pointer, in logical pixels in the global
|
||||||
/// coordinate space.
|
/// coordinate space.
|
||||||
final Point position;
|
final Offset position;
|
||||||
|
|
||||||
/// Distance in logical pixels that the pointer moved since the last
|
/// Distance in logical pixels that the pointer moved since the last
|
||||||
/// PointerMoveEvent. Always 0.0 for down, up, and cancel events.
|
/// PointerMoveEvent. Always 0.0 for down, up, and cancel events.
|
||||||
@ -257,7 +257,7 @@ class PointerAddedEvent extends PointerEvent {
|
|||||||
Duration timeStamp: Duration.ZERO,
|
Duration timeStamp: Duration.ZERO,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
double pressureMin: 1.0,
|
double pressureMin: 1.0,
|
||||||
double pressureMax: 1.0,
|
double pressureMax: 1.0,
|
||||||
@ -331,7 +331,7 @@ class PointerHoverEvent extends PointerEvent {
|
|||||||
Duration timeStamp: Duration.ZERO,
|
Duration timeStamp: Duration.ZERO,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
Offset delta: Offset.zero,
|
Offset delta: Offset.zero,
|
||||||
int buttons: 0,
|
int buttons: 0,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
@ -377,7 +377,7 @@ class PointerDownEvent extends PointerEvent {
|
|||||||
int pointer: 0,
|
int pointer: 0,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
int buttons: 0,
|
int buttons: 0,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
double pressure: 1.0,
|
double pressure: 1.0,
|
||||||
@ -429,7 +429,7 @@ class PointerMoveEvent extends PointerEvent {
|
|||||||
int pointer: 0,
|
int pointer: 0,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
Offset delta: Offset.zero,
|
Offset delta: Offset.zero,
|
||||||
int buttons: 0,
|
int buttons: 0,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
@ -477,7 +477,7 @@ class PointerUpEvent extends PointerEvent {
|
|||||||
int pointer: 0,
|
int pointer: 0,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
int buttons: 0,
|
int buttons: 0,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
double pressureMin: 1.0,
|
double pressureMin: 1.0,
|
||||||
@ -518,7 +518,7 @@ class PointerCancelEvent extends PointerEvent {
|
|||||||
int pointer: 0,
|
int pointer: 0,
|
||||||
PointerDeviceKind kind: PointerDeviceKind.touch,
|
PointerDeviceKind kind: PointerDeviceKind.touch,
|
||||||
int device: 0,
|
int device: 0,
|
||||||
Point position: Point.origin,
|
Offset position: Offset.zero,
|
||||||
int buttons: 0,
|
int buttons: 0,
|
||||||
bool obscured: false,
|
bool obscured: false,
|
||||||
double pressureMin: 1.0,
|
double pressureMin: 1.0,
|
||||||
|
@ -10,7 +10,7 @@ abstract class HitTestable { // ignore: one_member_abstracts
|
|||||||
///
|
///
|
||||||
/// If this given position hits this object, consider adding a [HitTestEntry]
|
/// If this given position hits this object, consider adding a [HitTestEntry]
|
||||||
/// to the given hit test result.
|
/// to the given hit test result.
|
||||||
void hitTest(HitTestResult result, Point position);
|
void hitTest(HitTestResult result, Offset position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An object that can dispatch events.
|
/// An object that can dispatch events.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui' show Point, Offset;
|
import 'dart:ui' show Offset;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import 'recognizer.dart';
|
|||||||
import 'velocity_tracker.dart';
|
import 'velocity_tracker.dart';
|
||||||
|
|
||||||
/// Signature for when [MultiDragGestureRecognizer] recognizes the start of a drag gesture.
|
/// 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].
|
/// Interface for receiving updates about drags from a [MultiDragGestureRecognizer].
|
||||||
abstract class Drag {
|
abstract class Drag {
|
||||||
@ -49,7 +49,7 @@ abstract class MultiDragPointerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The global coordinates of the pointer when the pointer contacted the screen.
|
/// The global coordinates of the pointer when the pointer contacted the screen.
|
||||||
final Point initialPosition;
|
final Offset initialPosition;
|
||||||
|
|
||||||
final VelocityTracker _velocityTracker = new VelocityTracker();
|
final VelocityTracker _velocityTracker = new VelocityTracker();
|
||||||
Drag _client;
|
Drag _client;
|
||||||
@ -251,10 +251,10 @@ abstract class MultiDragGestureRecognizer<T extends MultiDragPointerState> exten
|
|||||||
final T state = _pointers[pointer];
|
final T state = _pointers[pointer];
|
||||||
if (state == null)
|
if (state == null)
|
||||||
return; // We might already have canceled this drag if the up comes before the accept.
|
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);
|
assert(_pointers != null);
|
||||||
final T state = _pointers[pointer];
|
final T state = _pointers[pointer];
|
||||||
assert(state != null);
|
assert(state != null);
|
||||||
@ -303,7 +303,7 @@ abstract class MultiDragGestureRecognizer<T extends MultiDragPointerState> exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ImmediatePointerState extends MultiDragPointerState {
|
class _ImmediatePointerState extends MultiDragPointerState {
|
||||||
_ImmediatePointerState(Point initialPosition) : super(initialPosition);
|
_ImmediatePointerState(Offset initialPosition) : super(initialPosition);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void checkForResolutionAfterMove() {
|
void checkForResolutionAfterMove() {
|
||||||
@ -340,7 +340,7 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im
|
|||||||
|
|
||||||
|
|
||||||
class _HorizontalPointerState extends MultiDragPointerState {
|
class _HorizontalPointerState extends MultiDragPointerState {
|
||||||
_HorizontalPointerState(Point initialPosition) : super(initialPosition);
|
_HorizontalPointerState(Offset initialPosition) : super(initialPosition);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void checkForResolutionAfterMove() {
|
void checkForResolutionAfterMove() {
|
||||||
@ -377,7 +377,7 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H
|
|||||||
|
|
||||||
|
|
||||||
class _VerticalPointerState extends MultiDragPointerState {
|
class _VerticalPointerState extends MultiDragPointerState {
|
||||||
_VerticalPointerState(Point initialPosition) : super(initialPosition);
|
_VerticalPointerState(Offset initialPosition) : super(initialPosition);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void checkForResolutionAfterMove() {
|
void checkForResolutionAfterMove() {
|
||||||
@ -413,7 +413,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DelayedPointerState extends MultiDragPointerState {
|
class _DelayedPointerState extends MultiDragPointerState {
|
||||||
_DelayedPointerState(Point initialPosition, Duration delay) : super(initialPosition) {
|
_DelayedPointerState(Offset initialPosition, Duration delay) : super(initialPosition) {
|
||||||
assert(delay != null);
|
assert(delay != null);
|
||||||
_timer = new Timer(delay, _delayPassed);
|
_timer = new Timer(delay, _delayPassed);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui' show Point, Offset;
|
import 'dart:ui' show Offset;
|
||||||
|
|
||||||
import 'arena.dart';
|
import 'arena.dart';
|
||||||
import 'binding.dart';
|
import 'binding.dart';
|
||||||
@ -41,7 +41,7 @@ class _TapTracker {
|
|||||||
|
|
||||||
final int pointer;
|
final int pointer;
|
||||||
final GestureArenaEntry entry;
|
final GestureArenaEntry entry;
|
||||||
final Point _initialPosition;
|
final Offset _initialPosition;
|
||||||
|
|
||||||
bool _isTrackingPointer = false;
|
bool _isTrackingPointer = false;
|
||||||
|
|
||||||
@ -249,8 +249,8 @@ class _TapGesture extends _TapTracker {
|
|||||||
bool _wonArena = false;
|
bool _wonArena = false;
|
||||||
Timer _timer;
|
Timer _timer;
|
||||||
|
|
||||||
Point _lastPosition;
|
Offset _lastPosition;
|
||||||
Point _finalPosition;
|
Offset _finalPosition;
|
||||||
|
|
||||||
void handleEvent(PointerEvent event) {
|
void handleEvent(PointerEvent event) {
|
||||||
assert(event.pointer == pointer);
|
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
|
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));
|
assert(_gestureMap.containsKey(pointer));
|
||||||
_gestureMap.remove(pointer);
|
_gestureMap.remove(pointer);
|
||||||
if (onTapUp != null)
|
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
|
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));
|
assert(_gestureMap.containsKey(pointer));
|
||||||
if (onLongTapDown != null)
|
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
|
invokeCallback<Null>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:ui' show Point, Offset;
|
import 'dart:ui' show Offset;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
|
|||||||
int primaryPointer;
|
int primaryPointer;
|
||||||
|
|
||||||
/// The global location at which the primary pointer contacted the screen.
|
/// The global location at which the primary pointer contacted the screen.
|
||||||
Point initialPosition;
|
Offset initialPosition;
|
||||||
|
|
||||||
Timer _timer;
|
Timer _timer;
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ class ScaleStartDetails {
|
|||||||
/// Creates details for [GestureScaleStartCallback].
|
/// Creates details for [GestureScaleStartCallback].
|
||||||
///
|
///
|
||||||
/// The [focalPoint] argument must not be null.
|
/// The [focalPoint] argument must not be null.
|
||||||
ScaleStartDetails({ this.focalPoint: Point.origin }) {
|
ScaleStartDetails({ this.focalPoint: Offset.zero }) {
|
||||||
assert(focalPoint != null);
|
assert(focalPoint != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The initial focal point of the pointers in contact with the screen.
|
/// The initial focal point of the pointers in contact with the screen.
|
||||||
/// Reported in global coordinates.
|
/// Reported in global coordinates.
|
||||||
final Point focalPoint;
|
final Offset focalPoint;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'ScaleStartDetails(focalPoint: $focalPoint)';
|
String toString() => 'ScaleStartDetails(focalPoint: $focalPoint)';
|
||||||
@ -50,14 +50,14 @@ class ScaleUpdateDetails {
|
|||||||
///
|
///
|
||||||
/// The [focalPoint] and [scale] arguments must not be null. The [scale]
|
/// The [focalPoint] and [scale] arguments must not be null. The [scale]
|
||||||
/// argument must be greater than or equal to zero.
|
/// 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(focalPoint != null);
|
||||||
assert(scale != null && scale >= 0.0);
|
assert(scale != null && scale >= 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The focal point of the pointers in contact with the screen. Reported in
|
/// The focal point of the pointers in contact with the screen. Reported in
|
||||||
/// global coordinates.
|
/// global coordinates.
|
||||||
final Point focalPoint;
|
final Offset focalPoint;
|
||||||
|
|
||||||
/// The scale implied by the pointers in contact with the screen. A value
|
/// The scale implied by the pointers in contact with the screen. A value
|
||||||
/// greater than or equal to zero.
|
/// greater than or equal to zero.
|
||||||
@ -121,11 +121,11 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
|
|||||||
|
|
||||||
_ScaleState _state = _ScaleState.ready;
|
_ScaleState _state = _ScaleState.ready;
|
||||||
|
|
||||||
Point _initialFocalPoint;
|
Offset _initialFocalPoint;
|
||||||
Point _currentFocalPoint;
|
Offset _currentFocalPoint;
|
||||||
double _initialSpan;
|
double _initialSpan;
|
||||||
double _currentSpan;
|
double _currentSpan;
|
||||||
Map<int, Point> _pointerLocations;
|
Map<int, Offset> _pointerLocations;
|
||||||
final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
|
final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
|
||||||
|
|
||||||
double get _scaleFactor => _initialSpan > 0.0 ? _currentSpan / _initialSpan : 1.0;
|
double get _scaleFactor => _initialSpan > 0.0 ? _currentSpan / _initialSpan : 1.0;
|
||||||
@ -138,7 +138,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
|
|||||||
_state = _ScaleState.possible;
|
_state = _ScaleState.possible;
|
||||||
_initialSpan = 0.0;
|
_initialSpan = 0.0;
|
||||||
_currentSpan = 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;
|
final int count = _pointerLocations.keys.length;
|
||||||
|
|
||||||
// Compute the focal point
|
// Compute the focal point
|
||||||
Point focalPoint = Point.origin;
|
Offset focalPoint = Offset.zero;
|
||||||
for (int pointer in _pointerLocations.keys)
|
for (int pointer in _pointerLocations.keys)
|
||||||
focalPoint += _pointerLocations[pointer].toOffset();
|
focalPoint += _pointerLocations[pointer];
|
||||||
_currentFocalPoint = count > 0 ? new Point(focalPoint.x / count, focalPoint.y / count) : Point.origin;
|
_currentFocalPoint = count > 0 ? focalPoint / count.toDouble() : Offset.zero;
|
||||||
|
|
||||||
// Span is the average deviation from focal point
|
// Span is the average deviation from focal point
|
||||||
double totalDeviation = 0.0;
|
double totalDeviation = 0.0;
|
||||||
|
@ -12,12 +12,12 @@ class TapDownDetails {
|
|||||||
/// Creates details for a [GestureTapDownCallback].
|
/// Creates details for a [GestureTapDownCallback].
|
||||||
///
|
///
|
||||||
/// The [globalPosition] argument must not be null.
|
/// The [globalPosition] argument must not be null.
|
||||||
TapDownDetails({ this.globalPosition: Point.origin }) {
|
TapDownDetails({ this.globalPosition: Offset.zero }) {
|
||||||
assert(globalPosition != null);
|
assert(globalPosition != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The global position at which the pointer contacted the screen.
|
/// 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
|
/// Signature for when a pointer that might cause a tap has contacted the
|
||||||
@ -32,12 +32,12 @@ class TapUpDetails {
|
|||||||
/// Creates details for a [GestureTapUpCallback].
|
/// Creates details for a [GestureTapUpCallback].
|
||||||
///
|
///
|
||||||
/// The [globalPosition] argument must not be null.
|
/// The [globalPosition] argument must not be null.
|
||||||
TapUpDetails({ this.globalPosition: Point.origin }) {
|
TapUpDetails({ this.globalPosition: Offset.zero }) {
|
||||||
assert(globalPosition != null);
|
assert(globalPosition != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The global position at which the pointer contacted the screen.
|
/// 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
|
/// 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 _sentTapDown = false;
|
||||||
bool _wonArenaForPrimaryPointer = false;
|
bool _wonArenaForPrimaryPointer = false;
|
||||||
Point _finalPosition;
|
Offset _finalPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handlePrimaryPointer(PointerEvent event) {
|
void handlePrimaryPointer(PointerEvent event) {
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:ui' show Point, Offset;
|
import 'dart:ui' show Offset;
|
||||||
|
|
||||||
import 'lsq_solver.dart';
|
import 'lsq_solver.dart';
|
||||||
|
|
||||||
export 'dart:ui' show Point, Offset;
|
export 'dart:ui' show Offset;
|
||||||
|
|
||||||
/// A velocity in two dimensions.
|
/// A velocity in two dimensions.
|
||||||
class Velocity {
|
class Velocity {
|
||||||
@ -119,7 +119,7 @@ class _PointAtTime {
|
|||||||
const _PointAtTime(this.point, this.time);
|
const _PointAtTime(this.point, this.time);
|
||||||
|
|
||||||
final Duration time;
|
final Duration time;
|
||||||
final Point point;
|
final Offset point;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '_PointAtTime($point at $time)';
|
String toString() => '_PointAtTime($point at $time)';
|
||||||
@ -148,7 +148,7 @@ class VelocityTracker {
|
|||||||
int _index = 0;
|
int _index = 0;
|
||||||
|
|
||||||
/// Adds a position as the given time to the tracker.
|
/// Adds a position as the given time to the tracker.
|
||||||
void addPosition(Duration time, Point position) {
|
void addPosition(Duration time, Offset position) {
|
||||||
_index += 1;
|
_index += 1;
|
||||||
if (_index == _kHistorySize)
|
if (_index == _kHistorySize)
|
||||||
_index = 0;
|
_index = 0;
|
||||||
@ -186,9 +186,9 @@ class VelocityTracker {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
oldestSample = sample;
|
oldestSample = sample;
|
||||||
final Point position = sample.point;
|
final Offset position = sample.point;
|
||||||
x.add(position.x);
|
x.add(position.dx);
|
||||||
y.add(position.y);
|
y.add(position.dy);
|
||||||
w.add(1.0);
|
w.add(1.0);
|
||||||
time.add(-age);
|
time.add(-age);
|
||||||
index = (index == 0 ? _kHistorySize : index) - 1;
|
index = (index == 0 ? _kHistorySize : index) - 1;
|
||||||
|
@ -13,7 +13,7 @@ import 'package:flutter/painting.dart';
|
|||||||
// vertical or horizontal.
|
// vertical or horizontal.
|
||||||
const double _kOnAxisDelta = 2.0;
|
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]
|
/// 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
|
/// 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:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [MaterialRectArcTween]
|
/// * [MaterialRectArcTween]
|
||||||
class MaterialPointArcTween extends Tween<Point> {
|
class MaterialPointArcTween extends Tween<Offset> {
|
||||||
/// Creates a [Tween] for animating [Point]s along a circular arc.
|
/// Creates a [Tween] for animating [Offset]s along a circular arc.
|
||||||
///
|
///
|
||||||
/// The [begin] and [end] points are required, cannot be null, and are
|
/// The [begin] and [end] points are required, cannot be null, and are
|
||||||
/// immutable.
|
/// immutable.
|
||||||
MaterialPointArcTween({
|
MaterialPointArcTween({
|
||||||
@required Point begin,
|
@required Offset begin,
|
||||||
@required Point end
|
@required Offset end
|
||||||
}) : super(begin: begin, end: end) {
|
}) : super(begin: begin, end: end) {
|
||||||
assert(begin != null);
|
assert(begin != null);
|
||||||
assert(end != null);
|
assert(end != null);
|
||||||
@ -43,43 +43,43 @@ class MaterialPointArcTween extends Tween<Point> {
|
|||||||
final double deltaX = delta.dx.abs();
|
final double deltaX = delta.dx.abs();
|
||||||
final double deltaY = delta.dy.abs();
|
final double deltaY = delta.dy.abs();
|
||||||
final double distanceFromAtoB = delta.distance;
|
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));
|
double sweepAngle() => 2.0 * math.asin(distanceFromAtoB / (2.0 * _radius));
|
||||||
|
|
||||||
if (deltaX > _kOnAxisDelta && deltaY > _kOnAxisDelta) {
|
if (deltaX > _kOnAxisDelta && deltaY > _kOnAxisDelta) {
|
||||||
if (deltaX < deltaY) {
|
if (deltaX < deltaY) {
|
||||||
_radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0;
|
_radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0;
|
||||||
_center = new Point(end.x + _radius * (begin.x - end.x).sign, end.y);
|
_center = new Offset(end.dx + _radius * (begin.dx - end.dx).sign, end.dy);
|
||||||
if (begin.x < end.x) {
|
if (begin.dx < end.dx) {
|
||||||
_beginAngle = sweepAngle() * (begin.y - end.y).sign;
|
_beginAngle = sweepAngle() * (begin.dy - end.dy).sign;
|
||||||
_endAngle = 0.0;
|
_endAngle = 0.0;
|
||||||
} else {
|
} else {
|
||||||
_beginAngle = math.PI + sweepAngle() * (end.y - begin.y).sign;
|
_beginAngle = math.PI + sweepAngle() * (end.dy - begin.dy).sign;
|
||||||
_endAngle = math.PI;
|
_endAngle = math.PI;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0;
|
_radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0;
|
||||||
_center = new Point(begin.x, begin.y + (end.y - begin.y).sign * _radius);
|
_center = new Offset(begin.dx, begin.dy + (end.dy - begin.dy).sign * _radius);
|
||||||
if (begin.y < end.y) {
|
if (begin.dy < end.dy) {
|
||||||
_beginAngle = -math.PI / 2.0;
|
_beginAngle = -math.PI / 2.0;
|
||||||
_endAngle = _beginAngle + sweepAngle() * (end.x - begin.x).sign;
|
_endAngle = _beginAngle + sweepAngle() * (end.dx - begin.dx).sign;
|
||||||
} else {
|
} else {
|
||||||
_beginAngle = math.PI / 2.0;
|
_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 _radius;
|
||||||
double _beginAngle;
|
double _beginAngle;
|
||||||
double _endAngle;
|
double _endAngle;
|
||||||
|
|
||||||
/// The center of the circular arc, null if [begin] and [end] are horiztonally or
|
/// The center of the circular arc, null if [begin] and [end] are horiztonally or
|
||||||
/// vertically aligned.
|
/// vertically aligned.
|
||||||
Point get center => _center;
|
Offset get center => _center;
|
||||||
|
|
||||||
/// The radius of the circular arc, null if begin and end are horiztonally or
|
/// The radius of the circular arc, null if begin and end are horiztonally or
|
||||||
/// vertically aligned.
|
/// 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.
|
/// Setting the arc's [begin] parameter is not supported. Construct a new arc instead.
|
||||||
@override
|
@override
|
||||||
set begin(Point value) {
|
set begin(Offset value) {
|
||||||
assert(false); // not supported
|
assert(false); // not supported
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setting the arc's [end] parameter is not supported. Construct a new arc instead.
|
/// Setting the arc's [end] parameter is not supported. Construct a new arc instead.
|
||||||
@override
|
@override
|
||||||
set end(Point value) {
|
set end(Offset value) {
|
||||||
assert(false); // not supported
|
assert(false); // not supported
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Point lerp(double t) {
|
Offset lerp(double t) {
|
||||||
if (t == 0.0)
|
if (t == 0.0)
|
||||||
return begin;
|
return begin;
|
||||||
if (t == 1.0)
|
if (t == 1.0)
|
||||||
return end;
|
return end;
|
||||||
if (_beginAngle == null || _endAngle == null)
|
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 angle = lerpDouble(_beginAngle, _endAngle, t);
|
||||||
final double x = math.cos(angle) * _radius;
|
final double x = math.cos(angle) * _radius;
|
||||||
final double y = math.sin(angle) * _radius;
|
final double y = math.sin(angle) * _radius;
|
||||||
@ -186,7 +186,7 @@ T _maxBy<T>(Iterable<T> input, _KeyFunc<T> keyFunc) {
|
|||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [MaterialPointArcTween]. the analogue for [Point] interporation.
|
/// * [MaterialPointArcTween]. the analogue for [Offset] interporation.
|
||||||
/// * [RectTween], which does a linear rectangle interpolation.
|
/// * [RectTween], which does a linear rectangle interpolation.
|
||||||
class MaterialRectArcTween extends RectTween {
|
class MaterialRectArcTween extends RectTween {
|
||||||
/// Creates a [Tween] for animating [Rect]s along a circular arc.
|
/// Creates a [Tween] for animating [Rect]s along a circular arc.
|
||||||
@ -215,14 +215,14 @@ class MaterialRectArcTween extends RectTween {
|
|||||||
MaterialPointArcTween _beginArc;
|
MaterialPointArcTween _beginArc;
|
||||||
MaterialPointArcTween _endArc;
|
MaterialPointArcTween _endArc;
|
||||||
|
|
||||||
Point _cornerFor(Rect rect, _CornerId id) {
|
Offset _cornerFor(Rect rect, _CornerId id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case _CornerId.topLeft: return rect.topLeft;
|
case _CornerId.topLeft: return rect.topLeft;
|
||||||
case _CornerId.topRight: return rect.topRight;
|
case _CornerId.topRight: return rect.topRight;
|
||||||
case _CornerId.bottomLeft: return rect.bottomLeft;
|
case _CornerId.bottomLeft: return rect.bottomLeft;
|
||||||
case _CornerId.bottomRight: return rect.bottomRight;
|
case _CornerId.bottomRight: return rect.bottomRight;
|
||||||
}
|
}
|
||||||
return Point.origin;
|
return Offset.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _diagonalSupport(Offset centersVector, _Diagonal diagonal) {
|
double _diagonalSupport(Offset centersVector, _Diagonal diagonal) {
|
||||||
|
@ -571,7 +571,7 @@ class _RadialPainter extends CustomPainter {
|
|||||||
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.height);
|
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.height);
|
||||||
canvas.clipRect(rect);
|
canvas.clipRect(rect);
|
||||||
final double navWidth = math.min(bottomNavMaxWidth, size.width);
|
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,
|
(size.width - navWidth) / 2.0 + circle.offset.dx * navWidth,
|
||||||
circle.offset.dy * size.height
|
circle.offset.dy * size.height
|
||||||
);
|
);
|
||||||
|
@ -172,7 +172,7 @@ class _RenderCheckbox extends RenderToggleable {
|
|||||||
final double offsetX = offset.dx + (size.width - _kEdgeSize) / 2.0;
|
final double offsetX = offset.dx + (size.width - _kEdgeSize) / 2.0;
|
||||||
final double offsetY = offset.dy + (size.height - _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;
|
final double t = position.value;
|
||||||
|
|
||||||
@ -203,14 +203,14 @@ class _RenderCheckbox extends RenderToggleable {
|
|||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = _kStrokeWidth;
|
..strokeWidth = _kStrokeWidth;
|
||||||
final Path path = new Path();
|
final Path path = new Path();
|
||||||
final Point start = const Point(_kEdgeSize * 0.15, _kEdgeSize * 0.45);
|
final Offset start = const Offset(_kEdgeSize * 0.15, _kEdgeSize * 0.45);
|
||||||
final Point mid = const Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7);
|
final Offset mid = const Offset(_kEdgeSize * 0.4, _kEdgeSize * 0.7);
|
||||||
final Point end = const Point(_kEdgeSize * 0.85, _kEdgeSize * 0.25);
|
final Offset end = const Offset(_kEdgeSize * 0.85, _kEdgeSize * 0.25);
|
||||||
final Point drawStart = Point.lerp(start, mid, 1.0 - value);
|
final Offset drawStart = Offset.lerp(start, mid, 1.0 - value);
|
||||||
final Point drawEnd = Point.lerp(mid, end, value);
|
final Offset drawEnd = Offset.lerp(mid, end, value);
|
||||||
path.moveTo(offsetX + drawStart.x, offsetY + drawStart.y);
|
path.moveTo(offsetX + drawStart.dx, offsetY + drawStart.dy);
|
||||||
path.lineTo(offsetX + mid.x, offsetY + mid.y);
|
path.lineTo(offsetX + mid.dx, offsetY + mid.dy);
|
||||||
path.lineTo(offsetX + drawEnd.x, offsetY + drawEnd.y);
|
path.lineTo(offsetX + drawEnd.dx, offsetY + drawEnd.dy);
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class _DropdownMenuPainter extends CustomPainter {
|
|||||||
|
|
||||||
final Rect rect = new Rect.fromLTRB(0.0, top.evaluate(resize), size.width, bottom.evaluate(resize));
|
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
|
@override
|
||||||
@ -231,7 +231,7 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
|
|||||||
top = bottom - childSize.height;
|
top = bottom - childSize.height;
|
||||||
}
|
}
|
||||||
assert(() {
|
assert(() {
|
||||||
final Rect container = Point.origin & size;
|
final Rect container = Offset.zero & size;
|
||||||
if (container.intersect(buttonRect) == buttonRect) {
|
if (container.intersect(buttonRect) == buttonRect) {
|
||||||
// If the button was entirely on-screen, then verify
|
// If the button was entirely on-screen, then verify
|
||||||
// that the menu is also on-screen.
|
// that the menu is also on-screen.
|
||||||
@ -499,7 +499,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> {
|
|||||||
|
|
||||||
void _handleTap() {
|
void _handleTap() {
|
||||||
final RenderBox itemBox = context.findRenderObject();
|
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>(
|
Navigator.push(context, new _DropdownRoute<T>(
|
||||||
items: widget.items,
|
items: widget.items,
|
||||||
buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect),
|
buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect),
|
||||||
|
@ -131,7 +131,7 @@ class InkHighlight extends InkFeature {
|
|||||||
void paintFeature(Canvas canvas, Matrix4 transform) {
|
void paintFeature(Canvas canvas, Matrix4 transform) {
|
||||||
final Paint paint = new Paint()..color = color.withAlpha(_alpha.value);
|
final Paint paint = new Paint()..color = color.withAlpha(_alpha.value);
|
||||||
final Offset originOffset = MatrixUtils.getAsTranslation(transform);
|
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) {
|
if (originOffset == null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.transform(transform.storage);
|
canvas.transform(transform.storage);
|
||||||
|
@ -22,11 +22,11 @@ RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, Rec
|
|||||||
return rectCallback;
|
return rectCallback;
|
||||||
}
|
}
|
||||||
if (containedInkWell)
|
if (containedInkWell)
|
||||||
return () => Point.origin & referenceBox.size;
|
return () => Offset.zero & referenceBox.size;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Point position) {
|
double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Offset position) {
|
||||||
if (containedInkWell) {
|
if (containedInkWell) {
|
||||||
final Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
|
final Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
|
||||||
return _getSplashRadiusForPoistionInSize(size, position);
|
return _getSplashRadiusForPoistionInSize(size, position);
|
||||||
@ -34,11 +34,11 @@ double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallb
|
|||||||
return Material.defaultSplashRadius;
|
return Material.defaultSplashRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _getSplashRadiusForPoistionInSize(Size bounds, Point position) {
|
double _getSplashRadiusForPoistionInSize(Size bounds, Offset position) {
|
||||||
final double d1 = (position - bounds.topLeft(Point.origin)).distance;
|
final double d1 = (position - bounds.topLeft(Offset.zero)).distance;
|
||||||
final double d2 = (position - bounds.topRight(Point.origin)).distance;
|
final double d2 = (position - bounds.topRight(Offset.zero)).distance;
|
||||||
final double d3 = (position - bounds.bottomLeft(Point.origin)).distance;
|
final double d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
|
||||||
final double d4 = (position - bounds.bottomRight(Point.origin)).distance;
|
final double d4 = (position - bounds.bottomRight(Offset.zero)).distance;
|
||||||
return math.max(math.max(d1, d2), math.max(d3, d4)).ceilToDouble();
|
return math.max(math.max(d1, d2), math.max(d3, d4)).ceilToDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class InkSplash extends InkFeature {
|
|||||||
InkSplash({
|
InkSplash({
|
||||||
@required MaterialInkController controller,
|
@required MaterialInkController controller,
|
||||||
@required RenderBox referenceBox,
|
@required RenderBox referenceBox,
|
||||||
Point position,
|
Offset position,
|
||||||
Color color,
|
Color color,
|
||||||
bool containedInkWell: false,
|
bool containedInkWell: false,
|
||||||
RectCallback rectCallback,
|
RectCallback rectCallback,
|
||||||
@ -109,7 +109,7 @@ class InkSplash extends InkFeature {
|
|||||||
controller.addInkFeature(this);
|
controller.addInkFeature(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Point _position;
|
final Offset _position;
|
||||||
final BorderRadius _borderRadius;
|
final BorderRadius _borderRadius;
|
||||||
final double _targetRadius;
|
final double _targetRadius;
|
||||||
final RectCallback _clipCallback;
|
final RectCallback _clipCallback;
|
||||||
@ -185,9 +185,9 @@ class InkSplash extends InkFeature {
|
|||||||
@override
|
@override
|
||||||
void paintFeature(Canvas canvas, Matrix4 transform) {
|
void paintFeature(Canvas canvas, Matrix4 transform) {
|
||||||
final Paint paint = new Paint()..color = _color.withAlpha(_alpha.value);
|
final Paint paint = new Paint()..color = _color.withAlpha(_alpha.value);
|
||||||
Point center = _position;
|
Offset center = _position;
|
||||||
if (_repositionToReferenceBox)
|
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);
|
final Offset originOffset = MatrixUtils.getAsTranslation(transform);
|
||||||
if (originOffset == null) {
|
if (originOffset == null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
|
@ -340,7 +340,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
@ -348,7 +348,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
|
|||||||
final Canvas canvas = context.canvas;
|
final Canvas canvas = context.canvas;
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(offset.dx, offset.dy);
|
canvas.translate(offset.dx, offset.dy);
|
||||||
canvas.clipRect(Point.origin & size);
|
canvas.clipRect(Offset.zero & size);
|
||||||
for (InkFeature inkFeature in _inkFeatures)
|
for (InkFeature inkFeature in _inkFeatures)
|
||||||
inkFeature._paint(canvas);
|
inkFeature._paint(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
@ -524,15 +524,17 @@ class PopupMenuButton<T> extends StatefulWidget {
|
|||||||
class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
||||||
void showButtonMenu() {
|
void showButtonMenu() {
|
||||||
final RenderBox renderBox = context.findRenderObject();
|
final RenderBox renderBox = context.findRenderObject();
|
||||||
final Point topLeft = renderBox.localToGlobal(Point.origin);
|
final Offset topLeft = renderBox.localToGlobal(Offset.zero);
|
||||||
showMenu<T>(
|
showMenu<T>(
|
||||||
context: context,
|
context: context,
|
||||||
elevation: widget.elevation,
|
elevation: widget.elevation,
|
||||||
items: widget.itemBuilder(context),
|
items: widget.itemBuilder(context),
|
||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
position: new RelativeRect.fromLTRB(
|
position: new RelativeRect.fromLTRB(
|
||||||
topLeft.x, topLeft.y + (widget.initialValue != null ? renderBox.size.height / 2.0 : 0.0),
|
topLeft.dx,
|
||||||
0.0, 0.0
|
topLeft.dy + (widget.initialValue != null ? renderBox.size.height / 2.0 : 0.0),
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then<Null>((T newValue) {
|
.then<Null>((T newValue) {
|
||||||
|
@ -89,18 +89,18 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
|
|||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..color = backgroundColor
|
..color = backgroundColor
|
||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
canvas.drawRect(Point.origin & size, paint);
|
canvas.drawRect(Offset.zero & size, paint);
|
||||||
|
|
||||||
paint.color = valueColor;
|
paint.color = valueColor;
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final double width = value.clamp(0.0, 1.0) * size.width;
|
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 {
|
} else {
|
||||||
final double startX = size.width * (1.5 * animationValue - 0.5);
|
final double startX = size.width * (1.5 * animationValue - 0.5);
|
||||||
final double endX = startX + 0.5 * size.width;
|
final double endX = startX + 0.5 * size.width;
|
||||||
final double x = startX.clamp(0.0, size.width);
|
final double x = startX.clamp(0.0, size.width);
|
||||||
final double width = endX.clamp(0.0, size.width) - x;
|
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
|
if (value == null) // Indeterminate
|
||||||
paint.strokeCap = StrokeCap.square;
|
paint.strokeCap = StrokeCap.square;
|
||||||
|
|
||||||
canvas.drawArc(Point.origin & size, arcStart, arcSweep, false, paint);
|
canvas.drawArc(Offset.zero & size, arcStart, arcSweep, false, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -190,9 +190,9 @@ class _RenderRadio extends RenderToggleable {
|
|||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
final Canvas canvas = context.canvas;
|
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;
|
final Color radioColor = onChanged != null ? activeColor : inactiveColor;
|
||||||
|
|
||||||
// Outer circle
|
// Outer circle
|
||||||
|
@ -143,13 +143,13 @@ class _ScrollbarController extends ChangeNotifier {
|
|||||||
Paint get _paint => new Paint()..color = color.withOpacity(_opacity.value);
|
Paint get _paint => new Paint()..color = color.withOpacity(_opacity.value);
|
||||||
|
|
||||||
void _paintVerticalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
|
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);
|
final Size thumbSize = new Size(_kThumbGirth, thumbExtent);
|
||||||
canvas.drawRect(thumbOrigin & thumbSize, _paint);
|
canvas.drawRect(thumbOrigin & thumbSize, _paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _paintHorizontalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) {
|
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);
|
final Size thumbSize = new Size(thumbExtent, _kThumbGirth);
|
||||||
canvas.drawRect(thumbOrigin & thumbSize, _paint);
|
canvas.drawRect(thumbOrigin & thumbSize, _paint);
|
||||||
}
|
}
|
||||||
|
@ -389,8 +389,8 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
|
|||||||
|
|
||||||
bool get isInteractive => onChanged != null;
|
bool get isInteractive => onChanged != null;
|
||||||
|
|
||||||
double _getValueFromGlobalPosition(Point globalPosition) {
|
double _getValueFromGlobalPosition(Offset globalPosition) {
|
||||||
return (globalToLocal(globalPosition).x - _kReactionRadius) / _trackLength;
|
return (globalToLocal(globalPosition).dx - _kReactionRadius) / _trackLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _discretize(double value) {
|
double _discretize(double value) {
|
||||||
@ -430,7 +430,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
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 primaryPaint = new Paint()..color = enabled ? _activeColor : _kInactiveTrackColor;
|
||||||
final Paint trackPaint = new Paint()..color = _kTrackColorTween.evaluate(_reaction);
|
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;
|
final double thumbRadius = enabled ? _kThumbRadiusTween.evaluate(_reaction) : _kDisabledThumbRadius;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
@ -495,22 +495,22 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (label != null) {
|
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 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;
|
final double tipAttachment = _kLabelBalloonTipAttachmentRatio * radius;
|
||||||
|
|
||||||
canvas.drawCircle(center, radius, primaryPaint);
|
canvas.drawCircle(center, radius, primaryPaint);
|
||||||
final Path path = new Path()
|
final Path path = new Path()
|
||||||
..moveTo(tip.x, tip.y)
|
..moveTo(tip.dx, tip.dy)
|
||||||
..lineTo(center.x - tipAttachment, center.y + tipAttachment)
|
..lineTo(center.dx - tipAttachment, center.dy + tipAttachment)
|
||||||
..lineTo(center.x + tipAttachment, center.y + tipAttachment)
|
..lineTo(center.dx + tipAttachment, center.dy + tipAttachment)
|
||||||
..close();
|
..close();
|
||||||
canvas.drawPath(path, primaryPaint);
|
canvas.drawPath(path, primaryPaint);
|
||||||
_labelPainter.layout();
|
_labelPainter.layout();
|
||||||
final Offset labelOffset = new Offset(
|
final Offset labelOffset = new Offset(
|
||||||
center.x - _labelPainter.width / 2.0,
|
center.dx - _labelPainter.width / 2.0,
|
||||||
center.y - _labelPainter.height / 2.0
|
center.dy - _labelPainter.height / 2.0
|
||||||
);
|
);
|
||||||
_labelPainter.paint(canvas, labelOffset);
|
_labelPainter.paint(canvas, labelOffset);
|
||||||
return;
|
return;
|
||||||
|
@ -652,7 +652,7 @@ class _TrianglePainter extends CustomPainter {
|
|||||||
final Color color;
|
final Color color;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Point point) => true; // Hitting the rectangle is fine enough.
|
bool hitTest(Offset point) => true; // Hitting the rectangle is fine enough.
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(_TrianglePainter oldPainter) {
|
bool shouldRepaint(_TrianglePainter oldPainter) {
|
||||||
@ -664,10 +664,10 @@ class _TrianglePainter extends CustomPainter {
|
|||||||
final double base = size.width;
|
final double base = size.width;
|
||||||
final double halfBase = size.width / 2.0;
|
final double halfBase = size.width / 2.0;
|
||||||
final double height = size.height;
|
final double height = size.height;
|
||||||
final List<Point> points = <Point>[
|
final List<Offset> points = <Offset>[
|
||||||
new Point(0.0, height),
|
new Offset(0.0, height),
|
||||||
new Point(base, height),
|
new Offset(base, height),
|
||||||
new Point(halfBase, 0.0),
|
new Offset(halfBase, 0.0),
|
||||||
];
|
];
|
||||||
|
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
|
@ -365,7 +365,7 @@ class _RenderSwitch extends RenderToggleable {
|
|||||||
final RRect trackRRect = new RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius));
|
final RRect trackRRect = new RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius));
|
||||||
canvas.drawRRect(trackRRect, paint);
|
canvas.drawRRect(trackRRect, paint);
|
||||||
|
|
||||||
final Point thumbPosition = new Point(
|
final Offset thumbPosition = new Offset(
|
||||||
kRadialReactionRadius + currentPosition * _trackInnerLength,
|
kRadialReactionRadius + currentPosition * _trackInnerLength,
|
||||||
size.height / 2.0
|
size.height / 2.0
|
||||||
);
|
);
|
||||||
@ -389,7 +389,7 @@ class _RenderSwitch extends RenderToggleable {
|
|||||||
final double radius = _kThumbRadius - inset;
|
final double radius = _kThumbRadius - inset;
|
||||||
thumbPainter.paint(
|
thumbPainter.paint(
|
||||||
canvas,
|
canvas,
|
||||||
thumbPosition.toOffset() + offset - new Offset(radius, radius),
|
thumbPosition + offset - new Offset(radius, radius),
|
||||||
configuration.copyWith(size: new Size.fromRadius(radius))
|
configuration.copyWith(size: new Size.fromRadius(radius))
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -92,7 +92,7 @@ class _TextSelectionToolbar extends StatelessWidget {
|
|||||||
class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate {
|
class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate {
|
||||||
_TextSelectionToolbarLayout(this.position);
|
_TextSelectionToolbarLayout(this.position);
|
||||||
|
|
||||||
final Point position;
|
final Offset position;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
|
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
|
||||||
@ -101,8 +101,8 @@ class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Offset getPositionForChild(Size size, Size childSize) {
|
Offset getPositionForChild(Size size, Size childSize) {
|
||||||
double x = position.x - childSize.width/2.0;
|
double x = position.dx - childSize.width / 2.0;
|
||||||
double y = position.y - childSize.height;
|
double y = position.dy - childSize.height;
|
||||||
|
|
||||||
if (x < _kToolbarScreenPadding)
|
if (x < _kToolbarScreenPadding)
|
||||||
x = _kToolbarScreenPadding;
|
x = _kToolbarScreenPadding;
|
||||||
@ -133,7 +133,7 @@ class _TextSelectionHandlePainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final Paint paint = new Paint()..color = color;
|
final Paint paint = new Paint()..color = color;
|
||||||
final double radius = size.width/2.0;
|
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);
|
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.
|
/// Builder for material-style copy/paste text selection toolbar.
|
||||||
@override
|
@override
|
||||||
Widget buildToolbar(
|
Widget buildToolbar(
|
||||||
BuildContext context, Point position, TextSelectionDelegate delegate) {
|
BuildContext context, Offset position, TextSelectionDelegate delegate) {
|
||||||
final Size screenSize = MediaQuery.of(context).size;
|
final Size screenSize = MediaQuery.of(context).size;
|
||||||
return new ConstrainedBox(
|
return new ConstrainedBox(
|
||||||
constraints: new BoxConstraints.loose(screenSize),
|
constraints: new BoxConstraints.loose(screenSize),
|
||||||
|
@ -393,7 +393,7 @@ class _DialPainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final double radius = size.shortestSide / 2.0;
|
final double radius = size.shortestSide / 2.0;
|
||||||
final Offset center = new Offset(size.width / 2.0, size.height / 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);
|
canvas.drawCircle(centerPoint, radius, new Paint()..color = backgroundColor);
|
||||||
|
|
||||||
const double labelPadding = 24.0;
|
const double labelPadding = 24.0;
|
||||||
@ -418,7 +418,7 @@ class _DialPainter extends CustomPainter {
|
|||||||
|
|
||||||
final Paint selectorPaint = new Paint()
|
final Paint selectorPaint = new Paint()
|
||||||
..color = accentColor;
|
..color = accentColor;
|
||||||
final Point focusedPoint = getOffsetForTheta(theta).toPoint();
|
final Offset focusedPoint = getOffsetForTheta(theta);
|
||||||
final double focusedRadius = labelPadding - 4.0;
|
final double focusedRadius = labelPadding - 4.0;
|
||||||
canvas.drawCircle(centerPoint, 4.0, selectorPaint);
|
canvas.drawCircle(centerPoint, 4.0, selectorPaint);
|
||||||
canvas.drawCircle(focusedPoint, focusedRadius, selectorPaint);
|
canvas.drawCircle(focusedPoint, focusedRadius, selectorPaint);
|
||||||
@ -549,15 +549,15 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Point _position;
|
Offset _position;
|
||||||
Point _center;
|
Offset _center;
|
||||||
|
|
||||||
void _handlePanStart(DragStartDetails details) {
|
void _handlePanStart(DragStartDetails details) {
|
||||||
assert(!_dragging);
|
assert(!_dragging);
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
final RenderBox box = context.findRenderObject();
|
final RenderBox box = context.findRenderObject();
|
||||||
_position = box.globalToLocal(details.globalPosition);
|
_position = box.globalToLocal(details.globalPosition);
|
||||||
_center = box.size.center(Point.origin);
|
_center = box.size.center(Offset.zero);
|
||||||
_updateThetaForPan();
|
_updateThetaForPan();
|
||||||
_notifyOnChangedIfNeeded();
|
_notifyOnChangedIfNeeded();
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
|
|||||||
bool get isInteractive => onChanged != null;
|
bool get isInteractive => onChanged != null;
|
||||||
|
|
||||||
TapGestureRecognizer _tap;
|
TapGestureRecognizer _tap;
|
||||||
Point _downPosition;
|
Offset _downPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void attach(PipelineOwner owner) {
|
void attach(PipelineOwner owner) {
|
||||||
@ -257,7 +257,7 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
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
|
/// origin is the center point of the reaction (usually distinct from the
|
||||||
/// point at which the user interacted with the control, which is handled
|
/// point at which the user interacted with the control, which is handled
|
||||||
/// automatically).
|
/// automatically).
|
||||||
void paintRadialReaction(Canvas canvas, Offset offset, Point origin) {
|
void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) {
|
||||||
if (!_reaction.isDismissed) {
|
if (!_reaction.isDismissed) {
|
||||||
// TODO(abarth): We should have a different reaction color when position is zero.
|
// TODO(abarth): We should have a different reaction color when position is zero.
|
||||||
final Paint reactionPaint = new Paint()..color = activeColor.withAlpha(kRadialReactionAlpha);
|
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);
|
final double radius = _kRadialReactionRadiusTween.evaluate(_reaction);
|
||||||
canvas.drawCircle(center + offset, radius, reactionPaint);
|
canvas.drawCircle(center + offset, radius, reactionPaint);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
|||||||
return; // Already visible.
|
return; // Already visible.
|
||||||
}
|
}
|
||||||
final RenderBox box = context.findRenderObject();
|
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
|
// 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
|
// updated values from happening to leak into the overlay when the overlay
|
||||||
// rebuilds.
|
// rebuilds.
|
||||||
@ -195,7 +195,7 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
|
|||||||
this.preferBelow
|
this.preferBelow
|
||||||
});
|
});
|
||||||
|
|
||||||
final Point target;
|
final Offset target;
|
||||||
final double verticalOffset;
|
final double verticalOffset;
|
||||||
final bool preferBelow;
|
final bool preferBelow;
|
||||||
|
|
||||||
@ -205,16 +205,16 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
|
|||||||
@override
|
@override
|
||||||
Offset getPositionForChild(Size size, Size childSize) {
|
Offset getPositionForChild(Size size, Size childSize) {
|
||||||
// VERTICAL DIRECTION
|
// VERTICAL DIRECTION
|
||||||
final bool fitsBelow = target.y + verticalOffset + childSize.height <= size.height - _kScreenEdgeMargin;
|
final bool fitsBelow = target.dy + verticalOffset + childSize.height <= size.height - _kScreenEdgeMargin;
|
||||||
final bool fitsAbove = target.y - verticalOffset - childSize.height >= _kScreenEdgeMargin;
|
final bool fitsAbove = target.dy - verticalOffset - childSize.height >= _kScreenEdgeMargin;
|
||||||
final bool tooltipBelow = preferBelow ? fitsBelow || !fitsAbove : !(fitsAbove || !fitsBelow);
|
final bool tooltipBelow = preferBelow ? fitsBelow || !fitsAbove : !(fitsAbove || !fitsBelow);
|
||||||
double y;
|
double y;
|
||||||
if (tooltipBelow)
|
if (tooltipBelow)
|
||||||
y = math.min(target.y + verticalOffset, size.height - _kScreenEdgeMargin);
|
y = math.min(target.dy + verticalOffset, size.height - _kScreenEdgeMargin);
|
||||||
else
|
else
|
||||||
y = math.max(target.y - verticalOffset - childSize.height, _kScreenEdgeMargin);
|
y = math.max(target.dy - verticalOffset - childSize.height, _kScreenEdgeMargin);
|
||||||
// HORIZONTAL DIRECTION
|
// HORIZONTAL DIRECTION
|
||||||
final double normalizedTargetX = target.x.clamp(_kScreenEdgeMargin, size.width - _kScreenEdgeMargin);
|
final double normalizedTargetX = target.dx.clamp(_kScreenEdgeMargin, size.width - _kScreenEdgeMargin);
|
||||||
double x;
|
double x;
|
||||||
if (normalizedTargetX < _kScreenEdgeMargin + childSize.width / 2.0) {
|
if (normalizedTargetX < _kScreenEdgeMargin + childSize.width / 2.0) {
|
||||||
x = _kScreenEdgeMargin;
|
x = _kScreenEdgeMargin;
|
||||||
@ -250,7 +250,7 @@ class _TooltipOverlay extends StatelessWidget {
|
|||||||
final double height;
|
final double height;
|
||||||
final EdgeInsets padding;
|
final EdgeInsets padding;
|
||||||
final Animation<double> animation;
|
final Animation<double> animation;
|
||||||
final Point target;
|
final Offset target;
|
||||||
final double verticalOffset;
|
final double verticalOffset;
|
||||||
final bool preferBelow;
|
final bool preferBelow;
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ export 'dart:ui' show
|
|||||||
PaintingStyle,
|
PaintingStyle,
|
||||||
Path,
|
Path,
|
||||||
PathFillType,
|
PathFillType,
|
||||||
Point,
|
|
||||||
Radius,
|
Radius,
|
||||||
RRect,
|
RRect,
|
||||||
RSTransform,
|
RSTransform,
|
||||||
|
@ -89,7 +89,7 @@ class FittedSizes {
|
|||||||
/// ```dart
|
/// ```dart
|
||||||
/// final Size imageSize = new Size(image.width.toDouble(), image.height.toDouble());
|
/// final Size imageSize = new Size(image.width.toDouble(), image.height.toDouble());
|
||||||
/// final FittedSizes sizes = applyBoxFit(fit, imageSize, outputRect.size);
|
/// 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);
|
/// final Rect outputSubrect = FractionalOffset.center.inscribe(sizes.destination, outputRect);
|
||||||
/// canvas.drawImageRect(image, inputSubrect, outputSubrect, paint);
|
/// canvas.drawImageRect(image, inputSubrect, outputSubrect, paint);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -668,8 +668,9 @@ class LinearGradient extends Gradient {
|
|||||||
@override
|
@override
|
||||||
Shader createShader(Rect rect) {
|
Shader createShader(Rect rect) {
|
||||||
return new ui.Gradient.linear(
|
return new ui.Gradient.linear(
|
||||||
<Point>[begin.withinRect(rect), end.withinRect(rect)],
|
begin.withinRect(rect),
|
||||||
colors, stops, tileMode
|
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 dx = (outputSize.width - destinationSize.width) * (alignment?.dx ?? 0.5);
|
||||||
final double dy = (outputSize.height - destinationSize.height) * (alignment?.dy ?? 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;
|
final Rect destinationRect = destinationPosition & destinationSize;
|
||||||
if (repeat != ImageRepeat.noRepeat) {
|
if (repeat != ImageRepeat.noRepeat) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
@ -946,7 +947,7 @@ void paintImage({
|
|||||||
}
|
}
|
||||||
if (centerSlice == null) {
|
if (centerSlice == null) {
|
||||||
final Rect sourceRect = (alignment ?? FractionalOffset.center).inscribe(
|
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))
|
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
|
||||||
canvas.drawImageRect(image, sourceRect, tileRect, paint);
|
canvas.drawImageRect(image, sourceRect, tileRect, paint);
|
||||||
@ -1228,19 +1229,19 @@ class BoxDecoration extends Decoration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Size size, Point position) {
|
bool hitTest(Size size, Offset position) {
|
||||||
assert(shape != null);
|
assert(shape != null);
|
||||||
assert((Point.origin & size).contains(position));
|
assert((Offset.zero & size).contains(position));
|
||||||
switch (shape) {
|
switch (shape) {
|
||||||
case BoxShape.rectangle:
|
case BoxShape.rectangle:
|
||||||
if (borderRadius != null) {
|
if (borderRadius != null) {
|
||||||
final RRect bounds = borderRadius.toRRect(Point.origin & size);
|
final RRect bounds = borderRadius.toRRect(Offset.zero & size);
|
||||||
return bounds.contains(position);
|
return bounds.contains(position);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case BoxShape.circle:
|
case BoxShape.circle:
|
||||||
// Circles are inscribed into our smallest dimension.
|
// 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;
|
final double distance = (position - center).distance;
|
||||||
return distance <= math.min(size.width, size.height) / 2.0;
|
return distance <= math.min(size.width, size.height) / 2.0;
|
||||||
}
|
}
|
||||||
@ -1292,7 +1293,7 @@ class _BoxDecorationPainter extends BoxPainter {
|
|||||||
switch (_decoration.shape) {
|
switch (_decoration.shape) {
|
||||||
case BoxShape.circle:
|
case BoxShape.circle:
|
||||||
assert(_decoration.borderRadius == null);
|
assert(_decoration.borderRadius == null);
|
||||||
final Point center = rect.center;
|
final Offset center = rect.center;
|
||||||
final double radius = rect.shortestSide / 2.0;
|
final double radius = rect.shortestSide / 2.0;
|
||||||
canvas.drawCircle(center, radius, paint);
|
canvas.drawCircle(center, radius, paint);
|
||||||
break;
|
break;
|
||||||
|
@ -10,7 +10,7 @@ import 'edge_insets.dart';
|
|||||||
|
|
||||||
export 'package:flutter/services.dart' show ImageConfiguration;
|
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;
|
export 'edge_insets.dart' show EdgeInsets;
|
||||||
|
|
||||||
// This group of classes is intended for painting in cartesian coordinates.
|
// 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
|
/// if the decoration only draws a circle, this function might
|
||||||
/// return true if the point was inside the circle and false
|
/// return true if the point was inside the circle and false
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
bool hitTest(Size size, Point position) => true;
|
bool hitTest(Size size, Offset position) => true;
|
||||||
|
|
||||||
/// Returns a [BoxPainter] that will paint this decoration.
|
/// Returns a [BoxPainter] that will paint this decoration.
|
||||||
///
|
///
|
||||||
|
@ -174,7 +174,7 @@ class FlutterLogoDecoration extends Decoration {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO(ianh): better hit testing
|
// TODO(ianh): better hit testing
|
||||||
bool hitTest(Size size, Point position) => true;
|
bool hitTest(Size size, Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
BoxPainter createBoxPainter([VoidCallback onChanged]) {
|
BoxPainter createBoxPainter([VoidCallback onChanged]) {
|
||||||
@ -275,10 +275,8 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
..color = _config.darkColor;
|
..color = _config.darkColor;
|
||||||
|
|
||||||
final ui.Gradient triangleGradient = new ui.Gradient.linear(
|
final ui.Gradient triangleGradient = new ui.Gradient.linear(
|
||||||
const <Point>[
|
const Offset(87.2623 + 37.9092, 28.8384 + 123.4389),
|
||||||
const Point(87.2623 + 37.9092, 28.8384 + 123.4389),
|
const Offset(42.9205 + 37.9092, 35.0952 + 123.4389),
|
||||||
const Point(42.9205 + 37.9092, 35.0952 + 123.4389),
|
|
||||||
],
|
|
||||||
<Color>[
|
<Color>[
|
||||||
const Color(0xBFFFFFFF),
|
const Color(0xBFFFFFFF),
|
||||||
const Color(0xBFFCFCFC),
|
const Color(0xBFFCFCFC),
|
||||||
@ -290,17 +288,15 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
const Color(0xBF6E6E6E),
|
const Color(0xBF6E6E6E),
|
||||||
const Color(0xBF616161),
|
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()
|
final Paint trianglePaint = new Paint()
|
||||||
..shader = triangleGradient
|
..shader = triangleGradient
|
||||||
..blendMode = BlendMode.multiply;
|
..blendMode = BlendMode.multiply;
|
||||||
|
|
||||||
final ui.Gradient rectangleGradient = new ui.Gradient.linear(
|
final ui.Gradient rectangleGradient = new ui.Gradient.linear(
|
||||||
const <Point>[
|
const Offset(62.3643 + 37.9092, 40.135 + 123.4389),
|
||||||
const Point(62.3643 + 37.9092, 40.135 + 123.4389),
|
const Offset(54.0376 + 37.9092, 31.8083 + 123.4389),
|
||||||
const Point(54.0376 + 37.9092, 31.8083 + 123.4389),
|
|
||||||
],
|
|
||||||
<Color>[
|
<Color>[
|
||||||
const Color(0x80FFFFFF),
|
const Color(0x80FFFFFF),
|
||||||
const Color(0x80FCFCFC),
|
const Color(0x80FCFCFC),
|
||||||
@ -440,11 +436,11 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
);
|
);
|
||||||
canvas.save();
|
canvas.save();
|
||||||
if (_config._position < 1.0) {
|
if (_config._position < 1.0) {
|
||||||
final Point center = logoSquare.center;
|
final Offset center = logoSquare.center;
|
||||||
final Path path = new Path()
|
final Path path = new Path()
|
||||||
..moveTo(center.x, center.y)
|
..moveTo(center.dx, center.dy)
|
||||||
..lineTo(center.x + rect.width, center.y - rect.width)
|
..lineTo(center.dx + rect.width, center.dy - rect.width)
|
||||||
..lineTo(center.x + rect.width, center.y + rect.width)
|
..lineTo(center.dx + rect.width, center.dy + rect.width)
|
||||||
..close();
|
..close();
|
||||||
canvas.clipPath(path);
|
canvas.clipPath(path);
|
||||||
}
|
}
|
||||||
@ -462,7 +458,7 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
canvas.save();
|
canvas.save();
|
||||||
}
|
}
|
||||||
canvas.translate(
|
canvas.translate(
|
||||||
logoTargetSquare.center.x - (_textBoundingRect.width * scale / 2.0),
|
logoTargetSquare.center.dx - (_textBoundingRect.width * scale / 2.0),
|
||||||
logoTargetSquare.bottom
|
logoTargetSquare.bottom
|
||||||
);
|
);
|
||||||
canvas.scale(scale, scale);
|
canvas.scale(scale, scale);
|
||||||
@ -471,7 +467,8 @@ class _FlutterLogoPainter extends BoxPainter {
|
|||||||
canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint()
|
canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint()
|
||||||
..blendMode = BlendMode.modulate
|
..blendMode = BlendMode.modulate
|
||||||
..shader = new ui.Gradient.linear(
|
..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)],
|
<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 ],
|
<double>[ 0.0, math.max(0.0, _config._position.abs() - 0.1), math.min(_config._position.abs() + 0.1, 1.0), 1.0 ],
|
||||||
)
|
)
|
||||||
|
@ -103,8 +103,8 @@ class FractionalOffset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the point that is this fraction within the given rect.
|
/// Returns the point that is this fraction within the given rect.
|
||||||
Point withinRect(Rect rect) {
|
Offset withinRect(Rect rect) {
|
||||||
return new Point(rect.left + dx * rect.width, rect.top + dy * rect.height);
|
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.
|
/// Returns a rect of the given size, centered at this fraction of the given rect.
|
||||||
|
@ -94,10 +94,10 @@ class MatrixUtils {
|
|||||||
///
|
///
|
||||||
/// This function assumes the given point has a z-coordinate of 0.0. The
|
/// This function assumes the given point has a z-coordinate of 0.0. The
|
||||||
/// z-coordinate of the result is ignored.
|
/// z-coordinate of the result is ignored.
|
||||||
static Point transformPoint(Matrix4 transform, Point point) {
|
static Offset transformPoint(Matrix4 transform, Offset point) {
|
||||||
final Vector3 position3 = new Vector3(point.x, point.y, 0.0);
|
final Vector3 position3 = new Vector3(point.dx, point.dy, 0.0);
|
||||||
final Vector3 transformed3 = transform.perspectiveTransform(position3);
|
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
|
/// 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
|
/// The transformed rect is then projected back into the plane with z equals
|
||||||
/// 0.0 before computing its bounding rect.
|
/// 0.0 before computing its bounding rect.
|
||||||
static Rect transformRect(Matrix4 transform, Rect rect) {
|
static Rect transformRect(Matrix4 transform, Rect rect) {
|
||||||
final Point point1 = transformPoint(transform, rect.topLeft);
|
final Offset point1 = transformPoint(transform, rect.topLeft);
|
||||||
final Point point2 = transformPoint(transform, rect.topRight);
|
final Offset point2 = transformPoint(transform, rect.topRight);
|
||||||
final Point point3 = transformPoint(transform, rect.bottomLeft);
|
final Offset point3 = transformPoint(transform, rect.bottomLeft);
|
||||||
final Point point4 = transformPoint(transform, rect.bottomRight);
|
final Offset point4 = transformPoint(transform, rect.bottomRight);
|
||||||
return new Rect.fromLTRB(
|
return new Rect.fromLTRB(
|
||||||
_min4(point1.x, point2.x, point3.x, point4.x),
|
_min4(point1.dx, point2.dx, point3.dx, point4.dx),
|
||||||
_min4(point1.y, point2.y, point3.y, point4.y),
|
_min4(point1.dy, point2.dy, point3.dy, point4.dy),
|
||||||
_max4(point1.x, point2.x, point3.x, point4.x),
|
_max4(point1.dx, point2.dx, point3.dx, point4.dx),
|
||||||
_max4(point1.y, point2.y, point3.y, point4.y)
|
_max4(point1.dy, point2.dy, point3.dy, point4.dy)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
|
|||||||
@override
|
@override
|
||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (child != null && _hasVisualOverflow) {
|
if (child != null && _hasVisualOverflow) {
|
||||||
final Rect rect = Point.origin & size;
|
final Rect rect = Offset.zero & size;
|
||||||
context.pushClipRect(needsCompositing, offset, rect, super.paint);
|
context.pushClipRect(needsCompositing, offset, rect, super.paint);
|
||||||
} else {
|
} else {
|
||||||
super.paint(context, offset);
|
super.paint(context, offset);
|
||||||
|
@ -243,7 +243,7 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void hitTest(HitTestResult result, Point position) {
|
void hitTest(HitTestResult result, Offset position) {
|
||||||
assert(renderView != null);
|
assert(renderView != null);
|
||||||
renderView.hitTest(result, position: position);
|
renderView.hitTest(result, position: position);
|
||||||
// This super call is safe since it will be bound to a mixed-in declaration.
|
// This super call is safe since it will be bound to a mixed-in declaration.
|
||||||
|
@ -242,7 +242,7 @@ class RenderListBody extends RenderBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return defaultHitTestChildren(result, position: position);
|
return defaultHitTestChildren(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ class BoxHitTestEntry extends HitTestEntry {
|
|||||||
RenderBox get target => super.target;
|
RenderBox get target => super.target;
|
||||||
|
|
||||||
/// The position of the hit test in the local coordinates of [target].
|
/// The position of the hit test in the local coordinates of [target].
|
||||||
final Point localPosition;
|
final Offset localPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '${target.runtimeType}#${target.hashCode}@$localPosition';
|
String toString() => '${target.runtimeType}#${target.hashCode}@$localPosition';
|
||||||
@ -899,7 +899,7 @@ class _IntrinsicDimensionsCacheEntry {
|
|||||||
/// [hitTestChildren]. When implementing hit testing, you can either override
|
/// [hitTestChildren]. When implementing hit testing, you can either override
|
||||||
/// these latter two methods, or ignore them and just override [hitTest].
|
/// 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
|
/// 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
|
/// this one from being hit), or false if the hit can continue to other objects
|
||||||
/// below this one.
|
/// below this one.
|
||||||
@ -1424,7 +1424,7 @@ abstract class RenderBox extends RenderObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect get semanticBounds => Point.origin & size;
|
Rect get semanticBounds => Offset.zero & size;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugResetSize() {
|
void debugResetSize() {
|
||||||
@ -1691,7 +1691,7 @@ abstract class RenderBox extends RenderObject {
|
|||||||
/// called. For example, a render object might be a child of a [RenderOpacity]
|
/// 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
|
/// object, which calls [hitTest] on its children when its opacity is zero
|
||||||
/// even through it does not [paint] its children.
|
/// even through it does not [paint] its children.
|
||||||
bool hitTest(HitTestResult result, { @required Point position }) {
|
bool hitTest(HitTestResult result, { @required Offset position }) {
|
||||||
assert(() {
|
assert(() {
|
||||||
if (!hasSize) {
|
if (!hasSize) {
|
||||||
if (debugNeedsLayout) {
|
if (debugNeedsLayout) {
|
||||||
@ -1719,8 +1719,7 @@ abstract class RenderBox extends RenderObject {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (position.x >= 0.0 && position.x < _size.width &&
|
if (_size.contains(position)) {
|
||||||
position.y >= 0.0 && position.y < _size.height) {
|
|
||||||
if (hitTestChildren(result, position: position) || hitTestSelf(position)) {
|
if (hitTestChildren(result, position: position) || hitTestSelf(position)) {
|
||||||
result.add(new BoxHitTestEntry(this, position));
|
result.add(new BoxHitTestEntry(this, position));
|
||||||
return true;
|
return true;
|
||||||
@ -1735,7 +1734,7 @@ abstract class RenderBox extends RenderObject {
|
|||||||
/// Used by [hitTest]. If you override [hitTest] and do not call this
|
/// Used by [hitTest]. If you override [hitTest] and do not call this
|
||||||
/// function, then you don't need to implement this function.
|
/// function, then you don't need to implement this function.
|
||||||
@protected
|
@protected
|
||||||
bool hitTestSelf(Point position) => false;
|
bool hitTestSelf(Offset position) => false;
|
||||||
|
|
||||||
/// Override this method to check whether any children are located at the
|
/// Override this method to check whether any children are located at the
|
||||||
/// given position.
|
/// given position.
|
||||||
@ -1747,7 +1746,7 @@ abstract class RenderBox extends RenderObject {
|
|||||||
/// Used by [hitTest]. If you override [hitTest] and do not call this
|
/// Used by [hitTest]. If you override [hitTest] and do not call this
|
||||||
/// function, then you don't need to implement this function.
|
/// function, then you don't need to implement this function.
|
||||||
@protected
|
@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
|
/// Multiply the transform from the parent's coordinate system to this box's
|
||||||
/// coordinate system into the given transform.
|
/// coordinate system into the given transform.
|
||||||
@ -1808,16 +1807,16 @@ abstract class RenderBox extends RenderObject {
|
|||||||
/// coordinate system for this box.
|
/// coordinate system for this box.
|
||||||
///
|
///
|
||||||
/// If the transform from global coordinates to local coordinates is
|
/// 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
|
/// 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
|
/// coordinate system of `ancestor` (which must be an ancestor of this render
|
||||||
/// object) instead of from the global coordinate system.
|
/// 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 Matrix4 transform = getTransformTo(ancestor);
|
||||||
final double det = transform.invert();
|
final double det = transform.invert();
|
||||||
if (det == 0.0)
|
if (det == 0.0)
|
||||||
return Point.origin;
|
return Offset.zero;
|
||||||
return MatrixUtils.transformPoint(transform, point);
|
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
|
/// 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
|
/// coordinate system of `ancestor` (which must be an ancestor of this render
|
||||||
/// object) instead of to the global coordinate system.
|
/// 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);
|
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.
|
/// The returned paint bounds are in the local coordinate system of this box.
|
||||||
@override
|
@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.
|
/// 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
|
/// Stops walking once after the first child reports that it contains the
|
||||||
/// given point. Returns whether any children contain the given point.
|
/// 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
|
// the x, y parameters have the top left of the node's box as the origin
|
||||||
ChildType child = lastChild;
|
ChildType child = lastChild;
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
final ParentDataType childParentData = child.parentData;
|
final ParentDataType childParentData = child.parentData;
|
||||||
final Point transformed = new Point(position.x - childParentData.offset.dx,
|
if (child.hitTest(result, position: position - childParentData.offset))
|
||||||
position.y - childParentData.offset.dy);
|
|
||||||
if (child.hitTest(result, position: transformed))
|
|
||||||
return true;
|
return true;
|
||||||
child = childParentData.previousSibling;
|
child = childParentData.previousSibling;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return defaultHitTestChildren(result, position: position);
|
return defaultHitTestChildren(result, position: position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class TextSelectionPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Screen coordinates of the lower left or lower right corner of the selection.
|
/// 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.
|
/// Direction of the text at this edge of the selection.
|
||||||
final TextDirection direction;
|
final TextDirection direction;
|
||||||
@ -271,12 +271,12 @@ class RenderEditable extends RenderBox {
|
|||||||
if (selection.isCollapsed) {
|
if (selection.isCollapsed) {
|
||||||
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
|
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
|
||||||
final Offset caretOffset = _textPainter.getOffsetForCaret(selection.extent, _caretPrototype);
|
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)];
|
return <TextSelectionPoint>[new TextSelectionPoint(localToGlobal(start), null)];
|
||||||
} else {
|
} else {
|
||||||
final List<ui.TextBox> boxes = _textPainter.getBoxesForSelection(selection);
|
final List<ui.TextBox> boxes = _textPainter.getBoxesForSelection(selection);
|
||||||
final Point start = new Point(boxes.first.start, boxes.first.bottom) + paintOffset;
|
final Offset start = new Offset(boxes.first.start, boxes.first.bottom) + paintOffset;
|
||||||
final Point end = new Point(boxes.last.end, boxes.last.bottom) + paintOffset;
|
final Offset end = new Offset(boxes.last.end, boxes.last.bottom) + paintOffset;
|
||||||
return <TextSelectionPoint>[
|
return <TextSelectionPoint>[
|
||||||
new TextSelectionPoint(localToGlobal(start), boxes.first.direction),
|
new TextSelectionPoint(localToGlobal(start), boxes.first.direction),
|
||||||
new TextSelectionPoint(localToGlobal(end), boxes.last.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.
|
/// Returns the position in the text for the given global coordinate.
|
||||||
TextPosition getPositionForPoint(Point globalPosition) {
|
TextPosition getPositionForPoint(Offset globalPosition) {
|
||||||
globalPosition += -_paintOffset;
|
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
|
/// Returns the Rect in local coordinates for the caret at the given text
|
||||||
@ -311,7 +311,7 @@ class RenderEditable extends RenderBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
TapGestureRecognizer _tap;
|
TapGestureRecognizer _tap;
|
||||||
LongPressGestureRecognizer _longPress;
|
LongPressGestureRecognizer _longPress;
|
||||||
@ -325,18 +325,18 @@ class RenderEditable extends RenderBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Point _lastTapDownPosition;
|
Offset _lastTapDownPosition;
|
||||||
Point _longPressPosition;
|
Offset _longPressPosition;
|
||||||
void _handleTapDown(TapDownDetails details) {
|
void _handleTapDown(TapDownDetails details) {
|
||||||
_lastTapDownPosition = details.globalPosition + -_paintOffset;
|
_lastTapDownPosition = details.globalPosition + -_paintOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleTap() {
|
void _handleTap() {
|
||||||
assert(_lastTapDownPosition != null);
|
assert(_lastTapDownPosition != null);
|
||||||
final Point globalPosition = _lastTapDownPosition;
|
final Offset globalPosition = _lastTapDownPosition;
|
||||||
_lastTapDownPosition = null;
|
_lastTapDownPosition = null;
|
||||||
if (onSelectionChanged != 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);
|
onSelectionChanged(new TextSelection.fromPosition(position), this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,10 +348,10 @@ class RenderEditable extends RenderBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleLongPress() {
|
void _handleLongPress() {
|
||||||
final Point globalPosition = _longPressPosition;
|
final Offset globalPosition = _longPressPosition;
|
||||||
_longPressPosition = null;
|
_longPressPosition = null;
|
||||||
if (onSelectionChanged != null) {
|
if (onSelectionChanged != null) {
|
||||||
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition).toOffset());
|
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(globalPosition));
|
||||||
onSelectionChanged(_selectWordAtOffset(position), this, true);
|
onSelectionChanged(_selectWordAtOffset(position), this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,13 +419,13 @@ class RenderEditable extends RenderBox {
|
|||||||
@override
|
@override
|
||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (_hasVisualOverflow)
|
if (_hasVisualOverflow)
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintContents);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents);
|
||||||
else
|
else
|
||||||
_paintContents(context, offset);
|
_paintContents(context, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Point.origin & size : null;
|
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
|
@ -73,7 +73,7 @@ class RenderErrorBox extends RenderBox {
|
|||||||
bool get sizedByParent => true;
|
bool get sizedByParent => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void performResize() {
|
void performResize() {
|
||||||
|
@ -681,7 +681,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return defaultHitTestChildren(result, position: position);
|
return defaultHitTestChildren(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,7 +693,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We have overflow. Clip it.
|
// We have overflow. Clip it.
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, defaultPaint);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
|
||||||
|
|
||||||
assert(() {
|
assert(() {
|
||||||
// In debug mode, if you have overflow, we highlight where the
|
// In debug mode, if you have overflow, we highlight where the
|
||||||
@ -729,7 +729,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect describeApproximatePaintClip(RenderObject child) => _overflow > 0.0 ? Point.origin & size : null;
|
Rect describeApproximatePaintClip(RenderObject child) => _overflow > 0.0 ? Offset.zero & size : null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
@ -364,11 +364,11 @@ class RenderFlow extends RenderBox
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintWithDelegate);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintWithDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
final List<RenderBox> children = getChildrenAsList();
|
final List<RenderBox> children = getChildrenAsList();
|
||||||
for (int i = _lastPaintOrder.length - 1; i >= 0; --i) {
|
for (int i = _lastPaintOrder.length - 1; i >= 0; --i) {
|
||||||
final int childIndex = _lastPaintOrder[i];
|
final int childIndex = _lastPaintOrder[i];
|
||||||
@ -386,7 +386,7 @@ class RenderFlow extends RenderBox
|
|||||||
// on screen and cannot be hit.
|
// on screen and cannot be hit.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Point childPosition = MatrixUtils.transformPoint(inverse, position);
|
final Offset childPosition = MatrixUtils.transformPoint(inverse, position);
|
||||||
if (child.hitTest(result, position: childPosition))
|
if (child.hitTest(result, position: childPosition))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class RenderImage extends RenderBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
|
@ -1249,7 +1249,7 @@ class PipelineOwner {
|
|||||||
///
|
///
|
||||||
/// The general behaviour of your hit-testing method should be similar to the
|
/// The general behaviour of your hit-testing method should be similar to the
|
||||||
/// behavior described for [RenderBox]. The main difference is that the input
|
/// 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
|
/// [HitTestEntry] when adding entries to the [HitTestResult]. When the
|
||||||
/// [handleEvent] method is called, the same object that was added to 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
|
/// [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
|
// (with the signature being whatever passes for coordinates for this
|
||||||
// particular class):
|
// 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.
|
// // If the given position is not inside this node, then return false.
|
||||||
// // Otherwise:
|
// // Otherwise:
|
||||||
// // For each child that intersects the position, in z-order starting from
|
// // For each child that intersects the position, in z-order starting from
|
||||||
|
@ -172,7 +172,7 @@ class RenderParagraph extends RenderBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => true;
|
bool hitTestSelf(Offset position) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
||||||
@ -180,7 +180,7 @@ class RenderParagraph extends RenderBox {
|
|||||||
if (event is! PointerDownEvent)
|
if (event is! PointerDownEvent)
|
||||||
return;
|
return;
|
||||||
_layoutTextWithConstraints(constraints);
|
_layoutTextWithConstraints(constraints);
|
||||||
final Offset offset = entry.localPosition.toOffset();
|
final Offset offset = entry.localPosition;
|
||||||
final TextPosition position = _textPainter.getPositionForOffset(offset);
|
final TextPosition position = _textPainter.getPositionForOffset(offset);
|
||||||
final TextSpan span = _textPainter.text.getSpanForPosition(position);
|
final TextSpan span = _textPainter.text.getSpanForPosition(position);
|
||||||
span?.recognizer?.addPointer(event);
|
span?.recognizer?.addPointer(event);
|
||||||
@ -222,15 +222,17 @@ class RenderParagraph extends RenderBox {
|
|||||||
final double fadeStart = fadeEnd - fadeSizePainter.width;
|
final double fadeStart = fadeEnd - fadeSizePainter.width;
|
||||||
// TODO(abarth): This shader has an LTR bias.
|
// TODO(abarth): This shader has an LTR bias.
|
||||||
_overflowShader = new ui.Gradient.linear(
|
_overflowShader = new ui.Gradient.linear(
|
||||||
<Point>[new Point(fadeStart, 0.0), new Point(fadeEnd, 0.0)],
|
new Offset(fadeStart, 0.0),
|
||||||
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)]
|
new Offset(fadeEnd, 0.0),
|
||||||
|
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final double fadeEnd = size.height;
|
final double fadeEnd = size.height;
|
||||||
final double fadeStart = fadeEnd - fadeSizePainter.height / 2.0;
|
final double fadeStart = fadeEnd - fadeSizePainter.height / 2.0;
|
||||||
_overflowShader = new ui.Gradient.linear(
|
_overflowShader = new ui.Gradient.linear(
|
||||||
<Point>[new Point(0.0, fadeStart), new Point(0.0, fadeEnd)],
|
new Offset(0.0, fadeStart),
|
||||||
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)]
|
new Offset(0.0, fadeEnd),
|
||||||
|
<Color>[const Color(0xFFFFFFFF), const Color(0x00FFFFFF)],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -279,7 +281,7 @@ class RenderParagraph extends RenderBox {
|
|||||||
final Paint paint = new Paint()
|
final Paint paint = new Paint()
|
||||||
..blendMode = BlendMode.modulate
|
..blendMode = BlendMode.modulate
|
||||||
..shader = _overflowShader;
|
..shader = _overflowShader;
|
||||||
canvas.drawRect(Point.origin & size, paint);
|
canvas.drawRect(Offset.zero & size, paint);
|
||||||
}
|
}
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ abstract class RenderProxyBoxMixin implements RenderBox, RenderObjectWithChildMi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return child?.hitTest(result, position: position) ?? false;
|
return child?.hitTest(result, position: position) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,10 +150,9 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox {
|
|||||||
HitTestBehavior behavior;
|
HitTestBehavior behavior;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
bool hitTarget = false;
|
bool hitTarget = false;
|
||||||
if (position.x >= 0.0 && position.x < size.width &&
|
if (size.contains(position)) {
|
||||||
position.y >= 0.0 && position.y < size.height) {
|
|
||||||
hitTarget = hitTestChildren(result, position: position) || hitTestSelf(position);
|
hitTarget = hitTestChildren(result, position: position) || hitTestSelf(position);
|
||||||
if (hitTarget || behavior == HitTestBehavior.translucent)
|
if (hitTarget || behavior == HitTestBehavior.translucent)
|
||||||
result.add(new BoxHitTestEntry(this, position));
|
result.add(new BoxHitTestEntry(this, position));
|
||||||
@ -162,7 +161,7 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) => behavior == HitTestBehavior.opaque;
|
bool hitTestSelf(Offset position) => behavior == HitTestBehavior.opaque;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
@ -821,7 +820,7 @@ class RenderShaderMask extends RenderProxyBox {
|
|||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
assert(needsCompositing);
|
assert(needsCompositing);
|
||||||
final Rect rect = Point.origin & size;
|
final Rect rect = Offset.zero & size;
|
||||||
context.pushShaderMask(offset, _shaderCallback(rect), rect, _blendMode, super.paint);
|
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
|
/// the RenderObject. If getClip returns a shape that is roughly the
|
||||||
/// same size as the RenderObject (e.g. it's a rounded rectangle
|
/// same size as the RenderObject (e.g. it's a rounded rectangle
|
||||||
/// with very small arcs in the corners), then this may be adequate.
|
/// 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
|
/// 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
|
/// 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
|
@override
|
||||||
Rect describeApproximatePaintClip(RenderObject child) {
|
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);
|
}) : super(child: child, clipper: clipper);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect get _defaultClip => Point.origin & size;
|
Rect get _defaultClip => Offset.zero & size;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (_clipper != null) {
|
if (_clipper != null) {
|
||||||
_updateClip();
|
_updateClip();
|
||||||
assert(_clip != null);
|
assert(_clip != null);
|
||||||
@ -1068,10 +1067,10 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RRect get _defaultClip => _borderRadius.toRRect(Point.origin & size);
|
RRect get _defaultClip => _borderRadius.toRRect(Offset.zero & size);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (_clipper != null) {
|
if (_clipper != null) {
|
||||||
_updateClip();
|
_updateClip();
|
||||||
assert(_clip != null);
|
assert(_clip != null);
|
||||||
@ -1117,16 +1116,16 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect get _defaultClip => Point.origin & size;
|
Rect get _defaultClip => Offset.zero & size;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
_updateClip();
|
_updateClip();
|
||||||
assert(_clip != null);
|
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
|
// convert the position to an offset from the center of the unit circle
|
||||||
final Offset offset = new Offset((position.x - center.x) / _clip.width,
|
final Offset offset = new Offset((position.dx - center.dx) / _clip.width,
|
||||||
(position.y - center.y) / _clip.height);
|
(position.dy - center.dy) / _clip.height);
|
||||||
// check if the point is outside the unit circle
|
// check if the point is outside the unit circle
|
||||||
if (offset.distanceSquared > 0.25) // x^2 + y^2 > r^2
|
if (offset.distanceSquared > 0.25) // x^2 + y^2 > r^2
|
||||||
return false;
|
return false;
|
||||||
@ -1166,10 +1165,10 @@ class RenderClipPath extends _RenderCustomClip<Path> {
|
|||||||
}) : super(child: child, clipper: clipper);
|
}) : super(child: child, clipper: clipper);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Path get _defaultClip => new Path()..addRect(Point.origin & size);
|
Path get _defaultClip => new Path()..addRect(Offset.zero & size);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (_clipper != null) {
|
if (_clipper != null) {
|
||||||
_updateClip();
|
_updateClip();
|
||||||
assert(_clip != null);
|
assert(_clip != null);
|
||||||
@ -1183,7 +1182,7 @@ class RenderClipPath extends _RenderCustomClip<Path> {
|
|||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
_updateClip();
|
_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
|
@override
|
||||||
RRect get _defaultClip {
|
RRect get _defaultClip {
|
||||||
if (_shape == BoxShape.rectangle) {
|
if (_shape == BoxShape.rectangle) {
|
||||||
return _borderRadius.toRRect(Point.origin & size);
|
return _borderRadius.toRRect(Offset.zero & size);
|
||||||
} else {
|
} else {
|
||||||
final Rect rect = Point.origin & size;
|
final Rect rect = Offset.zero & size;
|
||||||
return new RRect.fromRectXY(rect, rect.width / 2, rect.height / 2);
|
return new RRect.fromRectXY(rect, rect.width / 2, rect.height / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (_clipper != null) {
|
if (_clipper != null) {
|
||||||
_updateClip();
|
_updateClip();
|
||||||
assert(_clip != null);
|
assert(_clip != null);
|
||||||
@ -1368,7 +1367,7 @@ class RenderDecoratedBox extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) {
|
bool hitTestSelf(Offset position) {
|
||||||
return _decoration.hitTest(size, position);
|
return _decoration.hitTest(size, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1543,7 +1542,7 @@ class RenderTransform extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
if (transformHitTests) {
|
if (transformHitTests) {
|
||||||
Matrix4 inverse;
|
Matrix4 inverse;
|
||||||
try {
|
try {
|
||||||
@ -1660,8 +1659,8 @@ class RenderFittedBox extends RenderProxyBox {
|
|||||||
final FittedSizes sizes = applyBoxFit(_fit, childSize, size);
|
final FittedSizes sizes = applyBoxFit(_fit, childSize, size);
|
||||||
final double scaleX = sizes.destination.width / sizes.source.width;
|
final double scaleX = sizes.destination.width / sizes.source.width;
|
||||||
final double scaleY = sizes.destination.height / sizes.source.height;
|
final double scaleY = sizes.destination.height / sizes.source.height;
|
||||||
final Rect sourceRect = _alignment.inscribe(sizes.source, Point.origin & childSize);
|
final Rect sourceRect = _alignment.inscribe(sizes.source, Offset.zero & childSize);
|
||||||
final Rect destinationRect = _alignment.inscribe(sizes.destination, Point.origin & size);
|
final Rect destinationRect = _alignment.inscribe(sizes.destination, Offset.zero & size);
|
||||||
_hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.width;
|
_hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.width;
|
||||||
_transform = new Matrix4.translationValues(destinationRect.left, destinationRect.top, 0.0)
|
_transform = new Matrix4.translationValues(destinationRect.left, destinationRect.top, 0.0)
|
||||||
..scale(scaleX, scaleY, 1.0)
|
..scale(scaleX, scaleY, 1.0)
|
||||||
@ -1684,14 +1683,14 @@ class RenderFittedBox extends RenderProxyBox {
|
|||||||
_updatePaintData();
|
_updatePaintData();
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
if (_hasVisualOverflow)
|
if (_hasVisualOverflow)
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintChildWithTransform);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintChildWithTransform);
|
||||||
else
|
else
|
||||||
_paintChildWithTransform(context, offset);
|
_paintChildWithTransform(context, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
_updatePaintData();
|
_updatePaintData();
|
||||||
Matrix4 inverse;
|
Matrix4 inverse;
|
||||||
try {
|
try {
|
||||||
@ -1758,10 +1757,10 @@ class RenderFractionalTranslation extends RenderProxyBox {
|
|||||||
bool transformHitTests;
|
bool transformHitTests;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
assert(!debugNeedsLayout);
|
assert(!debugNeedsLayout);
|
||||||
if (transformHitTests)
|
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);
|
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
|
/// 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
|
/// point that should be considered outside the painted image, and null to use
|
||||||
/// the default behavior.
|
/// the default behavior.
|
||||||
bool hitTest(Point position) => null;
|
bool hitTest(Offset position) => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType#$hashCode';
|
String toString() => '$runtimeType#$hashCode';
|
||||||
@ -2024,14 +2023,14 @@ class RenderCustomPaint extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
if (_foregroundPainter != null && (_foregroundPainter.hitTest(position) ?? false))
|
if (_foregroundPainter != null && (_foregroundPainter.hitTest(position) ?? false))
|
||||||
return true;
|
return true;
|
||||||
return super.hitTestChildren(result, position: position);
|
return super.hitTestChildren(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestSelf(Point position) {
|
bool hitTestSelf(Offset position) {
|
||||||
return _painter != null && (_painter.hitTest(position) ?? true);
|
return _painter != null && (_painter.hitTest(position) ?? true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2361,7 +2360,7 @@ class RenderIgnorePointer extends RenderProxyBox {
|
|||||||
bool get _effectiveIgnoringSemantics => ignoringSemantics == null ? ignoring : ignoringSemantics;
|
bool get _effectiveIgnoringSemantics => ignoringSemantics == null ? ignoring : ignoringSemantics;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
return ignoring ? false : super.hitTest(result, position: position);
|
return ignoring ? false : super.hitTest(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2465,7 +2464,7 @@ class RenderOffstage extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
return !offstage && super.hitTest(result, position: position);
|
return !offstage && super.hitTest(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2521,7 +2520,7 @@ class RenderAbsorbPointer extends RenderProxyBox {
|
|||||||
bool absorbing;
|
bool absorbing;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(HitTestResult result, { Point position }) {
|
bool hitTest(HitTestResult result, { Offset position }) {
|
||||||
return absorbing ? true : super.hitTest(result, position: 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;
|
final double primaryDelta = size.width * -scrollFactor;
|
||||||
onHorizontalDragUpdate(new DragUpdateDetails(
|
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||||
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
|
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
|
||||||
globalPosition: localToGlobal(size.center(Point.origin)),
|
globalPosition: localToGlobal(size.center(Offset.zero)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2683,7 +2682,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
|
|||||||
final double primaryDelta = size.width * scrollFactor;
|
final double primaryDelta = size.width * scrollFactor;
|
||||||
onHorizontalDragUpdate(new DragUpdateDetails(
|
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||||
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
|
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta,
|
||||||
globalPosition: localToGlobal(size.center(Point.origin)),
|
globalPosition: localToGlobal(size.center(Offset.zero)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2692,7 +2691,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
|
|||||||
final double primaryDelta = size.height * -scrollFactor;
|
final double primaryDelta = size.height * -scrollFactor;
|
||||||
onVerticalDragUpdate(new DragUpdateDetails(
|
onVerticalDragUpdate(new DragUpdateDetails(
|
||||||
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
|
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
|
||||||
globalPosition: localToGlobal(size.center(Point.origin)),
|
globalPosition: localToGlobal(size.center(Offset.zero)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2701,7 +2700,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA
|
|||||||
final double primaryDelta = size.height * scrollFactor;
|
final double primaryDelta = size.height * scrollFactor;
|
||||||
onVerticalDragUpdate(new DragUpdateDetails(
|
onVerticalDragUpdate(new DragUpdateDetails(
|
||||||
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
|
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta,
|
||||||
globalPosition: localToGlobal(size.center(Point.origin)),
|
globalPosition: localToGlobal(size.center(Offset.zero)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -90,7 +90,7 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin<RenderB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
assert(_paintTransform != null || debugNeedsLayout || child == null);
|
assert(_paintTransform != null || debugNeedsLayout || child == null);
|
||||||
if (child == null || _paintTransform == null)
|
if (child == null || _paintTransform == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -716,7 +716,7 @@ class SemanticsOwner extends ChangeNotifier {
|
|||||||
handler?.performAction(action);
|
handler?.performAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticsActionHandler _getSemanticsActionHandlerForPosition(SemanticsNode node, Point position, SemanticsAction action) {
|
SemanticsActionHandler _getSemanticsActionHandlerForPosition(SemanticsNode node, Offset position, SemanticsAction action) {
|
||||||
if (node.transform != null) {
|
if (node.transform != null) {
|
||||||
final Matrix4 inverse = new Matrix4.identity();
|
final Matrix4 inverse = new Matrix4.identity();
|
||||||
if (inverse.copyInverse(node.transform) == 0.0)
|
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,
|
/// If the [SemanticsNode] has not indicated that it can perform the action,
|
||||||
/// this function does nothing.
|
/// this function does nothing.
|
||||||
void performActionAt(Point position, SemanticsAction action) {
|
void performActionAt(Offset position, SemanticsAction action) {
|
||||||
assert(action != null);
|
assert(action != null);
|
||||||
final SemanticsNode node = rootSemanticsNode;
|
final SemanticsNode node = rootSemanticsNode;
|
||||||
if (node == null)
|
if (node == null)
|
||||||
|
@ -70,12 +70,10 @@ abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
final BoxParentData childParentData = child.parentData;
|
final BoxParentData childParentData = child.parentData;
|
||||||
final Point childPosition = new Point(position.x - childParentData.offset.dx,
|
return child.hitTest(result, position: position - childParentData.offset);
|
||||||
position.y - childParentData.offset.dy);
|
|
||||||
return child.hitTest(result, position: childPosition);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1014,13 +1014,13 @@ abstract class RenderSliver extends RenderObject {
|
|||||||
return null;
|
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(() {
|
assert(() {
|
||||||
if (p0 == p1)
|
if (p0 == p1)
|
||||||
return true;
|
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;
|
final double d = (p1 - p0).distance * 0.2;
|
||||||
Point temp;
|
Offset temp;
|
||||||
double dx1, dx2, dy1, dy2;
|
double dx1, dx2, dy1, dy2;
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case GrowthDirection.forward:
|
case GrowthDirection.forward:
|
||||||
@ -1033,18 +1033,18 @@ abstract class RenderSliver extends RenderObject {
|
|||||||
dx1 = dx2 = dy1 = dy2 = -d;
|
dx1 = dx2 = dy1 = dy2 = -d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (p0.x == p1.x) {
|
if (p0.dx == p1.dx) {
|
||||||
dx2 = -dx2;
|
dx2 = -dx2;
|
||||||
} else {
|
} else {
|
||||||
dy2 = -dy2;
|
dy2 = -dy2;
|
||||||
}
|
}
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
new Path()
|
new Path()
|
||||||
..moveTo(p0.x, p0.y)
|
..moveTo(p0.dx, p0.dy)
|
||||||
..lineTo(p1.x, p1.y)
|
..lineTo(p1.dx, p1.dy)
|
||||||
..moveTo(p1.x - dx1, p1.y - dy1)
|
..moveTo(p1.dx - dx1, p1.dy - dy1)
|
||||||
..lineTo(p1.x, p1.y)
|
..lineTo(p1.dx, p1.dy)
|
||||||
..lineTo(p1.x - dx2, p1.y - dy2),
|
..lineTo(p1.dx - dx2, p1.dy - dy2),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -1065,50 +1065,50 @@ abstract class RenderSliver extends RenderObject {
|
|||||||
final double padding = math.max(2.0, strokeWidth);
|
final double padding = math.max(2.0, strokeWidth);
|
||||||
final Canvas canvas = context.canvas;
|
final Canvas canvas = context.canvas;
|
||||||
canvas.drawCircle(
|
canvas.drawCircle(
|
||||||
offset.translate(padding, padding).toPoint(),
|
offset.translate(padding, padding),
|
||||||
padding * 0.5,
|
padding * 0.5,
|
||||||
paint,
|
paint,
|
||||||
);
|
);
|
||||||
switch (constraints.axis) {
|
switch (constraints.axis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
offset.toPoint(),
|
offset,
|
||||||
offset.translate(constraints.crossAxisExtent, 0.0).toPoint(),
|
offset.translate(constraints.crossAxisExtent, 0.0),
|
||||||
paint,
|
paint,
|
||||||
);
|
);
|
||||||
_debugDrawArrow(
|
_debugDrawArrow(
|
||||||
canvas,
|
canvas,
|
||||||
paint,
|
paint,
|
||||||
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, padding).toPoint(),
|
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, padding),
|
||||||
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, arrowExtent - padding).toPoint(),
|
offset.translate(constraints.crossAxisExtent * 1.0 / 4.0, arrowExtent - padding),
|
||||||
constraints.normalizedGrowthDirection,
|
constraints.normalizedGrowthDirection,
|
||||||
);
|
);
|
||||||
_debugDrawArrow(
|
_debugDrawArrow(
|
||||||
canvas,
|
canvas,
|
||||||
paint,
|
paint,
|
||||||
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, padding).toPoint(),
|
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, padding),
|
||||||
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, arrowExtent - padding).toPoint(),
|
offset.translate(constraints.crossAxisExtent * 3.0 / 4.0, arrowExtent - padding),
|
||||||
constraints.normalizedGrowthDirection,
|
constraints.normalizedGrowthDirection,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
offset.toPoint(),
|
offset,
|
||||||
offset.translate(0.0, constraints.crossAxisExtent).toPoint(),
|
offset.translate(0.0, constraints.crossAxisExtent),
|
||||||
paint,
|
paint,
|
||||||
);
|
);
|
||||||
_debugDrawArrow(
|
_debugDrawArrow(
|
||||||
canvas,
|
canvas,
|
||||||
paint,
|
paint,
|
||||||
offset.translate(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).toPoint(),
|
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 1.0 / 4.0),
|
||||||
constraints.normalizedGrowthDirection,
|
constraints.normalizedGrowthDirection,
|
||||||
);
|
);
|
||||||
_debugDrawArrow(
|
_debugDrawArrow(
|
||||||
canvas,
|
canvas,
|
||||||
paint,
|
paint,
|
||||||
offset.translate(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).toPoint(),
|
offset.translate(arrowExtent - padding, constraints.crossAxisExtent * 3.0 / 4.0),
|
||||||
constraints.normalizedGrowthDirection,
|
constraints.normalizedGrowthDirection,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -1177,11 +1177,11 @@ abstract class RenderSliverHelpers implements RenderSliver {
|
|||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
if (!rightWayUp)
|
if (!rightWayUp)
|
||||||
absolutePosition = child.size.width - absolutePosition;
|
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:
|
case Axis.vertical:
|
||||||
if (!rightWayUp)
|
if (!rightWayUp)
|
||||||
absolutePosition = child.size.height - absolutePosition;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ class RenderStack extends RenderBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return defaultHitTestChildren(result, position: position);
|
return defaultHitTestChildren(result, position: position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,14 +436,14 @@ class RenderStack extends RenderBox
|
|||||||
@override
|
@override
|
||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (_overflow == Overflow.clip && _hasVisualOverflow) {
|
if (_overflow == Overflow.clip && _hasVisualOverflow) {
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, paintStack);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintStack);
|
||||||
} else {
|
} else {
|
||||||
paintStack(context, offset);
|
paintStack(context, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Point.origin & size : null;
|
Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
@ -496,15 +496,13 @@ class RenderIndexedStack extends RenderStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { @required Point position }) {
|
bool hitTestChildren(HitTestResult result, { @required Offset position }) {
|
||||||
if (firstChild == null || index == null)
|
if (firstChild == null || index == null)
|
||||||
return false;
|
return false;
|
||||||
assert(position != null);
|
assert(position != null);
|
||||||
final RenderBox child = _childAtIndex();
|
final RenderBox child = _childAtIndex();
|
||||||
final StackParentData childParentData = child.parentData;
|
final StackParentData childParentData = child.parentData;
|
||||||
final Point transformed = new Point(position.x - childParentData.offset.dx,
|
return child.hitTest(result, position: position - childParentData.offset);
|
||||||
position.y - childParentData.offset.dy);
|
|
||||||
return child.hitTest(result, position: transformed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1196,15 +1196,13 @@ class RenderTable extends RenderBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
assert(_children.length == rows * columns);
|
assert(_children.length == rows * columns);
|
||||||
for (int index = _children.length - 1; index >= 0; index -= 1) {
|
for (int index = _children.length - 1; index >= 0; index -= 1) {
|
||||||
final RenderBox child = _children[index];
|
final RenderBox child = _children[index];
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
final BoxParentData childParentData = child.parentData;
|
final BoxParentData childParentData = child.parentData;
|
||||||
final Point transformed = new Point(position.x - childParentData.offset.dx,
|
if (child.hitTest(result, position: position - childParentData.offset))
|
||||||
position.y - childParentData.offset.dy);
|
|
||||||
if (child.hitTest(result, position: transformed))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
/// given hit test result.
|
/// given hit test result.
|
||||||
///
|
///
|
||||||
/// The [position] argument is in the coordinate system of the render view.
|
/// 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)
|
if (child != null)
|
||||||
child.hitTest(result, position: position);
|
child.hitTest(result, position: position);
|
||||||
result.add(new HitTestEntry(this));
|
result.add(new HitTestEntry(this));
|
||||||
@ -164,10 +164,10 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect get paintBounds => Point.origin & size;
|
Rect get paintBounds => Offset.zero & size;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect get semanticBounds => Point.origin & size;
|
Rect get semanticBounds => Offset.zero & size;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
|
@ -223,7 +223,7 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
|
|||||||
if (firstChild == null)
|
if (firstChild == null)
|
||||||
return;
|
return;
|
||||||
if (hasVisualOverflow) {
|
if (hasVisualOverflow) {
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintContents);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents);
|
||||||
} else {
|
} else {
|
||||||
_paintContents(context, offset);
|
_paintContents(context, offset);
|
||||||
}
|
}
|
||||||
@ -265,16 +265,16 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
double mainAxisPosition, crossAxisPosition;
|
double mainAxisPosition, crossAxisPosition;
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
mainAxisPosition = position.y;
|
mainAxisPosition = position.dy;
|
||||||
crossAxisPosition = position.x;
|
crossAxisPosition = position.dx;
|
||||||
break;
|
break;
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
mainAxisPosition = position.x;
|
mainAxisPosition = position.dx;
|
||||||
crossAxisPosition = position.y;
|
crossAxisPosition = position.dy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(mainAxisPosition != null);
|
assert(mainAxisPosition != null);
|
||||||
|
@ -560,7 +560,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return defaultHitTestChildren(result, position: 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
|
// TODO(ianh): move the debug flex overflow paint logic somewhere common so
|
||||||
// it can be reused here
|
// it can be reused here
|
||||||
if (_hasVisualOverflow)
|
if (_hasVisualOverflow)
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, defaultPaint);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
|
||||||
else
|
else
|
||||||
defaultPaint(context, offset);
|
defaultPaint(context, offset);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class BannerPainter extends CustomPainter {
|
|||||||
..drawRect(_kRect, _paintBanner);
|
..drawRect(_kRect, _paintBanner);
|
||||||
final double width = _kOffset * 2.0;
|
final double width = _kOffset * 2.0;
|
||||||
_textPainter.layout(minWidth: width, maxWidth: width);
|
_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
|
@override
|
||||||
@ -111,7 +111,7 @@ class BannerPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Point position) => false;
|
bool hitTest(Offset position) => false;
|
||||||
|
|
||||||
double _translationX(double width) {
|
double _translationX(double width) {
|
||||||
assert(location != null);
|
assert(location != null);
|
||||||
|
@ -234,7 +234,7 @@ class LongPressDraggable<T> extends Draggable<T> {
|
|||||||
@override
|
@override
|
||||||
DelayedMultiDragGestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) {
|
DelayedMultiDragGestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) {
|
||||||
return new DelayedMultiDragGestureRecognizer()
|
return new DelayedMultiDragGestureRecognizer()
|
||||||
..onStart = (Point position) {
|
..onStart = (Offset position) {
|
||||||
final Drag result = onStart(position);
|
final Drag result = onStart(position);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
HapticFeedback.vibrate();
|
HapticFeedback.vibrate();
|
||||||
@ -281,17 +281,17 @@ class _DraggableState<T> extends State<Draggable<T>> {
|
|||||||
_recognizer.addPointer(event);
|
_recognizer.addPointer(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
_DragAvatar<T> _startDrag(Point position) {
|
_DragAvatar<T> _startDrag(Offset position) {
|
||||||
if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags)
|
if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags)
|
||||||
return null;
|
return null;
|
||||||
Point dragStartPoint;
|
Offset dragStartPoint;
|
||||||
switch (widget.dragAnchor) {
|
switch (widget.dragAnchor) {
|
||||||
case DragAnchor.child:
|
case DragAnchor.child:
|
||||||
final RenderBox renderObject = context.findRenderObject();
|
final RenderBox renderObject = context.findRenderObject();
|
||||||
dragStartPoint = renderObject.globalToLocal(position);
|
dragStartPoint = renderObject.globalToLocal(position);
|
||||||
break;
|
break;
|
||||||
case DragAnchor.pointer:
|
case DragAnchor.pointer:
|
||||||
dragStartPoint = Point.origin;
|
dragStartPoint = Offset.zero;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -439,8 +439,8 @@ class _DragAvatar<T> extends Drag {
|
|||||||
_DragAvatar({
|
_DragAvatar({
|
||||||
@required this.overlayState,
|
@required this.overlayState,
|
||||||
this.data,
|
this.data,
|
||||||
Point initialPosition,
|
Offset initialPosition,
|
||||||
this.dragStartPoint: Point.origin,
|
this.dragStartPoint: Offset.zero,
|
||||||
this.feedback,
|
this.feedback,
|
||||||
this.feedbackOffset: Offset.zero,
|
this.feedbackOffset: Offset.zero,
|
||||||
this.onDragEnd
|
this.onDragEnd
|
||||||
@ -455,7 +455,7 @@ class _DragAvatar<T> extends Drag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final T data;
|
final T data;
|
||||||
final Point dragStartPoint;
|
final Offset dragStartPoint;
|
||||||
final Widget feedback;
|
final Widget feedback;
|
||||||
final Offset feedbackOffset;
|
final Offset feedbackOffset;
|
||||||
final _OnDragEnd onDragEnd;
|
final _OnDragEnd onDragEnd;
|
||||||
@ -463,7 +463,7 @@ class _DragAvatar<T> extends Drag {
|
|||||||
|
|
||||||
_DragTargetState<T> _activeTarget;
|
_DragTargetState<T> _activeTarget;
|
||||||
final List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
|
final List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
|
||||||
Point _position;
|
Offset _position;
|
||||||
Offset _lastOffset;
|
Offset _lastOffset;
|
||||||
OverlayEntry _entry;
|
OverlayEntry _entry;
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ class _DragAvatar<T> extends Drag {
|
|||||||
finishDrag(_DragEndKind.canceled);
|
finishDrag(_DragEndKind.canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateDrag(Point globalPosition) {
|
void updateDrag(Offset globalPosition) {
|
||||||
_lastOffset = globalPosition - dragStartPoint;
|
_lastOffset = globalPosition - dragStartPoint;
|
||||||
_entry.markNeedsBuild();
|
_entry.markNeedsBuild();
|
||||||
final HitTestResult result = new HitTestResult();
|
final HitTestResult result = new HitTestResult();
|
||||||
@ -558,10 +558,10 @@ class _DragAvatar<T> extends Drag {
|
|||||||
|
|
||||||
Widget _build(BuildContext context) {
|
Widget _build(BuildContext context) {
|
||||||
final RenderBox box = overlayState.context.findRenderObject();
|
final RenderBox box = overlayState.context.findRenderObject();
|
||||||
final Point overlayTopLeft = box.localToGlobal(Point.origin);
|
final Offset overlayTopLeft = box.localToGlobal(Offset.zero);
|
||||||
return new Positioned(
|
return new Positioned(
|
||||||
left: _lastOffset.dx - overlayTopLeft.x,
|
left: _lastOffset.dx - overlayTopLeft.dx,
|
||||||
top: _lastOffset.dy - overlayTopLeft.y,
|
top: _lastOffset.dy - overlayTopLeft.dy,
|
||||||
child: new IgnorePointer(
|
child: new IgnorePointer(
|
||||||
child: feedback
|
child: feedback
|
||||||
)
|
)
|
||||||
|
@ -27,11 +27,11 @@ class _GridPaperPainter extends CustomPainter {
|
|||||||
final double allDivisions = (divisions * subDivisions).toDouble();
|
final double allDivisions = (divisions * subDivisions).toDouble();
|
||||||
for (double x = 0.0; x <= size.width; x += interval / allDivisions) {
|
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;
|
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) {
|
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;
|
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
|
@override
|
||||||
bool hitTest(Point position) => false;
|
bool hitTest(Offset position) => false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A widget that draws a rectilinear grid of 1px wide lines.
|
/// A widget that draws a rectilinear grid of 1px wide lines.
|
||||||
|
@ -31,7 +31,7 @@ enum _HeroFlightType {
|
|||||||
Rect _globalRect(BuildContext context) {
|
Rect _globalRect(BuildContext context) {
|
||||||
final RenderBox box = context.findRenderObject();
|
final RenderBox box = context.findRenderObject();
|
||||||
assert(box != null && box.hasSize);
|
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.
|
/// 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
|
// 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.
|
// supposed to end up (heroRect.end) then recreate the heroRect tween.
|
||||||
final RenderBox routeBox = manifest.toRoute.subtreeContext?.findRenderObject();
|
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) {
|
if (heroOriginEnd != heroRect.end.topLeft) {
|
||||||
final Rect heroRectEnd = heroOriginEnd & heroRect.end.size;
|
final Rect heroRectEnd = heroOriginEnd & heroRect.end.size;
|
||||||
heroRect = _doCreateRectTween(heroRect.begin, heroRectEnd);
|
heroRect = _doCreateRectTween(heroRect.begin, heroRectEnd);
|
||||||
|
@ -214,7 +214,7 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin<Ren
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
return child?.hitTest(result, position: position) ?? false;
|
return child?.hitTest(result, position: position) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,13 +165,13 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
|
|||||||
assert(renderer != null);
|
assert(renderer != null);
|
||||||
assert(renderer.hasSize);
|
assert(renderer.hasSize);
|
||||||
final Size size = renderer.size;
|
final Size size = renderer.size;
|
||||||
final Point position = renderer.globalToLocal(notification.dragDetails.globalPosition);
|
final Offset position = renderer.globalToLocal(notification.dragDetails.globalPosition);
|
||||||
switch (notification.axis) {
|
switch (notification.axis) {
|
||||||
case Axis.horizontal:
|
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;
|
break;
|
||||||
case Axis.vertical:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ class _GlowController extends ChangeNotifier {
|
|||||||
final double height = math.min(size.height, size.width * _kWidthToHeightFactor);
|
final double height = math.min(size.height, size.width * _kWidthToHeightFactor);
|
||||||
final double scaleY = _glowSize.value * baseGlowScale;
|
final double scaleY = _glowSize.value * baseGlowScale;
|
||||||
final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, height);
|
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);
|
final Paint paint = new Paint()..color = color.withOpacity(_glowOpacity.value);
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.scale(1.0, scaleY);
|
canvas.scale(1.0, scaleY);
|
||||||
|
@ -68,7 +68,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Point _lastPointerDownLocation;
|
Offset _lastPointerDownLocation;
|
||||||
void _handlePointerDown(PointerDownEvent event) {
|
void _handlePointerDown(PointerDownEvent event) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_lastPointerDownLocation = event.position;
|
_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);
|
_pipelineOwner.semanticsOwner?.performActionAt(position, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ void _paintMessage(Canvas canvas, SemanticsNode node) {
|
|||||||
..text = new TextSpan(style: _messageStyle, text: message)
|
..text = new TextSpan(style: _messageStyle, text: message)
|
||||||
..layout(maxWidth: rect.width);
|
..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();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class _SemanticsDebuggerPainter extends CustomPainter {
|
|||||||
|
|
||||||
final PipelineOwner owner;
|
final PipelineOwner owner;
|
||||||
final int generation;
|
final int generation;
|
||||||
final Point pointerPosition;
|
final Offset pointerPosition;
|
||||||
|
|
||||||
SemanticsNode get _rootSemanticsNode {
|
SemanticsNode get _rootSemanticsNode {
|
||||||
return owner.semanticsOwner?.rootSemanticsNode;
|
return owner.semanticsOwner?.rootSemanticsNode;
|
||||||
|
@ -351,7 +351,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_shouldClipAtPaintOffset(paintOffset)) {
|
if (_shouldClipAtPaintOffset(paintOffset)) {
|
||||||
context.pushClipRect(needsCompositing, offset, Point.origin & size, paintContents);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintContents);
|
||||||
} else {
|
} else {
|
||||||
paintContents(context, offset);
|
paintContents(context, offset);
|
||||||
}
|
}
|
||||||
@ -367,14 +367,14 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
|
|||||||
@override
|
@override
|
||||||
Rect describeApproximatePaintClip(RenderObject child) {
|
Rect describeApproximatePaintClip(RenderObject child) {
|
||||||
if (child != null && _shouldClipAtPaintOffset(_paintOffset))
|
if (child != null && _shouldClipAtPaintOffset(_paintOffset))
|
||||||
return Point.origin & size;
|
return Offset.zero & size;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTestChildren(HitTestResult result, { Point position }) {
|
bool hitTestChildren(HitTestResult result, { Offset position }) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
final Point transformed = position + -_paintOffset;
|
final Offset transformed = position + -_paintOffset;
|
||||||
return child.hitTest(result, position: transformed);
|
return child.hitTest(result, position: transformed);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,7 +74,7 @@ abstract class TextSelectionControls {
|
|||||||
///
|
///
|
||||||
/// Typically displays buttons for copying and pasting text.
|
/// Typically displays buttons for copying and pasting text.
|
||||||
// TODO(mpcomplete): A single position is probably insufficient.
|
// 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.
|
/// Returns the size of the selection handle.
|
||||||
Size get handleSize;
|
Size get handleSize;
|
||||||
@ -237,11 +237,11 @@ class TextSelectionOverlay implements TextSelectionDelegate {
|
|||||||
|
|
||||||
// Find the horizontal midpoint, just above the selected text.
|
// Find the horizontal midpoint, just above the selected text.
|
||||||
final List<TextSelectionPoint> endpoints = renderObject.getEndpointsForSelection(_selection);
|
final List<TextSelectionPoint> endpoints = renderObject.getEndpointsForSelection(_selection);
|
||||||
final Point midpoint = new Point(
|
final Offset midpoint = new Offset(
|
||||||
(endpoints.length == 1) ?
|
(endpoints.length == 1) ?
|
||||||
endpoints[0].point.x :
|
endpoints[0].point.dx :
|
||||||
(endpoints[0].point.x + endpoints[1].point.x) / 2.0,
|
(endpoints[0].point.dx + endpoints[1].point.dx) / 2.0,
|
||||||
endpoints[0].point.y - renderObject.size.height
|
endpoints[0].point.dy - renderObject.size.height
|
||||||
);
|
);
|
||||||
|
|
||||||
return new FadeTransition(
|
return new FadeTransition(
|
||||||
@ -318,7 +318,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {
|
class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {
|
||||||
Point _dragPosition;
|
Offset _dragPosition;
|
||||||
|
|
||||||
void _handleDragStart(DragStartDetails details) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
_dragPosition = details.globalPosition + new Offset(0.0, -widget.selectionControls.handleSize.height);
|
_dragPosition = details.globalPosition + new Offset(0.0, -widget.selectionControls.handleSize.height);
|
||||||
@ -362,7 +362,7 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<TextSelectionPoint> endpoints = widget.renderObject.getEndpointsForSelection(widget.selection);
|
final List<TextSelectionPoint> endpoints = widget.renderObject.getEndpointsForSelection(widget.selection);
|
||||||
Point point;
|
Offset point;
|
||||||
TextSelectionHandleType type;
|
TextSelectionHandleType type;
|
||||||
|
|
||||||
switch (widget.position) {
|
switch (widget.position) {
|
||||||
@ -386,8 +386,8 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay
|
|||||||
child: new Stack(
|
child: new Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Positioned(
|
new Positioned(
|
||||||
left: point.x,
|
left: point.dx,
|
||||||
top: point.y,
|
top: point.dy,
|
||||||
child: widget.selectionControls.buildHandle(context, type)
|
child: widget.selectionControls.buildHandle(context, type)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -133,7 +133,7 @@ void main() {
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
// Keep a "down" gesture on the button
|
// 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.startGesture(center);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ void main() {
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
// Keep a "down" gesture on the button
|
// 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.startGesture(center);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(value, equals(0.0));
|
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 unit = CupertinoThumbPainter.radius;
|
||||||
const double delta = 3.0 * unit;
|
const double delta = 3.0 * unit;
|
||||||
await tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
|
await tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
|
||||||
|
@ -29,61 +29,61 @@ void main() {
|
|||||||
// Down/up pair 1: normal tap sequence
|
// Down/up pair 1: normal tap sequence
|
||||||
const PointerDownEvent down1 = const PointerDownEvent(
|
const PointerDownEvent down1 = const PointerDownEvent(
|
||||||
pointer: 1,
|
pointer: 1,
|
||||||
position: const Point(10.0, 10.0)
|
position: const Offset(10.0, 10.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up1 = const PointerUpEvent(
|
const PointerUpEvent up1 = const PointerUpEvent(
|
||||||
pointer: 1,
|
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
|
// Down/up pair 2: normal tap sequence close to pair 1
|
||||||
const PointerDownEvent down2 = const PointerDownEvent(
|
const PointerDownEvent down2 = const PointerDownEvent(
|
||||||
pointer: 2,
|
pointer: 2,
|
||||||
position: const Point(12.0, 12.0)
|
position: const Offset(12.0, 12.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up2 = const PointerUpEvent(
|
const PointerUpEvent up2 = const PointerUpEvent(
|
||||||
pointer: 2,
|
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
|
// Down/up pair 3: normal tap sequence far away from pair 1
|
||||||
const PointerDownEvent down3 = const PointerDownEvent(
|
const PointerDownEvent down3 = const PointerDownEvent(
|
||||||
pointer: 3,
|
pointer: 3,
|
||||||
position: const Point(130.0, 130.0)
|
position: const Offset(130.0, 130.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up3 = const PointerUpEvent(
|
const PointerUpEvent up3 = const PointerUpEvent(
|
||||||
pointer: 3,
|
pointer: 3,
|
||||||
position: const Point(131.0, 129.0)
|
position: const Offset(131.0, 129.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Down/move/up sequence 4: intervening motion
|
// Down/move/up sequence 4: intervening motion
|
||||||
const PointerDownEvent down4 = const PointerDownEvent(
|
const PointerDownEvent down4 = const PointerDownEvent(
|
||||||
pointer: 4,
|
pointer: 4,
|
||||||
position: const Point(10.0, 10.0)
|
position: const Offset(10.0, 10.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerMoveEvent move4 = const PointerMoveEvent(
|
const PointerMoveEvent move4 = const PointerMoveEvent(
|
||||||
pointer: 4,
|
pointer: 4,
|
||||||
position: const Point(25.0, 25.0)
|
position: const Offset(25.0, 25.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up4 = const PointerUpEvent(
|
const PointerUpEvent up4 = const PointerUpEvent(
|
||||||
pointer: 4,
|
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
|
// Down/up pair 5: normal tap sequence identical to pair 1 with different pointer
|
||||||
const PointerDownEvent down5 = const PointerDownEvent(
|
const PointerDownEvent down5 = const PointerDownEvent(
|
||||||
pointer: 5,
|
pointer: 5,
|
||||||
position: const Point(10.0, 10.0)
|
position: const Offset(10.0, 10.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up5 = const PointerUpEvent(
|
const PointerUpEvent up5 = const PointerUpEvent(
|
||||||
pointer: 5,
|
pointer: 5,
|
||||||
position: const Point(11.0, 9.0)
|
position: const Offset(11.0, 9.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
testGesture('Should recognize double tap', (GestureTester tester) {
|
testGesture('Should recognize double tap', (GestureTester tester) {
|
||||||
|
@ -35,7 +35,7 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final TestPointer pointer = new TestPointer(5);
|
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);
|
pan.addPointer(down);
|
||||||
tap.addPointer(down);
|
tap.addPointer(down);
|
||||||
tester.closeArena(5);
|
tester.closeArena(5);
|
||||||
@ -50,7 +50,7 @@ void main() {
|
|||||||
expect(didEndPan, isFalse);
|
expect(didEndPan, isFalse);
|
||||||
expect(didTap, 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);
|
expect(didStartPan, isTrue);
|
||||||
didStartPan = false;
|
didStartPan = false;
|
||||||
expect(updatedScrollDelta, const Offset(10.0, 10.0));
|
expect(updatedScrollDelta, const Offset(10.0, 10.0));
|
||||||
@ -58,7 +58,7 @@ void main() {
|
|||||||
expect(didEndPan, isFalse);
|
expect(didEndPan, isFalse);
|
||||||
expect(didTap, 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(didStartPan, isFalse);
|
||||||
expect(updatedScrollDelta, const Offset(0.0, 5.0));
|
expect(updatedScrollDelta, const Offset(0.0, 5.0));
|
||||||
updatedScrollDelta = null;
|
updatedScrollDelta = null;
|
||||||
@ -95,7 +95,7 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final TestPointer pointer = new TestPointer(5);
|
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);
|
drag.addPointer(down);
|
||||||
tester.closeArena(5);
|
tester.closeArena(5);
|
||||||
expect(didStartDrag, isFalse);
|
expect(didStartDrag, isFalse);
|
||||||
@ -107,14 +107,14 @@ void main() {
|
|||||||
expect(updatedDelta, isNull);
|
expect(updatedDelta, isNull);
|
||||||
expect(didEndDrag, isFalse);
|
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);
|
expect(didStartDrag, isTrue);
|
||||||
didStartDrag = false;
|
didStartDrag = false;
|
||||||
expect(updatedDelta, 10.0);
|
expect(updatedDelta, 10.0);
|
||||||
updatedDelta = null;
|
updatedDelta = null;
|
||||||
expect(didEndDrag, isFalse);
|
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(didStartDrag, isFalse);
|
||||||
expect(updatedDelta, 0.0);
|
expect(updatedDelta, 0.0);
|
||||||
updatedDelta = null;
|
updatedDelta = null;
|
||||||
@ -140,21 +140,21 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final TestPointer pointer = new TestPointer(5);
|
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);
|
drag.addPointer(down);
|
||||||
tester.closeArena(5);
|
tester.closeArena(5);
|
||||||
tester.route(down);
|
tester.route(down);
|
||||||
tester.route(pointer.move(const Point(20.0, 25.0), timeStamp: const Duration(milliseconds: 10)));
|
tester.route(pointer.move(const Offset(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 Offset(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 Offset(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 Offset(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 Offset(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 Offset(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 Offset(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 Offset(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 Offset(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 Offset(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(120.0, 25.0), timeStamp: const Duration(milliseconds: 20)));
|
||||||
tester.route(pointer.up(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.dx, inInclusiveRange(0.99 * kMaxFlingVelocity, kMaxFlingVelocity));
|
||||||
expect(velocity.pixelsPerSecond.dy, moreOrLessEquals(0.0));
|
expect(velocity.pixelsPerSecond.dy, moreOrLessEquals(0.0));
|
||||||
@ -166,7 +166,7 @@ void main() {
|
|||||||
testGesture('Drag details', (GestureTester tester) {
|
testGesture('Drag details', (GestureTester tester) {
|
||||||
expect(new DragDownDetails(), hasOneLineDescription);
|
expect(new DragDownDetails(), hasOneLineDescription);
|
||||||
expect(new DragStartDetails(), hasOneLineDescription);
|
expect(new DragStartDetails(), hasOneLineDescription);
|
||||||
expect(new DragUpdateDetails(globalPosition: Point.origin), hasOneLineDescription);
|
expect(new DragUpdateDetails(globalPosition: Offset.zero), hasOneLineDescription);
|
||||||
expect(new DragEndDetails(), hasOneLineDescription);
|
expect(new DragEndDetails(), hasOneLineDescription);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ import 'gesture_tester.dart';
|
|||||||
|
|
||||||
const PointerDownEvent down = const PointerDownEvent(
|
const PointerDownEvent down = const PointerDownEvent(
|
||||||
pointer: 5,
|
pointer: 5,
|
||||||
position: const Point(10.0, 10.0)
|
position: const Offset(10.0, 10.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
const PointerUpEvent up = const PointerUpEvent(
|
const PointerUpEvent up = const PointerUpEvent(
|
||||||
pointer: 5,
|
pointer: 5,
|
||||||
position: const Point(11.0, 9.0)
|
position: const Offset(11.0, 9.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -17,23 +17,23 @@ void main() {
|
|||||||
final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer();
|
final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer();
|
||||||
|
|
||||||
bool didStartDrag = false;
|
bool didStartDrag = false;
|
||||||
drag.onStart = (Point position) {
|
drag.onStart = (Offset position) {
|
||||||
didStartDrag = true;
|
didStartDrag = true;
|
||||||
return new TestDrag();
|
return new TestDrag();
|
||||||
};
|
};
|
||||||
|
|
||||||
final TestPointer pointer = new TestPointer(5);
|
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);
|
drag.addPointer(down);
|
||||||
tester.closeArena(5);
|
tester.closeArena(5);
|
||||||
expect(didStartDrag, isFalse);
|
expect(didStartDrag, isFalse);
|
||||||
tester.async.flushMicrotasks();
|
tester.async.flushMicrotasks();
|
||||||
expect(didStartDrag, isFalse);
|
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);
|
expect(didStartDrag, isFalse);
|
||||||
tester.async.elapse(kLongPressTimeout * 2);
|
tester.async.elapse(kLongPressTimeout * 2);
|
||||||
expect(didStartDrag, isFalse);
|
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);
|
expect(didStartDrag, isFalse);
|
||||||
drag.dispose();
|
drag.dispose();
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
final TestPointer pointer5 = new TestPointer(5);
|
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);
|
tap.addPointer(down5);
|
||||||
tester.closeArena(5);
|
tester.closeArena(5);
|
||||||
expect(log, <String>['tap-down 5']);
|
expect(log, <String>['tap-down 5']);
|
||||||
@ -35,7 +35,7 @@ void main() {
|
|||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
final TestPointer pointer6 = new TestPointer(6);
|
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);
|
tap.addPointer(down6);
|
||||||
tester.closeArena(6);
|
tester.closeArena(6);
|
||||||
expect(log, <String>['tap-down 6']);
|
expect(log, <String>['tap-down 6']);
|
||||||
@ -43,10 +43,10 @@ void main() {
|
|||||||
tester.route(down6);
|
tester.route(down6);
|
||||||
expect(log, isEmpty);
|
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);
|
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);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
tester.route(pointer5.up());
|
tester.route(pointer5.up());
|
||||||
@ -60,7 +60,7 @@ void main() {
|
|||||||
expect(log, <String>['long-tap-down 6']);
|
expect(log, <String>['long-tap-down 6']);
|
||||||
log.clear();
|
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']);
|
expect(log, <String>['tap-cancel 6']);
|
||||||
log.clear();
|
log.clear();
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user