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

Side by Side Diff: sky/sdk/example/rendering/simple_autolayout.dart

Issue 1230033002: [AutoLayout] Address further concerns raised in https://codereview.chromium.org/1230583003 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
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:sky'; 5 import 'dart:sky';
6 import 'package:sky/rendering/box.dart'; 6 import 'package:sky/rendering/box.dart';
7 import 'package:sky/rendering/object.dart'; 7 import 'package:sky/rendering/object.dart';
8 import 'package:sky/rendering/sky_binding.dart'; 8 import 'package:sky/rendering/sky_binding.dart';
9 import 'package:sky/rendering/auto_layout.dart'; 9 import 'package:sky/rendering/auto_layout.dart';
10 import 'package:cassowary/cassowary.dart' as al; 10 import 'package:cassowary/cassowary.dart' as al;
11 11
12 void main() { 12 void main() {
13 var c1 = new RenderDecoratedBox( 13 RenderDecoratedBox c1 = new RenderDecoratedBox(
14 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFF0000)) 14 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFF0000))
15 ); 15 );
16 16
17 var c2 = new RenderDecoratedBox( 17 RenderDecoratedBox c2 = new RenderDecoratedBox(
18 decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00)) 18 decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FF00))
19 ); 19 );
20 20
21 var c3 = new RenderDecoratedBox( 21 RenderDecoratedBox c3 = new RenderDecoratedBox(
22 decoration: new BoxDecoration(backgroundColor: const Color(0xFF0000FF)) 22 decoration: new BoxDecoration(backgroundColor: const Color(0xFF0000FF))
23 ); 23 );
24 24
25 var c4 = new RenderDecoratedBox( 25 RenderDecoratedBox c4 = new RenderDecoratedBox(
26 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)) 26 decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF))
27 ); 27 );
28 28
29 var root = new RenderAutoLayout(children: [c1, c2, c3, c4]); 29 RenderAutoLayout root = new RenderAutoLayout(children: [c1, c2, c3, c4]);
30 30
31 AutoLayoutParentData p1 = c1.parentData; 31 AutoLayoutParentData p1 = c1.parentData;
32 AutoLayoutParentData p2 = c2.parentData; 32 AutoLayoutParentData p2 = c2.parentData;
33 AutoLayoutParentData p3 = c3.parentData; 33 AutoLayoutParentData p3 = c3.parentData;
34 AutoLayoutParentData p4 = c4.parentData; 34 AutoLayoutParentData p4 = c4.parentData;
35 35
36 root.addConstraints(<al.Constraint>[ 36 root.addConstraints(<al.Constraint>[
37 // Sum of widths of each box must be equal to that of the container 37 // Sum of widths of each box must be equal to that of the container
38 (p1.width + p2.width + p3.width == root.width) as al.Constraint, 38 (p1.width + p2.width + p3.width == root.width) as al.Constraint,
39 39
(...skipping 16 matching lines...) Expand all
56 // The fourth box should be half as wide as the second and must be attached 56 // The fourth box should be half as wide as the second and must be attached
57 // to the right edge of the same (by its center) 57 // to the right edge of the same (by its center)
58 (p4.width == p2.width / al.cm(2.0)) as al.Constraint, 58 (p4.width == p2.width / al.cm(2.0)) as al.Constraint,
59 (p4.height == al.cm(50.0)) as al.Constraint, 59 (p4.height == al.cm(50.0)) as al.Constraint,
60 (p4.horizontalCenter == p2.rightEdge) as al.Constraint, 60 (p4.horizontalCenter == p2.rightEdge) as al.Constraint,
61 (p4.verticalCenter == p2.height / al.cm(2.0)) as al.Constraint, 61 (p4.verticalCenter == p2.height / al.cm(2.0)) as al.Constraint,
62 ]); 62 ]);
63 63
64 new SkyBinding(root: root); 64 new SkyBinding(root: root);
65 } 65 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/rendering/auto_layout.dart » ('j') | sky/sdk/lib/rendering/auto_layout.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698