]> git.mxchange.org Git - flightgear.git/commitdiff
add an optional property node pointer to ObjectProperty. This is currently
authormfranz <mfranz>
Fri, 28 Apr 2006 15:55:41 +0000 (15:55 +0000)
committermfranz <mfranz>
Fri, 28 Apr 2006 15:55:41 +0000 (15:55 +0000)
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.

src/GUI/dialog.cxx
src/GUI/dialog.hxx

index a1ff28ae0f4ee81ee13f7555f7224b45d2da1ea2..4befc5855076eead94953d0937c9c8e2e542c65a 100644 (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)
 {
 }
 
index 270d8aefb9b72b8c4750e2a862c506bbd07647dd..65c010395f069d25d5ca03e306300f86fd398cb1 100644 (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;