Commit ac7f2ff8 authored by Adam Barth's avatar Adam Barth

Ink splashes should start at the touch point

Previously, they always started at the center of the RenderInkWell. Now we
remember the local coordinates we computed during the hit test and provide that
information when handling the event.

R=ianh@google.com

Review URL: https://codereview.chromium.org/1180553002.
parent 4d6d5769
...@@ -14,7 +14,7 @@ class GameBox extends SpriteBox { ...@@ -14,7 +14,7 @@ class GameBox extends SpriteBox {
int _secondPointer = -1; int _secondPointer = -1;
Vector2 _firstPointerDownPos; Vector2 _firstPointerDownPos;
void handleEvent(Event event) { void handleEvent(Event event, BoxHitTestEntry entry) {
if (event is PointerEvent) { if (event is PointerEvent) {
Vector2 pointerPos = new Vector2(event.x, event.y); Vector2 pointerPos = new Vector2(event.x, event.y);
int pointer = event.pointer; int pointer = event.pointer;
......
...@@ -56,7 +56,7 @@ class SpriteBox extends RenderBox { ...@@ -56,7 +56,7 @@ class SpriteBox extends RenderBox {
size = constraints.constrain(Size.infinite); size = constraints.constrain(Size.infinite);
} }
void handleEvent(Event event) { void handleEvent(Event event, BoxHitTestEntry entry) {
switch (event.type) { switch (event.type) {
case 'pointerdown': case 'pointerdown':
print("pointerdown"); print("pointerdown");
......
...@@ -90,7 +90,7 @@ abstract class RenderSector extends RenderObject { ...@@ -90,7 +90,7 @@ abstract class RenderSector extends RenderObject {
theta < parentData.theta || theta >= parentData.theta + deltaTheta) theta < parentData.theta || theta >= parentData.theta + deltaTheta)
return false; return false;
hitTestChildren(result, radius: radius, theta: theta); hitTestChildren(result, radius: radius, theta: theta);
result.add(this); result.add(new HitTestEntry(this));
return true; return true;
} }
void hitTestChildren(HitTestResult result, { double radius, double theta }) { } void hitTestChildren(HitTestResult result, { double radius, double theta }) { }
...@@ -454,7 +454,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox { ...@@ -454,7 +454,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
if (theta > child.deltaTheta) if (theta > child.deltaTheta)
return false; return false;
child.hitTest(result, radius: radius, theta: theta); child.hitTest(result, radius: radius, theta: theta);
result.add(this); result.add(new BoxHitTestEntry(this, position));
return true; return true;
} }
...@@ -480,7 +480,7 @@ class RenderSolidColor extends RenderDecoratedSector { ...@@ -480,7 +480,7 @@ class RenderSolidColor extends RenderDecoratedSector {
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta); deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
} }
void handleEvent(sky.Event event) { void handleEvent(sky.Event event, HitTestEntry entry) {
if (event.type == 'pointerdown') if (event.type == 'pointerdown')
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000)); decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
else if (event.type == 'pointerup') else if (event.type == 'pointerup')
......
...@@ -42,7 +42,7 @@ class RenderTouchDemo extends RenderBox { ...@@ -42,7 +42,7 @@ class RenderTouchDemo extends RenderBox {
RenderTouchDemo(); RenderTouchDemo();
void handleEvent(sky.Event event) { void handleEvent(Event event, BoxHitTestEntry entry) {
switch (event.type) { switch (event.type) {
case 'pointerdown': case 'pointerdown':
int color = colors[event.pointer.remainder(colors.length)]; int color = colors[event.pointer.remainder(colors.length)];
......
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