Sort post-shaders alphabetically in the list.

This commit is contained in:
Henrik Rydgård 2022-12-03 18:58:47 +01:00
parent f651f365b0
commit f5c0dc717a
3 changed files with 23 additions and 12 deletions

View file

@ -50,18 +50,6 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
}
shaderInfo.clear();
ShaderInfo off{};
off.visible = true;
off.name = "Off";
off.section = "Off";
for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) {
off.settings[i].name.clear();
off.settings[i].value = 0.0f;
off.settings[i].minValue = -1.0f;
off.settings[i].maxValue = 1.0f;
off.settings[i].step = 0.01f;
}
shaderInfo.push_back(off);
textureShaderInfo.clear();
TextureShaderInfo textureOff{};
@ -231,6 +219,22 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
}
}
// Sort shaders alphabetically.
std::sort(shaderInfo.begin(), shaderInfo.end());
ShaderInfo off{};
off.visible = true;
off.name = "Off";
off.section = "Off";
for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) {
off.settings[i].name.clear();
off.settings[i].value = 0.0f;
off.settings[i].minValue = -1.0f;
off.settings[i].maxValue = 1.0f;
off.settings[i].step = 0.01f;
}
shaderInfo.insert(shaderInfo.begin(), off);
// We always want the not visible ones at the end. Makes menus easier.
for (const auto &info : notVisible) {
appendShader(info);

View file

@ -66,6 +66,12 @@ struct ShaderInfo {
bool operator == (const ShaderInfo &other) {
return name == other.name;
}
bool operator < (const ShaderInfo &other) {
if (name < other.name) return true;
if (name > other.name) return false;
return false;
}
};
struct TextureShaderInfo {

View file

@ -267,6 +267,7 @@ void DisplayLayoutScreen::CreateViews() {
postProcChoice_->OnClick.Add([=](EventParams &e) {
auto gr = GetI18NCategory("Graphics");
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i, false);
procScreen->SetHasDropShadow(false);
procScreen->OnChoice.Handle(this, &DisplayLayoutScreen::OnPostProcShaderChange);
if (e.v)
procScreen->SetPopupOrigin(e.v);