From dc31c565ef6cb417a6ea6502b45b3bd129c11c98 Mon Sep 17 00:00:00 2001 From: chyzman <32403637+chyzman@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:55:44 -0400 Subject: [PATCH 1/4] label directly from string --- src/main/java/io/wispforest/owo/ui/component/Components.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/io/wispforest/owo/ui/component/Components.java b/src/main/java/io/wispforest/owo/ui/component/Components.java index 765c4051..52594a2c 100644 --- a/src/main/java/io/wispforest/owo/ui/component/Components.java +++ b/src/main/java/io/wispforest/owo/ui/component/Components.java @@ -102,6 +102,10 @@ public static LabelComponent label(Text text) { return new LabelComponent(text); } + public static LabelComponent label(String string) { + return new LabelComponent(Text.literal(string)); + } + public static CheckboxComponent checkbox(Text message) { return new CheckboxComponent(message); } From a431b69a5534c397de31b1281b69e5a7a20d66d0 Mon Sep 17 00:00:00 2001 From: chyzman <32403637+chyzman@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:57:14 -0400 Subject: [PATCH 2/4] ParentComponent.alignCenter --- .../io/wispforest/owo/ui/core/ParentComponent.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java b/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java index 7d7daca3..4062d97b 100644 --- a/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java +++ b/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java @@ -49,6 +49,16 @@ default ParentComponent alignment(HorizontalAlignment horizontalAlignment, Verti return this; } + /** + * Set this component to align its children to the center + * + * @author chyzman + */ + default ParentComponent alignCenter() { + this.alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER); + return this; + } + /** * Set how this component should vertically arrange its children * From 4397d6f2900be2ac67a2d0e48fb4899d17c44f9a Mon Sep 17 00:00:00 2001 From: chyzman <32403637+chyzman@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:59:18 -0400 Subject: [PATCH 3/4] quick padding --- .../java/io/wispforest/owo/ui/core/ParentComponent.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java b/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java index 4062d97b..1462849a 100644 --- a/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java +++ b/src/main/java/io/wispforest/owo/ui/core/ParentComponent.java @@ -90,6 +90,15 @@ default ParentComponent alignCenter() { */ ParentComponent padding(Insets padding); + /** + * Set the internal padding of this component + * + * @param padding The new padding to use + */ + default ParentComponent padding(int padding) { + return this.padding(Insets.of(padding)); + } + /** * @return The internal padding of this component */ From b3bcdc8d705b1c4a082ed2189bd6a9c44af9514d Mon Sep 17 00:00:00 2001 From: chyzman <32403637+chyzman@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:02:56 -0400 Subject: [PATCH 4/4] the square update:tm: --- .../owo/ui/component/Components.java | 13 +++++++++ .../owo/ui/container/Containers.java | 28 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/io/wispforest/owo/ui/component/Components.java b/src/main/java/io/wispforest/owo/ui/component/Components.java index 52594a2c..9914d063 100644 --- a/src/main/java/io/wispforest/owo/ui/component/Components.java +++ b/src/main/java/io/wispforest/owo/ui/component/Components.java @@ -55,12 +55,20 @@ public static TextAreaComponent textArea(Sizing horizontalSizing, Sizing vertica return new TextAreaComponent(horizontalSizing, verticalSizing); } + public static TextAreaComponent textArea(Sizing sizing) { + return textArea(sizing, sizing); + } + public static TextAreaComponent textArea(Sizing horizontalSizing, Sizing verticalSizing, String text) { var textArea = new TextAreaComponent(horizontalSizing, verticalSizing); textArea.setText(text); return textArea; } + public static TextAreaComponent textArea(Sizing sizing, String text) { + return textArea(sizing, sizing, text); + } + // ------------------ // Default Components // ------------------ @@ -142,6 +150,8 @@ public static BoxComponent box(Sizing horizontalSizing, Sizing verticalSizing) { return new BoxComponent(horizontalSizing, verticalSizing); } + public static BoxComponent box(Sizing sizing) {return box(sizing, sizing);} + public static DropdownComponent dropdown(Sizing horizontalSizing) { return new DropdownComponent(horizontalSizing); } @@ -187,4 +197,7 @@ public static T createWithSizing(Supplier componentMake return component; } + public static T createWithSizing(Supplier componentMaker, Sizing sizing) { + return createWithSizing(componentMaker, sizing, sizing); + } } diff --git a/src/main/java/io/wispforest/owo/ui/container/Containers.java b/src/main/java/io/wispforest/owo/ui/container/Containers.java index 9ece7286..e9a905eb 100644 --- a/src/main/java/io/wispforest/owo/ui/container/Containers.java +++ b/src/main/java/io/wispforest/owo/ui/container/Containers.java @@ -16,22 +16,42 @@ public static GridLayout grid(Sizing horizontalSizing, Sizing verticalSizing, in return new GridLayout(horizontalSizing, verticalSizing, rows, columns); } + public static GridLayout grid(Sizing sizing, int rows, int columns) { + return grid(sizing, sizing, rows, columns); + } + public static FlowLayout verticalFlow(Sizing horizontalSizing, Sizing verticalSizing) { return new FlowLayout(horizontalSizing, verticalSizing, FlowLayout.Algorithm.VERTICAL); } + public static FlowLayout verticalFlow(Sizing sizing) { + return verticalFlow(sizing, sizing); + } + public static FlowLayout horizontalFlow(Sizing horizontalSizing, Sizing verticalSizing) { return new FlowLayout(horizontalSizing, verticalSizing, FlowLayout.Algorithm.HORIZONTAL); } + public static FlowLayout horizontalFlow(Sizing sizing) { + return horizontalFlow(sizing, sizing); + } + public static FlowLayout ltrTextFlow(Sizing horizontalSizing, Sizing verticalSizing) { return new FlowLayout(horizontalSizing, verticalSizing, FlowLayout.Algorithm.LTR_TEXT); } + public static FlowLayout ltrTextFlow(Sizing sizing) { + return ltrTextFlow(sizing, sizing); + } + public static StackLayout stack(Sizing horizontalSizing, Sizing verticalSizing) { return new StackLayout(horizontalSizing, verticalSizing); } + public static StackLayout stack(Sizing sizing) { + return stack(sizing, sizing); + } + // ------ // Scroll // ------ @@ -52,10 +72,18 @@ public static DraggableContainer draggable(Sizing horiz return new DraggableContainer<>(horizontalSizing, verticalSizing, child); } + public static DraggableContainer draggable(Sizing sizing, C child) { + return draggable(sizing, sizing, child); + } + public static CollapsibleContainer collapsible(Sizing horizontalSizing, Sizing verticalSizing, Text title, boolean expanded) { return new CollapsibleContainer(horizontalSizing, verticalSizing, title, expanded); } + public static CollapsibleContainer collapsible(Sizing sizing, Text title, boolean expanded) { + return collapsible(sizing, sizing, title, expanded); + } + public static OverlayContainer overlay(C child) { return new OverlayContainer<>(child); }