diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2021-02-27 16:58:33 +0200 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2021-02-27 16:58:33 +0200 |
commit | 0ad2ba61b8bebc8a47a04e2c858a60700aaa6d8b (patch) | |
tree | bc3d4665aefb7b518963cdd7841337031a7afb23 /GuiTest/src/main/java/io | |
parent | eca69cd75a986af22a18e48cd51861e92c70ca1e (diff) | |
download | LibGui-0ad2ba61b8bebc8a47a04e2c858a60700aaa6d8b.tar.gz LibGui-0ad2ba61b8bebc8a47a04e2c858a60700aaa6d8b.tar.bz2 LibGui-0ad2ba61b8bebc8a47a04e2c858a60700aaa6d8b.zip |
Add test gui for scroll panels
Diffstat (limited to 'GuiTest/src/main/java/io')
-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); } |