Skip to content
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

Fix minimum size growing but not shrinking #77568

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,10 @@ void Control::_update_minimum_size() {
Size2 minsize = get_combined_minimum_size();
data.updating_last_minimum_size = false;

if (minsize != data.last_minimum_size) {
// If data.minimum_size_valid is still false after calling get_combined_minimum_size().
// This is usually because the child control's minimum size is determined automatically.
// Now it is an intermediate state and still needs to be negotiated.
if (minsize != data.last_minimum_size || !data.minimum_size_valid) {
data.last_minimum_size = minsize;
_size_changed();
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
Expand Down Expand Up @@ -1666,17 +1669,14 @@ void Control::_update_minimum_size_cache() {
minsize.x = MAX(minsize.x, data.custom_minimum_size.x);
minsize.y = MAX(minsize.y, data.custom_minimum_size.y);

bool size_changed = false;
if (data.minimum_size_cache != minsize) {
size_changed = true;
}
data.minimum_size_valid = true; // Reset to true anyway.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, update_minimum_size() would only be called when the minimum size has changed, but in reality the minimum size may not have changed.


if (data.minimum_size_cache == minsize) {
return;
}
data.minimum_size_cache = minsize;
data.minimum_size_valid = true;

if (size_changed) {
update_minimum_size();
}
update_minimum_size();
}

Size2 Control::get_combined_minimum_size() const {
Expand Down