OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 import "dart:math"; | |
6 import 'dart:sky'; | |
7 | |
8 import 'package:sky/framework/shell.dart' as shell; | |
9 import 'package:mojom/intents/intents.mojom.dart'; | |
10 | |
11 Picture draw(int a, int r, int g, int b) { | |
12 Size size = new Size(view.width, view.height); | |
13 | |
14 PictureRecorder recorder = new PictureRecorder(); | |
15 Canvas canvas = new Canvas(recorder, size); | |
16 double radius = size.shortestSide * 0.45; | |
17 | |
18 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b); | |
19 canvas.drawRect(new Rect.fromSize(size), paint); | |
20 return recorder.endRecording(); | |
21 } | |
22 | |
23 bool handleEvent(Event event) { | |
24 if (event.type == "pointerdown") { | |
25 view.picture = draw(255, 0, 0, 255); | |
26 view.scheduleFrame(); | |
27 return true; | |
28 } | |
29 | |
30 if (event.type == "pointerup") { | |
31 view.picture = draw(255, 255, 255, 0); | |
32 view.scheduleFrame(); | |
33 | |
34 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound(); | |
35 Intent intent = new Intent() | |
36 ..action = 'android.intent.action.VIEW' | |
37 ..url = 'sky://localhost:9888/sky/sdk/lib/example/raw/hello_world.dart'; | |
38 shell.requestService(null, activityManager); | |
39 activityManager.ptr.startActivity(intent); | |
40 return true; | |
41 } | |
42 | |
43 if (event.type == "back") { | |
44 print("Pressed back button."); | |
45 return true; | |
46 } | |
47 | |
48 return false; | |
49 } | |
50 | |
51 void main() { | |
52 print("Hello, world"); | |
53 view.picture = draw(255, 255, 255, 0); | |
54 view.scheduleFrame(); | |
55 | |
56 view.setEventCallback(handleEvent); | |
57 } | |
OLD | NEW |