Fixed LayoutVertical
This commit is contained in:
parent
068f229a45
commit
aa3cb630fb
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user