--- a/svghmi/gen_index_xhtml.xslt Tue Apr 14 10:56:45 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Tue Apr 14 12:07:08 2020 +0200
@@ -822,7 +822,7 @@
<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>text box button</xsl:text> <xsl:text> dispatch: function(value) {
@@ -833,9 +833,9 @@
<xsl:text> init: function() {
- <xsl:text> this.element.setAttribute("onclick", "hmi_widgets['</xsl:text>
+ <xsl:text> this.button_elt.setAttribute("onclick", "hmi_widgets['</xsl:text> <xsl:value-of select="$hmi_element/@id"/>
- <xsl:text>'].on_click()");
+ <xsl:text>'].on_button_click()"); <xsl:text> this.text_bbox = this.text_elt.getBBox()
@@ -845,11 +845,7 @@
<xsl:text> tmargin = this.text_bbox.y - this.box_bbox.y;
- <xsl:text> rmargin = this.box_bbox.width - this.text_bbox.width - lmargin;
- <xsl:text> bmargin = this.box_bbox.height - this.text_bbox.height - tmargin;
- <xsl:text> this.margins = [lmargin, tmargin, rmargin, bmargin].map(x => Math.max(x,0));
+ <xsl:text> this.margins = [lmargin, tmargin].map(x => Math.max(x,0)); <xsl:text> this.content = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
@@ -867,21 +863,17 @@
<xsl:text> on_selection_click: function(selection) {
+ <xsl:text> console.log("selected "+selection); + <xsl:text> this.close(); <xsl:text> this.set_selection(selection);
- <xsl:text> on_click: function() {
- <xsl:text> if(this.opened){
- <xsl:text> //this.close();
- <xsl:text> this.open();
+ <xsl:text> on_button_click: function() { + <xsl:text> this.open(); @@ -977,6 +969,8 @@
<xsl:text> this.reset_box();
+ <xsl:text> this.element.appendChild(this.button_elt); <xsl:text> this.opened = false;
@@ -1107,6 +1101,8 @@
<xsl:text> this.adjust_box_to_text();
+ <xsl:text> this.element.removeChild(this.button_elt); <xsl:text> /* TODO disable interaction with background */
<xsl:text> this.opened = true;
@@ -1149,7 +1145,7 @@
<xsl:text> adjust_box_to_text: function(){
- <xsl:text> let [lmargin, tmargin, rmargin, bmargin] = this.margins;
+ <xsl:text> let [lmargin, tmargin] = this.margins; <xsl:text> let m = this.text_elt.getBBox();
@@ -1159,9 +1155,9 @@
<xsl:text> b.y.baseVal.value = m.y - tmargin;
- <xsl:text> b.width.baseVal.value = lmargin + m.width + rmargin;
- <xsl:text> b.height.baseVal.value = tmargin + m.height + bmargin;
+ <xsl:text> b.width.baseVal.value = 2 * lmargin + m.width; + <xsl:text> b.height.baseVal.value = 2 * tmargin + m.height; --- a/svghmi/widget_dropdown.ysl2 Tue Apr 14 10:56:45 2020 +0200
+++ b/svghmi/widget_dropdown.ysl2 Tue Apr 14 12:07:08 2020 +0200
@@ -2,20 +2,18 @@
template "widget[@type='DropDown']", mode="widget_defs" {
+ labels("text box button"); dispatch: function(value) {
if(!this.opened) this.set_selection(value);
- this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click()");
+ this.button_elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_button_click()"); this.text_bbox = this.text_elt.getBBox()
this.box_bbox = this.box_elt.getBBox()
lmargin = this.text_bbox.x - this.box_bbox.x;
tmargin = this.text_bbox.y - this.box_bbox.y;
- rmargin = this.box_bbox.width - this.text_bbox.width - lmargin;
- bmargin = this.box_bbox.height - this.text_bbox.height - tmargin;
- this.margins = [lmargin, tmargin, rmargin, bmargin].map(x => Math.max(x,0));
+ this.margins = [lmargin, tmargin].map(x => Math.max(x,0)); this.content = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen"];
//this.content = ["one", "two", "three", "four", "5", "6"];
@@ -24,14 +22,12 @@
on_selection_click: function(selection) {
+ console.log("selected "+selection); this.set_selection(selection);
+ on_button_click: function() { on_backward_click:function(){
@@ -79,6 +75,7 @@
+ this.element.appendChild(this.button_elt); set_complete_text: function(){
@@ -140,6 +137,7 @@
this.adjust_box_to_text();
+ this.element.removeChild(this.button_elt); /* TODO disable interaction with background */
@@ -161,13 +159,13 @@
b.height.baseVal.value = m.height;
adjust_box_to_text: function(){
- let [lmargin, tmargin, rmargin, bmargin] = this.margins;
+ let [lmargin, tmargin] = this.margins; let m = this.text_elt.getBBox();
b.x.baseVal.value = m.x - lmargin;
b.y.baseVal.value = m.y - tmargin;
- b.width.baseVal.value = lmargin + m.width + rmargin;
- b.height.baseVal.value = tmargin + m.height + bmargin;
+ b.width.baseVal.value = 2 * lmargin + m.width; + b.height.baseVal.value = 2 * tmargin + m.height; --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Apr 14 10:56:45 2020 +0200
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Apr 14 12:07:08 2020 +0200
@@ -16,7 +16,7 @@
sodipodi:docname="svghmi.svg"
- inkscape:version="0.92.3 (2405546, 2018-03-11)">
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"> @@ -124,17 +124,17 @@
inkscape:document-units="px"
- inkscape:current-layer="g2432"
+ inkscape:current-layer="g14237" inkscape:zoom="0.35355339"
- inkscape:window-width="1800"
- inkscape:window-height="836"
- inkscape:window-maximized="1"
+ inkscape:window-width="2112" + inkscape:window-height="1367" + inkscape:window-x="2960" + inkscape:window-maximized="0" inkscape:guide-bbox="true" />
@@ -1124,7 +1124,7 @@
- transform="matrix(0.5,0,0,0.5,828.32451,303.15679)"
+ transform="matrix(0.5,0,0,0.5,126.87458,546.40152)" inkscape:label="HMI:Input@/PUMP0/STRIN"
@@ -2492,33 +2492,52 @@
- inkscape:label="HMI:DropDown:Primes">
+ inkscape:label="HMI:DropDown:Primes" + transform="translate(0,-640)"> 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"
- 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"
+ 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:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#d42aff;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"
+ style="text-align:start;text-anchor:start;fill:#d42aff;stroke-width:1px"
- sodipodi:role="line">sel_0</tspan></text>
+ id="tspan421">sel_0</tspan></text> + style="opacity:1;vector-effect:none;fill:#a7a5a6;fill-opacity:1;stroke:none;stroke-width:0.35277769;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + sodipodi:r1="43.683521" + sodipodi:r2="21.841761" + sodipodi:arg1="1.5707963" + sodipodi:arg2="2.6179939" + inkscape:flatsided="false" + inkscape:randomized="0" + d="m 1200.5,1018.6835 -18.9155,-32.76262 -18.9155,-32.76264 37.831,0 37.831,0 -18.9155,32.76264 z" + inkscape:transform-center-y="10.92088" + inkscape:label="button" /> - inkscape:label="HMI:ScrollbarTemplate">
+ inkscape:label="HMI:ScrollbarTemplate" + transform="translate(0,-640)"> @@ -2556,38 +2575,38 @@
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
sodipodi:role="line">one</tspan><tspan
id="tspan14257">two</tspan><tspan
id="tspan14259">three</tspan><tspan
id="tspan14261">five</tspan><tspan
id="tspan14263">seven</tspan><tspan
id="tspan14265">eleven</tspan></text>