Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: sky/examples/raw/hello_world.dart

Issue 1129333005: Plumb input events into SkyView (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/examples/raw/hello_world.dart
diff --git a/sky/examples/raw/hello_world.dart b/sky/examples/raw/hello_world.dart
index 0b99a9cb6d01cb03ab09f60f08a9fdc1c778bd75..50139b021557e0beb213f8705d2d860ae3e15e38 100644
--- a/sky/examples/raw/hello_world.dart
+++ b/sky/examples/raw/hello_world.dart
@@ -5,22 +5,38 @@
import "dart:math";
import 'dart:sky';
-void main() {
- print("Hello, world");
-
+Picture draw(int a, int r, int g, int b) {
double width = view.width;
double height = view.height;
PictureRecorder recorder = new PictureRecorder(width, height);
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);
+ return recorder.endRecording();
+}
+
+bool handleEvent(Event event) {
+ if (event.type == "pointerdown") {
+ view.picture = draw(255, 0, 0, 255);
+ view.schedulePaint();
+ return true;
+ }
- print("Storing picture");
- view.picture = recorder.endRecording();
+ if (event.type == "pointerup") {
+ view.picture = draw(255, 0, 255, 0);
+ view.schedulePaint();
+ return true;
+ }
- print("Scheduling paint");
+ return false;
+}
+
+void main() {
+ print("Hello, world");
+ view.picture = draw(255, 0, 255, 0);
view.schedulePaint();
+
+ view.setEventCallback(handleEvent);
}

Powered by Google App Engine
This is Rietveld 408576698