--- a/svghmi/widgets_common.ysl2 Wed Jun 22 11:55:38 2022 +0200
+++ b/svghmi/widgets_common.ysl2 Fri Jun 24 09:21:24 2022 +0200
@@ -14,9 +14,16 @@
+decl warning_labels(*ptr) alias - { + with "mandatory","'warn'"; decl activable() alias - {
- labels("/active /inactive") {
+ warning_labels("/active /inactive") { @@ -181,14 +188,20 @@
function set_activation_state(eltsub, state){
- if(eltsub.active_elt_placeholder == undefined){
- eltsub.active_elt_placeholder = document.createComment("");
- eltsub.active_elt.parentNode.insertBefore(eltsub.active_elt_placeholder, eltsub.active_elt);
- eltsub.inactive_elt_placeholder = document.createComment("");
- eltsub.inactive_elt.parentNode.insertBefore(eltsub.inactive_elt_placeholder, eltsub.inactive_elt);
+ if(eltsub.active_elt != undefined){ + if(eltsub.active_elt_placeholder == undefined){ + eltsub.active_elt_placeholder = document.createComment(""); + eltsub.active_elt.parentNode.insertBefore(eltsub.active_elt_placeholder, eltsub.active_elt); + (state?_show:_hide)(eltsub.active_elt, eltsub.active_elt_placeholder); - (state?_show:_hide)(eltsub.active_elt, eltsub.active_elt_placeholder);
- ((state || state==undefined)?_hide:_show)(eltsub.inactive_elt, eltsub.inactive_elt_placeholder);
+ if(eltsub.inactive_elt != undefined){ + if(eltsub.inactive_elt_placeholder == undefined){ + eltsub.inactive_elt_placeholder = document.createComment(""); + eltsub.inactive_elt.parentNode.insertBefore(eltsub.inactive_elt_placeholder, eltsub.inactive_elt); + ((state || state==undefined)?_hide:_show)(eltsub.inactive_elt, eltsub.inactive_elt_placeholder); function activate_activable(eltsub) {
@@ -489,6 +502,7 @@
param "subelements","/..";
const "widget_type","@type";
+ const "widget_id","@id"; foreach "str:split($labels)" {
const "absolute", "starts-with(., '/')";
const "name","substring(.,number($absolute)+1)";
@@ -496,8 +510,16 @@
const "elt","($widget//*[not($absolute) and @inkscape:label=$name] | $widget/*[$absolute and @inkscape:label=$name])[1]";
- if "$mandatory='yes'" {
- error > «$widget_type» widget must have a «$name» element
+ if "$mandatory!='no'" { + const "errmsg" > «$widget_type» widget (id=«$widget_id») must have a «$name» element + when "$mandatory='yes'" { // otherwise produce nothing
@@ -510,8 +532,16 @@
const "subelt","$elt/*[@inkscape:label=$subname][1]";
when "not($subelt/@id)" {
- if "$mandatory='yes'" {
- error > «$widget_type» widget must have a «$name»/«$subname» element
+ if "$mandatory!='no'" { + const "errmsg" > «$widget_type» widget (id=«$widget_id») must have a «$name»/«$subname» element + when "$mandatory='yes'" { | /* missing «$name»/«$subname» element */