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

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: address review comments 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
« no previous file with comments | « sky/examples/raw/sector-layout.dart ('k') | sky/sdk/lib/framework/app.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f2db8ee3dfd263b09c9a35bf6f406940a9f6d167..7ed385b2d6a252512a470714d0769fa5922cd6a8 100644
--- a/sky/examples/raw/simple_render_tree.dart
+++ b/sky/examples/raw/simple_render_tree.dart
@@ -7,24 +7,22 @@ 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 })
: backgroundColor = backgroundColor,
- super(new BoxDecoration(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);
}
void performLayout() {
- width = constraints.constrainWidth(desiredWidth);
- height = constraints.constrainHeight(desiredHeight);
+ size = constraints.constrain(desiredSize);
}
void handlePointer(PointerEvent event) {
@@ -43,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());
parent.add(child);
child.parentData.flex = flex;
}
@@ -52,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));
« no previous file with comments | « sky/examples/raw/sector-layout.dart ('k') | sky/sdk/lib/framework/app.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698