From d25780ae4a9b376fee5743c45b9bb99cb1477779 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 31 Oct 2023 16:23:13 +0800 Subject: [PATCH] Fix-position tooltip should also be clamped inside render area --- src/imgui/imgui.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/imgui/imgui.cpp b/src/imgui/imgui.cpp index fd32e4cf5f..8f45263a39 100644 --- a/src/imgui/imgui.cpp +++ b/src/imgui/imgui.cpp @@ -6046,8 +6046,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->Pos = FindBestWindowPosForPopup(window); else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize) window->Pos = FindBestWindowPosForPopup(window); - else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip) - window->Pos = FindBestWindowPosForPopup(window); + // Orca: Allow fixed tooltip pos while still being clamped inside the render area + else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_is_child_tooltip) { + if (window_pos_set_by_api) { + // Hack: add ImGuiWindowFlags_Popup so it does not follow cursor + ImGuiWindowFlags old_flags = window->Flags; + window->Flags |= ImGuiWindowFlags_Popup; + window->Pos = FindBestWindowPosForPopup(window); + window->Flags = old_flags; + } else { + window->Pos = FindBestWindowPosForPopup(window); + } + } // Calculate the range of allowed position for that window (to be movable and visible past safe area padding) // When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect.