Fixed LayoutVertical

This commit is contained in:
OLEGSHA 2020-09-02 09:15:54 +03:00
parent 068f229a45
commit aa3cb630fb
2 changed files with 10 additions and 12 deletions

View File

@ -81,7 +81,7 @@ public class LayerTestGUI extends GUILayer {
panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100), 0x44FF44));
Component charlie = new DebugComponent("Charlie", null, 0x222222);
charlie.setLayout(new LayoutVertical());
charlie.setLayout(new LayoutVertical(5));
//Debug
Localizer.getInstance().setLanguage("ru-RU");
@ -90,16 +90,16 @@ public class LayerTestGUI extends GUILayer {
// These two are swapped in code due to a bug in layouts, fixing ATM
charlie.addChild(
new Label(
"Epsilon",
new Font().withColor(0x4444BB).deriveItalic(),
() -> epsilon.get().concat("\u269b")
"Delta",
new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
"Пре-альфа!"
)
);
charlie.addChild(
new Label(
"Delta",
new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
"Пре-альфа!"
"Epsilon",
new Font().withColor(0x4444BB).deriveItalic(),
() -> epsilon.get().concat("\u269b")
)
);
panel.addChild(charlie);

View File

@ -43,16 +43,14 @@ public class LayoutVertical implements Layout {
@Override
public void layout(Component c) {
int x = c.getX() + margin,
y = c.getY() + margin;
int height;
y = c.getY() + c.getHeight();
synchronized (c.getChildren()) {
for (Component child : c.getChildren()) {
height = child.getPreferredSize().y;
int height = child.getPreferredSize().y;
y -= gap + height;
child.setBounds(x, y, c.getWidth() - 2 * margin, height);
y += gap + height;
}
}