aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorBlazingTwist <39350649+BlazingTwist@users.noreply.github.com>2023-02-08 18:25:51 +0100
committerGitHub <noreply@github.com>2023-02-08 19:25:51 +0200
commit91e4e6401089d6dc5b92589fa1fb1501b7217cf0 (patch)
tree1911155ca1d4d215cf89fc41553d646392a772a7 /src/main/java/io
parent509850c97a828d721db9e5f968d888882dce2bfb (diff)
downloadLibGui-91e4e6401089d6dc5b92589fa1fb1501b7217cf0.tar.gz
LibGui-91e4e6401089d6dc5b92589fa1fb1501b7217cf0.tar.bz2
LibGui-91e4e6401089d6dc5b92589fa1fb1501b7217cf0.zip
Fix WBox Horizontal Offset (#184)
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java
index 5452b93..dd7e771 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java
@@ -78,16 +78,18 @@ public class WBox extends WPanelWithInsets {
int dimension = axis.choose(insets.left(), insets.top());
// Set position offset from alignment along the box axis
- if (axis == Axis.HORIZONTAL && horizontalAlignment != HorizontalAlignment.LEFT) {
- int widgetWidth = spacing * (children.size() - 1);
- for (WWidget child : children) {
- widgetWidth += child.getWidth();
- }
-
- if (horizontalAlignment == HorizontalAlignment.CENTER) {
- dimension = (getWidth() - widgetWidth) / 2;
- } else { // right
- dimension = getWidth() - widgetWidth;
+ if (axis == Axis.HORIZONTAL) {
+ if (horizontalAlignment != HorizontalAlignment.LEFT) {
+ int widgetWidth = spacing * (children.size() - 1);
+ for (WWidget child : children) {
+ widgetWidth += child.getWidth();
+ }
+
+ if (horizontalAlignment == HorizontalAlignment.CENTER) {
+ dimension = (getWidth() - widgetWidth) / 2;
+ } else { // right
+ dimension = getWidth() - widgetWidth;
+ }
}
} else if (verticalAlignment != VerticalAlignment.TOP) {
int widgetHeight = spacing * (children.size() - 1);