imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Restoring position and size after undock

Open PointlessReboot opened this issue 6 years ago • 13 comments

Version/Branch of Dear ImGui:

Version: 1.69 Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: custom Compiler: vc++ 2017 Operating System: windows

My Issue/Question:

I was wondering if there is anyway to keep the undocked position/size, so when you undock it can restore it. I am doing this via code, but size would be nice when draging to undock also..

I had a look through and couldn't see anything obvious. If it's not any thoughts on how it might be implemented?

Cheers

PointlessReboot avatar May 23 '19 11:05 PointlessReboot

This has been requested for Size before so I'd assume it is desirable. I don't quite understand the purpose for Position since undocking is generally a manual dragging act.

Implement it would probably involve storing extra fields in ImGuiWindow and have them be stored in the .ini file. And/or technically speaking we might not need to store the current position/size in the .ini if we are being docked (as it will be rewritten by the docking), and we could consider just storing that undocked pos/size in the .ini file. So, save one or the other based on whether we are currently docked, and restore them when undocking.

ocornut avatar May 23 '19 18:05 ocornut

Hey, is there any progress on this?

wolfpld avatar May 03 '20 12:05 wolfpld

Hello,

I have a branch with it but last time I looked the flexible docking model of dear imgui made the concept of "undocked size" very ambiguous in certain use cases. I don't remember which right now, but I've recently been pinged on this topic elsewhere so I'm going to have a look at it.

ocornut avatar Jun 22 '20 11:06 ocornut

Yeah, this is not as simple as it looks. The basic expectation is that you have a window of given dimensions, which you dock somewhere, and it fills the available space. Then you undock it and the original window dimensions are restored.

Now, let's assume you have docked another window in the same place, to create a tabbed dock group. Then you undock the whole group. Which window size should be restored now? What happens when you break the dock group to have the two original windows?

wolfpld avatar Jun 22 '20 11:06 wolfpld

bump for status check (sorry)

codingus-g avatar Oct 16 '20 03:10 codingus-g

I'd like to see it too. This causes problem when undocking while in fullscreen mode, because now the window is outside the main viewport, so it's rendered in its own desktop window instead of being rendered inside the fullscreen one.

Nahor avatar Feb 21 '22 22:02 Nahor

You should probably disable multi-viewports when in fullscreen mode..

Also a few versions ago we added special code when undocking viewport-or-monitor sized window to slightly scale them down on undock to facilitate interactions.

ocornut avatar Feb 21 '22 23:02 ocornut

Multi-viewport is still useful when working with dual monitors:

  • an outside window for statistics and other "read-only" info about the main viewport (to not cover anything in the main viewport)
  • an inside-main-viewport window for interactive widgets (so the monitor doesn't need to switch between the fullscreen app and the desktop view constantly)

Nahor avatar Feb 21 '22 23:02 Nahor

Hello :)

Just wondering if this is being looked at or there are plans to be looked at sometime in the near future? I used to live with it until I got an ultrawide monitor, which magnifies the issue by a factor of 10 I'd say.

trapazza avatar Jul 31 '23 23:07 trapazza

Gave it a quick try that worked, apparently (I'm probably missing something of course): https://github.com/ocornut/imgui/assets/8068377/de89391b-a701-4fdf-a722-faf9786d597f

If anyone's insterested, that's the simple idea behind: image

trapazza avatar Aug 01 '23 00:08 trapazza

Attached is a WIP patch from June 2020, rebased on latest.

imgui-112a7a1-WIP preserve undocked size (2576).patch

It mostly appears to work at first glance but I am pretty sure there are ambiguous cases which are tricky to settle on and may cause user confusion. I'll make an effort to write them down here if I can remember them :)

ocornut avatar Aug 01 '23 06:08 ocornut

Note on the patch: the behavior described in imgui.cpp:4465/ImGui::StartMouseMovingWindowOrNode ("Alter pivot to project ourselves on undocked") wasn't working for me, I had to move it to imgui.cpp:16257/ImGui::DockNodeStartMouseMovingWindow.

JoshuaS3 avatar Sep 04 '23 01:09 JoshuaS3

I would find this feature useful as well. Docked windows in my use case are often either large or awkward shapes and if you are switching them from docked/undocked state it becomes cumbersome to always have to resize.

nickvonkaenel avatar Apr 05 '25 14:04 nickvonkaenel