godotengine / godotengine/godot
`Control::set_offsets_preset` ignores custom minimum size of the control
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.3.stable.mono.official [77dcf97d8]
### System information
archlinux
### Issue description
[Relevant code](https://github.com/godotengine/godot/blob/af77100e394dcaca609b15bef815ed17475e51ed/scene/gui/control.cpp#L1191)
In the method linked above, `get_minimum_size` method is used instead of combined minimum size, resulting in erroneous offset state after method call. Other methods that call this method with preset mode other than `PRESET_MODE_KEEP_SIZE`, notably `set_anchors_and_offsets_preset`, may also be affected by this issue.
### Steps to reproduce
Try to call the method on control with custom minimum size.
### Minimal reproduction project (MRP)
[offset-thing.zip](https://github.com/user-attachments/files/17369146/offset-thing.zip)
Simple side-by-side setup showing two rectangles being programmatically aligned with `set_anchors_preset` and `set_offsets_preset` call on `_ready`. (This is essentially identical to calling `set_anchors_and_offsets_preset`.) White area show the intended position of the rectangles getting aligned.
The red rectangle has custom min size of (100, 100) and default min size. The blue rectangle has no custom min size, but has min size of (100, 100) defined in code. The blue one is able to produce desired result, while the red one produces odd behavior.

Contributor guide
Research direction
Start in scene/gui/control.cpp at the linked set_offsets_preset implementation, then inspect set_anchors_and_offsets_preset and the related preset modes. Run the attached minimal reproduction project with controls using custom minimum sizes; done means preset calls produce the intended aligned positions without an erroneous offset state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100