# HG changeset patch # User Edouard Tisserant # Date 1589121139 -7200 # Node ID 1e53d8b60ee9a155dcb496c17f11c9c553ec8b82 # Parent e50908ddec60460a225fa838a30dca1a095a9b35 SVGHMI: Parameters common to all widget constructors now passed as ordered parameters. diff -r e50908ddec60 -r 1e53d8b60ee9 svghmi/widgets_common.ysl2 --- a/svghmi/widgets_common.ysl2 Fri May 08 16:51:43 2020 +0200 +++ b/svghmi/widgets_common.ysl2 Sun May 10 16:32:19 2020 +0200 @@ -24,25 +24,19 @@ template "svg:*", mode="hmi_elements" { const "widget", "func:widget(@id)"; const "eltid","@id"; - | "«@id»": new «$widget/@type»Widget ({ - | args: [ - foreach "$widget/arg" - | "«@value»"`if "position()!=last()" > ,` - | ], - | offset: 0, - | indexes: [ - foreach "$widget/path" { + const "args" foreach "$widget/arg" > "«@value»"`if "position()!=last()" > ,` + const "indexes" foreach "$widget/path" { choose { when "not(@index)" { warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree } otherwise { - | «@index» /* «@value» */ `if "position()!=last()" > ,` + > «@index»`if "position()!=last()" > ,` } } } - | ], - | element: id("«@id»"), + + | "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],{ apply "$widget", mode="widget_defs" with "hmi_element","."; apply "$widget", mode="widget_subscribe" with "hmi_element","."; | })`if "position()!=last()" > ,` @@ -72,7 +66,11 @@ emit "preamble:widget-base-class" { || class Widget { - constructor(members){ + constructor(elt_id,args,indexes,members){ + this.element = id(elt_id); + this.args = args; + this.indexes = indexes; + this.offset = 0; Object.keys(members).forEach(prop => this[prop]=members[prop]); } }