18 /* From Inkscape */ |
18 /* From Inkscape */ |
19 xmlns:dc="http://purl.org/dc/elements/1.1/" |
19 xmlns:dc="http://purl.org/dc/elements/1.1/" |
20 xmlns:cc="http://creativecommons.org/ns#" |
20 xmlns:cc="http://creativecommons.org/ns#" |
21 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
21 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
22 xmlns:svg="http://www.w3.org/2000/svg" |
22 xmlns:svg="http://www.w3.org/2000/svg" |
|
23 xmlns:xlink="http://www.w3.org/1999/xlink" |
23 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
24 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
24 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
25 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
25 xmlns:xhtml="http://www.w3.org/1999/xhtml" |
26 xmlns:xhtml="http://www.w3.org/1999/xhtml" |
26 |
27 |
27 /* Our namespace to invoke python code */ |
28 /* Our namespace to invoke python code */ |
200 } |
201 } |
201 } |
202 } |
202 } |
203 } |
203 |
204 |
204 func:result select="exsl:node-set($ast)" |
205 func:result select="exsl:node-set($ast)" |
|
206 } |
|
207 |
|
208 // returns all directly or indirectly refered elements |
|
209 func:function name="func:refered_elements" { |
|
210 param "elems"; |
|
211 const "descend", "$elems/descendant-or-self::svg:*"; |
|
212 const "clones", "$descend[self::svg:use]"; |
|
213 const "reals", "$descend[not(self::svg:use)]"; |
|
214 const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]"; |
|
215 choose { |
|
216 when "$originals" |
|
217 func:result select="$reals | func:refered_elements($originals)"; |
|
218 otherwise |
|
219 func:result select="$reals"; |
|
220 } |
205 } |
221 } |
206 |
222 |
207 function "scripts" |
223 function "scripts" |
208 { |
224 { |
209 | //(function(){ |
225 | //(function(){ |
274 const "page", "."; |
290 const "page", "."; |
275 const "p", "$hmi_geometry[@Id = $page/@id]"; |
291 const "p", "$hmi_geometry[@Id = $page/@id]"; |
276 const "page_ids","""$hmi_geometry[@Id != $page/@id and |
292 const "page_ids","""$hmi_geometry[@Id != $page/@id and |
277 @x >= $p/@x and @y >= $p/@y and |
293 @x >= $p/@x and @y >= $p/@y and |
278 @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id"""; |
294 @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id"""; |
279 const "page_elements", "$hmi_elements[@id = $page_ids]"; |
295 const "page_sub_ids", "func:refered_elements($page)[@id = $hmi_elements/@id]/@id"; |
|
296 const "all_page_ids","$page_ids | $page_sub_ids[not(. = $page_ids)]"; |
280 | "«$desc/arg[1]/@value»": { |
297 | "«$desc/arg[1]/@value»": { |
281 | id: "«@id»", |
298 | id: "«@id»", |
282 | bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»], |
299 | bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»], |
283 | widgets: [ |
300 | widgets: [ |
284 foreach "$page_ids" { |
301 foreach "$all_page_ids" { |
285 | hmi_widgets["«.»"]`if "position()!=last()" > ,` |
302 | hmi_widgets["«.»"]`if "position()!=last()" > ,` |
286 } |
303 } |
287 | ] |
304 | ] |
288 | }`if "position()!=last()" > ,` |
305 | }`if "position()!=last()" > ,` |
289 } |
306 } |
453 } |
470 } |
454 template "widget[@type='Change']", mode="widget_defs" { |
471 template "widget[@type='Change']", mode="widget_defs" { |
455 | frequency: 5, |
472 | frequency: 5, |
456 } |
473 } |
457 template "widget[@type='Jump']", mode="widget_defs" { |
474 template "widget[@type='Jump']", mode="widget_defs" { |
|
475 param "hmi_element"; |
|
476 | on_click: function() { |
|
477 | switch_page(this.args[0]); |
|
478 | }, |
458 | init: function() { |
479 | init: function() { |
459 | this.element.addEventListener( |
480 /* registering event this way doies not "click" through svg:use |
460 | "click", |
481 | this.element.onclick = evt => switch_page(this.args[0]); |
461 | evt => switch_page(this.args[0])); |
482 event must be registered by adding attribute to element instead |
|
483 TODO : generalize mouse event handling by global event capture + getElementsAtPoint() |
|
484 */ |
|
485 | this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click()"); |
462 | }, |
486 | }, |
463 } |
487 } |
464 } |
488 } |