]> git.mxchange.org Git - flightgear.git/commitdiff
add support for a <hide> property, which hides whole XML groups (widgets
authormfranz <mfranz>
Fri, 21 Oct 2005 17:47:48 +0000 (17:47 +0000)
committermfranz <mfranz>
Fri, 21 Oct 2005 17:47:48 +0000 (17:47 +0000)
or data blocks) from layouter and dialog creator. This is required for
dynamically generated/modified dialogs. Parts in the XML file can be
hidden and turned on by the C++ code. Other hidden parts can be used
as templates that are multiply used. Hidden datablocks can contain
strings that are used in dialog context, that are easier to translate
or modify in the XML file.

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

index 722fab29f78a7fee4c8e05e5a84d0c58a1b2cf81..7d1475bb9d7cbd11b4e94dd51ddc96d66c54e72a 100644 (file)
@@ -406,6 +406,9 @@ FGDialog::display (SGPropertyNode * props)
 puObject *
 FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
 {
+    if (props->getBoolValue("hide"))
+        return 0;
+
     bool presetSize = props->hasValue("width") && props->hasValue("height");
     int width = props->getIntValue("width", parentWidth);
     int height = props->getIntValue("height", parentHeight);
index 6783187db5580368a4e72f28e68d772bb99baf73..b887894cc125fd5034a874c569298240670f738e 100644 (file)
@@ -39,6 +39,9 @@ void LayoutWidget::calcPrefSize(int* w, int* h)
 {
     *w = *h = 0; // Ask for nothing by default
 
+    if (getBool("hide"))
+        return;
+
     int legw = stringLength(getStr("legend"));
     int labw = stringLength(getStr("label"));
 
@@ -94,6 +97,9 @@ void LayoutWidget::calcPrefSize(int* w, int* h)
 // Set up geometry such that the widget lives "inside" the specified 
 void LayoutWidget::layout(int x, int y, int w, int h)
 {
+    if (getBool("hide"))
+        return;
+
     setNum("__bx", x);
     setNum("__by", y);
     setNum("__bw", w);
@@ -192,6 +198,9 @@ void LayoutWidget::doHVBox(bool doLayout, bool vertical, int* w, int* h)
     int nEq = 0, eqA = 0, eqB = 0, eqTotalA = 0;
     for(i=0; i<nc; i++) {
         LayoutWidget child = getChild(i);
+        if (child.getBool("hide"))
+            continue;
+
         int a, b;
         child.calcPrefSize(vertical ? &b : &a, vertical ? &a : &b);
         if(doLayout) prefA[i] = a;
@@ -227,6 +236,9 @@ void LayoutWidget::doHVBox(bool doLayout, bool vertical, int* w, int* h)
         // from top to bottom instead of along the cartesian Y axis.
         int idx = vertical ? (nc-i-1) : i;
         LayoutWidget child = getChild(idx);
+        if (child.getBool("hide"))
+            continue;
+
         if(child.getBool("equal")) {
             int pad = child.padding();
             prefA[idx] = eqA + 2*pad;