From 09ccbf97254d3efc1b7724f8ebdb0d64700642e0 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 6 Dec 2021 11:08:43 -0500 Subject: [PATCH] Add Factory Categories to the Category DropDown (#5579) 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 --- src/surge-xt/gui/overlays/PatchStoreDialog.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp index 4bacac51d34..3a9bbd11125 100644 --- a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp +++ b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp @@ -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(), @@ -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; }