Skip to content

Commit

Permalink
Fixed expand/collapse category states
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed Feb 21, 2024
1 parent 75adaa1 commit b4ca4b4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6176,6 +6176,7 @@ SKIF_UI_Tab_DrawLibrary (void)
// TODO: Pinned on top has some large counting issues, e.g. disabling a platform or hiding games allows the user to bypass the 5 limit restriction

static int apply_header_state = 0;
bool new_header_state = false;

// Populate the list of games with all recognized games
for (auto& app : g_apps)
Expand Down Expand Up @@ -6298,19 +6299,15 @@ SKIF_UI_Tab_DrawLibrary (void)
if (ImGui::Selectable (SKIF_Util_FormatStringRaw ("Expand all###PopupExpand-%i", categories)))
{
apply_header_state = ImGui::GetFrameCount ( );

for (auto& category : _registry.vecCategories)
category.expanded = true;
new_header_state = true;

ImGui::CloseCurrentPopup ( );
}

if (ImGui::Selectable (SKIF_Util_FormatStringRaw ("Collapse all###PopupCollapse-%i", categories)))
{
apply_header_state = ImGui::GetFrameCount ( );

for (auto& category : _registry.vecCategories)
category.expanded = false;
new_header_state = false;

ImGui::CloseCurrentPopup ( );
}
Expand Down Expand Up @@ -6607,8 +6604,19 @@ SKIF_UI_Tab_DrawLibrary (void)
}
}

if (apply_header_state > 0 && ImGui::GetFrameCount ( ) > apply_header_state)
apply_header_state = 0;
if (apply_header_state > 0)
{
if (ImGui::GetFrameCount() == apply_header_state)
{
for (auto& category : _registry.vecCategories)
category.expanded = new_header_state;
}

else
{
apply_header_state = 0;
}
}

if (resetNumOnTop)
numPinnedOnTop = 0;
Expand Down

0 comments on commit b4ca4b4

Please sign in to comment.