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));
|
panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100), 0x44FF44));
|
||||||
|
|
||||||
Component charlie = new DebugComponent("Charlie", null, 0x222222);
|
Component charlie = new DebugComponent("Charlie", null, 0x222222);
|
||||||
charlie.setLayout(new LayoutVertical());
|
charlie.setLayout(new LayoutVertical(5));
|
||||||
|
|
||||||
//Debug
|
//Debug
|
||||||
Localizer.getInstance().setLanguage("ru-RU");
|
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
|
// These two are swapped in code due to a bug in layouts, fixing ATM
|
||||||
charlie.addChild(
|
charlie.addChild(
|
||||||
new Label(
|
new Label(
|
||||||
"Epsilon",
|
"Delta",
|
||||||
new Font().withColor(0x4444BB).deriveItalic(),
|
new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
|
||||||
() -> epsilon.get().concat("\u269b")
|
"Пре-альфа!"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
charlie.addChild(
|
charlie.addChild(
|
||||||
new Label(
|
new Label(
|
||||||
"Delta",
|
"Epsilon",
|
||||||
new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
|
new Font().withColor(0x4444BB).deriveItalic(),
|
||||||
"Пре-альфа!"
|
() -> epsilon.get().concat("\u269b")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
panel.addChild(charlie);
|
panel.addChild(charlie);
|
||||||
|
@ -43,16 +43,14 @@ public class LayoutVertical implements Layout {
|
|||||||
@Override
|
@Override
|
||||||
public void layout(Component c) {
|
public void layout(Component c) {
|
||||||
int x = c.getX() + margin,
|
int x = c.getX() + margin,
|
||||||
y = c.getY() + margin;
|
y = c.getY() + c.getHeight();
|
||||||
|
|
||||||
int height;
|
|
||||||
|
|
||||||
synchronized (c.getChildren()) {
|
synchronized (c.getChildren()) {
|
||||||
for (Component child : 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);
|
child.setBounds(x, y, c.getWidth() - 2 * margin, height);
|
||||||
y += gap + height;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user