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/style/block-layout.sky

Issue 745863002: Specs: update the layout and paint schemes to match discussions better (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « sky/examples/README.md ('k') | sky/examples/style/hex-layout.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 SKY MODULE 1 SKY MODULE
2 <import src="sky:core" as="sky"/> 2 <import src="sky:core" as="sky"/>
3 <!-- 3 <!--
4 ! this module provides trivial vertical block layout 4 ! this module provides trivial vertical block layout
5 ! no margins, padding, borders, etc 5 ! no margins, padding, borders, etc
6 !--> 6 !-->
7 <script> 7 <script>
8 module.exports.BlockLayoutManager = class BlockLayoutManager extends sky.Layout Manager { 8 module.exports.BlockLayoutManager = class BlockLayoutManager extends sky.Layout Manager {
9 function layout(width, height) { 9 function layout(width, height) {
10 this.markAsLaidOut(); 10 this.markAsLaidOut();
11 if (width == null) 11 if (width == null)
12 width = this.getIntrinsicWidth().value; 12 width = this.getIntrinsicWidth().value;
13 let autoHeight = false; 13 let autoHeight = false;
14 if (height == null) { 14 if (height == null) {
15 height = 0; 15 height = 0;
16 autoHeight = true; 16 autoHeight = true;
17 } 17 }
18 this.assumeDimensions(width, height); 18 this.assumeDimensions(width, height);
19 let children = this.walkChildren(); 19 let children = this.walkChildren();
20 let loop = children.next(); 20 let loop = children.next();
21 let y = 0; 21 let y = 0;
22 while (!loop.done) { 22 while (!loop.done) {
23 let child = loop.value; 23 let child = loop.value;
24 if (child.needsLayout) { 24 if (child.needsLayout || child.descendantNeedsLayout) {
25 let dims = child.layoutManager.layout(width, null); 25 let dims = child.layoutManager.layout(width, null);
26 this.setChildSize(child, dims.width, dims.height); 26 this.setChildSize(child, dims.width, dims.height);
27 } 27 }
28 this.setChildPosition(child, 0, y); 28 this.setChildPosition(child, 0, y);
29 y += child.height; 29 y += child.height;
30 loop = children.next(); 30 loop = children.next();
31 } 31 }
32 if (autoHeight) 32 if (autoHeight)
33 height = y; 33 height = y;
34 return { 34 return {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (height < childHeight.value) 66 if (height < childHeight.value)
67 height = childHeight.value; 67 height = childHeight.value;
68 loop = children.next(); 68 loop = children.next();
69 } 69 }
70 } 70 }
71 return super(height); // applies and provides our own min-height/max-height rules 71 return super(height); // applies and provides our own min-height/max-height rules
72 } 72 }
73 } 73 }
74 sky.registerLayoutManager('block', module.exports.BlockLayoutManager); 74 sky.registerLayoutManager('block', module.exports.BlockLayoutManager);
75 </script> 75 </script>
OLDNEW
« no previous file with comments | « sky/examples/README.md ('k') | sky/examples/style/hex-layout.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698