-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Prevent window collision when moving #8483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just a small thing. Deltas are usually the other way around: current value minus previous value. That way they correspond to the direction of movement and must be added instead of subtracted to update a value. It is functionally identical to your version with the flipped sign, but not following the norm might get confusing for someone else using your code. |
Fair enough, messed up my pan code and fixed it shortly after writing the issue, will edit to reduce confusion |
TLDRUse Example
Whyimgui.cpp (line: 7390)
How
|
I may be doing something wrong then, I end up unable to drag the window ( Your example with keys down is indeed what I had prior (with Although resizing the window down works fine and give me the updated position. And |
The key presses were just an example. You can’t move the window because you're constantly setting its position (otherwise, it would clamp). I didn't really think about dragging. As you already figured out in #8485, you'd need a new flag. |
So perhaps that the bug is actually the |
I took another look at your canvas and noticed some more problems. When using normal windows on your canvas, they are not clipped to your canvas. You are basically restricting yourself to non-docking ImGui with a full screen canvas. Even something small like a main menu above the canvas can break this. Your new flag to remove clamping would help only in this restricted scenario. So just as a suggestion: you should attempt to get your canvas working as an item inside of a window (which can itself span the entire viewport) and your windows as child windows, after all they are conceptually child windows to your canvas. That way you can use docking, multiple canvases in multiple windows and all that stuff. Child windows are clipped to their parent and also not subjected to clamping. You would need to implement window dragging for canvas windows yourself, but if you design your interface carefully you only need to do it once (f.e. in wrapper functions like |
It sounds interesting, but also a bit messy. If I am to implement my own dragging, won't I have to write some sort of docking support as well? Guess I will have to give the docking branch a check EDIT: |
I guess I was assuming your intentions for your canvas wrong. I was thinking of f.e. nodes in a node graph based on child windows in a canvas widget. Those wouldn't need full window functionality and would most likely be data driven, so adjusting draw order by sorting the issue order would be possible. Now I think I see what your intentions actually are. The canvas approach I described wouldn't fit that and docking with additional viewports most likely is not compatible with that idea either. While a truly infinite canvas isn't possible due to floating point precision issues, you could try to adjust |
Disclaimer I haven't read this thread nor the other carefully yet, but I have been meaning to add a concept of decorated child windows, aka windows that looks normal but are part of the boundaries of their parent. This would essentially allow for that. |
Yeah that would for sure be the ideal solution. For now, it seems that my hacked version works well enough. Except |
Uh oh!
There was an error while loading. Please reload this page.
Version/Branch of Dear ImGui:
master
Back-ends:
SDL3 + SDL_GPU
Compiler, OS:
Windows 11 MSVC
Full config/build information:
No response
Details:
I am making an infinite canvas application, and I wish to have ImGui windows over it, with the ability to be moved/resized and follow the camera.
I got it somewhat working with this simple solution (please tell me if there is a better way)
(Got the idea from #1604)
One problem however, seems that the window does not want to go out of view, which seem fair as a default since you do not want to lose track of it, but in my case it is mostly a nuisance.
Screenshots/Video:
ezyZip.mp4
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: