SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Fri, 17 Jul 2020 12:19:53 +0200
branchsvghmi
changeset 2995 7769e7c7f925
parent 2994 b6a9ef7f7e43
child 2996 14635b09d329
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
svghmi/inline_svg.ysl2
--- a/svghmi/inline_svg.ysl2	Tue Jul 14 22:05:47 2020 +0200
+++ b/svghmi/inline_svg.ysl2	Fri Jul 17 12:19:53 2020 +0200
@@ -47,12 +47,17 @@
 // For now, clone unlinkink applies to descendants of all widget except HMI:Page
 // TODO: narrow application of clone unlinking to active elements,
 //       while keeping static decoration cloned
-const "to_unlink", "$hmi_elements[not(@id = $hmi_pages)]/descendant-or-self::svg:use";
+const "hmi_lists_descs", "$parsed_widgets/widget[@type = 'List']";
+const "hmi_lists", "$hmi_elements[@id = $hmi_lists_descs/@id]";
+const "targets_not_to_unlink", "$hmi_elements[@id = $hmi_lists/@id]/descendant::svg:*";
+const "to_unlink", "$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use";
 svgtmpl "svg:use", mode="inline_svg"
 {
+    const "targetid","substring-after(@xlink:href,'#')";
     choose {
-        when "@id = $to_unlink/@id"
-            call "unlink_clone";
+        when "@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)" {
+            call "unlink_clone" with "targetid", "$targetid";
+        }
         otherwise
             xsl:copy apply "@* | node()", mode="inline_svg";
     }
@@ -76,7 +81,7 @@
 const "merge_use_attrs","exsl:node-set($_merge_use_attrs)";
 
 svgfunc "unlink_clone"{
-    const "targetid","substring-after(@xlink:href,'#')";
+    param "targetid";
     const "target", "//svg:*[@id = $targetid]";
     g{
         choose {
@@ -158,4 +163,8 @@
     foreach "$to_unlink"{
         | «@id»
     }
+    | Not to unlink :
+    foreach "$targets_not_to_unlink"{
+        | «@id»
+    }
 }