diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-06-05 00:43:59 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-06-05 00:43:59 +0300 |
commit | f15d6c10ff057d906e138a4e3c199a9a90c3a92a (patch) | |
tree | 94b84d23c0fd141ede0889900e4f4c99ab97565b /GuiTest/src | |
parent | 1a92028f3b019eca1cf2d460f598bb131dae8457 (diff) | |
download | LibGui-f15d6c10ff057d906e138a4e3c199a9a90c3a92a.tar.gz LibGui-f15d6c10ff057d906e138a4e3c199a9a90c3a92a.tar.bz2 LibGui-f15d6c10ff057d906e138a4e3c199a9a90c3a92a.zip |
Make insets properly swappable, add WPanelWithInsets4.0.0-beta.4
Diffstat (limited to 'GuiTest/src')
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java | 22 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java | 7 |
2 files changed, 29 insertions, 0 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java new file mode 100644 index 0000000..abd36e6 --- /dev/null +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java @@ -0,0 +1,22 @@ +package io.github.cottonmc.test.client; + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; +import io.github.cottonmc.cotton.gui.widget.WButton; +import io.github.cottonmc.cotton.gui.widget.WGridPanel; + +import io.github.cottonmc.cotton.gui.widget.WLabel; + +import io.github.cottonmc.cotton.gui.widget.data.Insets; + +import net.minecraft.text.LiteralText; + +public class InsetsTestGui extends LightweightGuiDescription { + public InsetsTestGui() { + WGridPanel root = (WGridPanel) rootPanel; + + root.add(new WLabel(new LiteralText("Insets demo")), 0, 0); + root.add(new WButton(new LiteralText("Default")).setOnClick(() -> root.setInsets(Insets.ROOT_PANEL)), 0, 1, 2, 1); + root.add(new WButton(new LiteralText("None")).setOnClick(() -> root.setInsets(Insets.NONE)), 2, 1, 2, 1); + root.add(new WButton(new LiteralText("Large")).setOnClick(() -> root.setInsets(new Insets(16))), 4, 1, 2, 1); + } +} diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java index b45145e..2f78fcd 100644 --- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -47,6 +47,13 @@ public class LibGuiTestClient implements ClientModInitializer { }); return 0; })) + .then(literal("insets").executes(context -> { + var client = context.getSource().getClient(); + client.send(() -> { + client.openScreen(new CottonClientScreen(new InsetsTestGui())); + }); + return 0; + })) ); } |