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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/framework/layout2.dart » ('j') | sky/sdk/lib/framework/layout2.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math'; 5 import 'dart:math';
6 import 'dart:sky'; 6 import 'dart:sky';
7 import 'package:sky/framework/layout2.dart'; 7 import 'package:sky/framework/layout2.dart';
8 8
9 class RenderBlueCircle extends RenderBox { 9 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? :-)
10 void paint(RenderNodeDisplayList canvas) { 10 SimpleBlock(int backgroundColor)
11 double radius = min(width, height) * 0.45; 11 : super(new BoxDecoration(backgroundColor: backgroundColor));
12 Paint paint = new Paint()..setARGB(255, 0, 255, 255); 12
13 canvas.drawCircle(width / 2, height / 2, radius, paint); 13 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
14 return new BoxDimensions.withConstraints(constraints, height: 200.0);
15 }
16
17 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) {
18 setWidth(constraints, constraints.maxWidth);
19 setHeight(constraints, 200.0);
20 layoutDone();
14 } 21 }
15 } 22 }
16 23
17 void main() { 24 void main() {
18 RenderView renderView = new RenderView(root: new RenderBlueCircle()); 25 var root = new RenderBlock(
26 decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF));
27
28 root.add(new SimpleBlock(0xFF00FF00));
29 root.add(new SimpleBlock(0xFF0000FF));
30
31 RenderView renderView = new RenderView(root: root);
19 renderView.layout(newWidth: view.width, newHeight: view.height); 32 renderView.layout(newWidth: view.width, newHeight: view.height);
20 renderView.paintFrame(); 33 renderView.paintFrame();
21 } 34 }
OLDNEW
« 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