From f56fb016c5fd6154061543ac7163c642e3b84a2f Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sun, 15 Oct 2023 14:07:47 +0300 Subject: WButton: Make height freely adjustable --- .../java/io/github/cottonmc/cotton/gui/widget/WButton.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/main/java/io') 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) { -- cgit