Translate Dear ImGui windows when a Host Viewport has been moved (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
| 15825 | // Translate Dear ImGui windows when a Host Viewport has been moved |
| 15826 | // (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!) |
| 15827 | void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos, const ImVec2& old_size, const ImVec2& new_size) |
| 15828 | { |
| 15829 | ImGuiContext& g = *GImGui; |
| 15830 | IM_ASSERT(viewport->Window == NULL && (viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows)); |
| 15831 | |
| 15832 | // 1) We test if ImGuiConfigFlags_ViewportsEnable was just toggled, which allows us to conveniently |
| 15833 | // translate imgui windows from OS-window-local to absolute coordinates or vice-versa. |
| 15834 | // 2) If it's not going to fit into the new size, keep it at same absolute position. |
| 15835 | // One problem with this is that most Win32 applications doesn't update their render while dragging, |
| 15836 | // and so the window will appear to teleport when releasing the mouse. |
| 15837 | const bool translate_all_windows = (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) != (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable); |
| 15838 | ImRect test_still_fit_rect(old_pos, old_pos + viewport->Size); |
| 15839 | ImVec2 delta_pos = new_pos - old_pos; |
| 15840 | for (ImGuiWindow* window : g.Windows) // FIXME-OPT |
| 15841 | if (translate_all_windows || (window->Viewport == viewport && (old_size == new_size || test_still_fit_rect.Contains(window->Rect())))) |
| 15842 | TranslateWindow(window, delta_pos); |
| 15843 | } |
| 15844 | |
| 15845 | // Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!) |
| 15846 | void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) |
nothing calls this directly
no test coverage detected