Skip to content
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

Docking behavior on window resize #5802

Open
ypujante opened this issue Oct 20, 2022 · 5 comments
Open

Docking behavior on window resize #5802

ypujante opened this issue Oct 20, 2022 · 5 comments

Comments

@ypujante
Copy link
Contributor

Here are 2 screenshots showing the "problem"

When the window is "small" (~1280x700)
small

After stretching the window (~ 2275x1480)
big

I know I am putting "problem" in between quotes because I do not know if this is an actual problem with ImGui, expected behavior or an error on my part. What I would obviously like to happen is that as the window is stretched, each docked window is stretched proportionally and this is obviously not what is happening (in this instance, it seems that the top left window is stretched and the other are occupying the remaining space).

Am I using Docking improperly?

This is what my .ini file looks like:

[Window][DockSpaceViewport_11111111]
Pos=0,18
Size=1280,702
Collapsed=0

[Window][re-edit]
Pos=0,18
Size=389,367
Collapsed=0
DockId=0x00000007,0

[Window][Panel]
Pos=0,387
Size=1280,333
Collapsed=0
DockId=0x00000009,0

[Window][Panel Widgets]
Pos=391,18
Size=465,367
Collapsed=0
DockId=0x00000003,0

[Window][Widgets]
Pos=858,18
Size=247,367
Collapsed=0
DockId=0x00000001,0

[Window][Properties]
Pos=1107,18
Size=173,367
Collapsed=0
DockId=0x00000002,0

[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

[Window][Save | Warning]
Pos=374,310
Size=532,100
Collapsed=0

[Window][Log]
Pos=0,571
Size=1280,149
Collapsed=0
DockId=0x0000000A,0

[Window][values Editor]
Pos=266,171
Size=748,378
Collapsed=0

[Window][Debug]
Pos=357,308
Size=541,142
Collapsed=0

[Docking][Data]
DockSpace         ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,18 Size=1280,702 Split=Y
  DockNode        ID=0x00000005 Parent=0x8B93E3BD SizeRef=1280,367 Split=X Selected=0xE560F6EE
    DockNode      ID=0x00000007 Parent=0x00000005 SizeRef=389,351 CentralNode=1 Selected=0xE560F6EE
    DockNode      ID=0x00000008 Parent=0x00000005 SizeRef=889,351 Split=X Selected=0xC781E574
      DockNode    ID=0x00000003 Parent=0x00000008 SizeRef=465,351 Selected=0xC781E574
      DockNode    ID=0x00000004 Parent=0x00000008 SizeRef=422,351 Split=X Selected=0x939C4135
        DockNode  ID=0x00000001 Parent=0x00000004 SizeRef=247,351 Selected=0x939C4135
        DockNode  ID=0x00000002 Parent=0x00000004 SizeRef=173,351 Selected=0x199AB496
  DockNode        ID=0x00000006 Parent=0x8B93E3BD SizeRef=1280,333 Split=Y Selected=0xFFEA1EA4
    DockNode      ID=0x00000009 Parent=0x00000006 SizeRef=1280,182 Selected=0xFFEA1EA4
    DockNode      ID=0x0000000A Parent=0x00000006 SizeRef=1280,149 Selected=0x64F50EE5
Dear ImGui 1.89 WIP (18828)
--------------------------------

sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1933
define: _MSVC_LANG=201703
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------

io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000040
 DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------

io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,256
io.DisplaySize: 2560.00,1440.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------

style.WindowPadding: 16.00,16.00
style.WindowBorderSize: 1.00
style.FramePadding: 8.00,6.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 16.00,8.00
style.ItemInnerSpacing: 8.00,8.00
@ypujante
Copy link
Contributor Author

It's actually far worse if I make the window smaller as the UI gets completely unusable.

smaller

@ocornut
Copy link
Owner

ocornut commented Oct 21, 2022

Not a full answer as this has been covered elsewhere, but notice in your .ini file the "re-edit" node is marked as a CentralNode and we apply specific behavior to that node.

See this answer:
#5209 (comment)

Links #3168 #4334 #5209 #4516 ##2350

It's an open issue AFAIK, but you may be able to manually clear that flag in the node for now.

@ypujante
Copy link
Contributor Author

I edited the ini info to remove CentralNode=1 and it totally works and does what I was expecting. Thank you very much.

As a side note, I use ".ini strings" in my code like this (which have been generated by positioning the windows where I wanted and generating them):

constexpr char const *kDefaultHorizontalLayout = R"(
[Window][DockSpaceViewport_11111111]
Pos=0,18
Size=1280,702
Collapsed=0
// ... rest of the string
)";

constexpr char const *kDefaultVerticalLayout = R"(
[Window][DockSpaceViewport_11111111]
Pos=0,18
Size=1280,702
Collapsed=0
// ... rest of the string
)";

When the application boots I simply do something like:

ImGui::LoadIniSettingsFromMemory(kDefaultHorizontalLayout.c_str(), kDefaultHorizontalLayout.size());

This is really cool because I don't have to define all this values programmatically in my code.

And this allows me to have 2 menu options to swap between horizontal and vertical layout by simply calling ImGui::LoadIniSettingsFromMemory with the proper string...

And of course when the user saves the project I also save the current layout in the project file by retrieving it using ImGui::SaveIniSettingsToMemory()

This is working quite well for my use case!

@ocornut
Copy link
Owner

ocornut commented Oct 21, 2022

ini format is likely to be brittle. I understand this is attractive for many but you should be using the work-in-progress DockBuilderXXX api for this.

@howprice
Copy link

howprice commented Jul 2, 2024

It's an open issue AFAIK, but you may be able to manually clear that flag in the node for now.

I've just run into this issue myself. Trying to fix in code at dock build time. Is the below what you mean by clearing the flag? It seems to be working, but I'm concerned about the root pointer to the central node. Will this be handled in this case?

	...
	ImGui::DockBuilderFinish(mainDockNode);
	ImGuiDockNode* pCentralNode = ImGui::DockBuilderGetCentralNode(mainDockNode);
	ASSERT(pCentralNode->LocalFlags & ImGuiDockNodeFlags_CentralNode);
	pCentralNode->SetLocalFlags(pCentralNode->LocalFlags & ~ImGuiDockNodeFlags_CentralNode);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants