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

Side by Side Diff: sky/sdk/example/rendering/sector_layout.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/game/lib/sprite_box.dart ('k') | sky/sdk/example/rendering/touch_demo.dart » ('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:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import 'package:sky/rendering/box.dart'; 8 import 'package:sky/rendering/box.dart';
9 import 'package:sky/rendering/object.dart'; 9 import 'package:sky/rendering/object.dart';
10 import 'package:sky/rendering/sky_binding.dart'; 10 import 'package:sky/rendering/sky_binding.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 BoxDecoration _decoration; 120 BoxDecoration _decoration;
121 BoxDecoration get decoration => _decoration; 121 BoxDecoration get decoration => _decoration;
122 void set decoration (BoxDecoration value) { 122 void set decoration (BoxDecoration value) {
123 if (value == _decoration) 123 if (value == _decoration)
124 return; 124 return;
125 _decoration = value; 125 _decoration = value;
126 markNeedsPaint(); 126 markNeedsPaint();
127 } 127 }
128 128
129 // offset must point to the center of the circle 129 // offset must point to the center of the circle
130 void paint(RenderCanvas canvas, Offset offset) { 130 void paint(PaintingCanvas canvas, Offset offset) {
131 assert(deltaRadius != null); 131 assert(deltaRadius != null);
132 assert(deltaTheta != null); 132 assert(deltaTheta != null);
133 assert(parentData is SectorParentData); 133 assert(parentData is SectorParentData);
134 134
135 if (_decoration == null) 135 if (_decoration == null)
136 return; 136 return;
137 137
138 if (_decoration.backgroundColor != null) { 138 if (_decoration.backgroundColor != null) {
139 Paint paint = new Paint()..color = _decoration.backgroundColor; 139 Paint paint = new Paint()..color = _decoration.backgroundColor;
140 Path path = new Path(); 140 Path path = new Path();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if (child != null) { 257 if (child != null) {
258 innerTheta += paddingTheta; 258 innerTheta += paddingTheta;
259 remainingDeltaTheta -= paddingTheta; 259 remainingDeltaTheta -= paddingTheta;
260 } 260 }
261 } 261 }
262 deltaTheta = innerTheta; 262 deltaTheta = innerTheta;
263 } 263 }
264 264
265 // offset must point to the center of our circle 265 // offset must point to the center of our circle
266 // each sector then knows how to paint itself at its location 266 // each sector then knows how to paint itself at its location
267 void paint(RenderCanvas canvas, Offset offset) { 267 void paint(PaintingCanvas canvas, Offset offset) {
268 // TODO(ianh): avoid code duplication 268 // TODO(ianh): avoid code duplication
269 super.paint(canvas, offset); 269 super.paint(canvas, offset);
270 RenderSector child = firstChild; 270 RenderSector child = firstChild;
271 while (child != null) { 271 while (child != null) {
272 assert(child.parentData is SectorChildListParentData); 272 assert(child.parentData is SectorChildListParentData);
273 canvas.paintChild(child, offset.toPoint()); 273 canvas.paintChild(child, offset.toPoint());
274 child = child.parentData.nextSibling; 274 child = child.parentData.nextSibling;
275 } 275 }
276 } 276 }
277 277
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 assert(child.parentData is SectorChildListParentData); 362 assert(child.parentData is SectorChildListParentData);
363 child = child.parentData.nextSibling; 363 child = child.parentData.nextSibling;
364 childRadius += padding; 364 childRadius += padding;
365 remainingDeltaRadius -= padding; 365 remainingDeltaRadius -= padding;
366 } 366 }
367 deltaRadius = childRadius - this.parentData.radius; 367 deltaRadius = childRadius - this.parentData.radius;
368 } 368 }
369 369
370 // offset must point to the center of our circle 370 // offset must point to the center of our circle
371 // each sector then knows how to paint itself at its location 371 // each sector then knows how to paint itself at its location
372 void paint(RenderCanvas canvas, Offset offset) { 372 void paint(PaintingCanvas canvas, Offset offset) {
373 // TODO(ianh): avoid code duplication 373 // TODO(ianh): avoid code duplication
374 super.paint(canvas, offset); 374 super.paint(canvas, offset);
375 RenderSector child = firstChild; 375 RenderSector child = firstChild;
376 while (child != null) { 376 while (child != null) {
377 assert(child.parentData is SectorChildListParentData); 377 assert(child.parentData is SectorChildListParentData);
378 canvas.paintChild(child, offset.toPoint()); 378 canvas.paintChild(child, offset.toPoint());
379 child = child.parentData.nextSibling; 379 child = child.parentData.nextSibling;
380 } 380 }
381 } 381 }
382 382
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.ma xHeight) / 2.0 - innerRadius; 455 double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.ma xHeight) / 2.0 - innerRadius;
456 assert(child.parentData is SectorParentData); 456 assert(child.parentData is SectorParentData);
457 child.parentData.radius = innerRadius; 457 child.parentData.radius = innerRadius;
458 child.parentData.theta = 0.0; 458 child.parentData.theta = 0.0;
459 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p arentUsesSize: true); 459 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p arentUsesSize: true);
460 double dimension = (innerRadius + child.deltaRadius) * 2.0; 460 double dimension = (innerRadius + child.deltaRadius) * 2.0;
461 size = constraints.constrain(new Size(dimension, dimension)); 461 size = constraints.constrain(new Size(dimension, dimension));
462 } 462 }
463 } 463 }
464 464
465 void paint(RenderCanvas canvas, Offset offset) { 465 void paint(PaintingCanvas canvas, Offset offset) {
466 super.paint(canvas, offset); 466 super.paint(canvas, offset);
467 if (child != null) { 467 if (child != null) {
468 Rect bounds = offset & size; 468 Rect bounds = offset & size;
469 // we move the offset to the center of the circle for the RenderSectors 469 // we move the offset to the center of the circle for the RenderSectors
470 canvas.paintChild(child, bounds.center); 470 canvas.paintChild(child, bounds.center);
471 } 471 }
472 } 472 }
473 473
474 bool hitTest(HitTestResult result, { Point position }) { 474 bool hitTest(HitTestResult result, { Point position }) {
475 double x = position.x; 475 double x = position.x;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0)); 531 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0));
532 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0)); 532 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0));
533 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); 533 stack.add(new RenderSolidColor(const Color(0xFF00FF00)));
534 rootCircle.add(stack); 534 rootCircle.add(stack);
535 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle ); 535 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle );
536 } 536 }
537 537
538 void main() { 538 void main() {
539 new SkyBinding(root: buildSectorExample()); 539 new SkyBinding(root: buildSectorExample());
540 } 540 }
OLDNEW
« no previous file with comments | « sky/sdk/example/game/lib/sprite_box.dart ('k') | sky/sdk/example/rendering/touch_demo.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698