--- a/svghmi/gen_index_xhtml.xslt Tue Apr 07 10:01:23 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Thu Apr 09 09:52:34 2020 +0200
@@ -817,6 +817,55 @@
+ <xsl:template mode="widget_defs" match="widget[@type='DropDown']"> + <xsl:param name="hmi_element"/> + <xsl:call-template name="defs_by_labels"> + <xsl:with-param name="hmi_element" select="$hmi_element"/> + <xsl:with-param name="labels"> + <xsl:text>text box</xsl:text> + <xsl:text> dispatch: function(value) { + <xsl:text> this.text_elt.textContent = String(value); + <xsl:text> init: function() { + <xsl:text> this.element.setAttribute("onclick", "hmi_widgets['</xsl:text> + <xsl:value-of select="$hmi_element/@id"/> + <xsl:text>'].on_click()"); + <xsl:variable name="box_elt" select="$hmi_element/*[@inkscape:label='box'][1]"/> + <xsl:variable name="g" select="$geometry[@Id = $box_elt/@id]"/> + <xsl:text> original_box: [</xsl:text> + <xsl:value-of select="$g/@x"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$g/@y"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$g/@w"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$g/@h"/> + <xsl:text> on_click: function() { + <xsl:text> let [x,y,w,h] = page_desc[current_visible_page].bbox; + <xsl:text> let p = new DOMPoint(this.box_elt.x.baseVal.value, this.box_elt.y.baseVal.value); + <xsl:text> let k = DOMMatrix.fromMatrix(this.box_elt.getCTM()); + <xsl:text> let l = DOMMatrix.fromMatrix(this.box_elt.getScreenCTM()); + <xsl:text> console.log(p, k.transformPoint(p), l.transformPoint(p)); <xsl:template mode="widget_defs" match="widget[@type='ForEach']">
<xsl:param name="hmi_element"/>
<xsl:variable name="widgets" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"/>
@@ -2157,16 +2206,10 @@
<xsl:text> let old_val = cache[index]
- <xsl:text> console.log("apply", index, new_val);
- <xsl:text> if(new_val != undefined && old_val != new_val){
- <xsl:text> console.log("sending", new_val);
+ <xsl:text> if(new_val != undefined && old_val != new_val) <xsl:text> send_hmi_value(index, new_val);
<xsl:text> return new_val;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/widget_dropdown.ysl2 Thu Apr 09 09:52:34 2020 +0200
@@ -0,0 +1,24 @@
+template "widget[@type='DropDown']", mode="widget_defs" { + | dispatch: function(value) { + /* TODO : get selection text by index */ + | this.text_elt.textContent = String(value); + | this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click()"); + const "box_elt","$hmi_element/*[@inkscape:label='box'][1]"; + const "g", "$geometry[@Id = $box_elt/@id]"; + | original_box: [«$g/@x», «$g/@y», «$g/@w», «$g/@h»], + | on_click: function() { + | let [x,y,w,h] = page_desc[current_visible_page].bbox; + | let p = new DOMPoint(this.box_elt.x.baseVal.value, this.box_elt.y.baseVal.value); + | let k = DOMMatrix.fromMatrix(this.box_elt.getCTM()); + | let l = DOMMatrix.fromMatrix(this.box_elt.getScreenCTM()); + | console.log(p, k.transformPoint(p), l.transformPoint(p)); --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Apr 07 10:01:23 2020 +0200
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Thu Apr 09 09:52:34 2020 +0200
@@ -2490,4 +2490,108 @@
sodipodi:role="line">information</tspan></text>
+ inkscape:label="HMI:DropDown:Primes"> + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#53676c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + inkscape:label="box" /> + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="text"><tspan + style="stroke-width:1px" + sodipodi:role="line">sel_0</tspan></text> + inkscape:label="HMI:ScrollbarTemplate"> + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#010000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + inkscape:label="border" /> + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + inkscape:label="cursor" /> + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + d="m 1706.2165,965.67108 17.0639,17.37276 h -34.1278 z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 1706.2165,1323.0438 17.0639,-17.3727 h -34.1278 z" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" + inkscape:label="down" /> + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="HMI:List:Primes"><tspan + style="stroke-width:1px" + sodipodi:role="line">one</tspan><tspan + style="stroke-width:1px" + id="tspan14257">two</tspan><tspan + style="stroke-width:1px" + id="tspan14259">three</tspan><tspan + style="stroke-width:1px" + id="tspan14261">five</tspan><tspan + style="stroke-width:1px" + id="tspan14263">seven</tspan><tspan + style="stroke-width:1px" + id="tspan14265">eleven</tspan></text> + inkscape:label="HMI:List:HoodNames:ForEach:HOOD:NAME@/" />