From 218f2846785e2b92442b4dc28c2a52cc81312b89 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 17 Aug 2021 13:39:46 +0200 Subject: [PATCH] nodes: Move ImNodes initialization to window class --- source/window.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/window.cpp b/source/window.cpp index 4ef519b4d..4ab026ae3 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -697,6 +697,7 @@ namespace hex { GImGui = ImGui::CreateContext(); GImPlot = ImPlot::CreateContext(); + GImNodes = ImNodes::CreateContext(); ImGuiIO& io = ImGui::GetIO(); ImGuiStyle& style = ImGui::GetStyle(); @@ -731,6 +732,14 @@ namespace hex { io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; + ImNodes::PushAttributeFlag(ImNodesAttributeFlags_EnableLinkDetachWithDragClick); + ImNodes::PushAttributeFlag(ImNodesAttributeFlags_EnableLinkCreationOnSnap); + + { + static bool always = true; + ImNodes::GetIO().LinkDetachWithModifierClick.Modifier = &always; + } + io.UserData = new ImGui::ImHexCustomData(); if (this->m_globalScale != 0.0f) @@ -818,8 +827,12 @@ namespace hex { void Window::deinitImGui() { delete static_cast(ImGui::GetIO().UserData); + ImNodes::PopAttributeFlag(); + ImNodes::PopAttributeFlag(); + ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); + ImNodes::DestroyContext(); ImPlot::DestroyContext(); ImGui::DestroyContext(); }