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
diff --git a/dev/manual_tests/material_arc.dart b/dev/manual_tests/material_arc.dart
index 9e815b5..65d915a 100644
--- a/dev/manual_tests/material_arc.dart
+++ b/dev/manual_tests/material_arc.dart
@@ -54,7 +54,7 @@
final MaterialPointArcTween arc;
Animation<double> _repaint;
- void drawPoint(Canvas canvas, Point point, Color color) {
+ void drawPoint(Canvas canvas, Offset point, Color color) {
final Paint paint = new Paint()
..color = color.withOpacity(0.25)
..style = PaintingStyle.fill;
@@ -93,7 +93,7 @@
}
@override
- bool hitTest(Point position) {
+ bool hitTest(Offset position) {
return (arc.begin - position).distanceSquared < _kTargetSlop
|| (arc.end - position).distanceSquared < _kTargetSlop;
}
@@ -117,8 +117,8 @@
CurvedAnimation _animation;
_DragTarget _dragTarget;
Size _screenSize;
- Point _begin;
- Point _end;
+ Offset _begin;
+ Offset _end;
@override
void initState() {
@@ -132,7 +132,7 @@
super.dispose();
}
- Drag _handleOnStart(Point position) {
+ Drag _handleOnStart(Offset position) {
// TODO(hansmuller): allow the user to drag both points at the same time.
if (_dragTarget != null)
return new _IgnoreDrag();
@@ -181,8 +181,8 @@
final Size screenSize = MediaQuery.of(context).size;
if (_screenSize == null || _screenSize != screenSize) {
_screenSize = screenSize;
- _begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2);
- _end = new Point(screenSize.width * 0.1, screenSize.height * 0.4);
+ _begin = new Offset(screenSize.width * 0.5, screenSize.height * 0.2);
+ _end = new Offset(screenSize.width * 0.1, screenSize.height * 0.4);
}
final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
@@ -229,7 +229,7 @@
final MaterialRectArcTween arc;
Animation<double> _repaint;
- void drawPoint(Canvas canvas, Point p, Color color) {
+ void drawPoint(Canvas canvas, Offset p, Color color) {
final Paint paint = new Paint()
..color = color.withOpacity(0.25)
..style = PaintingStyle.fill;
@@ -258,7 +258,7 @@
}
@override
- bool hitTest(Point position) {
+ bool hitTest(Offset position) {
return (arc.begin.center - position).distanceSquared < _kTargetSlop
|| (arc.end.center - position).distanceSquared < _kTargetSlop;
}
@@ -297,7 +297,7 @@
super.dispose();
}
- Drag _handleOnStart(Point position) {
+ Drag _handleOnStart(Offset position) {
// TODO(hansmuller): allow the user to drag both points at the same time.
if (_dragTarget != null)
return new _IgnoreDrag();