aquire and release

This commit is contained in:
2025-04-20 14:58:39 -05:00
parent c6fa731df0
commit d253ebb197
7 changed files with 78 additions and 45 deletions

View File

@@ -7,6 +7,8 @@
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
#include "modules/WindowModule/src/WindowModule.h"
class ImguiModule : public Archimedes::Module {
public:
@@ -20,12 +22,27 @@ class ImguiModule : public Archimedes::Module {
bool onEvent(const Archimedes::Event&) override;
ImGuiContext* getContext() { return context; }
ImGuiContext* aquireContext() {
contextRefs++;
return context;
}
void releaseContext(ImGuiContext* ctxt) {
if(ctxt == context && context != nullptr) {
if(--contextRefs == 0) {
app->stopModule(name);
}
}
}
private:
int contextRefs = 0;
ImGuiContext* context;
Archimedes::Window* window;
std::list<std::function<void()>>::iterator rcmd_it;
};