aboutsummaryrefslogtreecommitdiff
path: root/GuiTest
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2021-02-02 17:52:04 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2021-02-02 17:52:36 +0200
commite9523d714508e15ae0262a21cccec847250e2bcd (patch)
treeff5da4cbc176d17283c73c6c99a107660dc3048c /GuiTest
parentf5e123896a53957d61c40a48beea8a0a473f9db6 (diff)
downloadLibGui-e9523d714508e15ae0262a21cccec847250e2bcd.tar.gz
LibGui-e9523d714508e15ae0262a21cccec847250e2bcd.tar.bz2
LibGui-e9523d714508e15ae0262a21cccec847250e2bcd.zip
Add test gui for scroll panels
Diffstat (limited to 'GuiTest')
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java24
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java10
2 files changed, 34 insertions, 0 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
new file mode 100644
index 0000000..3dc41d3
--- /dev/null
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java
@@ -0,0 +1,24 @@
+package io.github.cottonmc.test.client;
+
+import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
+import io.github.cottonmc.cotton.gui.widget.WBox;
+import io.github.cottonmc.cotton.gui.widget.WButton;
+import io.github.cottonmc.cotton.gui.widget.WGridPanel;
+import io.github.cottonmc.cotton.gui.widget.WScrollPanel;
+import io.github.cottonmc.cotton.gui.widget.data.Axis;
+
+import net.minecraft.text.LiteralText;
+
+public class ScrollingTestGui extends LightweightGuiDescription {
+ public ScrollingTestGui() {
+ WGridPanel root = (WGridPanel) rootPanel;
+ WBox box = new WBox(Axis.VERTICAL);
+
+ for (int i = 0; i < 20; i++) {
+ box.add(new WButton(new LiteralText("Button #" + i)));
+ }
+
+ root.add(new WScrollPanel(box), 0, 0, 5, 3);
+ root.validate(this);
+ }
+}
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
index bdc47b3..de5df3d 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java
@@ -1,7 +1,11 @@
package io.github.cottonmc.test.client;
+import io.github.cottonmc.cotton.gui.client.CottonClientScreen;
+import io.github.cottonmc.cotton.gui.widget.WButton;
+
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
@@ -107,6 +111,12 @@ public class TestClientGui extends LightweightGuiDescription {
this.b = i;
updateCol(col);
});
+
+ WButton openOther = new WButton(new LiteralText("Go to scrolling"));
+ openOther.setOnClick(() -> {
+ MinecraftClient.getInstance().openScreen(new CottonClientScreen(new ScrollingTestGui()));
+ });
+ root.add(openOther, 0, -1, 4, 1);
root.validate(this);