aquire and release
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user