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
I have an issue with an imgui docking window. I am trying to create a right hand side docking window which is split in two horizontally. The split is set initially at 50/50, but it shouldn't matter, because I am changing the size of the node split depending on the content of the top docking window (or at least that's what I'm attempting to do)
This does sort of work, but not as I would expect it, and I don't know what to attribute the strange behaviour. The dock window is in fact changing the height of the split window, but it's not exactly taking my values into account, it's using some other parameters to determine what size the node should be. Also, I've observed some strange exponential height changes toward the extreme (ver small and very large dock size)
Is this logic supported, to scale the dock dynamically based on content? I want the card to always be fully visible in the Preview window, at the cost of the other docked window in that vertical split group
void Interface::drawCardWindow(const Card* card, const std::string& cardName) {
ImGui::Begin("Preview");
// Get the size of the preview window. We use it to set the texture size and update the dock node size.
ImVec2 windowSize = ImGui::GetWindowSize();
float width = windowSize.x;
float height = width * 1.395973154362416f;
if (ImGui::IsWindowDocked()) {
ImGuiID dockID = ImGui::GetWindowDockID();
ImGuiDockNode* dockNode = ImGui::DockBuilderGetNode(dockID);
if (dockNode) {
ImGui::DockBuilderSetNodeSize(dockID, ImVec2(width, height*1.5));
}
}
// Set the texture size based on the window size
ImGui::Image((void*)(intptr_t)card->getFrontTexture()->getID(), ImVec2(width - ImGui::GetStyle().WindowPadding.x * 2, height));
ImGui::End();
}
basically I get the window width,
multiply the width by the aspect ratio of the image to get the height,
and modify the dock window node size to match the height.
You may notice height*1.5 in the DockBuilderSetNodeSize, that's just because I was playing around with the values. Changing that value affects the initial placement of the split after loading the preview window, but doesn't affect anything once we start scaling the docking window horizontally
The text was updated successfully, but these errors were encountered:
I don't think you're missing anything, this isn't something that's currently straightforward to accomplish in the current iteration of the docking API. Improving this sort of situation is mentioned in section 6.5 of Omar's 10 year update.
(Also I can't speak for everyone who helps out around here, but I almost never reply to dock builder questions because they're just too situation-specific to answer quickly and they turn into support rabbit holes.)
My suggestion would be to make the card art fit to the window bounds rather than always filling the width.
Version/Branch of Dear ImGui:
v1.91.1 WIP Docking
Back-ends:
imgui_impl_sdl2.h, imgui_impl_opengl3.h
Compiler, OS:
Windows 64 mingw, windows 32 mingw, Linux 64 gcc, Linux 32 gcc, Emscripten llvm
Full config/build information:
Details:
I have an issue with an imgui docking window. I am trying to create a right hand side docking window which is split in two horizontally. The split is set initially at 50/50, but it shouldn't matter, because I am changing the size of the node split depending on the content of the top docking window (or at least that's what I'm attempting to do)
This does sort of work, but not as I would expect it, and I don't know what to attribute the strange behaviour. The dock window is in fact changing the height of the split window, but it's not exactly taking my values into account, it's using some other parameters to determine what size the node should be. Also, I've observed some strange exponential height changes toward the extreme (ver small and very large dock size)
Is this logic supported, to scale the dock dynamically based on content? I want the card to always be fully visible in the Preview window, at the cost of the other docked window in that vertical split group
Screenshots/Video:
vlc-record-2025-02-09-21h41m31s-2025-02-09.21-40-21.mkv-.mp4
Minimal, Complete and Verifiable Example code:
basically I get the window width,
multiply the width by the aspect ratio of the image to get the height,
and modify the dock window node size to match the height.
You may notice height*1.5 in the DockBuilderSetNodeSize, that's just because I was playing around with the values. Changing that value affects the initial placement of the split after loading the preview window, but doesn't affect anything once we start scaling the docking window horizontally
The text was updated successfully, but these errors were encountered: