3 // overrides yslt's output function to set CDATA |
3 // overrides yslt's output function to set CDATA |
4 decl output(method, cdata-section-elements="xhtml:script"); |
4 decl output(method, cdata-section-elements="xhtml:script"); |
5 |
5 |
6 in xsl decl labels(*ptr, name="defs_by_labels") alias call-template { |
6 in xsl decl labels(*ptr, name="defs_by_labels") alias call-template { |
7 with "hmi_element", "$hmi_element"; |
7 with "hmi_element", "$hmi_element"; |
8 with "labels"{test *ptr}; |
8 with "labels"{text *ptr}; |
9 }; |
9 }; |
10 |
10 |
11 istylesheet |
11 istylesheet |
12 /* From Inkscape */ |
12 /* From Inkscape */ |
13 xmlns:dc="http://purl.org/dc/elements/1.1/" |
13 xmlns:dc="http://purl.org/dc/elements/1.1/" |
261 | var svg_root = document.getElementById("«$svg_root_id»"); |
274 | var svg_root = document.getElementById("«$svg_root_id»"); |
262 include text svghmi.js |
275 include text svghmi.js |
263 | //})(); |
276 | //})(); |
264 } |
277 } |
265 |
278 |
|
279 // template "*", mode="code_from_descs" { |
|
280 // || |
|
281 // { |
|
282 // var path, role, name, priv; |
|
283 // var id = "«@id»"; |
|
284 // || |
|
285 |
|
286 // /* if label is used, use it as default name */ |
|
287 // if "@inkscape:label" |
|
288 // |> name = "«@inkscape:label»"; |
|
289 |
|
290 // | /* -------------- */ |
|
291 |
|
292 // // this breaks indent, but fixing indent could break string literals |
|
293 // value "substring-after(svg:desc, $mark)"; |
|
294 // // nobody reads generated code anyhow... |
|
295 |
|
296 // || |
|
297 |
|
298 // /* -------------- */ |
|
299 // res.push({ |
|
300 // path:path, |
|
301 // role:role, |
|
302 // name:name, |
|
303 // priv:priv |
|
304 // }) |
|
305 // } |
|
306 // || |
|
307 // } |
|
308 |
|
309 |
266 /* |
310 /* |
267 Parses: |
|
268 "HMI:WidgetType:param1:param2@path1@path2" |
|
269 |
|
270 Into: |
|
271 widget type="WidgetType" { |
|
272 arg value="param1"; |
|
273 arg value="param2"; |
|
274 path value="path1"; |
|
275 path value="path2"; |
|
276 } |
|
277 */ |
|
278 |
|
279 template "*", mode="page_desc" { |
|
280 } |
|
281 |
|
282 template "*", mode="code_from_descs" { |
|
283 || |
|
284 { |
|
285 var path, role, name, priv; |
|
286 var id = "«@id»"; |
|
287 || |
|
288 |
|
289 /* if label is used, use it as default name */ |
|
290 if "@inkscape:label" |
|
291 |> name = "«@inkscape:label»"; |
|
292 |
|
293 | /* -------------- */ |
|
294 |
|
295 // this breaks indent, but fixing indent could break string literals |
|
296 value "substring-after(svg:desc, $mark)"; |
|
297 // nobody reads generated code anyhow... |
|
298 |
|
299 || |
|
300 |
|
301 /* -------------- */ |
|
302 res.push({ |
|
303 path:path, |
|
304 role:role, |
|
305 name:name, |
|
306 priv:priv |
|
307 }) |
|
308 } |
|
309 || |
|
310 } |
|
311 |
|
312 |
|
313 template "bbox", mode="testgeo"{ |
311 template "bbox", mode="testgeo"{ |
314 | ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h» |
312 | ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h» |
315 } |
313 } |
316 |
314 |
317 template "*", mode="testtree"{ |
315 template "*", mode="testtree"{ |
321 > \n |
319 > \n |
322 apply "*", mode="testtree" { |
320 apply "*", mode="testtree" { |
323 with "indent" value "concat($indent,'>')" |
321 with "indent" value "concat($indent,'>')" |
324 }; |
322 }; |
325 } |
323 } |
326 |
324 */ |
327 |
325 |
328 function "defs_by_labels" { |
326 function "defs_by_labels" { |
329 param "labels","''"; |
327 param "labels","''"; |
330 param "mandatory","'yes'"; |
328 param "mandatory","'yes'"; |
331 param "hmi_element"; |
329 param "hmi_element"; |
361 | dispatch: function(value) { |
359 | dispatch: function(value) { |
362 | this.value_elt.textContent = String(value); |
360 | this.value_elt.textContent = String(value); |
363 | let [min,max,totallength] = this.range; |
361 | let [min,max,totallength] = this.range; |
364 | let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
362 | let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min))); |
365 | let tip = this.range_elt.getPointAtLength(length); |
363 | let tip = this.range_elt.getPointAtLength(length); |
|
364 // TODO : deal with transformations between needle and range |
366 | this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
365 | this.needle_elt.setAttribute('d', "M "+this.origin.x+","+this.origin.y+" "+tip.x+","+tip.y); |
367 | }, |
366 | }, |
368 | origin: undefined, |
367 | origin: undefined, |
369 | range: undefined, |
368 | range: undefined, |
370 | init: function() { |
369 | init: function() { |