edouard@2883: // widget_input.ysl2 Edouard@2779: edouard@3094: template "widget[@type='Input']", mode="widget_class"{ edouard@3094: || edouard@3094: class InputWidget extends Widget{ edouard@3094: on_op_click(opstr) { edouard@3101: this.change_hmi_value(0, opstr); edouard@3094: } edouard@3094: edit_callback(new_val) { edouard@3094: this.apply_hmi_value(0, new_val); edouard@3094: } edouard@3100: edouard@3100: overshot(new_val, max) { edouard@3100: this.last_display = "max: "+max; edouard@3100: this.request_animate(); edouard@3100: } edouard@3100: edouard@3100: undershot(new_val, min) { edouard@3100: this.last_display = "min: "+min; edouard@3100: this.request_animate(); edouard@3100: } edouard@3100: edouard@3100: edouard@3094: } edouard@3094: || edouard@3094: } edouard@3094: edouard@2883: template "widget[@type='Input']", mode="widget_defs" { edouard@2883: param "hmi_element"; edouard@3094: edouard@3094: const "value_elt" optional_labels("value"); edouard@2883: const "have_value","string-length($value_elt)>0"; edouard@2883: value "$value_elt"; edouard@3094: edouard@3094: const "edit_elt" optional_labels("edit"); edouard@3094: const "have_edit","string-length($edit_elt)>0"; edouard@3094: value "$edit_elt"; edouard@3094: edouard@2883: if "$have_value" edouard@2883: | frequency: 5, edouard@3094: edouard@2883: | dispatch: function(value) { edouard@3094: edouard@3094: if "$have_edit" Edouard@2911: | this.last_val = value; edouard@3094: edouard@3100: if "$have_value" { edouard@3100: | this.last_display = value; edouard@3100: | this.request_animate(); edouard@3100: } edouard@3100: | }, Edouard@2836: edouard@3100: if "$have_value" { edouard@3100: | animate: function(){ edouard@3100: | this.value_elt.textContent = String(this.last_display); edouard@2883: | }, edouard@3100: } edouard@3094: edouard@2883: | init: function() { edouard@3094: edouard@3094: if "$have_edit" { Edouard@3118: | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_val); edouard@2883: } edouard@3094: edouard@2883: foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { edouard@3094: | id("«@id»").onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»"); Edouard@2792: } Edouard@2911: Edouard@2911: | }, Edouard@2753: }