Fix the transforms for horizontal glows. (#8252)

Also, make all painters have a toString by default.
This commit is contained in:
Ian Hickson 2017-02-17 20:03:23 -08:00 committed by GitHub
parent 4a02afade1
commit c4127ee60b
3 changed files with 12 additions and 10 deletions

View File

@ -1777,6 +1777,9 @@ abstract class CustomPainter {
/// point that should be considered outside the painted image, and null to use
/// the default behavior.
bool hitTest(Point position) => null;
@override
String toString() => '$runtimeType#$hashCode';
}
/// Provides a canvas on which to draw during the paint phase.

View File

@ -450,16 +450,15 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter {
break;
case AxisDirection.left:
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));
canvas.restore();
break;
case AxisDirection.right:
canvas.save();
canvas.translate(size.width, size.height);
canvas.rotate(-piOver2);
canvas.scale(1.0, -1.0);
canvas.translate(size.width, 0.0);
canvas.rotate(piOver2);
controller.paint(canvas, new Size(size.height, size.width));
canvas.restore();
break;

View File

@ -187,11 +187,11 @@ void main() {
);
RenderObject painter = tester.renderObject(find.byType(CustomPaint));
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()));
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()
..rotate(angle: -math.PI / 2.0)..scale(y: -1.0)..circle());
expect(painter, paints..rotate(angle: math.PI / 2.0)..circle()
..rotate(angle: math.PI / 2.0)..circle());
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
expect(painter, doesNotOverscroll);
@ -237,7 +237,7 @@ void main() {
);
painter = tester.renderObject(find.byType(CustomPaint));
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()));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
@ -254,7 +254,7 @@ void main() {
);
painter = tester.renderObject(find.byType(CustomPaint));
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()));
});
}