- make fuel checkbox/slider "live"
- add two dialog helper functions dialog_apply() and dialog_update()
This commit is contained in:
parent
137f1cef4a
commit
88b81056e1
1 changed files with 37 additions and 1 deletions
|
@ -167,7 +167,7 @@ Dialog = {
|
||||||
if (m.prop.getName() != "dialog") {
|
if (m.prop.getName() != "dialog") {
|
||||||
die("Dialog class: node name must end with '/dialog'");
|
die("Dialog class: node name must end with '/dialog'");
|
||||||
}
|
}
|
||||||
m.listener = setlistener("/sim/signals/reinit-gui", func { m.load () }, 1);
|
m.listener = setlistener("/sim/signals/reinit-gui", func { m.load() }, 1);
|
||||||
return m;
|
return m;
|
||||||
},
|
},
|
||||||
# doesn't need to be called explicitly, but can be used to force a reload
|
# doesn't need to be called explicitly, but can be used to force a reload
|
||||||
|
@ -243,6 +243,39 @@ settimer(func {
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Apply whole dialog or list of widgets. This copies the widgets'
|
||||||
|
# visible contents to the respective <property>.
|
||||||
|
#
|
||||||
|
var dialog_apply = func(dialog, objects...) {
|
||||||
|
var n = props.Node.new({ "dialog-name" : dialog });
|
||||||
|
if (!size(objects)) {
|
||||||
|
return fgcommand("dialog-apply", n);
|
||||||
|
}
|
||||||
|
var name = n.getNode("object-name", 1);
|
||||||
|
foreach (var o; objects) {
|
||||||
|
name.setValue(o);
|
||||||
|
fgcommand("dialog-apply", n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Update whole dialog or list of widgets. This makes the widgets
|
||||||
|
# adopt and display the value of their <property>.
|
||||||
|
#
|
||||||
|
var dialog_update = func(dialog, objects...) {
|
||||||
|
var n = props.Node.new({ "dialog-name" : dialog });
|
||||||
|
if (!size(objects)) {
|
||||||
|
return fgcommand("dialog-update", n);
|
||||||
|
}
|
||||||
|
var name = n.getNode("object-name", 1);
|
||||||
|
foreach (var o; objects) {
|
||||||
|
name.setValue(o);
|
||||||
|
fgcommand("dialog-update", n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# GUI theming
|
# GUI theming
|
||||||
|
@ -429,10 +462,12 @@ showWeightDialog = func {
|
||||||
|
|
||||||
sel = tcell(fuelTable, "checkbox", i+1, 1);
|
sel = tcell(fuelTable, "checkbox", i+1, 1);
|
||||||
sel.set("property", tankprop ~ "/selected");
|
sel.set("property", tankprop ~ "/selected");
|
||||||
|
sel.set("live", 1);
|
||||||
sel.setBinding("dialog-apply");
|
sel.setBinding("dialog-apply");
|
||||||
|
|
||||||
slider = tcell(fuelTable, "slider", i+1, 2);
|
slider = tcell(fuelTable, "slider", i+1, 2);
|
||||||
slider.set("property", tankprop ~ "/level-gal_us");
|
slider.set("property", tankprop ~ "/level-gal_us");
|
||||||
|
slider.set("live", 1);
|
||||||
slider.set("min", 0);
|
slider.set("min", 0);
|
||||||
slider.set("max", cap);
|
slider.set("max", cap);
|
||||||
slider.setBinding("dialog-apply");
|
slider.setBinding("dialog-apply");
|
||||||
|
@ -513,6 +548,7 @@ showWeightDialog = func {
|
||||||
var max = w.getNode("max-lb", 1).getValue();
|
var max = w.getNode("max-lb", 1).getValue();
|
||||||
slider.set("min", min != nil ? min : 0);
|
slider.set("min", min != nil ? min : 0);
|
||||||
slider.set("max", max != nil ? max : 100);
|
slider.set("max", max != nil ? max : 100);
|
||||||
|
slider.set("live", 1);
|
||||||
slider.setBinding("dialog-apply");
|
slider.setBinding("dialog-apply");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue