From f15d6c10ff057d906e138a4e3c199a9a90c3a92a Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sat, 5 Jun 2021 00:43:59 +0300 Subject: Make insets properly swappable, add WPanelWithInsets --- .../github/cottonmc/test/client/InsetsTestGui.java | 22 ++++++++++++++++++++++ .../cottonmc/test/client/LibGuiTestClient.java | 7 +++++++ 2 files changed, 29 insertions(+) create mode 100644 GuiTest/src/main/java/io/github/cottonmc/test/client/InsetsTestGui.java (limited to 'GuiTest') 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; + })) ); } -- cgit