- fix <hrule>
- 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.
This commit is contained in:
parent
154917477f
commit
e73dffb99f
3 changed files with 28 additions and 13 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() ) ;
|
||||
|
|
Loading…
Add table
Reference in a new issue