diff options
Diffstat (limited to 'src/testMod/java')
-rw-r--r-- | src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java | 1 | ||||
-rw-r--r-- | src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java index e15eb83..57c2790 100644 --- a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -53,6 +53,7 @@ public class LibGuiTestClient implements ClientModInitializer { .then(literal("config").executes(openScreen(client -> new ConfigGui(client.currentScreen)))) .then(literal("tab").executes(openScreen(client -> new TabTestGui()))) .then(literal("scrolling").executes(openScreen(client -> new ScrollingTestGui()))) + .then(literal("scrollbar").executes(openScreen(client -> new ScrollBarTestGui()))) .then(literal("insets").executes(openScreen(client -> new InsetsTestGui()))) .then(literal("textfield").executes(openScreen(client -> new TextFieldTestGui()))) .then(literal("paddings") diff --git a/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java new file mode 100644 index 0000000..efac9d5 --- /dev/null +++ b/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java @@ -0,0 +1,44 @@ +package io.github.cottonmc.test.client; + +import net.fabricmc.fabric.api.util.TriState; + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; +import io.github.cottonmc.cotton.gui.widget.WPlainPanel; +import io.github.cottonmc.cotton.gui.widget.WScrollBar; +import io.github.cottonmc.cotton.gui.widget.WToggleButton; +import io.github.cottonmc.cotton.gui.widget.data.Axis; +import io.github.cottonmc.cotton.gui.widget.data.Insets; + +public class ScrollBarTestGui extends LightweightGuiDescription { + private boolean darkMode = false; + + public ScrollBarTestGui() { + WPlainPanel root = new WPlainPanel(); + setRootPanel(root); + root.setSize(256, 240); + root.setInsets(Insets.ROOT_PANEL); + + WScrollBar scrollBar1 = new WScrollBar(Axis.HORIZONTAL); + root.add(scrollBar1, 0, 0, 256, 16); + + WScrollBar scrollBar2 = new WScrollBar(Axis.HORIZONTAL); + root.add(scrollBar2, 0, 240 - scrollBar2.getHeight(), 256, 8); + + WScrollBar scrollBar3 = new WScrollBar(Axis.VERTICAL); + root.add(scrollBar3, 0, 18, 16, 202); + + WScrollBar scrollBar4 = new WScrollBar(Axis.VERTICAL); + root.add(scrollBar4, 248, 18, 8, 202); + + WToggleButton toggleButton = new WToggleButton(); + toggleButton.setOnToggle(on -> darkMode = on); + root.add(toggleButton, 128 - (toggleButton.getWidth() / 2), 120 - (toggleButton.getHeight() / 2)); + + root.validate(this); + } + + @Override + public TriState isDarkMode() { + return TriState.of(darkMode); + } +} |