SVGHMI: Exclude non-widget HMI:* labeled elements from hmi_widget. Namely : HMI:Page HMI:Lang and HMI:List have been excluded. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 10 May 2020 23:40:43 +0200
branchsvghmi
changeset 2955 64e603b84aa3
parent 2954 b5dccd0d99ac
child 2957 c0ea5015e46f
SVGHMI: Exclude non-widget HMI:* labeled elements from hmi_widget. Namely : HMI:Page HMI:Lang and HMI:List have been excluded.
svghmi/detachable_pages.ysl2
svghmi/gen_index_xhtml.xslt
svghmi/widgets_common.ysl2
--- a/svghmi/detachable_pages.ysl2	Sun May 10 17:01:09 2020 +0200
+++ b/svghmi/detachable_pages.ysl2	Sun May 10 23:40:43 2020 +0200
@@ -131,7 +131,7 @@
            ancestor-or-self::*[@id = $detachable_elements/@id]""";
 
     |   "«$desc/arg[1]/@value»": {
-    |     widget: hmi_widgets["«@id»"],
+    //|     widget: hmi_widgets["«@id»"],
     |     bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»],
     if "$desc/path/@value" {
         if "count($desc/path/@index)=0"
--- a/svghmi/gen_index_xhtml.xslt	Sun May 10 17:01:09 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt	Sun May 10 23:40:43 2020 +0200
@@ -472,10 +472,6 @@
     <xsl:value-of select="$desc/arg[1]/@value"/>
     <xsl:text>": {
 </xsl:text>
-    <xsl:text>    widget: hmi_widgets["</xsl:text>
-    <xsl:value-of select="@id"/>
-    <xsl:text>"],
-</xsl:text>
     <xsl:text>    bbox: [</xsl:text>
     <xsl:value-of select="$p/@x"/>
     <xsl:text>, </xsl:text>
@@ -781,7 +777,7 @@
     <xsl:text>
 </xsl:text>
   </xsl:template>
-  <xsl:template mode="hmi_elements" match="svg:*">
+  <xsl:template mode="hmi_widgets" match="svg:*">
     <xsl:variable name="widget" select="func:widget(@id)"/>
     <xsl:variable name="eltid" select="@id"/>
     <xsl:variable name="args">
@@ -974,6 +970,8 @@
     <xsl:text>}
 </xsl:text>
   </xsl:template>
+  <xsl:variable name="excluded_types" select="str:split('Page Lang List')"/>
+  <xsl:variable name="excluded_ids" select="$parsed_widgets/widget[not(@type = $excluded_types)]/@id"/>
   <preamble:hmi-elements/>
   <xsl:template match="preamble:hmi-elements">
     <xsl:text>
@@ -986,7 +984,7 @@
 </xsl:text>
     <xsl:text>var hmi_widgets = {
 </xsl:text>
-    <xsl:apply-templates mode="hmi_elements" select="$hmi_elements"/>
+    <xsl:apply-templates mode="hmi_widgets" select="$hmi_elements[@id = $excluded_ids]"/>
     <xsl:text>}
 </xsl:text>
     <xsl:text>
--- a/svghmi/widgets_common.ysl2	Sun May 10 17:01:09 2020 +0200
+++ b/svghmi/widgets_common.ysl2	Sun May 10 23:40:43 2020 +0200
@@ -21,7 +21,7 @@
     }
 };
 
-template "svg:*", mode="hmi_elements" {
+template "svg:*", mode="hmi_widgets" {
     const "widget", "func:widget(@id)";
     const "eltid","@id";
     const "args" foreach "$widget/arg" > "«@value»"`if "position()!=last()" > ,`
@@ -117,9 +117,12 @@
 }
 ||
 
+const "excluded_types", "str:split('Page Lang List')";
+const "excluded_ids","$parsed_widgets/widget[not(@type = $excluded_types)]/@id";
+
 emit "preamble:hmi-elements" {
     | var hmi_widgets = {
-    apply "$hmi_elements", mode="hmi_elements";
+    apply  "$hmi_elements[@id = $excluded_ids]", mode="hmi_widgets";
     | }
 }