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

Side by Side Diff: sky/sdk/example/rendering/touch_demo.dart

Issue 1217933002: Rename RenderCanvas to PaintingCanvas to avoid confusion with other classes that inherit from Rende… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « sky/sdk/example/rendering/sector_layout.dart ('k') | sky/sdk/lib/rendering/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:sky' as sky; 5 import 'dart:sky' as sky;
6 6
7 import 'package:sky/rendering/box.dart'; 7 import 'package:sky/rendering/box.dart';
8 import 'package:sky/rendering/object.dart'; 8 import 'package:sky/rendering/object.dart';
9 import 'package:sky/rendering/paragraph.dart'; 9 import 'package:sky/rendering/paragraph.dart';
10 import 'package:sky/rendering/sky_binding.dart'; 10 import 'package:sky/rendering/sky_binding.dart';
(...skipping 15 matching lines...) Expand all
26 Point position = Point.origin; 26 Point position = Point.origin;
27 double radius = 0.0; 27 double radius = 0.0;
28 28
29 Dot({ Color color }) : _paint = new Paint()..color = color; 29 Dot({ Color color }) : _paint = new Paint()..color = color;
30 30
31 void update(sky.PointerEvent event) { 31 void update(sky.PointerEvent event) {
32 position = new Point(event.x, event.y); 32 position = new Point(event.x, event.y);
33 radius = 5 + (95 * event.pressure); 33 radius = 5 + (95 * event.pressure);
34 } 34 }
35 35
36 void paint(RenderCanvas canvas, Offset offset) { 36 void paint(PaintingCanvas canvas, Offset offset) {
37 canvas.drawCircle(position + offset, radius, _paint); 37 canvas.drawCircle(position + offset, radius, _paint);
38 } 38 }
39 } 39 }
40 40
41 class RenderTouchDemo extends RenderBox { 41 class RenderTouchDemo extends RenderBox {
42 Map<int, Dot> dots = new Map(); 42 Map<int, Dot> dots = new Map();
43 43
44 RenderTouchDemo(); 44 RenderTouchDemo();
45 45
46 void handleEvent(sky.Event event, BoxHitTestEntry entry) { 46 void handleEvent(sky.Event event, BoxHitTestEntry entry) {
(...skipping 14 matching lines...) Expand all
61 break; 61 break;
62 } 62 }
63 } 63 }
64 markNeedsPaint(); 64 markNeedsPaint();
65 } 65 }
66 66
67 void performLayout() { 67 void performLayout() {
68 size = constraints.biggest; 68 size = constraints.biggest;
69 } 69 }
70 70
71 void paint(RenderCanvas canvas, Offset offset) { 71 void paint(PaintingCanvas canvas, Offset offset) {
72 Paint white = new Paint() 72 Paint white = new Paint()
73 ..color = const Color(0xFFFFFFFF); 73 ..color = const Color(0xFFFFFFFF);
74 canvas.drawRect(offset & size, white); 74 canvas.drawRect(offset & size, white);
75 for (Dot dot in dots.values) 75 for (Dot dot in dots.values)
76 dot.paint(canvas, offset); 76 dot.paint(canvas, offset);
77 } 77 }
78 } 78 }
79 79
80 void main() { 80 void main() {
81 var paragraph = new RenderParagraph(new InlineText("Touch me!")); 81 var paragraph = new RenderParagraph(new InlineText("Touch me!"));
82 var stack = new RenderStack(children: [ 82 var stack = new RenderStack(children: [
83 new RenderTouchDemo(), 83 new RenderTouchDemo(),
84 paragraph, 84 paragraph,
85 ]); 85 ]);
86 // Prevent the RenderParagraph from filling the whole screen so 86 // Prevent the RenderParagraph from filling the whole screen so
87 // that it doesn't eat events. 87 // that it doesn't eat events.
88 paragraph.parentData..top = 40.0 88 paragraph.parentData..top = 40.0
89 ..left = 20.0; 89 ..left = 20.0;
90 new SkyBinding(root: stack); 90 new SkyBinding(root: stack);
91 } 91 }
OLDNEW
« no previous file with comments | « sky/sdk/example/rendering/sector_layout.dart ('k') | sky/sdk/lib/rendering/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698