fix: Various issues with the new popup system

This commit is contained in:
WerWolv
2023-04-16 21:34:29 +02:00
parent 52925c99e8
commit 1690cd2740
18 changed files with 103 additions and 109 deletions

View File

@@ -31,7 +31,7 @@ namespace hex {
}
[[nodiscard]] virtual ImVec2 getMaxSize() const {
return { FLT_MAX, FLT_MAX };
return { 0, 0 };
}
[[nodiscard]] static std::vector<std::unique_ptr<PopupBase>> &getOpenPopups() {
@@ -50,30 +50,22 @@ namespace hex {
return this->m_modal;
}
static void close() {
if (s_openPopups.empty())
return;
TaskManager::doLater([]{
std::lock_guard lock(s_mutex);
ImGui::CloseCurrentPopup();
s_openPopups.pop_back();
});
void close() {
this->m_close = true;
}
static std::mutex& getMutex() {
return s_mutex;
[[nodiscard]] bool shouldClose() const {
return this->m_close;
}
protected:
static std::vector<std::unique_ptr<PopupBase>> s_openPopups;
static std::mutex s_mutex;
private:
std::string m_unlocalizedName;
bool m_closeButton, m_modal;
std::atomic<bool> m_close = false;
};
}
@@ -87,7 +79,8 @@ namespace hex {
public:
template<typename ...Args>
static void open(Args && ... args) {
std::lock_guard lock(s_mutex);
static std::mutex mutex;
std::lock_guard lock(mutex);
auto popup = std::make_unique<T>(std::forward<Args>(args)...);