godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.29k stars 21.05k forks source link

`Control::set_offsets_preset` ignores custom minimum size of the control #98186

Open Tictim opened 4 days ago

Tictim commented 4 days ago

Tested versions

v4.3.stable.mono.official [77dcf97d8]

System information

archlinux

Issue description

Relevant code

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

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.

Screenshot_20241015_053214

Gurka2 commented 1 day ago

I would like to give this issue a try, seems like a good first issue for me :slightly_smiling_face: