]> git.mxchange.org Git - flightgear.git/commitdiff
layout-props.cxx: hrule/vrule shall be accepted as widgets even if they
authormfranz <mfranz>
Mon, 26 Mar 2007 15:17:38 +0000 (15:17 +0000)
committermfranz <mfranz>
Mon, 26 Mar 2007 15:17:38 +0000 (15:17 +0000)
    have no children (in which case they default to 1px thickness & stretch).
    This allows to just write <hrule/> instead of <hrule><dummy/></hrule>.
    One can still use <hrule><pref-height>3</pref-height></hrule>, of course.
layout.cxx: drop silly do??Box calls for hrule/vrule (yes, I wrote that :-)

src/GUI/layout-props.cxx
src/GUI/layout.cxx

index b2fe085daaa91fef3239c81ada3d115754005fd1..8533c17c8c06401e8a72942dd9d265b798d33574 100644 (file)
@@ -42,11 +42,16 @@ LayoutWidget LayoutWidget::parent()
 
 int LayoutWidget::nChildren()
 {
-    // Hack: assume that any non-leaf nodes are widgets...
+    // Hack: assume that any non-leaf nodes but "hrule" and "vrule"
+    // are widgets...
     int n = 0;
-    for(int i=0; i<_prop->nChildren(); i++)
-        if(_prop->getChild(i)->nChildren() != 0)
+    for(int i=0; i<_prop->nChildren(); i++) {
+        SGPropertyNode* p = _prop->getChild(i);
+        const char* name = p->getName();
+        if(p->nChildren() != 0 || !strcmp(name, "hrule")
+                || !strcmp(name, "vrule"))
             n++;
+    }
     return n;
 }
 
@@ -57,7 +62,9 @@ LayoutWidget LayoutWidget::getChild(int idx)
     int n = 0;
     for(int i=0; i<_prop->nChildren(); i++) {
         SGPropertyNode* p = _prop->getChild(i);
-        if(p->nChildren() != 0) {
+        const char* name = p->getName();
+        if(p->nChildren() != 0 || !strcmp(name, "hrule")
+                || !strcmp(name, "vrule")) {
             if(idx == n) return LayoutWidget(p);
             n++;
         }
index 730142d04086d24924183d87494a04f9fdd6b95a..8d3aae86fd8db5d49541e0ce90577b47e42aaa51 100644 (file)
@@ -185,10 +185,7 @@ 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