--- 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" {
// cloned element must be part of a HMI:List
const "targetid", "substring-after(@xlink:href,'#')";
const "from_list", "$hmi_lists[(@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.
+ const "from_textstylelist", "$hmi_textstylelists[(@id | */@id) = $targetid]"; - | id("«@id»").setAttribute("xlink:href",
- // obtain new target id from HMI:List widget
- | "#"+hmi_widgets["«$from_list/@id»"].items[«$value_expr»]);
+ 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»]); + 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" {
- 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" {
- | 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»
--- 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 @@
-template "widget[@type='List']", mode="widget_defs" {
+template "widget[@type='List' or @type='TextStyleList']", mode="widget_defs" { foreach "$hmi_element/*[@inkscape:label]" {
--- 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"
- 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"
@@ -2850,17 +2850,15 @@
transform="matrix(0.7609336,0,0,0.7609336,199.15217,164.3798)"
inkscape:label=".sides" />
- style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none"
- inkscape:label=".name"><tspan
- y="56.106419">value</tspan></text>
+ transform="matrix(2,0,0,2,-474.04606,349.02524)" + inkscape:label=".textstyle content=.name" /> @@ -2893,7 +2891,8 @@
- inkscape:label="polygons">
+ inkscape:label="polygons" + transform="translate(-126,32)"> inkscape:transform-center-y="2.9995242"
inkscape:transform-center-x="0.14620371"
@@ -3005,7 +3004,8 @@
inkscape:label="HMI:List:polygons"
+ transform="translate(-126,32)"> @@ -5729,4 +5729,98 @@
inkscape:label="HMI:VarInit:"a page string"@.piff" />
+ inkscape:label="textstyles" + transform="translate(-136,-6.0000001)"> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.5" + xml:space="preserve"><tspan + style="stroke-width:0.5">value</tspan></text> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5" + inkscape:label="ack"><tspan + style="fill:#000000;stroke-width:0.5" + y="-191.54395">value</tspan></text> + inkscape:label="active" + style="font-style:normal;font-weight:normal;font-size:20px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#00ff00;fill-opacity:1;stroke:none;stroke-width:0.5" + xml:space="preserve"><tspan + style="fill:#00ff00;stroke-width:0.5">value</tspan></text> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#999999;fill-opacity:1;stroke:none;stroke-width:0.5" + inkscape:label="disabled"><tspan + style="fill:#999999;stroke-width:0.5" + y="-231.54395">value</tspan></text> + inkscape:label="HMI:StyleList:textstyles" + transform="translate(440,40)"> + transform="translate(-573,60.999998)" + inkscape:label=""active"" /> + transform="translate(-573,40.999998)" + inkscape:label=""ack"" /> + xlink:href="#text1382-7" + transform="translate(-573,20.999998)" + inkscape:label=""alarm"" /> + transform="translate(-573,80.999998)" + inkscape:label=""disabled"" />