Commit c4127ee6 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Fix the transforms for horizontal glows. (#8252)

Also, make all painters have a toString by default.
parent 4a02afad
...@@ -1777,6 +1777,9 @@ abstract class CustomPainter { ...@@ -1777,6 +1777,9 @@ abstract class CustomPainter {
/// 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(Point position) => null;
@override
String toString() => '$runtimeType#$hashCode';
} }
/// Provides a canvas on which to draw during the paint phase. /// Provides a canvas on which to draw during the paint phase.
......
...@@ -450,16 +450,15 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter { ...@@ -450,16 +450,15 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter {
break; break;
case AxisDirection.left: case AxisDirection.left:
canvas.save(); canvas.save();
canvas.translate(0.0, size.height); canvas.rotate(piOver2);
canvas.rotate(-piOver2); canvas.scale(1.0, -1.0);
controller.paint(canvas, new Size(size.height, size.width)); controller.paint(canvas, new Size(size.height, size.width));
canvas.restore(); canvas.restore();
break; break;
case AxisDirection.right: case AxisDirection.right:
canvas.save(); canvas.save();
canvas.translate(size.width, size.height); canvas.translate(size.width, 0.0);
canvas.rotate(-piOver2); canvas.rotate(piOver2);
canvas.scale(1.0, -1.0);
controller.paint(canvas, new Size(size.height, size.width)); controller.paint(canvas, new Size(size.height, size.width));
canvas.restore(); canvas.restore();
break; break;
......
...@@ -187,11 +187,11 @@ void main() { ...@@ -187,11 +187,11 @@ void main() {
); );
RenderObject painter = tester.renderObject(find.byType(CustomPaint)); RenderObject painter = tester.renderObject(find.byType(CustomPaint));
await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0));
expect(painter, paints..rotate(angle: -math.PI / 2.0)..circle()..scale(y: -1.0)); expect(painter, paints..rotate(angle: math.PI / 2.0)..circle()..saveRestore());
expect(painter, isNot(paints..circle()..circle())); expect(painter, isNot(paints..circle()..circle()));
await slowDrag(tester, const Point(200.0, 200.0), const Offset(-5.0, 0.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(-5.0, 0.0));
expect(painter, paints..rotate(angle: -math.PI / 2.0)..circle() expect(painter, paints..rotate(angle: math.PI / 2.0)..circle()
..rotate(angle: -math.PI / 2.0)..scale(y: -1.0)..circle()); ..rotate(angle: math.PI / 2.0)..circle());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
...@@ -237,7 +237,7 @@ void main() { ...@@ -237,7 +237,7 @@ void main() {
); );
painter = tester.renderObject(find.byType(CustomPaint)); painter = tester.renderObject(find.byType(CustomPaint));
await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0));
expect(painter, paints..scale(y: -1.0)..rotate(angle: -math.PI / 2.0)..circle(color: const Color(0x0A00FF00))); expect(painter, paints..rotate(angle: math.PI / 2.0)..circle(color: const Color(0x0A00FF00)));
expect(painter, isNot(paints..circle()..circle())); expect(painter, isNot(paints..circle()..circle()));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
...@@ -254,7 +254,7 @@ void main() { ...@@ -254,7 +254,7 @@ void main() {
); );
painter = tester.renderObject(find.byType(CustomPaint)); painter = tester.renderObject(find.byType(CustomPaint));
await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0)); await slowDrag(tester, const Point(200.0, 200.0), const Offset(5.0, 0.0));
expect(painter, paints..rotate(angle: -math.PI / 2.0)..circle(color: const Color(0x0A0000FF))..scale(y: -1.0)); expect(painter, paints..rotate(angle: math.PI / 2.0)..circle(color: const Color(0x0A0000FF))..saveRestore());
expect(painter, isNot(paints..circle()..circle())); expect(painter, isNot(paints..circle()..circle()));
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment