From 339b67c01a7f9b8c6910d9836c13f5d7135a50fc Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 20 Feb 2016 17:37:36 +0100 Subject: [PATCH] Exposed FindWindowByName() in imgui_internal.h --- imgui.cpp | 4 ++-- imgui.h | 4 ++-- imgui_internal.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 2c65efe4..04bd27a7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3459,9 +3459,9 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size, return pos; } -static ImGuiWindow* FindWindowByName(const char* name) +ImGuiWindow* ImGui::FindWindowByName(const char* name) { - // FIXME-OPT: Store sorted hashes -> pointers. + // FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block ImGuiState& g = *GImGui; ImGuiID id = ImHash(name, 0); for (int i = 0; i < g.Windows.Size; i++) diff --git a/imgui.h b/imgui.h index dbb7f854..5abc578b 100644 --- a/imgui.h +++ b/imgui.h @@ -146,8 +146,8 @@ namespace ImGui IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most - IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing - IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. may incur tearing + IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position. + IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus. diff --git a/imgui_internal.h b/imgui_internal.h index 54c777e0..a4caacff 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -675,6 +675,7 @@ namespace ImGui inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; } inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; } IMGUI_API ImGuiWindow* GetParentWindow(); + IMGUI_API ImGuiWindow* FindWindowByName(const char* name); IMGUI_API void FocusWindow(ImGuiWindow* window); IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);