SVGHMI: intermediate commit while working on dropdown widget.
Here is the plan :
HMI:DropDown : svg:g of svg:rect + svg:text
rect is extended to match content size, and if content size exceed page size, user can scroll
HMI:List : either HMI:List:ListName as svg:text, one tspan per list entry
or HMI:List:ListName:Foreach:HMI_CLASS:SUB/PATH/TO/VALUE@/ROOT/PATH as empty svg:g
// widget_dropdown.ysl2
template "widget[@type='DropDown']", mode="widget_defs" {
param "hmi_element";
labels("text box");
| dispatch: function(value) {
/* TODO : get selection text by index */
| this.text_elt.textContent = String(value);
| },
| init: function() {
| 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));
| },
}