Chromium Code Reviews| Index: sky/examples/raw/simple_render_tree.dart |
| diff --git a/sky/examples/raw/simple_render_tree.dart b/sky/examples/raw/simple_render_tree.dart |
| index 569c86ac11994268f40dd8a7d0b340aedd170a78..495f52eb0e81b1961514623bc77ba07ed3a8300c 100644 |
| --- a/sky/examples/raw/simple_render_tree.dart |
| +++ b/sky/examples/raw/simple_render_tree.dart |
| @@ -7,24 +7,21 @@ import 'package:sky/framework/app.dart'; |
| import 'package:sky/framework/layout2.dart'; |
| class RenderSolidColor extends RenderDecoratedBox { |
| - final double desiredHeight; |
| - final double desiredWidth; |
| + final Size desiredSize; |
| final int backgroundColor; |
| - RenderSolidColor(int backgroundColor, { this.desiredHeight: double.INFINITY, |
| - this.desiredWidth: double.INFINITY }) |
| + RenderSolidColor(int backgroundColor, { this.desiredSize }) |
|
Hixie
2015/05/28 18:45:22
If Size was a constant class, you could default it
|
| : backgroundColor = backgroundColor, |
| super(new BoxDecoration(backgroundColor: backgroundColor)); |
| BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { |
| return new BoxDimensions.withConstraints(constraints, |
| - height: desiredHeight, |
| - width: desiredWidth); |
| + width: desiredSize.width, |
| + height: desiredSize.height); |
|
Hixie
2015/05/28 18:45:22
This would be simplified by withConstraints() taki
|
| } |
| void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { |
| - width = constraints.constrainWidth(desiredWidth); |
| - height = constraints.constrainHeight(desiredHeight); |
| + size = constraints.constrain(desiredSize); |
| layoutDone(); |
| } |
| @@ -44,7 +41,7 @@ void main() { |
| decoration: new BoxDecoration(backgroundColor: 0xFF000000)); |
| void addFlexChild(RenderFlex parent, int backgroundColor, { int flex: 0 }) { |
| - RenderNode child = new RenderSolidColor(backgroundColor); |
| + RenderNode child = new RenderSolidColor(backgroundColor, desiredSize: new Size.infinite()); |
|
Hixie
2015/05/28 18:45:22
I think the old code looked better (implying infin
|
| parent.add(child); |
| child.parentData.flex = flex; |
| } |
| @@ -53,13 +50,13 @@ void main() { |
| addFlexChild(root, 0xFFFFFF00, flex: 1); |
| // Turquoise box |
| - root.add(new RenderSolidColor(0x7700FFFF, desiredHeight: 100.0, desiredWidth: 100.0)); |
| + root.add(new RenderSolidColor(0x7700FFFF, desiredSize: new Size(100.0, 100.0))); |
| // Green and cyan render block with padding |
| var renderBlock = new RenderBlock(decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF)); |
| - renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredHeight: 50.0, desiredWidth: 100.0)); |
| - renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredHeight: 100.0, desiredWidth: 50.0)); |
| + renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new Size(100.0, 50.0))); |
| + renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new Size(50.0, 100.0))); |
| root.add(new RenderPadding(const EdgeDims(10.0, 10.0, 10.0, 10.0), renderBlock)); |