mirror of
https://github.com/godotengine/godot.git
synced 2025-02-05 10:23:20 +00:00
Merge pull request #78009 from YuriSizov/gui-gently-massage-minimal-size
Ensure that controls update all their sizing information when required
This commit is contained in:
commit
1b5620d2a9
@ -34,8 +34,6 @@
|
|||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
|
|
||||||
void Container::_child_minsize_changed() {
|
void Container::_child_minsize_changed() {
|
||||||
//Size2 ms = get_combined_minimum_size();
|
|
||||||
//if (ms.width > get_size().width || ms.height > get_size().height) {
|
|
||||||
update_minimum_size();
|
update_minimum_size();
|
||||||
queue_sort();
|
queue_sort();
|
||||||
}
|
}
|
||||||
|
@ -1579,12 +1579,28 @@ Vector2 Control::get_pivot_offset() const {
|
|||||||
|
|
||||||
void Control::_update_minimum_size() {
|
void Control::_update_minimum_size() {
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
|
data.updating_last_minimum_size = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Control *invalidate = this;
|
Size2 minsize = get_combined_minimum_size();
|
||||||
|
data.updating_last_minimum_size = false;
|
||||||
|
|
||||||
|
if (minsize != data.last_minimum_size) {
|
||||||
|
data.last_minimum_size = minsize;
|
||||||
|
_size_changed();
|
||||||
|
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Control::update_minimum_size() {
|
||||||
|
ERR_MAIN_THREAD_GUARD;
|
||||||
|
if (!is_inside_tree() || data.block_minimum_size_adjust) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Invalidate cache upwards.
|
// Invalidate cache upwards.
|
||||||
|
Control *invalidate = this;
|
||||||
while (invalidate && invalidate->data.minimum_size_valid) {
|
while (invalidate && invalidate->data.minimum_size_valid) {
|
||||||
invalidate->data.minimum_size_valid = false;
|
invalidate->data.minimum_size_valid = false;
|
||||||
if (invalidate->is_set_as_top_level()) {
|
if (invalidate->is_set_as_top_level()) {
|
||||||
@ -1604,28 +1620,12 @@ void Control::_update_minimum_size() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2 minsize = get_combined_minimum_size();
|
|
||||||
data.updating_last_minimum_size = false;
|
|
||||||
if (minsize != data.last_minimum_size) {
|
|
||||||
data.last_minimum_size = minsize;
|
|
||||||
_size_changed();
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Control::update_minimum_size() {
|
|
||||||
ERR_MAIN_THREAD_GUARD;
|
|
||||||
if (!is_inside_tree() || data.block_minimum_size_adjust) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.updating_last_minimum_size) {
|
if (data.updating_last_minimum_size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.updating_last_minimum_size = true;
|
data.updating_last_minimum_size = true;
|
||||||
|
|
||||||
MessageQueue::get_singleton()->push_call(this, "_update_minimum_size");
|
MessageQueue::get_singleton()->push_callable(callable_mp(this, &Control::_update_minimum_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::set_block_minimum_size_adjust(bool p_block) {
|
void Control::set_block_minimum_size_adjust(bool p_block) {
|
||||||
@ -1665,17 +1665,8 @@ void Control::_update_minimum_size_cache() {
|
|||||||
minsize.x = MAX(minsize.x, data.custom_minimum_size.x);
|
minsize.x = MAX(minsize.x, data.custom_minimum_size.x);
|
||||||
minsize.y = MAX(minsize.y, data.custom_minimum_size.y);
|
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_cache = minsize;
|
data.minimum_size_cache = minsize;
|
||||||
data.minimum_size_valid = true;
|
data.minimum_size_valid = true;
|
||||||
|
|
||||||
if (size_changed) {
|
|
||||||
update_minimum_size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2 Control::get_combined_minimum_size() const {
|
Size2 Control::get_combined_minimum_size() const {
|
||||||
@ -3128,6 +3119,7 @@ void Control::_notification(int p_notification) {
|
|||||||
|
|
||||||
case NOTIFICATION_POST_ENTER_TREE: {
|
case NOTIFICATION_POST_ENTER_TREE: {
|
||||||
data.is_rtl_dirty = true;
|
data.is_rtl_dirty = true;
|
||||||
|
update_minimum_size();
|
||||||
_size_changed();
|
_size_changed();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -3243,10 +3235,13 @@ void Control::_notification(int p_notification) {
|
|||||||
|
|
||||||
case NOTIFICATION_THEME_CHANGED: {
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
emit_signal(SceneStringNames::get_singleton()->theme_changed);
|
emit_signal(SceneStringNames::get_singleton()->theme_changed);
|
||||||
|
|
||||||
_invalidate_theme_cache();
|
_invalidate_theme_cache();
|
||||||
_update_theme_item_cache();
|
_update_theme_item_cache();
|
||||||
update_minimum_size();
|
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
|
|
||||||
|
update_minimum_size();
|
||||||
|
_size_changed();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
@ -3255,7 +3250,8 @@ void Control::_notification(int p_notification) {
|
|||||||
get_viewport()->_gui_hide_control(this);
|
get_viewport()->_gui_hide_control(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_update_minimum_size();
|
update_minimum_size();
|
||||||
|
_size_changed();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -3263,8 +3259,12 @@ void Control::_notification(int p_notification) {
|
|||||||
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
|
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
|
||||||
if (is_inside_tree()) {
|
if (is_inside_tree()) {
|
||||||
data.is_rtl_dirty = true;
|
data.is_rtl_dirty = true;
|
||||||
|
|
||||||
_invalidate_theme_cache();
|
_invalidate_theme_cache();
|
||||||
_update_theme_item_cache();
|
_update_theme_item_cache();
|
||||||
|
queue_redraw();
|
||||||
|
|
||||||
|
update_minimum_size();
|
||||||
_size_changed();
|
_size_changed();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -3272,8 +3272,6 @@ void Control::_notification(int p_notification) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Control::_bind_methods() {
|
void Control::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_update_minimum_size"), &Control::_update_minimum_size);
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("accept_event"), &Control::accept_event);
|
ClassDB::bind_method(D_METHOD("accept_event"), &Control::accept_event);
|
||||||
ClassDB::bind_method(D_METHOD("get_minimum_size"), &Control::get_minimum_size);
|
ClassDB::bind_method(D_METHOD("get_minimum_size"), &Control::get_minimum_size);
|
||||||
ClassDB::bind_method(D_METHOD("get_combined_minimum_size"), &Control::get_combined_minimum_size);
|
ClassDB::bind_method(D_METHOD("get_combined_minimum_size"), &Control::get_combined_minimum_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user