Skip to content

Commit

Permalink
Sub-folder sorting
Browse files Browse the repository at this point in the history
Patches were sorted correctly as were categories, but in order to
enable sub-folders I construct an explicit child list in
categories. I do that before the patch sort and traverse it
at menu build time. That category list requires a sort to
display correctly.

Fixes surge-synthesizer#481


Former-commit-id: 9661a5d183197eb2ed7407969cb594123a27431d [formerly c13a481]
Former-commit-id: e83c07c6a79f4383ebb7c29f64d3c230ccb124f2
Former-commit-id: b1240d1c2b0d2bc4f1356c3a99409148e4fdb9f7
  • Loading branch information
baconpaul committed Feb 3, 2019
1 parent 920afb1 commit d25c20e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
** scanning for names; setting the 'root' to everything without a slash
** and finding the parent in the name map for everything with a slash
*/

std::map<std::string,int> nameToLocalIndex;
int idx=0;
for (auto &pc : local_patch_category)
Expand All @@ -368,6 +369,23 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
}
}

/*
** We need to sort the local patch category child to make sure subfolders remain
** sorted when displayed using the child data structure in the menu view.
*/

auto catCompare =
[this](const PatchCategory &c1, const PatchCategory &c2) -> bool
{
return _stricmp(c1.name.c_str(),c2.name.c_str()) < 0;
};
for (auto &pc : local_patch_category)
{
std::sort(pc.children.begin(), pc.children.end(), catCompare);
}



/*
** Then copy our local patch category onto the member and be done
*/
Expand Down

0 comments on commit d25c20e

Please sign in to comment.