From c4d7ec93187f6a325149947312440eb837dc19c2 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Thu, 22 Sep 2022 02:08:10 +0600 Subject: [PATCH] Fix issues with ImageList search --- src/utils/widget.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utils/widget.cpp b/src/utils/widget.cpp index b94e65b..1ddb868 100644 --- a/src/utils/widget.cpp +++ b/src/utils/widget.cpp @@ -285,13 +285,13 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo { if (Widget::ListBox("##Categories", data.m_Categories, data.m_Selected)) { - data.UpdateSearchList(favourites); + data.UpdateSearchList(favourites, getNameFunc, verifyFunc); } ImGui::SameLine(); } if (Widget::Filter("##Filter", data.m_Filter, TEXT("Window.Search"))) { - data.UpdateSearchList(favourites); + data.UpdateSearchList(favourites, getNameFunc, verifyFunc); } ImGui::PopItemWidth(); @@ -302,13 +302,21 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo Widget::TextCentered(TEXT("Menu.FavouritesNone")); } - float itemSz = imgSz.y/(imagesInRow+1); int imageCount = 1; - ImGuiListClipper clipper(data.m_nSearchList.size(), itemSz); + size_t totalSz = data.m_nSearchList.size(); + ImGuiListClipper clipper((totalSz > 3 ? totalSz/3 : totalSz), imgSz.y); while (clipper.Step()) { - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; ++i) + // hack to get clipper working with rowed items + size_t start = clipper.DisplayStart * imagesInRow; + size_t end = clipper.DisplayEnd * imagesInRow + imagesInRow; + for (size_t i = start; i < end; ++i) { + if (data.m_nSearchList.size() == i) + { + break; + } + std::string &text = std::get(data.m_nSearchList[i]).m_FileName; std::string &modelName = std::get(data.m_nSearchList[i]).m_ModelName; bool custom = std::get(data.m_nSearchList[i]).m_bCustom;