Commit 83805e2a authored by Adam Barth's avatar Adam Barth

Plumb input events into SkyView

Clients can now register a callback that gets called whenever we have an event
for the view. We'll need to update the Event class at some point, but this is a
start.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1129333005
parent 9523283b
...@@ -5,22 +5,38 @@ ...@@ -5,22 +5,38 @@
import "dart:math"; import "dart:math";
import 'dart:sky'; import 'dart:sky';
void main() { Picture draw(int a, int r, int g, int b) {
print("Hello, world");
double width = view.width; double width = view.width;
double height = view.height; double height = view.height;
PictureRecorder recorder = new PictureRecorder(width, height); PictureRecorder recorder = new PictureRecorder(width, height);
double radius = min(width, height) * 0.45; double radius = min(width, height) * 0.45;
Paint paint = new Paint()..setARGB(255, 0, 255, 0); Paint paint = new Paint()..setARGB(a, r, g, b);
recorder.drawCircle(width / 2, height / 2, radius, paint); recorder.drawCircle(width / 2, height / 2, radius, paint);
return recorder.endRecording();
}
print("Storing picture"); bool handleEvent(Event event) {
view.picture = recorder.endRecording(); if (event.type == "pointerdown") {
view.picture = draw(255, 0, 0, 255);
view.schedulePaint();
return true;
}
print("Scheduling paint"); if (event.type == "pointerup") {
view.picture = draw(255, 0, 255, 0);
view.schedulePaint(); view.schedulePaint();
return true;
}
return false;
}
void main() {
print("Hello, world");
view.picture = draw(255, 0, 255, 0);
view.schedulePaint();
view.setEventCallback(handleEvent);
} }
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