From aa3cb630fbef2a5bb8f77c0952813529ea4fdee1 Mon Sep 17 00:00:00 2001 From: OLEGSHA Date: Wed, 2 Sep 2020 09:15:54 +0300 Subject: [PATCH] Fixed LayoutVertical --- .../client/graphics/gui/LayerTestGUI.java | 14 +++++++------- .../client/graphics/gui/layout/LayoutVertical.java | 8 +++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/LayerTestGUI.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/LayerTestGUI.java index d8d364e..6a74d96 100755 --- a/src/main/java/ru/windcorp/progressia/client/graphics/gui/LayerTestGUI.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/LayerTestGUI.java @@ -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); diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutVertical.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutVertical.java index 3ceea63..83e331f 100644 --- a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutVertical.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutVertical.java @@ -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; } }