mirror of
https://github.com/ocornut/imgui.git
synced 2025-01-18 17:24:09 +01:00
Viewports: fixed an issue where a window manually constrained to the main viewport while crossing over main viewport bounds isn't translated properly. (#7985)
Amend 967073ba3
This commit is contained in:
parent
8326dabe5e
commit
8040c02b32
@ -78,6 +78,8 @@ Other changes:
|
||||
|
||||
Docking+Viewports Branch:
|
||||
|
||||
- Viewports: fixed an issue where a window manually constrained to the main viewport while crossing
|
||||
over main viewport bounds isn't translated properly. (#7985)
|
||||
- Backends: SDL3: added support for viewport->ParentViewportId field to support parenting
|
||||
windows at OS level. (#7973) [@RT2code]
|
||||
|
||||
|
@ -15224,7 +15224,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window)
|
||||
|
||||
// Translate Dear ImGui windows when a Host Viewport has been moved
|
||||
// (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
|
||||
void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos)
|
||||
void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos, const ImVec2& old_size, const ImVec2& new_size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(viewport->Window == NULL && (viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows));
|
||||
@ -15238,7 +15238,7 @@ void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& o
|
||||
ImRect test_still_fit_rect(old_pos, old_pos + viewport->Size);
|
||||
ImVec2 delta_pos = new_pos - old_pos;
|
||||
for (ImGuiWindow* window : g.Windows) // FIXME-OPT
|
||||
if (translate_all_windows || (window->Viewport == viewport && test_still_fit_rect.Contains(window->Rect())))
|
||||
if (translate_all_windows || (window->Viewport == viewport && (old_size == new_size || test_still_fit_rect.Contains(window->Rect()))))
|
||||
TranslateWindow(window, delta_pos);
|
||||
}
|
||||
|
||||
@ -15415,7 +15415,7 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
// (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
|
||||
const ImVec2 viewport_delta_pos = viewport->Pos - viewport->LastPos;
|
||||
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (viewport_delta_pos.x != 0.0f || viewport_delta_pos.y != 0.0f))
|
||||
TranslateWindowsInViewport(viewport, viewport->LastPos, viewport->Pos);
|
||||
TranslateWindowsInViewport(viewport, viewport->LastPos, viewport->Pos, viewport->LastSize, viewport->Size);
|
||||
|
||||
// Update DPI scale
|
||||
float new_dpi_scale;
|
||||
@ -15525,6 +15525,7 @@ static void ImGui::UpdateViewportsEndFrame()
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[i];
|
||||
viewport->LastPos = viewport->Pos;
|
||||
viewport->LastSize = viewport->Size;
|
||||
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
|
||||
if (i > 0) // Always include main viewport in the list
|
||||
continue;
|
||||
@ -15571,7 +15572,7 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
|
||||
viewport->ID = id;
|
||||
viewport->Idx = g.Viewports.Size;
|
||||
viewport->Pos = viewport->LastPos = pos;
|
||||
viewport->Size = size;
|
||||
viewport->Size = viewport->LastSize = size;
|
||||
viewport->Flags = flags;
|
||||
UpdateViewportPlatformMonitor(viewport);
|
||||
g.Viewports.push_back(viewport);
|
||||
|
@ -1968,6 +1968,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
int LastFocusedStampCount; // Last stamp number from when a window hosted by this viewport was focused (by comparing this value between two viewport we have an implicit viewport z-order we use as fallback)
|
||||
ImGuiID LastNameHash;
|
||||
ImVec2 LastPos;
|
||||
ImVec2 LastSize;
|
||||
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
||||
float LastAlpha;
|
||||
bool LastFocusedHadNavWindow;// Instead of maintaining a LastFocusedWindow (which may harder to correctly maintain), we merely store weither NavWindow != NULL last time the viewport was focused.
|
||||
@ -3411,7 +3412,7 @@ namespace ImGui
|
||||
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
||||
|
||||
// Viewports
|
||||
IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos);
|
||||
IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos, const ImVec2& old_size, const ImVec2& new_size);
|
||||
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
|
||||
IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport);
|
||||
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||
|
Loading…
x
Reference in New Issue
Block a user