1
0
Fork 0

add an optional property node pointer to ObjectProperty. This is currently

only used by the <list> widget. It allows to "dialog-update" the list,
which rescans the <value> children and redraws the list widget with new
contents. The old contents are only freed at dialog close, which should
eventually get changed.
This commit is contained in:
mfranz 2006-04-28 15:55:41 +00:00
parent 5b1dd6c8ae
commit ff52ed5072
2 changed files with 17 additions and 6 deletions

View file

@ -391,7 +391,11 @@ FGDialog::updateValues (const char * objectName)
continue;
puObject *obj = _propertyObjects[i]->object;
copy_to_pui(_propertyObjects[i]->node, obj);
SGPropertyNode *values = _propertyObjects[i]->values;
if (obj->getType() & PUCLASS_LIST && values)
((puList *)obj)->newList(value_list(values));
else
copy_to_pui(_propertyObjects[i]->node, obj);
}
}
@ -721,7 +725,9 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props)
const char * propname = props->getStringValue("property");
SGPropertyNode_ptr node = fgGetNode(propname, true);
copy_to_pui(node, object);
PropertyObject* po = new PropertyObject(name, object, node);
SGPropertyNode * values = type == "list" ? props : 0;
PropertyObject* po = new PropertyObject(name, object, node, values);
_propertyObjects.push_back(po);
if(props->getBoolValue("live"))
_liveObjects.push_back(po);
@ -962,10 +968,12 @@ FGDialog::destroy_char_array (char ** array)
FGDialog::PropertyObject::PropertyObject (const char * n,
puObject * o,
SGPropertyNode_ptr p)
SGPropertyNode_ptr p,
SGPropertyNode_ptr v)
: name(n),
object(o),
node(p)
node(p),
values(v)
{
}

View file

@ -141,15 +141,18 @@ private:
// PUI provides no way for userdata to be deleted automatically
// with a GUI object, so we have to keep track of all the special
// data we allocated and then free it manually when the dialog
// closes.
// closes. "values" is a node with "value" children and only used
// by the <list> widget.
vector<void *> _info;
struct PropertyObject {
PropertyObject (const char * name,
puObject * object,
SGPropertyNode_ptr node);
SGPropertyNode_ptr node,
SGPropertyNode_ptr values = 0);
string name;
puObject * object;
SGPropertyNode_ptr node;
SGPropertyNode_ptr values;
};
vector<PropertyObject *> _propertyObjects;
vector<PropertyObject *> _liveObjects;