haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
346 stars 72 forks source link

Label height resizing after theme change, showing one character per line #650

Open AdamHarte opened 2 weeks ago

AdamHarte commented 2 weeks ago

When I change the theme in my app at runtime, some of my labels resize to having one character per line. It is not all labels, and seems to be related to having a space character, or maybe its just when the words wrap.

Default, before theme change: image

After clicking button to change theme: image

I have specifically using HaxeUI with Flixel, and targeting Flash (AIR). running with lime test flash

I made a minimal reproduction of the issue, starting from the haxeui flixel template: haxelib run haxeui-core create flixel. Then a custom layout, with a function to change the theme.

It looks like the buttons must have a fixed width for the error to happen.

Potential Fixes

I did find that the Label component in haxeui-core has an override of the calcAutoSize function. The Button calls this from its resizeChildren function when the theme changes. When I add a "+4" to the following line in calcAutoSize, it seems to fix my issue.

size.width += component.getTextDisplay().textWidth;

I know Flash always had issues with this textWidth (and textHeight) properties, and needed a buffer like this when using ActionScript. But I am not sure if this is a good final solution.

My example project: HaxeUIThemes.zip

Environment

AdamHarte commented 2 weeks ago

It seems to be an issue since this commit, but that maybe just exposed the issue more: 225c25b0a136e4c7498024dafbba5755741a4ff6

ianharrigan commented 2 days ago

hmmm, interesting... this is haxeui-flixel, correct?

AdamHarte commented 1 day ago

hmmm, interesting... this is haxeui-flixel, correct?

Yes, that is correct. I am currently working around it with the "+4" mentioned in the main description.