diff options
Diffstat (limited to 'src/testMod/java/io/github/cottonmc')
-rw-r--r-- | src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java | 50 | ||||
-rw-r--r-- | src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java new file mode 100644 index 0000000..980e2c5 --- /dev/null +++ b/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java @@ -0,0 +1,50 @@ +package io.github.cottonmc.test.client; + +import io.github.cottonmc.cotton.gui.widget.WToggleButton; + +import io.github.cottonmc.cotton.gui.widget.data.Insets; + +import net.fabricmc.fabric.api.util.TriState; +import net.minecraft.text.Text; + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; +import io.github.cottonmc.cotton.gui.widget.WButton; +import io.github.cottonmc.cotton.gui.widget.WDynamicLabel; +import io.github.cottonmc.cotton.gui.widget.WGridPanel; +import io.github.cottonmc.cotton.gui.widget.WLabel; +import io.github.cottonmc.cotton.gui.widget.WLabeledSlider; +import io.github.cottonmc.cotton.gui.widget.WScrollBar; +import io.github.cottonmc.cotton.gui.widget.WSlider; +import io.github.cottonmc.cotton.gui.widget.WText; +import io.github.cottonmc.cotton.gui.widget.data.Axis; + +public final class DarkModeTestGui extends LightweightGuiDescription { + private boolean darkMode = false; + + public DarkModeTestGui() { + var root = new WGridPanel(20); + root.setInsets(Insets.ROOT_PANEL); + root.setGaps(3, 3); + + root.add(new WButton(Text.literal("Button A")), 0, 0, 3, 1); + root.add(new WButton(Text.literal("Button B")), 0, 1, 3, 1); + root.add(new WText(Text.literal("Text")), 0, 2, 3, 1); + root.add(new WLabeledSlider(1, 100, Text.literal("Slider A")), 3, 0, 3, 1); + root.add(new WSlider(1, 100, Axis.HORIZONTAL), 3, 1, 3, 1); + root.add(new WLabel(Text.literal("Label")), 3, 2, 3, 1); + root.add(new WScrollBar(Axis.HORIZONTAL), 0, 3, 3, 1); + root.add(new WDynamicLabel(() -> "Dynamic label: " + (darkMode ? "dark mode" : "light mode")), + 3, 3, 3, 1); + var toggle = new WToggleButton(Text.literal("Toggle button")); + toggle.setOnToggle(on -> darkMode = on); + root.add(toggle, 0, 4, 6, 1); + + root.validate(this); + setRootPanel(root); + } + + @Override + public TriState isDarkMode() { + return TriState.of(darkMode); + } +} 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 635040f..a8121fb 100644 --- a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -64,6 +64,7 @@ public class LibGuiTestClient implements ClientModInitializer { })))) .then(literal("#182").executes(openScreen(client -> new Issue182TestGui()))) .then(literal("#196").executes(openScreen(client -> new Issue196TestGui()))) + .then(literal("darkmode").executes(openScreen(client -> new DarkModeTestGui()))) )); } |