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

Table with ImGuiTableFlags_ScrollY does not reserve horizontal space for vertical scrollbar #7651

Closed
bratpilz opened this issue Jun 3, 2024 · 1 comment

Comments

@bratpilz
Copy link

bratpilz commented Jun 3, 2024

Version/Branch of Dear ImGui:

Version 1.90.8 WIP, Branch: master

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Linux + GCC 12

Full config/build information:

Dear ImGui 1.90.8 WIP (19073)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=12
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.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:

When using ImGuiTableFlags_ScrollY in a table, no horizontal space gets reserved for the vertical scroll bar, causing the end of the table content to be cut off.

I think the issue lies in line 1494 of imgui_tables.cpp:

        const float decoration_size = table->TempData->AngledHeadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f);

If I change ImGuiTableFlags_ScrollX to ImGuiTableFlags_ScrollY here, the issue goes away, and this change makes sense to me since only a vertical scrollbar would need additional horizontal space.

Screenshots/Video:

Before change:
imgui-table-scrollbar-fit-issue

After change:
imgui-table-scrollbar-fit-fixed

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
	ImGui::Begin("Table Issue", 0, ImGuiWindowFlags_AlwaysAutoResize);
	// ImGui::TextUnformatted("<Extra widgets>");
	unsigned flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollY;
	if (ImGui::BeginTable("Table", 1, flags, ImVec2(0.0f, 100.0f)))
	  {
	    for (int i = 0; i < 100; ++i)
	      {
		ImGui::TableNextColumn();
		ImGui::Text("Row %02d - Loooooong text", i);
	      }
	    ImGui::EndTable();
	  }
	ImGui::End();
ocornut added a commit that referenced this issue Jun 3, 2024
…wouldn't correctly take account of inner scrollbar. (#7651)
ocornut added a commit to ocornut/imgui_test_engine that referenced this issue Jun 3, 2024
@ocornut
Copy link
Owner

ocornut commented Jun 3, 2024

Thanks for reporting this.
I have pushed a fix : a31aa68

For clarity, it specifically relates to how the table reports its ideal contents size to the auto-resizing parent container.

The problem is a little big more complex than meet the eyes and it's not impossible we would need to get back to this.
One issue is that the reports bubbling up into parents may create one frame glitches, we could technically pre-compute expected visibility of scrollbar ahead to reduce issues in this case.

Amended "table_reported_size" test:
ocornut/imgui_test_engine@0231200

@ocornut ocornut closed this as completed Jun 3, 2024
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

2 participants