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

Using SubTables in repeated child windows used to work and now it doesnt #8226

Open
kalebs-anotheraxiom opened this issue Dec 12, 2024 · 1 comment

Comments

@kalebs-anotheraxiom
Copy link

Version/Branch of Dear ImGui:

Version v1.91.6 WIP, Branch: docking/stack layouts

Back-ends:

imgui_impl_XXX.cpp + imgui_impl_XXX.cpp

Compiler, OS:

Windows 11 + Unreal Engine

Full config/build information:

Dear ImGui 1.91.6 WIP (19151)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: _WIN32
define: _WIN64
define: _MSC_VER=1938
define: _MSVC_LANG=202002
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: NULL
io.BackendRendererName: NULL
io.ConfigFlags: 0x00000081
 NavEnableKeyboard
 DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00000000
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 1024,1024
io.DisplaySize: 2519.00,1815.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

My Issue/Question:
This code snippet used to work in an older version if ImGui and since updating doesn't.

Was what i was doing techincally not supposed to be possible and now the API has been corrected to make that impossible?
Or should what I'm doing still be possible

Im designing an custom items api that allows you to submit items to a Hierarchal structure and allow you to drag and drop, the api will handle all the complex table manipulation and adjusting the windows and stuff to give a convincing drag and drop experience

Screenshots/Video:

chrome_J0Zi4LpqPD

Minimal, Complete and Verifiable Example code:

                ImGui::Begin("TestingWindow");
		ImGui::BeginTable("Main Table", 1, ImGuiTableFlags_Borders);

		ImGui::TableNextColumn();
		ImGui::Text("MidText1");
		
		{
			ImGui::Begin("Sub Window");
			ImGui::BeginTable("Testing Table", 1, ImGuiTableFlags_Borders);
			ImGui::TableNextColumn();
			ImGui::Text("TestingText");
			ImGui::End();
		}
		ImGui::TableNextColumn();
		ImGui::Text("MidText2");
		{
			ImGui::Begin("Sub Window");
			ImGui::TableNextColumn();
			ImGui::Text("TestingText2");
			ImGui::EndTable();
			ImGui::End();
		}
		ImGui::TableNextColumn();
		ImGui::Text("MidText3");
		ImGui::EndTable();
		ImGui::End();
@ocornut
Copy link
Owner

ocornut commented Dec 13, 2024

Hello,

work in an older version if ImGui and since updating doesn't.

From which version?

Was what i was doing techincally not supposed to be possible and now the API has been corrected to make that impossible?

It's not 100% clear what's not working nor what you are expecting to be a "working" situation.
The screenshots seems unrelated to the provided code, and the description in the provided paragraph seems unrelated to the contents of code, so you are not making this easier.

That said, the code itself is unusual code that it is worth looking at.
AFAIK the only code that matter is:

{
    ImGui::Begin("Sub Window");
    ImGui::BeginTable("Testing Table", 1, ImGuiTableFlags_Borders);
    ImGui::TableNextColumn();
    ImGui::Text("TestingText");
    ImGui::End();
}
{
    ImGui::Begin("Sub Window");
    ImGui::TableNextColumn();
    ImGui::Text("TestingText2");
    ImGui::EndTable();
    ImGui::End();
}

Everything else seems unrelated to the issue.

First of all, out of clarity: names passed to Begin() are "absolute" in the sense that they are not derived from the ID Stack. So the first call to Begin("Sub Window") will create a window, and the second call to it will append to the already created window. But looking at the code I believe you already understood that.

1.91.3 added error recovery systems (main commit is 30c29d2) which among other things will automatically call EndTable() in End() to match the state at time of Begin() and should assert and report it as an error, is that what you are experiencing?

Indeed it is possible that this worked before but it was probably a little bit undefined behavior and prone to issues.
You could probably disable io.ConfigErrorRecovery for the whole duration of that setup, if it triggering is what's causing you problem (again, you didn't specify so I am guessing) but I honestly wouldn't recommend going that route.

It would be healthier to understand what precisely you are aiming to do so you can find alternative ways.

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

No branches or pull requests

2 participants