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 | 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 BoxDecoration _decoration; | 109 BoxDecoration _decoration; |
110 BoxDecoration get decoration => _decoration; | 110 BoxDecoration get decoration => _decoration; |
111 void set decoration (BoxDecoration value) { | 111 void set decoration (BoxDecoration value) { |
112 if (value == _decoration) | 112 if (value == _decoration) |
113 return; | 113 return; |
114 _decoration = value; | 114 _decoration = value; |
115 markNeedsPaint(); | 115 markNeedsPaint(); |
116 } | 116 } |
117 | 117 |
118 // origin must be set to the center of the circle | 118 // origin must be set to the center of the circle |
119 void paint(RenderObjectDisplayList canvas) { | 119 void paint(RenderCanvas canvas) { |
120 assert(deltaRadius != null); | 120 assert(deltaRadius != null); |
121 assert(deltaTheta != null); | 121 assert(deltaTheta != null); |
122 assert(parentData is SectorParentData); | 122 assert(parentData is SectorParentData); |
123 | 123 |
124 if (_decoration == null) | 124 if (_decoration == null) |
125 return; | 125 return; |
126 | 126 |
127 if (_decoration.backgroundColor != null) { | 127 if (_decoration.backgroundColor != null) { |
128 Paint paint = new Paint()..color = _decoration.backgroundColor; | 128 Paint paint = new Paint()..color = _decoration.backgroundColor; |
129 Path path = new Path(); | 129 Path path = new Path(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 if (child != null) { | 246 if (child != null) { |
247 innerTheta += paddingTheta; | 247 innerTheta += paddingTheta; |
248 remainingDeltaTheta -= paddingTheta; | 248 remainingDeltaTheta -= paddingTheta; |
249 } | 249 } |
250 } | 250 } |
251 deltaTheta = innerTheta; | 251 deltaTheta = innerTheta; |
252 } | 252 } |
253 | 253 |
254 // paint origin is 0,0 of our circle | 254 // paint origin is 0,0 of our circle |
255 // each sector then knows how to paint itself at its location | 255 // each sector then knows how to paint itself at its location |
256 void paint(RenderObjectDisplayList canvas) { | 256 void paint(RenderCanvas canvas) { |
257 // TODO(ianh): avoid code duplication | 257 // TODO(ianh): avoid code duplication |
258 super.paint(canvas); | 258 super.paint(canvas); |
259 RenderSector child = firstChild; | 259 RenderSector child = firstChild; |
260 while (child != null) { | 260 while (child != null) { |
261 assert(child.parentData is SectorChildListParentData); | 261 assert(child.parentData is SectorChildListParentData); |
262 canvas.paintChild(child, Point.origin); | 262 canvas.paintChild(child, Point.origin); |
263 child = child.parentData.nextSibling; | 263 child = child.parentData.nextSibling; |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 assert(child.parentData is SectorChildListParentData); | 351 assert(child.parentData is SectorChildListParentData); |
352 child = child.parentData.nextSibling; | 352 child = child.parentData.nextSibling; |
353 childRadius += padding; | 353 childRadius += padding; |
354 remainingDeltaRadius -= padding; | 354 remainingDeltaRadius -= padding; |
355 } | 355 } |
356 deltaRadius = childRadius - this.parentData.radius; | 356 deltaRadius = childRadius - this.parentData.radius; |
357 } | 357 } |
358 | 358 |
359 // paint origin is 0,0 of our circle | 359 // paint origin is 0,0 of our circle |
360 // each sector then knows how to paint itself at its location | 360 // each sector then knows how to paint itself at its location |
361 void paint(RenderObjectDisplayList canvas) { | 361 void paint(RenderCanvas canvas) { |
362 // TODO(ianh): avoid code duplication | 362 // TODO(ianh): avoid code duplication |
363 super.paint(canvas); | 363 super.paint(canvas); |
364 RenderSector child = firstChild; | 364 RenderSector child = firstChild; |
365 while (child != null) { | 365 while (child != null) { |
366 assert(child.parentData is SectorChildListParentData); | 366 assert(child.parentData is SectorChildListParentData); |
367 canvas.paintChild(child, Point.origin); | 367 canvas.paintChild(child, Point.origin); |
368 child = child.parentData.nextSibling; | 368 child = child.parentData.nextSibling; |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 assert(child.parentData is SectorParentData); | 445 assert(child.parentData is SectorParentData); |
446 child.parentData.radius = innerRadius; | 446 child.parentData.radius = innerRadius; |
447 child.parentData.theta = 0.0; | 447 child.parentData.theta = 0.0; |
448 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p
arentUsesSize: true); | 448 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p
arentUsesSize: true); |
449 double dimension = (innerRadius + child.deltaRadius) * 2.0; | 449 double dimension = (innerRadius + child.deltaRadius) * 2.0; |
450 size = constraints.constrain(new Size(dimension, dimension)); | 450 size = constraints.constrain(new Size(dimension, dimension)); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 // paint origin is 0,0 of our circle | 454 // paint origin is 0,0 of our circle |
455 void paint(RenderObjectDisplayList canvas) { | 455 void paint(RenderCanvas canvas) { |
456 super.paint(canvas); | 456 super.paint(canvas); |
457 if (child != null) { | 457 if (child != null) { |
458 Rect bounds = new Rect.fromSize(size); | 458 Rect bounds = new Rect.fromSize(size); |
459 canvas.paintChild(child, bounds.center); | 459 canvas.paintChild(child, bounds.center); |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 bool hitTest(HitTestResult result, { Point position }) { | 463 bool hitTest(HitTestResult result, { Point position }) { |
464 double x = position.x; | 464 double x = position.x; |
465 double y = position.y; | 465 double y = position.y; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20
.0)); | 520 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20
.0)); |
521 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20
.0)); | 521 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20
.0)); |
522 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); | 522 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); |
523 rootCircle.add(stack); | 523 rootCircle.add(stack); |
524 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle
); | 524 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle
); |
525 } | 525 } |
526 | 526 |
527 void main() { | 527 void main() { |
528 new SkyBinding(root: buildSectorExample()); | 528 new SkyBinding(root: buildSectorExample()); |
529 } | 529 } |
OLD | NEW |