# HG changeset patch # User Edouard Tisserant # Date 1584954998 -3600 # Node ID 27dd409fba1dc1d5ca5a80a0e561991647acf62c # Parent 8927ae8326b21b0363ff1a7eba89b5e2af1d725e SVGHMI: ForEach knows its own widgets diff -r 8927ae8326b2 -r 27dd409fba1d svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Fri Mar 20 10:46:15 2020 +0100 +++ b/svghmi/gen_index_xhtml.xslt Mon Mar 23 10:16:38 2020 +0100 @@ -680,51 +680,6 @@ - - - frequency: 2, - - dispatch: function(value) { - - // do something - - }, - - init: function() { - - - id(" - - ").addEventListener( - - "click", - - evt => {let new_val = " - - "); - - // do something with new_val - - }); - - - }, - - - - sub: function(off){ - - subscribe.call(this,off) - - }, - - unsub: function(){ - - unsubscribe.call(this) - - }, - - frequency: 5, @@ -745,6 +700,80 @@ }, + + + + frequency: 2, + + dispatch: function(value) { + + // do something + + }, + + init: function() { + + + id(" + + ").addEventListener( + + "click", + + evt => {let new_val = " + + "); + + // do something with new_val + + }); + + + }, + + widgets: [ + + + + [ /* + + */ + + + + hmi_widgets[" + + "] + + , + + + + + ] + + , + + + + + ], + + + + sub: function(off){ + + subscribe.call(this,off) + + }, + + unsub: function(){ + + unsubscribe.call(this) + + }, + + diff -r 8927ae8326b2 -r 27dd409fba1d svghmi/widget_foreach.ysl2 --- a/svghmi/widget_foreach.ysl2 Fri Mar 20 10:46:15 2020 +0100 +++ b/svghmi/widget_foreach.ysl2 Mon Mar 23 10:16:38 2020 +0100 @@ -1,6 +1,7 @@ template "widget[@type='ForEach']", mode="widget_defs" { param "hmi_element"; + const "widgets", "func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"; | frequency: 2, | dispatch: function(value) { | // do something @@ -14,15 +15,30 @@ | }); } | }, + + | widgets: [ + const "labels_regex","concat('^',arg[1]/@value,':[0-9]+')"; + foreach "$hmi_element/*[regexp:test(@inkscape:label, $labels_regex)]" { + | [ /* «@inkscape:label» */ + const "elt","."; + //foreach "$hmi_elements[ancestor::svg:*/@id = $_id]" { + foreach "func:refered_elements(.)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" { + | hmi_widgets["«@id»"]`if "position()!=last()" > ,` + } + | ]`if "position()!=last()" > ,` + } + | ], } template "widget[@type='ForEach']", mode="widget_subscribe"{ // param "hmi_element"; | sub: function(off){ - | subscribe.call(this,off) + | subscribe.call(this,off); + /* TODO */ | }, | unsub: function(){ - | unsubscribe.call(this) + | unsubscribe.call(this); + /* TODO */ | }, }