Skip to content

Commit

Permalink
WButton: Make height freely adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Oct 15, 2023
1 parent 693b838 commit f56fb01
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand Down Expand Up @@ -94,7 +93,7 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
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) {
Expand All @@ -106,15 +105,10 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
}*/

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) {
Expand Down

0 comments on commit f56fb01

Please sign in to comment.