GUI Sort Fix (#278)

Co-authored-by: Megumumpkin <megumumpkin@gmail.com>
This commit is contained in:
Megumumpkin
2021-07-10 18:02:35 +07:00
committed by GitHub
parent 93a5763d03
commit 40cafdf455
2 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -44,9 +44,11 @@ void wiGUI::Update(const wiCanvas& canvas, float dt)
}
}
std::sort(widgets.begin(), widgets.end(), [](const wiWidget* a, const wiWidget* b) {
return a->priority < b->priority;
});
if(priority > 0) //Sort only if there are priority changes
//Use std::stable_sort instead of std::sort to preserve UI element order with equal priorities
std::stable_sort(widgets.begin(), widgets.end(), [](const wiWidget* a, const wiWidget* b) {
return a->priority < b->priority;
});
}
void wiGUI::Render(const wiCanvas& canvas, CommandList cmd) const
+5 -3
View File
@@ -1727,9 +1727,11 @@ void wiWindow::Update(const wiCanvas& canvas, float dt)
}
}
std::sort(widgets.begin(), widgets.end(), [](const wiWidget* a, const wiWidget* b) {
return a->priority < b->priority;
});
if(priority > 0) //Sort only if there are priority changes
//Use std::stable_sort instead of std::sort to preserve UI element order with equal priorities
std::stable_sort(widgets.begin(), widgets.end(), [](const wiWidget* a, const wiWidget* b) {
return a->priority < b->priority;
});
if (IsMinimized())
{