Sorry for the bad title, the situation is somewhat complex to explain in words. So, to save me a thousand words, a picture:
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.
[kovarex] [1.0.0] Setting certain elements to stretch leads to weird results
[kovarex] [1.0.0] Setting certain elements to stretch leads to weird results
- Attachments
-
- test.zip
- (2.11 KiB) Downloaded 99 times
Re: [1.0.0] Setting certain elements to stretch leads to weird results
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.
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
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
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.