You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My Issue/Question:
I'm using a pannable virtual space for my application, basically being able to place windows within a larger virtual viewport than the viewport of the OS window and then being able to move the currently shown portion around with a minimap similar to the one under Viewports->Window Minimap in the metrics window. The way I have implemented this is to move the positions of all my windows when I change which part I'm viewing. This works nicely, the only trouble I've run into is that somewhere in Begin(), the position of each window gets clamped so that it is at least partially within the viewport bounds. This leads to any window not currently within the shown portion of my pannable space to have its position changed when I just need it to stay where it is for my use case.
I have currently added the new flag ImGuiConfigFlags_DoNotClampWindows to work around this. The full patch is as follows:
diff --git a/imgui.cpp b/imgui.cpp
index c783450c0..4db27d3ba 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -7843,7 +7843,10 @@ boolImGui::Begin(constchar* name, bool* p_open, ImGuiWindowFlags flags)
{
if (!window->ViewportOwned && viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
{
- ClampWindowPos(window, visibility_rect);
+ if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DoNotClampWindows))
+ {
+ ClampWindowPos(window, visibility_rect);
+ }
}
elseif (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
{
diff --git a/imgui.h b/imgui.hindex ba5fd518c..1f2c26e6f 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1659,6 +1659,9 @@ enum ImGuiConfigFlags_
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
ImGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse.
+ // Virtual area for window placement
+ ImGuiConfigFlags_DoNotClampWindows = 1 << 30, // Allow windows to be dragged out of viewport bounds.
+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // [moved/renamed in 1.91.4] -> use bool io.ConfigNavMoveSetMousePos
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // [moved/renamed in 1.91.4] -> use bool io.ConfigNavCaptureKeyboard
If something like this could be merged into the code, that would make things easier for me. Of course the flag's value should probably not be 1 << 30 then.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered:
ocornut
changed the title
Feature request: Add a flag to disable clamping windows to viewport bounds, for use with a pannable virtual space
Add a flag to disable clamping windows to viewport bounds, for use with a pannable virtual space
Jan 9, 2025
Version/Branch of Dear ImGui:
Version v1.91.7 WIP, Branch: master
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux + GCC 12
Full config/build information:
Details:
My Issue/Question:
I'm using a pannable virtual space for my application, basically being able to place windows within a larger virtual viewport than the viewport of the OS window and then being able to move the currently shown portion around with a minimap similar to the one under Viewports->Window Minimap in the metrics window. The way I have implemented this is to move the positions of all my windows when I change which part I'm viewing. This works nicely, the only trouble I've run into is that somewhere in
Begin()
, the position of each window gets clamped so that it is at least partially within the viewport bounds. This leads to any window not currently within the shown portion of my pannable space to have its position changed when I just need it to stay where it is for my use case.I have currently added the new flag
ImGuiConfigFlags_DoNotClampWindows
to work around this. The full patch is as follows:If something like this could be merged into the code, that would make things easier for me. Of course the flag's value should probably not be
1 << 30
then.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: