-
-
Notifications
You must be signed in to change notification settings - Fork 23.6k
Fix Control::_update_minimum_size() not updating offsets
#112525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This change will cause a regression when using anchors to have a control set to a relative size.
Keeping something a relative size with this change would require additional scripting to assign min size when sizes change when this is what anchors are designed for. I tried tackling this issue and the similar #100626 before, but ultimately figured that the desired behavior is possible without a change. To always keep a control at its min size is possible as long as the anchors are handled correctly. If the user keeps the anchored points (anchors + offsets) the same on an axis, then the control will always be its min size on that axis. So move while maintaining specific anchors, a user could use Maybe a |
Please test before reporting regressions. This uses node_2d.tscn.-.control.shrink.fix.-.Godot.Engine.2025-11-10.12-16-08.mp4node_2d.tscn.-.control.shrink.fix.-.Godot.Engine.2025-11-10.12-18-47.mp4
This is simply not an option. Moving the node in the editor uses |
|
I did test it, but I should have expected the confusion due to the exact steps I had to take to confirm the issue. I brought up the concern because of how difficult it'd be to realized what's going on if the stars aligned for someone unaware of this change.
Before: shrink.before.mp4After: shrink.after.mp4Here's the MRP project: Just open the project, select "relative child" and shrink its custom min size. With the change, offsets get changed despite expecting "relative child" to stay half the size of the parent. The MRP is vastly simplified, but it'd be possible to accidentally set up this scenario if "relative child" was a container with dynamic children or the parent changes size. Like I said, if a specialized function to set position isn't wanted, then I'm fine with the change with it put behind an |
|
I will look into seeing if that can be prevented with a code fix, otherwise I would also be in favor of introducing the by-axis setting. Edge cases suck |
96876bf to
292fe76
Compare
|
Managed to remove that edge case by adding a check for I still don't fully understand the conditions that could trigger this issue, so I fixed the one you pointed out, but I didn't know how else to try reaching that state. Please try the edge cases you can think of and let me know if the fix doesn't work for them.
This - if I understand it correctly - I couldn't "fix", but I ran it on master and the issue exists there already too. So I would be tempted to say it is a separate issue (namely, resizing the parent doesn't invalidate the child's cache, which should happen if the child is using anchor mode). ~ Backtested the updated PR on all previous tests I ran and it still performs as expected. |
|
Non-anchor MRP:
Although, this one can be worked around by setting the custom min size of "PanelContainer" to a desired size. The core of the edge cases is:
And there's plenty of ways for step 1 to happen by chance aside from the anchor + offset side effects from
I have a hunch that there's other cases I can't think of because it's a kind of generic requirement. |


GraphNodedoesn't shrink automatically #100536Before this PR, whenever
Control::set_positionorControl::set_sizewas called, they would "freeze" the container's minimum size by fixing its offsets. If the Container was made smaller by resizing/deleting a child node (e.g., anHBoxContainerwith a child deleted) afterset_positionorset_sizehad been called, it would not shrink to match the new expected size.This PR introduces an offset recalculation in
Control::_update_minimum_sizebefore_size_changed()is called, which fixes the issue.Before PR
node_2d.tscn.-.control.shrink.fix.-.Godot.Engine.2025-11-07.17-27-07.mp4
After PR
node_2d.tscn.-.control.shrink.fix.-.Godot.Engine.2025-11-07.17-29-01.mp4
Note: I don't know why the recordings are so messed up but they show the behavior and fix, so good enough for me