FSUI: Don't move IMGUI cursor unnecessarily in DrawGameGrid()

This commit is contained in:
TheLastRar 2024-10-31 12:29:43 +00:00 committed by lightningterror
parent b95eb5cd74
commit e57f7d92c3

View File

@ -6224,13 +6224,23 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
SmallString draw_title;
u32 grid_x = 0;
ImGui::SetCursorPos(ImVec2(start_x, 0.0f));
for (const GameList::Entry* entry : s_game_list_sorted_entries)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems)
continue;
if (grid_x == grid_count_x)
{
grid_x = 0;
ImGui::SetCursorPosX(start_x);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing);
}
else
{
ImGui::SameLine(start_x + static_cast<float>(grid_x) * (item_width + item_spacing));
}
const ImGuiID id = window->GetID(entry->path.c_str(), entry->path.c_str() + entry->path.length());
const ImVec2 pos(window->DC.CursorPos);
ImRect bb(pos, pos + item_size);
@ -6283,16 +6293,6 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
}
grid_x++;
if (grid_x == grid_count_x)
{
grid_x = 0;
ImGui::SetCursorPosX(start_x);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing);
}
else
{
ImGui::SameLine(start_x + static_cast<float>(grid_x) * (item_width + item_spacing));
}
}
EndMenuButtons();