feat: Added a much more flexible popup system

This commit is contained in:
WerWolv
2023-04-07 10:21:27 +02:00
parent 51e615095e
commit 9c9ac23818
7 changed files with 128 additions and 30 deletions

View File

@@ -11,6 +11,9 @@
#include <hex/helpers/logger.hpp>
#include <hex/helpers/stacktrace.hpp>
#include <hex/ui/view.hpp>
#include <hex/ui/popup.hpp>
#include <chrono>
#include <csignal>
#include <set>
@@ -520,6 +523,27 @@ namespace hex {
});
}
// Draw popup stack
{
if (auto &popups = PopupBase::getOpenPopups(); !popups.empty()) {
auto &currPopup = popups.back();
const auto &name = LangEntry(currPopup->getUnlocalizedName());
if (!ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId))
ImGui::OpenPopup(name);
bool open = true;
if (ImGui::BeginPopupModal(name, currPopup->hasCloseButton() ? &open : nullptr, currPopup->getFlags())) {
currPopup->drawContent();
ImGui::EndPopup();
}
if (!open)
popups.pop_back();
}
}
// Run all deferred calls
TaskManager::runDeferredCalls();