Skip to content

Commit

Permalink
Add Factory Categories to the Category DropDown (#5579)
Browse files Browse the repository at this point in the history
Put them at the end, do a sort, etc.... but basically this means
the dropdown is popupated even if you have no category

Closes #5572
  • Loading branch information
baconpaul authored Dec 6, 2021
1 parent 4d8cbb4 commit 09ccbf9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/surge-xt/gui/overlays/PatchStoreDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ struct PatchStoreDialogCategoryProvider : public Surge::Widgets::TypeAheadDataPr
int idx = 0;
for (auto &c : storage->patch_category)
{
if (!c.isFactory)
if (!c.isFactory || (idx < storage->firstThirdPartyCategory &&
c.name.find("Tutorial") == std::string::npos))
{
auto it = std::search(
c.name.begin(), c.name.end(), s.begin(), s.end(),
Expand All @@ -54,6 +55,21 @@ struct PatchStoreDialogCategoryProvider : public Surge::Widgets::TypeAheadDataPr
idx++;
}
}
// Now sort that res
std::sort(res.begin(), res.end(), [this](const auto &a, const auto &b) {
const auto pa = storage->patch_category[a];
const auto pb = storage->patch_category[b];

if (pa.isFactory == pb.isFactory)
{
return pa.name < pb.name;
}
else
{
// putting b here puts the user patches first
return pb.isFactory;
}
});
return res;
}

Expand Down

0 comments on commit 09ccbf9

Please sign in to comment.