From 80cc0dfef2b7c8b6452496183531c04bdbe1197e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 13 Jul 2023 13:03:39 +0200 Subject: [PATCH] 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. --- source/blender/editors/interface/views/grid_view.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index f8b1d42be15..936ff561067 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -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); } }