From 4bbdaa4e3c09688d58df472d76a91dcc5e2f90f3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 24 Jul 2016 11:56:36 +0200 Subject: [PATCH] Navigation: Moving NavInitWindow() around and making it static (#323) --- imgui.cpp | 36 ++++++++++++++++++------------------ imgui_internal.h | 1 - 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index c5322576e..8d51f5e73 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2265,6 +2265,24 @@ int ImGui::GetFrameCount() return GImGui->FrameCount; } +// This needs to be called before we submit any widget (aka in or before Begin) +static void NavInitWindow(ImGuiWindow* window) +{ + ImGuiContext& g = *GImGui; + if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastId == 0)) + { + g.NavId = window->NavLastId = 0; + g.NavInitDefaultRequest = true; + g.NavInitDefaultResultExplicit = false; + g.NavInitDefaultResultId = 0; + } + else + { + g.NavId = window->NavLastId; + } + g.NavWindow = window; +} + static ImVec2 NavCalcPreferredMousePos() { ImGuiContext& g = *GImGui; @@ -5059,24 +5077,6 @@ void ImGui::FocusWindow(ImGuiWindow* window) g.Windows.push_back(window); } -// This needs to be called before we submit any widget (aka in or before Begin) -void ImGui::NavInitWindow(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastId == 0)) - { - g.NavId = window->NavLastId = 0; - g.NavInitDefaultRequest = true; - g.NavInitDefaultResultExplicit = false; - g.NavInitDefaultResultId = 0; - } - else - { - g.NavId = window->NavLastId; - } - g.NavWindow = window; -} - void ImGui::PushItemWidth(float item_width) { ImGuiWindow* window = GetCurrentWindow(); diff --git a/imgui_internal.h b/imgui_internal.h index 6180891da..3da73debd 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -773,7 +773,6 @@ namespace ImGui IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing); - IMGUI_API void NavInitWindow(ImGuiWindow* window); IMGUI_API ImVec2 NavGetTweakDelta(); inline IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul) { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * alpha_mul; return ImGui::ColorConvertFloat4ToU32(c); }