| OLD | NEW |
| 1 library layout; | 1 library layout; |
| 2 | 2 |
| 3 // This version of layout.dart is an update to the other one, this one using new
APIs. | 3 // This version of layout.dart is an update to the other one, this one using new
APIs. |
| 4 // It will not work in a stock Sky setup currently. | 4 // It will not work in a stock Sky setup currently. |
| 5 | 5 |
| 6 import 'node.dart'; | 6 import 'node.dart'; |
| 7 | 7 |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 | 9 |
| 10 // ABSTRACT LAYOUT | 10 // ABSTRACT LAYOUT |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 | 222 |
| 223 // PAINTING | 223 // PAINTING |
| 224 | 224 |
| 225 static bool _debugDoingPaint = false; | 225 static bool _debugDoingPaint = false; |
| 226 void markNeedsPaint() { | 226 void markNeedsPaint() { |
| 227 assert(!_debugDoingPaint); | 227 assert(!_debugDoingPaint); |
| 228 var ancestor = this; | 228 var ancestor = this; |
| 229 while (ancestor.parent != null) | 229 while (ancestor.parent != null) |
| 230 ancestor = ancestor.parent; | 230 ancestor = ancestor.parent; |
| 231 assert(ancestor is Screen); | 231 assert(ancestor is RenderView); |
| 232 ancestor.paintFrame(); | 232 ancestor.paintFrame(); |
| 233 } | 233 } |
| 234 void paint(RenderNodeDisplayList canvas) { } | 234 void paint(RenderNodeDisplayList canvas) { } |
| 235 | 235 |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // GENERIC MIXIN FOR RENDER NODES THAT TAKE A LIST OF CHILDREN | 239 // GENERIC MIXIN FOR RENDER NODES THAT TAKE A LIST OF CHILDREN |
| 240 | 240 |
| 241 abstract class ContainerParentDataMixin<ChildType extends RenderNode> { | 241 abstract class ContainerParentDataMixin<ChildType extends RenderNode> { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 void rotate({ | 444 void rotate({ |
| 445 int oldAngle, // 0..3 | 445 int oldAngle, // 0..3 |
| 446 int newAngle, // 0..3 | 446 int newAngle, // 0..3 |
| 447 Duration time | 447 Duration time |
| 448 }) { } | 448 }) { } |
| 449 | 449 |
| 450 } | 450 } |
| 451 | 451 |
| 452 | 452 |
| 453 // SCREEN LAYOUT MANAGER | 453 // RENDER VIEW LAYOUT MANAGER |
| 454 | 454 |
| 455 class Screen extends RenderNode { | 455 class RenderView extends RenderNode { |
| 456 | 456 |
| 457 Screen({ | 457 RenderView({ |
| 458 RenderBox root, | 458 RenderBox root, |
| 459 this.timeForRotation: const Duration(microseconds: 83333) | 459 this.timeForRotation: const Duration(microseconds: 83333) |
| 460 }) { | 460 }) { |
| 461 assert(root != null); | 461 assert(root != null); |
| 462 this.root = root; | 462 this.root = root; |
| 463 } | 463 } |
| 464 | 464 |
| 465 double _width; | 465 double _width; |
| 466 double get width => _width; | 466 double get width => _width; |
| 467 double _height; | 467 double _height; |
| 468 double get height => _height; | 468 double get height => _height; |
| 469 | 469 |
| 470 int _orientation; // 0..3 | 470 int _orientation; // 0..3 |
| 471 int get orientation => _orientation; | 471 int get orientation => _orientation; |
| 472 Duration timeForRotation; | 472 Duration timeForRotation; |
| 473 | 473 |
| 474 RenderBox _root; | 474 RenderBox _root; |
| 475 RenderBox get root => _root; | 475 RenderBox get root => _root; |
| 476 void set root (RenderBox value) { | 476 void set root (RenderBox value) { |
| 477 assert(root != null); | 477 assert(value != null); |
| 478 _root = value; | 478 _root = value; |
| 479 adoptChild(_root); | 479 adoptChild(_root); |
| 480 markNeedsLayout(); | 480 markNeedsLayout(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void layout({ | 483 void layout({ |
| 484 double newWidth, | 484 double newWidth, |
| 485 double newHeight, | 485 double newHeight, |
| 486 int newOrientation | 486 int newOrientation |
| 487 }) { | 487 }) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 final double bottom; | 540 final double bottom; |
| 541 final double left; | 541 final double left; |
| 542 operator ==(EdgeDims other) => (top == other.top) || | 542 operator ==(EdgeDims other) => (top == other.top) || |
| 543 (right == other.right) || | 543 (right == other.right) || |
| 544 (bottom == other.bottom) || | 544 (bottom == other.bottom) || |
| 545 (left == other.left); | 545 (left == other.left); |
| 546 } | 546 } |
| 547 | 547 |
| 548 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } | 548 class BlockParentData extends BoxParentData with ContainerParentDataMixin<Render
Box> { } |
| 549 | 549 |
| 550 class BlockBox extends RenderBox with ContainerRenderNodeMixin<RenderBox, BlockP
arentData> { | 550 class RenderBlock extends RenderBox with ContainerRenderNodeMixin<RenderBox, Blo
ckParentData> { |
| 551 // lays out RenderBox children in a vertical stack | 551 // lays out RenderBox children in a vertical stack |
| 552 // uses the maximum width provided by the parent | 552 // uses the maximum width provided by the parent |
| 553 // sizes itself to the height of its child stack | 553 // sizes itself to the height of its child stack |
| 554 | 554 |
| 555 BlockBox({ | 555 RenderBlock({ |
| 556 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) | 556 EdgeDims padding: const EdgeDims(0.0, 0.0, 0.0, 0.0) |
| 557 }) { | 557 }) { |
| 558 _padding = padding; | 558 _padding = padding; |
| 559 } | 559 } |
| 560 | 560 |
| 561 EdgeDims _padding; | 561 EdgeDims _padding; |
| 562 EdgeDims get padding => _padding; | 562 EdgeDims get padding => _padding; |
| 563 void set padding(EdgeDims value) { | 563 void set padding(EdgeDims value) { |
| 564 assert(value != null); | 564 assert(value != null); |
| 565 if (_padding != value) { | 565 if (_padding != value) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa
ta as BoxParentData).y); | 748 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa
ta as BoxParentData).y); |
| 749 if (statusbar != null) | 749 if (statusbar != null) |
| 750 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s
tatusbar.parentData as BoxParentData).y); | 750 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s
tatusbar.parentData as BoxParentData).y); |
| 751 if (toolbar != null) | 751 if (toolbar != null) |
| 752 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb
ar.parentData as BoxParentData).y); | 752 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb
ar.parentData as BoxParentData).y); |
| 753 if (drawer != null) | 753 if (drawer != null) |
| 754 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer.
parentData as BoxParentData).y); | 754 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer.
parentData as BoxParentData).y); |
| 755 } | 755 } |
| 756 | 756 |
| 757 } | 757 } |
| OLD | NEW |