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

Side by Side Diff: sky/examples/style/toolbar-layout.sky

Issue 732243002: Specs: Define when needsLayout is reset (also, some unrelated markdown fixes) (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/style/hex-layout.sky ('k') | sky/specs/style.md » ('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 <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.PositiveLengthStyleValueType, 13 type: sky.PositiveLengthStyleValueType,
14 inherits: true, 14 inherits: true,
15 initialValue: 8, 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) {
26 this.markAsLaidOut();
26 let children = null; 27 let children = null;
27 let loop = null; 28 let loop = null;
28 if (height == null) 29 if (height == null)
29 height = this.getIntrinsicHeight().value; 30 height = this.getIntrinsicHeight().value;
30 if (width == null) 31 if (width == null)
31 this.assumeDimensions(0, height); 32 this.assumeDimensions(0, height);
32 else 33 else
33 this.assumeDimensions(width, height); 34 this.assumeDimensions(width, height);
34 let spacing = this.node.getProperty('toolbar-spacing'); 35 let spacing = this.node.getProperty('toolbar-spacing');
35 if (typeof spacing != 'number') 36 if (typeof spacing != 'number')
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 canvas.clip(); 201 canvas.clip();
201 child.paint(canvas); 202 child.paint(canvas);
202 } finally { 203 } finally {
203 canvas.restore(); 204 canvas.restore();
204 } 205 }
205 } 206 }
206 } 207 }
207 } 208 }
208 sky.registerLayoutManager('toolbar', module.exports.ToolbarLayoutManager); 209 sky.registerLayoutManager('toolbar', module.exports.ToolbarLayoutManager);
209 </script> 210 </script>
OLDNEW
« no previous file with comments | « sky/examples/style/hex-layout.sky ('k') | sky/specs/style.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698