Fix grid view sometimes dropping last row

As an important optimization, grid views skip items that are not in
view, and instead add empty space to the layout still has the right
dimensions (for scrolling). Calculations were off though, leading to the
last row being dropped when it had too few items to fill it completely.
This commit is contained in:
Julian Eisel
2023-07-13 13:03:39 +02:00
parent 9356e18d15
commit 80cc0dfef2

View File

@@ -329,9 +329,9 @@ void BuildOnlyVisibleButtonsHelper::fill_layout_after_visible(uiBlock &block) co
const int last_visible_idx = visible_items_range_.last();
if (last_item_idx > last_visible_idx) {
const int remaining_rows = (cols_per_row_ > 0) ?
(last_item_idx - last_visible_idx) / cols_per_row_ :
0;
const int remaining_rows = (cols_per_row_ > 0) ? ceilf((last_item_idx - last_visible_idx) /
float(cols_per_row_)) :
0;
BuildOnlyVisibleButtonsHelper::add_spacer_button(block, remaining_rows);
}
}