From c42baf392a37e7621f473a16a60031b4a3a62022 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 13 Oct 2017 16:48:14 +0200 Subject: [PATCH] Reluctantly exposed GetActiveID(), GetHoveredID() in imgui_internal because the demo code will need it. --- imgui.cpp | 12 ++++++++++++ imgui_internal.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 20610e6ac..e856846ad 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1974,6 +1974,12 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) } } +ImGuiID ImGui::GetActiveID() +{ + ImGuiContext& g = *GImGui; + return g.ActiveId; +} + // Assume that SetFocusID() is called in the context where its NavLayer is the current window nav layer. void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) { @@ -2000,6 +2006,12 @@ void ImGui::SetHoveredID(ImGuiID id) g.HoveredIdAllowOverlap = false; } +ImGuiID ImGui::GetHoveredID() +{ + ImGuiContext& g = *GImGui; + return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; +} + void ImGui::KeepAliveID(ImGuiID id) { ImGuiContext& g = *GImGui; diff --git a/imgui_internal.h b/imgui_internal.h index 2528b2ec9..7f9ee7a1d 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -865,9 +865,11 @@ namespace ImGui IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead! IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); + IMGUI_API ImGuiID GetActiveID(); IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window); IMGUI_API void ClearActiveID(); IMGUI_API void SetHoveredID(ImGuiID id); + IMGUI_API ImGuiID GetHoveredID(); IMGUI_API void KeepAliveID(ImGuiID id); IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);