Page 1 of 1

[kovarex] [1.0.0] Setting certain elements to stretch leads to weird results

Posted: Thu Oct 15, 2020 8:56 pm
by Therenas
Sorry for the bad title, the situation is somewhat complex to explain in words. So, to save me a thousand words, a picture:

Image

I'm not going to try and explain the exact situation in words, as it requires a somewhat particular setup to exhibit this behavior. The attached mod creates both the problematic top version and the 'working' bottom one.

In very rough terms though, the difference between those two setups is that in the upper frame, the button is set to horizontally stretch, while it is not in the bottom one. For some reason, telling the button on top (which is in a different flow altogether than the table) to stretch makes the scroll pane that the table is in not stretch correctly. In essence, the top frame's table/scrollpane should stretch the same way the bottom one does, while still allowing me to set the button on the left to stretch.

Please feel free to ask any questions, the code should explain it somewhat well though.

Re: [1.0.0] Setting certain elements to stretch leads to weird results

Posted: Thu Oct 22, 2020 10:07 pm
by kovarex
We have a special tool to calculate the distribution of squash sizes between individual items, as some of them are squashable and some of them have some minimal sizes.
And I was thinking, well, maybe we should have this also for stretching, but we will probably never need that ....
And yes, we are avoiding this in the base game gui, but it was only question of time until someone would encounter it in the mod gui.

Just to explain the problem. The layouting algorithm figures the size available for stretching and evenly (naivly) distributes it between the two elements. But the algorithm doesn't account for the maximum size of the button, so it gets stretched much less than it was planned.

The fact that the button is in completely different flow and still affected by the logic is a feature specifically designed to work like that, so that the stretching works regardless of layouting structure.

But, it also depends what you need to do, if you don't want to stretch the button to fill the size of frame, but you only want to stretch it to fill the space relative to some other things that might be added into the flow, you might just mark the flow to not be stretchable, so the "stretching property" wont "leak" outside the flow.

Re: [kovarex] [1.0.0] Setting certain elements to stretch leads to weird results

Posted: Fri Oct 23, 2020 8:00 am
by Therenas
Thanks for the explanations, that's interesting! I (and Raiguard too) actually ran into this before several times, but always worked around it somehow. I just got the motivation to write a reproduction this time.

Re: [kovarex] [1.0.0] Setting certain elements to stretch leads to weird results

Posted: Sat Oct 24, 2020 12:59 pm
by kovarex
To be honest, I think it is not worth it, and almost always when this happens, you actually want some different behaviour, so I'm moving it to won't fix for now.