Skip to content

Commit

Permalink
A few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shallowmallow committed Oct 15, 2024
1 parent 449efa8 commit 225c25b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions haxe/ui/components/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ class ButtonLayout extends DefaultLayout {
if (label != null) {
if (label.width > 0 && _component.componentWidth > 0 && ucx > 0 && label.width >= ucx) {
label.width = ucx;
} else if (label.width > 0 && _component.componentWidth > 0 && ucx > 0) {
// devezas so the label width "recovers" when dynamically (percent wise) we change the width of the button from lower (that has the text wrapped) to higher:
label.width = label.layout.calcAutoWidth();
}
}

Expand Down Expand Up @@ -248,7 +251,7 @@ class ButtonLayout extends DefaultLayout {
var label:Label = component.findComponent(Label, false);
var icon:Image = component.findComponent("button-icon", false);

if (label != null && icon == null){
if (label != null && (icon == null || icon.componentWidth == 0 || icon.componentHeight == 0)){
return Std.int((component.componentHeight / 2) - (label.componentHeight / 2)) + marginTop(label) - marginBottom(label);
}

Expand Down Expand Up @@ -298,7 +301,7 @@ class ButtonLayout extends DefaultLayout {
var icon:Image = component.findComponent("button-icon", false);
var textAlign = cast(component, Button).textAlign;

if (label != null && icon == null){
if (label != null && (icon == null || icon.componentWidth == 0 || icon.componentHeight == 0)){
return getTextAlignPos(label);
}

Expand Down

0 comments on commit 225c25b

Please sign in to comment.