// superclass to indicate "handled by child object", but all it
// tells us is that the pointer is inside the dialog. So do the
// intersection test (again) to make sure we don't start a drag
- // when inside controls. A further weirdness: plib inserts a
- // "ghost" child which covers the whole control. (?) Skip it.
+ // when inside controls.
if(!result) return result;
puObject* child = getFirstChild();
- if(child) child = child->getNextObject();
+ if(child) child = child->getNextObject(); // Skip the puFrame
while(child) {
int cx, cy, cw, ch;
child->getAbsolutePosition(&cx, &cy);
static void
copy_to_pui (SGPropertyNode * node, puObject * object)
{
+ // Treat puText objects specially, so their "values" can be set
+ // from properties.
+ if(object->getType() & PUCLASS_TEXT) {
+ object->setLabel(node->getStringValue());
+ return;
+ }
+
switch (node->getType()) {
case SGPropertyNode::BOOL:
case SGPropertyNode::INT:
static void
copy_from_pui (puObject * object, SGPropertyNode * node)
{
+ // puText objects are immutable, so should not be copied out
+ if(object->getType() & PUCLASS_TEXT)
+ return;
+
switch (node->getType()) {
case SGPropertyNode::BOOL:
case SGPropertyNode::INT:
_propertyObjects[i]->node);
}
+void
+FGDialog::update ()
+{
+ for (unsigned int i = 0; i < _liveObjects.size(); i++)
+ copy_to_pui(_liveObjects[i]->node, _liveObjects[i]->object);
+}
+
void
FGDialog::display (SGPropertyNode * props)
{
int screenw = globals->get_props()->getIntValue("/sim/startup/xsize");
int screenh = globals->get_props()->getIntValue("/sim/startup/ysize");
+ bool userx = props->hasValue("x");
+ bool usery = props->hasValue("y");
+ bool userw = props->hasValue("width");
+ bool userh = props->hasValue("height");
+
LayoutWidget wid(props);
int pw=0, ph=0;
- if(!props->hasValue("width") || !props->hasValue("height"))
+ if(!userw || !userh)
wid.calcPrefSize(&pw, &ph);
pw = props->getIntValue("width", pw);
ph = props->getIntValue("height", ph);
_object = makeObject(props, screenw, screenh);
+ // Remove automatically generated properties, so the layout looks
+ // the same next time around.
+ if(!userx) props->removeChild("x");
+ if(!usery) props->removeChild("y");
+ if(!userw) props->removeChild("width");
+ if(!userh) props->removeChild("height");
+
if (_object != 0) {
_object->reveal();
} else {
slider->setMinValue(props->getFloatValue("min", 0.0));
slider->setMaxValue(props->getFloatValue("max", 1.0));
setupObject(slider, props);
+ if(presetSize)
+ slider->setSize(width, height);
return slider;
} else if (type == "dial") {
puDial * dial = new puDial(x, y, width);
dial->setWrap(props->getBoolValue("wrap", true));
setupObject(dial, props);
return dial;
+ } else if (type == "textbox") {
+ int slider_width = props->getIntValue("slider", parentHeight);
+ if (slider_width==0) slider_width=20;
+ puLargeInput * puTextBox =
+ new puLargeInput(x, y, x+width, x+height, 2, slider_width);
+ if (props->hasValue("editable"))
+ {
+ if (props->getBoolValue("editable")==false)
+ puTextBox->disableInput();
+ else
+ puTextBox->enableInput();
+ }
+ setupObject(puTextBox,props);
+ return puTextBox;
} else if (type == "select") {
vector<SGPropertyNode_ptr> value_nodes;
SGPropertyNode * selection_node =
const char * propname = props->getStringValue("property");
SGPropertyNode_ptr node = fgGetNode(propname, true);
copy_to_pui(node, object);
- if (name != 0)
- _propertyObjects.push_back(new PropertyObject(name, object, node));
+ PropertyObject* po = new PropertyObject(name, object, node);
+ _propertyObjects.push_back(po);
+ if(props->getBoolValue("live"))
+ _liveObjects.push_back(po);
}
vector<SGPropertyNode_ptr> nodes = props->getChildren("binding");