aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2023-10-15 14:07:47 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2023-10-15 14:07:47 +0300
commitf56fb016c5fd6154061543ac7163c642e3b84a2f (patch)
treea6d9145c199452c8b6cdf21b1ce06595c52546a0
parent693b838fb4bd42cdd052fd8f0db008ebfba06374 (diff)
downloadLibGui-f56fb016c5fd6154061543ac7163c642e3b84a2f.tar.gz
LibGui-f56fb016c5fd6154061543ac7163c642e3b84a2f.tar.bz2
LibGui-f56fb016c5fd6154061543ac7163c642e3b84a2f.zip
WButton: Make height freely adjustable
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
index 5367483..a24f28a 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
@@ -21,7 +21,6 @@ import io.github.cottonmc.cotton.gui.widget.icon.Icon;
import org.jetbrains.annotations.Nullable;
public class WButton extends WWidget {
- private static final int BUTTON_HEIGHT = 20;
private static final int ICON_SPACING = 2;
@Nullable private Text label;
@@ -94,7 +93,7 @@ public class WButton extends WWidget {
context.drawGuiTexture(textures.get(enabled, hovered || isFocused()), x, y, getWidth(), getHeight());
if (icon != null) {
- icon.paint(context, x+ICON_SPACING, y+(BUTTON_HEIGHT-iconSize)/2, iconSize);
+ icon.paint(context, x+ICON_SPACING, y+(getHeight()-iconSize)/2, iconSize);
}
if (label!=null) {
@@ -106,15 +105,10 @@ public class WButton extends WWidget {
}*/
int xOffset = (icon != null && alignment == HorizontalAlignment.LEFT) ? ICON_SPACING+iconSize+ICON_SPACING : 0;
- ScreenDrawing.drawStringWithShadow(context, label.asOrderedText(), alignment, x + xOffset, y + ((20 - 8) / 2), width, color); //LibGuiClient.config.darkMode ? darkmodeColor : color);
+ ScreenDrawing.drawStringWithShadow(context, label.asOrderedText(), alignment, x + xOffset, y + ((getHeight() - 8) / 2), width, color); //LibGuiClient.config.darkMode ? darkmodeColor : color);
}
}
- @Override
- public void setSize(int x, int y) {
- super.setSize(x, BUTTON_HEIGHT);
- }
-
@Environment(EnvType.CLIENT)
@Override
public InputResult onClick(int x, int y, int button) {