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

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

Issue 1144423002: Actually perform a block layout (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Some more notes 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 | « no previous file | sky/sdk/lib/framework/layout2.dart » ('j') | sky/sdk/lib/framework/layout2.dart » ('J')
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 f5ae7e7dc0e52f106ec8a1c8cafc68ef4efb3371..13df0b893a6082398962f0efe87bc62154f18e0b 100644
--- a/sky/examples/raw/simple_render_tree.dart
+++ b/sky/examples/raw/simple_render_tree.dart
@@ -6,16 +6,29 @@ import 'dart:math';
import 'dart:sky';
import 'package:sky/framework/layout2.dart';
-class RenderBlueCircle extends RenderBox {
- void paint(RenderNodeDisplayList canvas) {
- double radius = min(width, height) * 0.45;
- Paint paint = new Paint()..setARGB(255, 0, 255, 255);
- canvas.drawCircle(width / 2, height / 2, radius, paint);
+class SimpleBlock extends RenderDecoratedBox {
eseidel 2015/05/21 18:08:14 Simple isnt' a very good name. SolidColorBlock?
Hixie 2015/05/21 19:45:03 TwoHundredPixelHighBlock? :-)
+ SimpleBlock(int backgroundColor)
+ : super(new BoxDecoration(backgroundColor: backgroundColor));
+
+ BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
+ return new BoxDimensions.withConstraints(constraints, height: 200.0);
+ }
+
+ void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) {
+ setWidth(constraints, constraints.maxWidth);
+ setHeight(constraints, 200.0);
+ layoutDone();
}
}
void main() {
- RenderView renderView = new RenderView(root: new RenderBlueCircle());
+ var root = new RenderBlock(
+ decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF));
+
+ root.add(new SimpleBlock(0xFF00FF00));
+ root.add(new SimpleBlock(0xFF0000FF));
+
+ RenderView renderView = new RenderView(root: root);
renderView.layout(newWidth: view.width, newHeight: view.height);
renderView.paintFrame();
}
« no previous file with comments | « no previous file | sky/sdk/lib/framework/layout2.dart » ('j') | sky/sdk/lib/framework/layout2.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698