]> git.mxchange.org Git - flightgear.git/commitdiff
- fix <hrule>
authormfranz <mfranz>
Sat, 2 Jul 2005 20:49:38 +0000 (20:49 +0000)
committermfranz <mfranz>
Sat, 2 Jul 2005 20:49:38 +0000 (20:49 +0000)
- add <vrule>
- allow elements to default to foreground color (black)
- remove redundant  if (foo) delete foo;

The rules do currently need a dummy child for the layouter to work correctly,
(<hrule><foo/></hrule>). The goal is to make a simple <hrule/> work.

src/GUI/dialog.cxx
src/GUI/layout.cxx
src/GUI/prop_picker.cxx

index 47657f3d12049ef23dcb6afb39c04d2a4c404e92..d067dbfd2598540a36dca6c203860961eacd9f55 100644 (file)
@@ -364,7 +364,7 @@ FGDialog::display (SGPropertyNode * props)
     bool userw = props->hasValue("width");
     bool userh = props->hasValue("height");
 
-     // Let the layout widget work in the same property subtree.
+    // Let the layout widget work in the same property subtree.
     LayoutWidget wid(props);
 
     int pw=0, ph=0;
@@ -407,17 +407,25 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
     int height = props->getIntValue("height", parentHeight);
     int x = props->getIntValue("x", (parentWidth - width) / 2);
     int y = props->getIntValue("y", (parentHeight - height) / 2);
+    string type = props->getName();
+
+    const sgVec4 background = {0.8, 0.8, 0.9, 0.85};
+    const sgVec4 foreground = {0, 0, 0, 1};
+    sgVec4 color;
+
+    if (type == "hrule" || type == "vrule")
+        sgCopyVec4(color, foreground);
+    else
+        sgCopyVec4(color, background);
 
-    sgVec4 color = {0.8, 0.8, 0.9, 0.85};
     SGPropertyNode *ncs = props->getNode("color", false);
     if ( ncs ) {
-       color[0] = ncs->getFloatValue("red", 0.8);
-       color[1] = ncs->getFloatValue("green", 0.8);
-       color[2] = ncs->getFloatValue("blue", 0.9);
-       color[3] = ncs->getFloatValue("alpha", 0.85);
+       color[0] = ncs->getFloatValue("red", color[0]);
+       color[1] = ncs->getFloatValue("green", color[1]);
+       color[2] = ncs->getFloatValue("blue", color[2]);
+       color[3] = ncs->getFloatValue("alpha", color[3]);
     }
 
-    string type = props->getName();
     if (type == "")
         type = "dialog";
 
@@ -438,8 +446,8 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
         puGroup * group = new puGroup(x, y);
         setupGroup(group, props, width, height, color, true);
         return group;
-    } else if (type == "hrule") {
-        puFrame * rule = new puFrame(3, y, parentWidth - 4, y + (height ? height : 1));
+    } else if (type == "hrule" || type == "vrule") {
+        puFrame * rule = new puFrame(x, y, x + width, y + height);
         rule->setBorderThickness(0);
         rule->setColorScheme(color[0], color[1], color[2], color[3]);
         return rule;
index 4bdf00190dbb08c90159a89fe42e670de97a5bc7..6783187db5580368a4e72f28e68d772bb99baf73 100644 (file)
@@ -71,6 +71,10 @@ void LayoutWidget::calcPrefSize(int* w, int* h)
         else                    *h = 4*UNIT;
     } else if (isType("list") || isType("airport-list") || isType("dial")) {
         *w = *h = 12*UNIT;
+    } else if (isType("hrule")) {
+        *h = 1;
+    } else if (isType("vrule")) {
+        *w = 1;
     }
 
     // Throw it all out if the user specified a fixed preference
@@ -115,7 +119,7 @@ void LayoutWidget::layout(int x, int y, int w, int h)
 
     // Correct our box for alignment.  The values above correspond to
     // a "fill" alignment.
-    const char* halign = isGroup ? "fill" : "center";
+    const char* halign = (isGroup || isType("hrule")) ? "fill" : "center";
     if(hasField("halign")) halign = getStr("halign");
     if(eq(halign, "left")) {
         w = prefw;
@@ -126,7 +130,7 @@ void LayoutWidget::layout(int x, int y, int w, int h)
         x += (w - prefw)/2;
         w = prefw;
     }
-    const char* valign = isGroup ? "fill" : "center";
+    const char* valign = (isGroup || isType("vrule")) ? "fill" : "center";
     if(hasField("valign")) valign = getStr("valign");
     if(eq(valign, "bottom")) {
         h = prefh;
@@ -172,7 +176,10 @@ void LayoutWidget::layout(int x, int y, int w, int h)
         if     (eq(layout, "hbox" )) doHVBox(true, false);
         else if(eq(layout, "vbox" )) doHVBox(true, true);
         else if(eq(layout, "table")) doTable(true);
-    }
+    } else if(isType("hrule"))
+        doHVBox(true, false);
+    else if(isType("vrule"))
+        doHVBox(true, true);
 }
 
 // Convention: the "A" cooridinate refers to the major axis of the
index 767769ad9976ba2d7bdd41fe6480867821f7c647..ee4c1f44dccc096e653260ab466f85f4ff675eab 100755 (executable)
@@ -530,7 +530,7 @@ void fgPropPicker::updateTextForEntry(int index)
     if (dotFiles) index +=2;
                
     // don't leak everywhere if we're updating
-    if (files[index]) delete[] files[index];
+    delete[] files[index];
                
     files[index] = new char[ strlen(line.c_str())+2 ] ;
     strcpy ( files [ index ], line.c_str() ) ;