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 filter improvement for custom window classes #5977

Open
wants to merge 2 commits into
base: docking
Choose a base branch
from

Conversation

pyroics
Copy link

@pyroics pyroics commented Dec 10, 2022

Fixes an edge case with docking behaviours where a split node of unclassed windows could be allowed to dock with a DockSpace that explicitly disallows it.

Fixes an edge case with docking behaviours where a split node of unclassed windows could be allowed to dock with a DockSpace that explicitly disallows it.
@ocornut
Copy link
Owner

ocornut commented Dec 10, 2022

Thank you for the PR !
If you can, please provide a pseudo repro (general instructions to reproduce the fixed issue) to facilitate handling this.

@pyroics
Copy link
Author

pyroics commented Dec 10, 2022

Hi Ocornut -- first time ever contributing to a GIT project, so apologies for any newbie behaviours ;)

General steps to reproduce the problem:

// Define a window class that can be used to restrict docking into a DockSpace for only certain
// types of windows. Make sure that DockingAllowUnclassed is set to 'false' to ensure that other 
// default typed windows cannot dock.
ImGuiWindowClass MyClass;
MyClass.ClassId = 28383; // Or any random / hashed ID
MyClass.DockingAllowUnclassed = false;

// Create main viewport dock space, and ensure it has class for matching windows.
ImGui::DockSpaceOverViewport( NULL, 0, &MyClass );

// Create two separate normal windows that are unclassed.
ImGui::Begin("Undockable Window 1");
ImGui::End();
ImGui::Begin("Undockable Window 2");
ImGui::End();

// Create a third window with the same class as the DockSpace. This should be the only one that can be docked here?
ImGui::SetNextWindowClass( &MyClass );
ImGui::Begin("Dockable Window 1");
ImGui::End();

My expected behaviour (although correct me if I'm wrong) is that it should be impossible for the windows titled "Undockable Window" to dock with the main DockSpace, and only the one titled "Dockable Window" should be allowed as it shares a common class.

This is indeed the case by default, however if you dock the "Undockable Windows" together to form a split window, then it becomes possible to dock the combined window to the DockSpace even though both windows are unclassed.

Edit: to elaborate -- the main problem above is not that the unclassed windows can be docked together (this is expected, and wanted), however when those unclassed windows are combined together, it becomes possible to dock the entire grouped window to the outer DockSpace, even though it disallows it.

I'm only just getting a handle on how the docking logic works, so it's entirely possible that there are other cases that the naive fix I implemented doesn't cover, but it does appear to correct the immediate issue I was facing.

Your far more experienced thoughts definitely welcome!

By the way, this library is absolutely fantastic. Kudos, sincerely. Loving every part of it and keep up the fantastic work sir :)

@ocornut
Copy link
Owner

ocornut commented Jan 4, 2023

Hello,
It seems that many other things were pushed to this branch, making it difficult to focus on the PR feature itself.
In git, 1 pr = 1 branch. You may need to force-push to cleanup that branch.
Regards, and happy new year :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants