mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Fix #100536: Control set_position resizes offsets/anchors
The set_position method computes the anchors/offsets to match a rectangle at the given position with size "size_cache". However, when the Control's combined minimum size is larger than the size obtained through the offsets and anchors, "size_cache" is set to be as large as the combined minimum size. Therefore, when position is set while the combined minimum size is larger than the rectangle given by the anchors and offsets, it would resize these two fields, which would then stop the Control from shrinking when its combined minimum size decreased. To fix this, set_position now uses the size given by the offsets and anchors instead of the "size_cache" field. This way, the rectangle denoted by the offsets and anchors is simply moved, without being resized, enabling the Control to shrink automatically when its combined minimum size decreases. I also added a test case to ensure that the Control shrinks correctly after setting its position while it has a larger custom minimum size than the one obtained through the offsets and anchors.
This commit is contained in:
parent
e585e6a3eb
commit
ca57fe1db4
3 changed files with 46 additions and 9 deletions
|
|
@ -300,6 +300,7 @@ private:
|
|||
|
||||
void _compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]);
|
||||
void _compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]);
|
||||
void _compute_edge_positions(Rect2 p_rect, real_t (&r_edge_positions)[4]);
|
||||
|
||||
void _set_layout_mode(LayoutMode p_mode);
|
||||
void _update_layout_mode();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue