X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2Flayout.cxx;h=dd6f1b6ca1ec8f8f84b5b2da6d7a193cfa76825e;hb=6dd47822545bf27f69a18a2d0ccc8abf91daa8d5;hp=4bdf00190dbb08c90159a89fe42e670de97a5bc7;hpb=c70e5f20dee44c4f48e21e1f1b8a21ac3945967e;p=flightgear.git diff --git a/src/GUI/layout.cxx b/src/GUI/layout.cxx index 4bdf00190..dd6f1b6ca 100644 --- a/src/GUI/layout.cxx +++ b/src/GUI/layout.cxx @@ -1,5 +1,11 @@ + +#ifdef HAVE_CONFIG_H +# include +#endif + #include "layout.hxx" + // This file contains the actual layout engine. It has no dependence // on outside libraries; see layout-props.cxx for the glue code. @@ -39,6 +45,9 @@ void LayoutWidget::calcPrefSize(int* w, int* h) { *w = *h = 0; // Ask for nothing by default + if (!getBool("enabled", true) || isType("nasal")) + return; + int legw = stringLength(getStr("legend")); int labw = stringLength(getStr("label")); @@ -69,8 +78,13 @@ void LayoutWidget::calcPrefSize(int* w, int* h) *w = *h = 17*UNIT; if(getBool("vertical")) *w = 4*UNIT; else *h = 4*UNIT; - } else if (isType("list") || isType("airport-list") || isType("dial")) { + } else if (isType("list") || isType("airport-list") + || isType("property-list") || isType("dial") || isType("waypointlist")) { *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 @@ -90,6 +104,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("enabled", true) || isType("nasal")) + return; + setNum("__bx", x); setNum("__by", y); setNum("__bw", w); @@ -115,7 +132,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 +143,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; @@ -143,7 +160,10 @@ void LayoutWidget::layout(int x, int y, int w, int h) // the x/y/w/h box we have calculated. if (isType("text")) { // puText labels are layed out to the right of the box, so - // zero the width. + // zero the width. Also subtract PUSTR_RGAP from the x + // coordinate to compensate for the added gap between the + // label and its empty puObject. + x -= 5; w = 0; } else if (isType("input") || isType("combo") || isType("select")) { // Fix the height to a constant @@ -185,6 +205,9 @@ void LayoutWidget::doHVBox(bool doLayout, bool vertical, int* w, int* h) int nEq = 0, eqA = 0, eqB = 0, eqTotalA = 0; for(i=0; irspan; j++) total += rowSizes[cell->row + j]; - int extra = total - cell->h; + int extra = cell->h - total; if(extra > 0) { for(j=0; jrspan; j++) { int chunk = extra / (cell->rspan - j); @@ -309,7 +335,7 @@ void LayoutWidget::doTable(bool doLayout, int* w, int* h) int total = 0; for(j=0; jcspan; j++) total += colSizes[cell->col + j]; - int extra = total - cell->w; + int extra = cell->w - total; if(extra > 0) { for(j=0; jcspan; j++) { int chunk = extra / (cell->cspan - j);