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 if (width == null) | 10 if (width == null) |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 if (autoHeight) | 31 if (autoHeight) |
32 height = y; | 32 height = y; |
33 return { | 33 return { |
34 width: width, | 34 width: width, |
35 height: height, | 35 height: height, |
36 } | 36 } |
37 } | 37 } |
38 function getIntrinsicWidth() { | 38 function getIntrinsicWidth() { |
39 let width = this.node.getProperty('width'); | 39 let width = this.node.getProperty('width'); |
40 if (typeof height != 'number') { | 40 if (typeof width != 'number') { |
41 // e.g. width: auto | 41 // e.g. width: auto |
42 width = 0; | 42 width = 0; |
43 let children = this.walkChildren(); | 43 let children = this.walkChildren(); |
44 let loop = children.next(); | 44 let loop = children.next(); |
45 while (!loop.done) { | 45 while (!loop.done) { |
46 let child = loop.value; | 46 let child = loop.value; |
47 let childWidth = child.layoutManager.getIntrinsicWidth(); | 47 let childWidth = child.layoutManager.getIntrinsicWidth(); |
48 if (width < childWidth.value) | 48 if (width < childWidth.value) |
49 width = childWidth.value; | 49 width = childWidth.value; |
50 loop = children.next(); | 50 loop = children.next(); |
(...skipping 14 matching lines...) Expand all Loading... |
65 if (height < childHeight.value) | 65 if (height < childHeight.value) |
66 height = childHeight.value; | 66 height = childHeight.value; |
67 loop = children.next(); | 67 loop = children.next(); |
68 } | 68 } |
69 } | 69 } |
70 return super(height); // applies and provides our own min-width/max-width r
ules | 70 return super(height); // applies and provides our own min-width/max-width r
ules |
71 } | 71 } |
72 } | 72 } |
73 sky.registerLayoutManager('block', module.exports.BlockLayoutManager); | 73 sky.registerLayoutManager('block', module.exports.BlockLayoutManager); |
74 </script> | 74 </script> |
OLD | NEW |