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

Unified Diff: sky/examples/raw/simple_render_tree.dart

Issue 1156303004: Use Point, Size, and Rect in layout2.dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698