]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/dialog.cxx
don't destroy iterated map entries; delete _menubar; restore closed
[flightgear.git] / src / GUI / dialog.cxx
index 28f60ad6129f74030fb050199b307263666d02ec..ca8e19753f53224aa22df321ec4bcb5d24d1024a 100644 (file)
@@ -432,12 +432,20 @@ FGDialog::display (SGPropertyNode * props)
     wid.setDefaultFont(fnt, int(fnt->getPointSize()));
 
     int pw=0, ph=0;
+    int px, py, savex, savey;
     if(!userw || !userh)
         wid.calcPrefSize(&pw, &ph);
     pw = props->getIntValue("width", pw);
     ph = props->getIntValue("height", ph);
-    int px = props->getIntValue("x", (screenw - pw) / 2);
-    int py = props->getIntValue("y", (screenh - ph) / 2);
+    px = savex = props->getIntValue("x", (screenw - pw) / 2);
+    py = savey = props->getIntValue("y", (screenh - ph) / 2);
+
+    // Negative x/y coordinates are interpreted as distance from the top/right
+    // corner rather than bottom/left.
+    if (px < 0)
+        px = screenw - pw + px;
+    if (py < 0)
+        py = screenh - ph + py;
 
     // Define "x", "y", "width" and/or "height" in the property tree if they
     // are not specified in the configuration file.
@@ -448,9 +456,17 @@ FGDialog::display (SGPropertyNode * props)
     _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");
+    // the same next time around, or restore x and y to preserve negative coords.
+    if(userx)
+        props->setIntValue("x", savex);
+    else
+        props->removeChild("x");
+
+    if(usery)
+        props->setIntValue("y", savey);
+    else
+        props->removeChild("y");
+
     if(!userw) props->removeChild("width");
     if(!userh) props->removeChild("height");
 
@@ -578,7 +594,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
              i < value_nodes.size();
              i++, j--)
             entries[i] = strdup((char *)value_nodes[i]->getStringValue());
-        puaComboBox * obj = new puaComboBox(x, y, x + width, y + height, entries,
+        puComboBox * obj = new puComboBox(x, y, x + width, y + height, entries,
                            props->getBoolValue("editable", false));
         setupObject(obj, props);
         setColor(obj, props, FOREGROUND|LABEL);
@@ -608,7 +624,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
         int slider_width = props->getIntValue("slider", parentHeight);
         int wrap = props->getBoolValue("wrap", true);
         if (slider_width==0) slider_width=20;
-        puaLargeInput * obj = new puaLargeInput(x, y,
+        puLargeInput * obj = new puLargeInput(x, y,
                 x+width, x+height, 2, slider_width, wrap);
 
         if (props->hasValue("editable")) {
@@ -634,8 +650,8 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
              i < value_nodes.size();
              i++, j--)
             entries[i] = strdup((char *)value_nodes[i]->getName());
-        puaSelectBox * obj =
-            new puaSelectBox(x, y, x + width, y + height, entries);
+        puSelectBox * obj =
+            new puSelectBox(x, y, x + width, y + height, entries);
         setupObject(obj, props);
         setColor(obj, props, FOREGROUND|LABEL);
         return obj;