aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);