Fix-position tooltip should also be clamped inside render area

This commit is contained in:
Noisyfox 2023-10-31 16:23:13 +08:00
parent c31e1f5229
commit d25780ae4a

View File

@ -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)
// 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.