SVGHMI: add FlatButton with no active or inactive elements.
authorEdouard Tisserant <edouard@beremiz.fr>
Thu, 28 Mar 2024 12:04:14 +0100
changeset 3920 0d491fada1ad
parent 3919 0ce4b50d1182
child 3921 9bb17341aebb
SVGHMI: add FlatButton with no active or inactive elements.
svghmi/analyse_widget.xslt
svghmi/gen_index_xhtml.xslt
svghmi/widget_button.ysl2
--- a/svghmi/analyse_widget.xslt	Wed Mar 20 16:44:29 2024 +0100
+++ b/svghmi/analyse_widget.xslt	Thu Mar 28 12:04:14 2024 +0100
@@ -875,10 +875,6 @@
 </xsl:text>
       <xsl:text>
 </xsl:text>
-      <xsl:text>"active"+"inactive" labeled elements can be provided to show feedback when pressed
-</xsl:text>
-      <xsl:text>
-</xsl:text>
       <xsl:text>Exemples:
 </xsl:text>
       <xsl:text>
--- a/svghmi/gen_index_xhtml.xslt	Wed Mar 20 16:44:29 2024 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Thu Mar 28 12:04:14 2024 +0100
@@ -3305,6 +3305,34 @@
     <xsl:text>,
 </xsl:text>
   </xsl:template>
+  <xsl:template match="widget[@type='FlatButton']" mode="widget_class">
+    <xsl:text>class </xsl:text>
+    <xsl:text>FlatButtonWidget</xsl:text>
+    <xsl:text> extends Widget{
+</xsl:text>
+    <xsl:text>    frequency = 5;
+</xsl:text>
+    <xsl:variable name="fsm" select="exsl:node-set($_button_fsm)"/>
+    <xsl:call-template name="generated_button_class">
+      <xsl:with-param name="fsm" select="$fsm"/>
+    </xsl:call-template>
+    <xsl:text>}
+</xsl:text>
+  </xsl:template>
+  <xsl:template match="widget[@type='FlatButton']" mode="widget_defs">
+    <xsl:param name="hmi_element"/>
+    <xsl:variable name="disability">
+      <xsl:call-template name="defs_by_labels">
+        <xsl:with-param name="hmi_element" select="$hmi_element"/>
+        <xsl:with-param name="labels">
+          <xsl:text>/disabled</xsl:text>
+        </xsl:with-param>
+        <xsl:with-param name="mandatory" select="'no'"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:value-of select="$disability"/>
+    <xsl:variable name="has_disability" select="string-length($disability)&gt;0"/>
+  </xsl:template>
   <xsl:template match="widget[@type='PushButton']" mode="widget_class">
     <xsl:text>class </xsl:text>
     <xsl:text>PushButtonWidget</xsl:text>
@@ -7249,10 +7277,6 @@
 </xsl:text>
       <xsl:text>
 </xsl:text>
-      <xsl:text>"active"+"inactive" labeled elements can be provided to show feedback when pressed
-</xsl:text>
-      <xsl:text>
-</xsl:text>
       <xsl:text>Exemples:
 </xsl:text>
       <xsl:text>
--- a/svghmi/widget_button.ysl2	Wed Mar 20 16:44:29 2024 +0100
+++ b/svghmi/widget_button.ysl2	Thu Mar 28 12:04:14 2024 +0100
@@ -199,6 +199,16 @@
     activable();
 }
 
+// FlatButton is same as Button, but it has no active/inactive elements
+// and doesn't reflect current state
+widget_class("FlatButton"){
+    |     frequency = 5;
+    const "fsm","exsl:node-set($_button_fsm)";
+    call "generated_button_class" with "fsm", "$fsm";
+}
+
+widget_defs("FlatButton");
+
 widget_class("PushButton"){
     |     frequency = 20;
     const "fsm","exsl:node-set($_push_button_fsm)";