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

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

Issue 845053002: Specs and Docs: minor updates to fix mistakes I found when proof-reading (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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 | « no previous file | sky/examples/style/sky-core-styles.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 #!mojo mojo:sky 1 #!mojo mojo:sky
2 <import src="sky:core" as="sky"/> 2 <import src="sky:core" as="sky"/>
3 <script> 3 <script>
4 class BeehiveLayoutManager extends sky.LayoutManager { 4 class BeehiveLayoutManager extends sky.LayoutManager {
5 function layout(width, height) { 5 function layout(width, height) {
6 this.markAsLaidOut(); 6 this.markAsLaidOut();
7 if (width == null) 7 if (width == null)
8 width = this.getIntrinsicWidth().value; 8 width = this.getIntrinsicWidth().value;
9 let autoHeight = false; 9 let autoHeight = false;
10 if (height == null) { 10 if (height == null) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 while (!loop.done) { 108 while (!loop.done) {
109 let child = loop.value; 109 let child = loop.value;
110 if (this.inHex(child.x, child.y, child.width, child.height, x, y)) 110 if (this.inHex(child.x, child.y, child.width, child.height, x, y))
111 return child.layoutManager.hitTest(x-child.x, y-child.y); 111 return child.layoutManager.hitTest(x-child.x, y-child.y);
112 loop = children.next(); 112 loop = children.next();
113 } 113 }
114 return this.node; 114 return this.node;
115 } 115 }
116 } 116 }
117 sky.registerLayoutManager('beehive', BeehiveLayoutManager); 117 sky.registerLayoutManager('beehive', BeehiveLayoutManager);
118 let BeehiveCountStyleValueType = new StyleValueType(); 118 let BeehiveCountStyleGrammar = new StyleGrammar();
119 BeehiveCountStyleValueType.addParser((tokens) => { 119 BeehiveCountStyleGrammar.addParser((tokens) => {
120 let token = tokens.next(); 120 let token = tokens.next();
121 if (token.done) 121 if (token.done)
122 throw new Error(); 122 throw new Error();
123 if (token.value.kind != 'number') 123 if (token.value.kind != 'number')
124 throw new Error(); 124 throw new Error();
125 if (token.value.value <= 0) 125 if (token.value.value <= 0)
126 throw new Error(); 126 throw new Error();
127 if (Math.trunc(token.value.value) != token.value.value) // is integer 127 if (Math.trunc(token.value.value) != token.value.value) // is integer
128 throw new Error(); 128 throw new Error();
129 return { 129 return new NumericStyleValue(token.value.value);
130 value: token.value.value;
131 }
132 }); 130 });
133 sky.registerProperty({ 131 sky.registerProperty({
134 name: 'beehive-count', 132 name: 'beehive-count',
135 type: BeehiveCountStyleValueType, 133 type: BeehiveCountStyleGrammar,
136 inherits: true, 134 inherits: true,
137 initialValue: 5, 135 initialValue: 5,
138 needsLayout: true, 136 needsLayout: true,
139 }); 137 });
140 </script> 138 </script>
141 <style> 139 <style>
142 div { display: beehive; beehive-count: 3; } 140 div { display: beehive; beehive-count: 3; }
143 </style> 141 </style>
144 <div> 142 <div>
145 <t>Hello</t> 143 <t>Hello</t>
146 <t>World</t> 144 <t>World</t>
147 <t>How</t> 145 <t>How</t>
148 <t>Are</t> 146 <t>Are</t>
149 <t>You</t> 147 <t>You</t>
150 <t>Today?</t> 148 <t>Today?</t>
151 </div> 149 </div>
OLDNEW
« no previous file with comments | « no previous file | sky/examples/style/sky-core-styles.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698