GrpcPrint/TestClient/external/imgui/imgui_context_extensions.cpp
2024-05-11 17:43:38 +08:00

28 lines
687 B
C++

#include "imgui_context_extensions.h"
#include <stack>
static std::stack<ImGuiContext*> CONTEXT_STACK;
namespace ImGui {
void PushContextSwitch(ImGuiContext *newCtx) {
CONTEXT_STACK.push(ImGui::GetCurrentContext()); // save current context
ImGui::SetCurrentContext(newCtx); // perform context switch
}
void PopContextSwitch() {
if (CONTEXT_STACK.empty()) return;
ImGui::SetCurrentContext(CONTEXT_STACK.top()); // restore previous context
CONTEXT_STACK.pop();
}
ScopedContextSwitch::ScopedContextSwitch(ImGuiContext *newCtx) {
ImGui::PushContextSwitch(newCtx);
}
ScopedContextSwitch::~ScopedContextSwitch() {
ImGui::PopContextSwitch();
}
} // namespace ImGui