Hi gang. I hope everyone’s having a decent summer.
https://www.babylonjs-playground.com/#I7LKJY#3
I have some curiosities… perhaps others can clear my mental fog.
At console - as a WARNING: Control (Name:skap1butt, UniqueId:14) is using width in percentage mode inside a horizontal StackPanel.
But, that width issue… causes the button to NOT display in the horz stackpanel within the orange-border rect. SO, at console, it’s really a SHOW-STOPPER (red) and not a warning (yellow), right?
That’s not important. What MIGHT BE important… is that I have set no width on the button. The warning is coming from DEFAULT width… and so is the failure to display. Gui system is causing the button to fail display and gen the warning.
Activate line 52, and the button appears.
I would THINK… that the button should appear WITHOUT needing a user-set width, also without a warning, and its width should be the full width of the rect (horz stackpanel would stretch width to 100% fit its rect container width). Yes?
Thoughts? I think I should be able to load-up that horz stack with no-width buttons, and they equally share the width of the rect. Bug? Normal? Wingnut stupidity festival? (thx for ideas/info/help)
update: Add toppanel.adaptWidthToChildren = true; … then width-less button displays, and acts as I wish, but still has warning. Interesting.
I introduced the warning with 4.0 because it is not possible to have a stackpanel (which height depends on its content) to host a control with a height set to percentage
Because: stack will ask control about its height and control will ask stack about its height and then we will all dance the stack overflow dance
All controls have a width and a height set to percentage by default and this is why I wanted to be vocal (a warning) when using with stackpanel. This is not ideal but I have no better idea while protecting the backward compat.
3 Likes
Ok, I think I understand, thx. (I am code-diving right now and that is also helping me see the issue.)
I assume you meant “width” for your reply, but I’m sure it applies to height for isVertical stacks, too.
https://www.babylonjs-playground.com/#I7LKJY#7
No button width, no adapt set.
The stackPanel-class ._postMeasure() is hijacked-in. Its call to super._postMeasure in line 74… is disabled. Not sure how to turn it on… without JS error.
Activate lines 33 & 34. Then, we still get warning, but button still displays.
User is still going to whine (like I am doing) about “Hey, I set no button width… so GUI system is causing its own warning.”
Yeah, this is a weird thing. I can’t see backwards compat FRR (far-reaching ramifications) very well. You can, though.
Could we make warning longer, perhaps? Tell user that it “MIGHT be caused by GUI system. Ensure you have non-percentage width setting on your stackpanel children, or set the stackpanel.adaptWidthToChildren = true;”
Too long of a warning, eh? nod. hmm. Interesting! (esp about WHY adaptWidthToChildren… fixes its display) Thanks for info on this, though.
1 Like