OLD | NEW |
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 if (width == null) | 11 if (width == null) |
11 width = this.getIntrinsicWidth().value; | 12 width = this.getIntrinsicWidth().value; |
12 let autoHeight = false; | 13 let autoHeight = false; |
13 if (height == null) { | 14 if (height == null) { |
14 height = 0; | 15 height = 0; |
15 autoHeight = true; | 16 autoHeight = true; |
16 } | 17 } |
17 this.assumeDimensions(width, height); | 18 this.assumeDimensions(width, height); |
18 let children = this.walkChildren(); | 19 let children = this.walkChildren(); |
19 let loop = children.next(); | 20 let loop = children.next(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 let children = this.walkChildren(); | 61 let children = this.walkChildren(); |
61 let loop = children.next(); | 62 let loop = children.next(); |
62 while (!loop.done) { | 63 while (!loop.done) { |
63 let child = loop.value; | 64 let child = loop.value; |
64 let childHeight = child.layoutManager.getIntrinsicHeight(); | 65 let childHeight = child.layoutManager.getIntrinsicHeight(); |
65 if (height < childHeight.value) | 66 if (height < childHeight.value) |
66 height = childHeight.value; | 67 height = childHeight.value; |
67 loop = children.next(); | 68 loop = children.next(); |
68 } | 69 } |
69 } | 70 } |
70 return super(height); // applies and provides our own min-width/max-width r
ules | 71 return super(height); // applies and provides our own min-height/max-height
rules |
71 } | 72 } |
72 } | 73 } |
73 sky.registerLayoutManager('block', module.exports.BlockLayoutManager); | 74 sky.registerLayoutManager('block', module.exports.BlockLayoutManager); |
74 </script> | 75 </script> |
OLD | NEW |