summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoumcashier <122149176+coumcashier@users.noreply.github.com>2023-11-10 19:50:58 +0100
committerYuri Sizov <yuris@humnom.net>2023-11-10 19:54:31 +0100
commit1533292f090972a1324827a91141ae8d67f3b0de (patch)
tree303a1ca0006a495ee6fa1eb2574a5110cf2e8f5c
parentbdd9034ad05e1824ff5d9c750acd87caeafe6dca (diff)
downloadredot-engine-1533292f090972a1324827a91141ae8d67f3b0de.tar.gz
Fix storing invalid item height values in `ItemList`
The height of the last N items is incorrectly overwritten with the max height of first row (N = number of columns). This happen in the first iteration of the while loop. Moving this code inside if (all_fit) makes sure the last rows height is only updated at the end when max height (max_h) is calculated for the last row.
-rw-r--r--scene/gui/item_list.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 343301e9c4..02d44caa1c 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1431,11 +1431,11 @@ void ItemList::force_update_list_size() {
}
}
- for (int j = items.size() - 1; j >= 0 && col > 0; j--, col--) {
- items.write[j].rect_cache.size.y = max_h;
- }
-
if (all_fit) {
+ for (int j = items.size() - 1; j >= 0 && col > 0; j--, col--) {
+ items.write[j].rect_cache.size.y = max_h;
+ }
+
float page = MAX(0, size.height - theme_cache.panel_style->get_minimum_size().height);
float max = MAX(page, ofs.y + max_h);
if (auto_height) {