# HG changeset patch
# User Edouard Tisserant
# Date 1611656062 -3600
# Node ID e704b04875152e1cda3db3d291f90d7d0536f04a
# Parent f058542d0caaa55fcc3f558ac573fb6772dc149f
SVGHMI : removed support for changing keyboard position and showing at user defined location. Feature was problematic in many respect.
diff -r f058542d0caa -r e704b0487515 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Mon Jan 25 14:02:08 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt Tue Jan 26 11:14:22 2021 +0100
@@ -264,9 +264,7 @@
"
- [
-
- ]
+
@@ -387,12 +385,16 @@
Home
- No Home page defined!
+
+ No Home page defined!
+
- No page defined!
+
+ No page defined!
+
@@ -511,6 +513,13 @@
+
+
+ HMI:Page
+
+ is nested in another HMI:Page
+
+
@@ -1549,7 +1558,7 @@
-
+
@@ -4219,16 +4228,6 @@
-
-
-
-
- key_pos
-
-
-
-
-
@@ -4280,27 +4279,11 @@
init: function() {
- this.edit_elt.onclick = () => edit_value(
-
- "
+ this.edit_elt.onclick = () => edit_value("
", "
- ",
-
- this, this.last_val,
-
-
-
- this.key_pos_elt.getBBox()
-
-
-
- undefined
-
-
-
- );
+ ", this, this.last_val);
@@ -4983,154 +4966,6 @@
class KeypadWidget extends Widget{
- moving = undefined;
-
- click = undefined;
-
- offset = undefined;
-
-
-
- on_position_click(evt) {
-
- this.moving = true;
-
-
-
- // chatch window events
-
- window.addEventListener("touchmove", this.bound_on_drag, true);
-
- window.addEventListener("mousemove", this.bound_on_drag, true);
-
-
-
- window.addEventListener("mouseup", this.bound_on_release, true)
-
- window.addEventListener("touchend", this.bound_on_release, true);
-
- window.addEventListener("touchcancel", this.bound_on_release, true);
-
-
-
- // get click position offset from widget x,y and save it to variable
-
- var keypad_borders = this.position_elt.getBoundingClientRect();
-
- var clickX = undefined;
-
- var clickY = undefined;
-
- if (evt.type == "touchstart"){
-
- clickX = Math.ceil(evt.touches[0].clientX);
-
- clickY = Math.ceil(evt.touches[0].clientY);
-
- }
-
- else{
-
- clickX = evt.pageX;
-
- clickY = evt.pageY;
-
- }
-
- this.offset=[clickX-keypad_borders.left,clickY-keypad_borders.top]
-
- }
-
-
-
- on_release(evt) {
-
- //relase binds
-
- window.removeEventListener("touchmove", this.bound_on_drag, true);
-
- window.removeEventListener("mousemove", this.bound_on_drag, true);
-
-
-
- window.removeEventListener("mouseup", this.bound_on_release, true)
-
- window.removeEventListener("touchend", this.bound_on_release, true);
-
- window.removeEventListener("touchcancel", this.bound_on_release, true);
-
-
-
- if(this.moving)
-
- this.moving = false;
-
- }
-
-
-
- on_drag(evt) {
-
- if(this.moving)
-
- //get mouse coordinates
-
- var clickX = undefined;
-
- var clickY = undefined;
-
- if (evt.type == "touchmove"){
-
- clickX = Math.ceil(evt.touches[0].clientX);
-
- clickY = Math.ceil(evt.touches[0].clientY);
-
- }
-
- else{
-
- clickX = evt.pageX;
-
- clickY = evt.pageY;
-
- }
-
- this.click = [clickX,clickY]
-
-
-
- //requeset redraw
-
- this.request_animate();
-
- }
-
-
-
- animate(){
-
- //get keyboard pos in html
-
- let [eltid, tmpgrp] = current_modal;
-
- let [xcoord,ycoord] = this.coordinates;
-
- let [clickX,clickY] = this.click;
-
- let [xdest,ydest,svgWidth,svgHeight] = page_desc[current_visible_page].bbox;
-
-
-
- //translate keyboard position
-
- let mouseX = ((clickX-this.offset[0])/window.innerWidth)*svgWidth;
-
- let mouseY = ((clickY-this.offset[1])/window.innerHeight)*svgHeight;
-
- tmpgrp.setAttribute("transform","translate("+String(xdest-xcoord+mouseX)+","+String(ydest-ycoord+mouseY)+")");
-
- }
-
on_key_click(symbols) {
@@ -5333,7 +5168,7 @@
- Sign Space NumDot position
+ Sign Space NumDot
@@ -5371,20 +5206,6 @@
_click()");
- if(this.position_elt){
-
- this.bound_on_release = this.on_release.bind(this);
-
- this.bound_on_drag = this.on_drag.bind(this);
-
-
-
- this.position_elt.setAttribute("onmousedown", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)");
-
- this.position_elt.setAttribute("ontouchstart", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)");
-
- }
-
},
@@ -7376,7 +7197,7 @@
const localtypes = {"PAGE_LOCAL":null, "HMI_LOCAL":null}
- function edit_value(path, valuetype, callback, initial, size) {
+ function edit_value(path, valuetype, callback, initial) {
if(valuetype in localtypes){
@@ -7390,7 +7211,7 @@
let widget = hmi_widgets[keypadid];
- widget.start_edit(path, valuetype, callback, initial, size);
+ widget.start_edit(path, valuetype, callback, initial);
};
@@ -7400,7 +7221,7 @@
- function show_modal(size) {
+ function show_modal() {
let [element, parent] = detachable_elements[this.element.id];
@@ -7414,17 +7235,7 @@
let [xdest,ydest] = page_desc[current_visible_page].bbox;
- if (typeof size === 'undefined'){
-
- tmpgrpattr.value = "translate("+String(xdest-xcoord)+","+String(ydest-ycoord)+")";
-
- }
-
- else{
-
- tmpgrpattr.value = "translate("+String(xdest-xcoord+size.x)+","+String(ydest-ycoord+size.y)+")";
-
- }
+ tmpgrpattr.value = "translate("+String(xdest-xcoord)+","+String(ydest-ycoord)+")";
diff -r f058542d0caa -r e704b0487515 svghmi/svghmi.js
--- a/svghmi/svghmi.js Mon Jan 25 14:02:08 2021 +0100
+++ b/svghmi/svghmi.js Tue Jan 26 11:14:22 2021 +0100
@@ -427,31 +427,26 @@
const xmlns = "http://www.w3.org/2000/svg";
var edit_callback;
const localtypes = {"PAGE_LOCAL":null, "HMI_LOCAL":null}
-function edit_value(path, valuetype, callback, initial, size) {
+function edit_value(path, valuetype, callback, initial) {
if(valuetype in localtypes){
valuetype = (typeof initial) == "number" ? "HMI_REAL" : "HMI_STRING";
}
let [keypadid, xcoord, ycoord] = keypads[valuetype];
edit_callback = callback;
let widget = hmi_widgets[keypadid];
- widget.start_edit(path, valuetype, callback, initial, size);
+ widget.start_edit(path, valuetype, callback, initial);
};
var current_modal; /* TODO stack ?*/
-function show_modal(size) {
+function show_modal() {
let [element, parent] = detachable_elements[this.element.id];
tmpgrp = document.createElementNS(xmlns,"g");
tmpgrpattr = document.createAttribute("transform");
let [xcoord,ycoord] = this.coordinates;
let [xdest,ydest] = page_desc[current_visible_page].bbox;
- if (typeof size === 'undefined'){
- tmpgrpattr.value = "translate("+String(xdest-xcoord)+","+String(ydest-ycoord)+")";
- }
- else{
- tmpgrpattr.value = "translate("+String(xdest-xcoord+size.x)+","+String(ydest-ycoord+size.y)+")";
- }
+ tmpgrpattr.value = "translate("+String(xdest-xcoord)+","+String(ydest-ycoord)+")";
tmpgrp.setAttributeNode(tmpgrpattr);
diff -r f058542d0caa -r e704b0487515 svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2 Mon Jan 25 14:02:08 2021 +0100
+++ b/svghmi/widget_input.ysl2 Tue Jan 26 11:14:22 2021 +0100
@@ -28,9 +28,6 @@
template "widget[@type='Input']", mode="widget_defs" {
param "hmi_element";
- const "key_pos_elt" optional_labels("key_pos");
- value "$key_pos_elt";
-
const "value_elt" optional_labels("value");
const "have_value","string-length($value_elt)>0";
value "$value_elt";
@@ -62,16 +59,7 @@
| init: function() {
if "$have_edit" {
- | this.edit_elt.onclick = () => edit_value(
- | "«path/@value»", "«path/@type»",
- | this, this.last_val,
- choose {
- when "string-length($key_pos_elt)>0"
- | this.key_pos_elt.getBBox()
- otherwise
- | undefined
- }
- | );
+ | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_val);
}
foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
diff -r f058542d0caa -r e704b0487515 svghmi/widget_keypad.ysl2
--- a/svghmi/widget_keypad.ysl2 Mon Jan 25 14:02:08 2021 +0100
+++ b/svghmi/widget_keypad.ysl2 Tue Jan 26 11:14:22 2021 +0100
@@ -16,80 +16,6 @@
template "widget[@type='Keypad']", mode="widget_class"
||
class KeypadWidget extends Widget{
- moving = undefined;
- click = undefined;
- offset = undefined;
-
- on_position_click(evt) {
- this.moving = true;
-
- // chatch window events
- window.addEventListener("touchmove", this.bound_on_drag, true);
- window.addEventListener("mousemove", this.bound_on_drag, true);
-
- window.addEventListener("mouseup", this.bound_on_release, true)
- window.addEventListener("touchend", this.bound_on_release, true);
- window.addEventListener("touchcancel", this.bound_on_release, true);
-
- // get click position offset from widget x,y and save it to variable
- var keypad_borders = this.position_elt.getBoundingClientRect();
- var clickX = undefined;
- var clickY = undefined;
- if (evt.type == "touchstart"){
- clickX = Math.ceil(evt.touches[0].clientX);
- clickY = Math.ceil(evt.touches[0].clientY);
- }
- else{
- clickX = evt.pageX;
- clickY = evt.pageY;
- }
- this.offset=[clickX-keypad_borders.left,clickY-keypad_borders.top]
- }
-
- on_release(evt) {
- //relase binds
- window.removeEventListener("touchmove", this.bound_on_drag, true);
- window.removeEventListener("mousemove", this.bound_on_drag, true);
-
- window.removeEventListener("mouseup", this.bound_on_release, true)
- window.removeEventListener("touchend", this.bound_on_release, true);
- window.removeEventListener("touchcancel", this.bound_on_release, true);
-
- if(this.moving)
- this.moving = false;
- }
-
- on_drag(evt) {
- if(this.moving)
- //get mouse coordinates
- var clickX = undefined;
- var clickY = undefined;
- if (evt.type == "touchmove"){
- clickX = Math.ceil(evt.touches[0].clientX);
- clickY = Math.ceil(evt.touches[0].clientY);
- }
- else{
- clickX = evt.pageX;
- clickY = evt.pageY;
- }
- this.click = [clickX,clickY]
-
- //requeset redraw
- this.request_animate();
- }
-
- animate(){
- //get keyboard pos in html
- let [eltid, tmpgrp] = current_modal;
- let [xcoord,ycoord] = this.coordinates;
- let [clickX,clickY] = this.click;
- let [xdest,ydest,svgWidth,svgHeight] = page_desc[current_visible_page].bbox;
-
- //translate keyboard position
- let mouseX = ((clickX-this.offset[0])/window.innerWidth)*svgWidth;
- let mouseY = ((clickY-this.offset[1])/window.innerHeight)*svgHeight;
- tmpgrp.setAttribute("transform","translate("+String(xdest-xcoord+mouseX)+","+String(ydest-ycoord+mouseY)+")");
- }
on_key_click(symbols) {
var syms = symbols.split(" ");
@@ -190,7 +116,7 @@
template "widget[@type='Keypad']", mode="widget_defs" {
param "hmi_element";
labels("Esc Enter BackSpace Keys Info Value");
- optional_labels("Sign Space NumDot position");
+ optional_labels("Sign Space NumDot");
activable_labels("CapsLock Shift");
| init: function() {
foreach "$hmi_element/*[@inkscape:label = 'Keys']/*" {
@@ -200,13 +126,6 @@
| if(this.«.»_elt)
| this.«.»_elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_«.»_click()");
}
- | if(this.position_elt){
- | this.bound_on_release = this.on_release.bind(this);
- | this.bound_on_drag = this.on_drag.bind(this);
- |
- | this.position_elt.setAttribute("onmousedown", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)");
- | this.position_elt.setAttribute("ontouchstart", "hmi_widgets['"+this.element_id+"'].on_position_click(evt)");
- | }
| },
|
const "g", "$geometry[@Id = $hmi_element/@id]";