# HG changeset patch # User Edouard Tisserant # Date 1597510225 -7200 # Node ID 72ee99635db7f2287272cfaa0e6776e3cf33a266 # Parent d660b1b6bf4f3945ba2922a4dcb432ddce00d159 SVGHMI: HMI:JsonTable also recognize TextStyleList, but parsing of textContent is still not implemented and style is still not updated. diff -r d660b1b6bf4f -r 72ee99635db7 svghmi/widget_jsontable.ysl2 --- a/svghmi/widget_jsontable.ysl2 Sat Aug 15 18:46:35 2020 +0200 +++ b/svghmi/widget_jsontable.ysl2 Sat Aug 15 18:50:25 2020 +0200 @@ -37,18 +37,31 @@ error > JsonTable Widget can't contain element of type «local-name()». } + +const "hmi_textstylelists_descs", "$parsed_widgets/widget[@type = 'TextStyleList']"; +const "hmi_textstylelists", "$hmi_elements[@id = $hmi_textstylelists_descs/@id]"; + template "svg:use", mode="json_table_elt_render" { param "value_expr"; // cloned element must be part of a HMI:List const "targetid", "substring-after(@xlink:href,'#')"; const "from_list", "$hmi_lists[(@id | */@id) = $targetid]"; + const "from_textstylelist", "$hmi_textstylelists[(@id | */@id) = $targetid]"; - if "count($from_list) = 0" - error > Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or HMI:List item. Reference "«@xlink:href»" is not valid. - - | id("«@id»").setAttribute("xlink:href", - // obtain new target id from HMI:List widget - | "#"+hmi_widgets["«$from_list/@id»"].items[«$value_expr»]); + choose { + when "count($from_list) > 0" { + | id("«@id»").setAttribute("xlink:href", + // obtain new target id from HMI:List widget + | "#"+hmi_widgets["«$from_list/@id»"].items[«$value_expr»]); + } + when "count($from_textstylelist) > 0" { + | console.log("from_textsylelist","«@id»", "«$value_expr»", «$value_expr», + // obtain new style from HMI:TextStyleList widget + | hmi_widgets["«$from_textstylelist/@id»"].items[«$value_expr»]); + } + otherwise + warning > Clones (svg:use) in JsonTable Widget must point to a valid HMI:List or HMI:TextStyleList widget or item. Reference "«@xlink:href»" is not valid and will not be updated. + } } template "svg:text", mode="json_table_elt_render" { @@ -58,12 +71,12 @@ template "svg:*", mode="json_table_render" { param "objname"; - apply ".", mode="json_table_elt_render" with "value_expr" > «$objname»«@inkscape:label» + apply ".", mode="json_table_elt_render" with "value_expr" > «$objname»«substring-before(@inkscape:label, ' ')» } template "svg:g", mode="json_table_render" { param "objname"; - | let obj_«@id» = «$objname»«@inkscape:label»; + | let obj_«@id» = «$objname»«substring-before(@inkscape:label, ' ')»; apply "*[@inkscape:label]", mode="json_table_render" with "objname" > obj_«@id» } diff -r d660b1b6bf4f -r 72ee99635db7 svghmi/widget_list.ysl2 --- a/svghmi/widget_list.ysl2 Sat Aug 15 18:46:35 2020 +0200 +++ b/svghmi/widget_list.ysl2 Sat Aug 15 18:50:25 2020 +0200 @@ -1,6 +1,6 @@ // widget_list.ysl2 -template "widget[@type='List']", mode="widget_defs" { +template "widget[@type='List' or @type='TextStyleList']", mode="widget_defs" { param "hmi_element"; | items: { foreach "$hmi_element/*[@inkscape:label]" { diff -r d660b1b6bf4f -r 72ee99635db7 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Sat Aug 15 18:46:35 2020 +0200 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Sat Aug 15 18:50:25 2020 +0200 @@ -185,9 +185,9 @@ inkscape:current-layer="hmi0" showgrid="false" units="px" - inkscape:zoom="0.25" - inkscape:cx="840.93557" - inkscape:cy="117.51363" + inkscape:zoom="1.4142136" + inkscape:cx="1149.6204" + inkscape:cy="676.68024" inkscape:window-width="1800" inkscape:window-height="836" inkscape:window-x="0" @@ -2850,17 +2850,15 @@ height="100%" transform="matrix(0.7609336,0,0,0.7609336,199.15217,164.3798)" inkscape:label=".sides" /> - value + + inkscape:label="polygons" + transform="translate(-126,32)"> + id="g1311" + transform="translate(-126,32)"> + + value + value + value + value + + + + + + +