summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbesh81 <besh81@virgilio.it>2022-07-08 13:07:15 +0200
committerbesh81 <besh81@virgilio.it>2022-07-14 08:42:39 +0200
commit153086152eb3e43ff6965c5df064d4a58f77a8a2 (patch)
tree5330736246b509971b8449e7397891b08896669f
parent5fec0d232a41a6e99bf4e00222a88bce719637cc (diff)
Fixed bug in grid_container with hidden children
Fix a bug that occour when there are hidden children in grid_container. The visualization isn't correct due to a wrong calculation of max_col and max_row that mistakenly includes hidden children.
-rw-r--r--scene/gui/grid_container.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 6f8518a7b0..eaa6943ad2 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -41,8 +41,6 @@ void GridContainer::_notification(int p_what) {
int hsep = get_theme_constant(SNAME("h_separation"));
int vsep = get_theme_constant(SNAME("v_separation"));
- int max_col = MIN(get_child_count(), columns);
- int max_row = ceil((float)get_child_count() / (float)columns);
// Compute the per-column/per-row data.
int valid_controls_index = 0;
@@ -79,6 +77,9 @@ void GridContainer::_notification(int p_what) {
}
}
+ int max_col = MIN(valid_controls_index, columns);
+ int max_row = ceil((float)valid_controls_index / (float)columns);
+
// Consider all empty columns expanded.
for (int i = valid_controls_index; i < columns; i++) {
col_expanded.insert(i);