OLD | NEW |
1 SKY MODULE | 1 SKY MODULE |
2 <import src="sky:core" as="sky"/> | 2 <import src="sky:core" as="sky"/> |
3 <script> | 3 <script> |
4 // display: toolbar; | 4 // display: toolbar; |
5 // toolbar-spacing: <length> | 5 // toolbar-spacing: <length> |
6 // display: spring; // remaining space is split equally amongst the springs | 6 // display: spring; // remaining space is split equally amongst the springs |
7 // children are vertically centered, layout out left-to-right with toolbar-spac
ing space between them | 7 // children are vertically centered, layout out left-to-right with toolbar-spac
ing space between them |
8 // last child is hidden by default unless there's not enough room for the other
s, then it's shown last, right-aligned | 8 // last child is hidden by default unless there's not enough room for the other
s, then it's shown last, right-aligned |
9 module.exports.SpringLayoutManager = class SpringLayoutManager extends sky.Layo
utManager { } | 9 module.exports.SpringLayoutManager = class SpringLayoutManager extends sky.Layo
utManager { } |
10 sky.registerLayoutManager('spring', module.exports.SpringLayoutManager); | 10 sky.registerLayoutManager('spring', module.exports.SpringLayoutManager); |
11 sky.registerProperty({ | 11 sky.registerProperty({ |
12 name: 'toolbar-spacing', | 12 name: 'toolbar-spacing', |
13 type: sky.LengthStyleValueType, | 13 type: sky.PositiveLengthStyleValueType, |
14 inherits: true, | 14 inherits: true, |
15 initialValue: { value: 8, unit: 'px' }, | 15 initialValue: 8, |
16 needsLayout: true, | 16 needsLayout: true, |
17 }); | 17 }); |
18 module.exports.ToolbarLayoutManager = class ToolbarLayoutManager extends sky.La
youtManager { | 18 module.exports.ToolbarLayoutManager = class ToolbarLayoutManager extends sky.La
youtManager { |
19 constructor (styleNode) { | 19 constructor (styleNode) { |
20 super(styleNode); | 20 super(styleNode); |
21 this.showingOverflow = false; | 21 this.showingOverflow = false; |
22 this.firstSkippedChild = null; | 22 this.firstSkippedChild = null; |
23 this.overflowChild = null; | 23 this.overflowChild = null; |
24 } | 24 } |
25 function layout(width, height) { | 25 function layout(width, height) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 else | 124 else |
125 this.firstSkippedChild = this.overflowChild; | 125 this.firstSkippedChild = this.overflowChild; |
126 | 126 |
127 return { | 127 return { |
128 width: width, | 128 width: width, |
129 height: height, | 129 height: height, |
130 } | 130 } |
131 } | 131 } |
132 function getIntrinsicWidth() { | 132 function getIntrinsicWidth() { |
133 let width = this.node.getProperty('width'); | 133 let width = this.node.getProperty('width'); |
134 if (typeof height != 'number') { | 134 if (typeof width != 'number') { |
135 let spacing = this.node.getProperty('toolbar-spacing'); | 135 let spacing = this.node.getProperty('toolbar-spacing'); |
136 if (typeof spacing != 'number') | 136 if (typeof spacing != 'number') |
137 spacing = 0; | 137 spacing = 0; |
138 width = 0; | 138 width = 0; |
139 let children = this.walkChildren(); | 139 let children = this.walkChildren(); |
140 let loop = children.next(); | 140 let loop = children.next(); |
141 // we exclude the last child because at our ideal width we wouldn't need
it | 141 // we exclude the last child because at our ideal width we wouldn't need
it |
142 let last1 = null; // last one | 142 let last1 = null; // last one |
143 let last2 = null; // one before the last one | 143 let last2 = null; // one before the last one |
144 while (!loop.done) { | 144 while (!loop.done) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 canvas.clip(); | 199 canvas.clip(); |
200 child.paint(canvas); | 200 child.paint(canvas); |
201 } finally { | 201 } finally { |
202 canvas.restore(); | 202 canvas.restore(); |
203 } | 203 } |
204 } | 204 } |
205 } | 205 } |
206 } | 206 } |
207 sky.registerLayoutManager('toolbar', module.exports.ToolbarLayoutManager); | 207 sky.registerLayoutManager('toolbar', module.exports.ToolbarLayoutManager); |
208 </script> | 208 </script> |
OLD | NEW |