Generalize list popup function

This commit is contained in:
Yousef Khadadeh 2025-12-01 18:12:22 +03:00
parent 303dac19a4
commit f227e074f8
3 changed files with 28 additions and 30 deletions

View file

@ -870,7 +870,7 @@ void GUIManager::paint_circle_popup_menu(const std::string& id, const Vector2f&
pop_id();
}
bool GUIManager::action_list_popup_menu(const std::string& id, Vector2f popupPos, const std::vector<std::pair<std::string, std::function<void()>>>& actions) {
void GUIManager::list_popup_menu(const std::string& id, Vector2f popupPos, const std::function<void()>& elemUpdate) {
push_id(id);
std::string& uniqueID = insert_any_with_id_with_function<std::string>(0, [&]() {
@ -886,8 +886,6 @@ bool GUIManager::action_list_popup_menu(const std::string& id, Vector2f popupPos
}
}
bool toRet = false;
CLAY({
.id = clayID,
.layout = {
@ -907,17 +905,10 @@ bool GUIManager::action_list_popup_menu(const std::string& id, Vector2f popupPos
}) {
obstructing_window();
push_id(1);
for(auto& [actionName, actionFunc] : actions) {
if(text_button_left_transparent(actionName, actionName)) {
actionFunc();
toRet = true;
}
}
elemUpdate();
pop_id();
}
pop_id();
return toRet;
}
void GUIManager::obstructing_window() {