diff options
Diffstat (limited to 'GuiTest/src')
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java | 25 | ||||
-rw-r--r-- | GuiTest/src/main/java/io/github/cottonmc/test/client/TestClientGui.java | 22 |
2 files changed, 40 insertions, 7 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..1ae78b6 --- /dev/null +++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/ScrollingTestGui.java @@ -0,0 +1,25 @@ +package io.github.cottonmc.test.client; + +import io.github.cottonmc.cotton.gui.widget.WLabeledSlider; + +import net.minecraft.text.LiteralText; + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; +import io.github.cottonmc.cotton.gui.widget.WBox; +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; + +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 WLabeledSlider(0, 10, new LiteralText("Slider #" + 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 23ea2a2..46db85f 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,9 +1,17 @@ package io.github.cottonmc.test.client; -import io.github.cottonmc.cotton.gui.client.BackgroundPainter; +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; + +import io.github.cottonmc.cotton.gui.client.CottonClientScreen; import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.widget.TooltipBuilder; +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.WSlider; @@ -12,11 +20,6 @@ import io.github.cottonmc.cotton.gui.widget.WTiledSprite; import io.github.cottonmc.cotton.gui.widget.WWidget; import io.github.cottonmc.cotton.gui.widget.data.Axis; import io.github.cottonmc.cotton.gui.widget.data.Color; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; -import net.minecraft.util.Identifier; public class TestClientGui extends LightweightGuiDescription { //private static final Identifier PORTAL1 = new Identifier("libgui-test:portal.png"); @@ -101,7 +104,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, 7, 4, 1); root.validate(this); } |