OLD | NEW |
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 import 'package:sky/framework/app.dart'; | 7 import 'package:sky/framework/app.dart'; |
8 import 'package:sky/framework/rendering/box.dart'; | 8 import 'package:sky/framework/rendering/box.dart'; |
9 import 'package:sky/framework/rendering/object.dart'; | 9 import 'package:sky/framework/rendering/object.dart'; |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 | 251 |
252 // paint origin is 0,0 of our circle | 252 // paint origin is 0,0 of our circle |
253 // each sector then knows how to paint itself at its location | 253 // each sector then knows how to paint itself at its location |
254 void paint(RenderObjectDisplayList canvas) { | 254 void paint(RenderObjectDisplayList canvas) { |
255 // TODO(ianh): avoid code duplication | 255 // TODO(ianh): avoid code duplication |
256 super.paint(canvas); | 256 super.paint(canvas); |
257 RenderSector child = firstChild; | 257 RenderSector child = firstChild; |
258 while (child != null) { | 258 while (child != null) { |
259 assert(child.parentData is SectorChildListParentData); | 259 assert(child.parentData is SectorChildListParentData); |
260 canvas.paintChild(child, new Point(0.0, 0.0)); | 260 canvas.paintChild(child, Point.origin); |
261 child = child.parentData.nextSibling; | 261 child = child.parentData.nextSibling; |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 } | 265 } |
266 | 266 |
267 class RenderSectorSlice extends RenderSectorWithChildren { | 267 class RenderSectorSlice extends RenderSectorWithChildren { |
268 // lays out RenderSector children in a stack | 268 // lays out RenderSector children in a stack |
269 | 269 |
270 RenderSectorSlice({ | 270 RenderSectorSlice({ |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 // paint origin is 0,0 of our circle | 357 // paint origin is 0,0 of our circle |
358 // each sector then knows how to paint itself at its location | 358 // each sector then knows how to paint itself at its location |
359 void paint(RenderObjectDisplayList canvas) { | 359 void paint(RenderObjectDisplayList canvas) { |
360 // TODO(ianh): avoid code duplication | 360 // TODO(ianh): avoid code duplication |
361 super.paint(canvas); | 361 super.paint(canvas); |
362 RenderSector child = firstChild; | 362 RenderSector child = firstChild; |
363 while (child != null) { | 363 while (child != null) { |
364 assert(child.parentData is SectorChildListParentData); | 364 assert(child.parentData is SectorChildListParentData); |
365 canvas.paintChild(child, new Point(0.0, 0.0)); | 365 canvas.paintChild(child, Point.origin); |
366 child = child.parentData.nextSibling; | 366 child = child.parentData.nextSibling; |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 } | 370 } |
371 | 371 |
372 class RenderBoxToRenderSectorAdapter extends RenderBox { | 372 class RenderBoxToRenderSectorAdapter extends RenderBox { |
373 | 373 |
374 RenderBoxToRenderSectorAdapter({ double innerRadius: 0.0, RenderSector child }
) : | 374 RenderBoxToRenderSectorAdapter({ double innerRadius: 0.0, RenderSector child }
) : |
375 _innerRadius = innerRadius { | 375 _innerRadius = innerRadius { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta
: kTwoPi * 0.4)); | 499 rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta
: kTwoPi * 0.4)); |
500 var stack = new RenderSectorSlice(padding: 2.0); | 500 var stack = new RenderSectorSlice(padding: 2.0); |
501 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20
.0)); | 501 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20
.0)); |
502 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20
.0)); | 502 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20
.0)); |
503 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); | 503 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); |
504 rootCircle.add(stack); | 504 rootCircle.add(stack); |
505 | 505 |
506 var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCi
rcle); | 506 var root = new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCi
rcle); |
507 app = new AppView(root); | 507 app = new AppView(root); |
508 } | 508 } |
OLD | NEW |