ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.31k stars 10.33k forks source link

Child resizing separator overlaying child contents #8034

Open o-3-o opened 1 month ago

o-3-o commented 1 month ago

Version/Branch of Dear ImGui:

Version 1.91.2, Branch: docking

Back-ends:

imgui_impl_Win32.cpp + imgui_impl_DX11.cpp

Compiler, OS:

win11+vs2022

Full config/build information:

Dear ImGui 1.91.2 (19120)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: IMGUI_DISABLE_OBSOLETE_KEYIO
define: _WIN32
define: _WIN64
define: _MSC_VER=1941
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x0000C483
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
 DpiEnableScaleViewports
 DpiEnableScaleFonts
io.ConfigViewportsNoAutoMerge
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigDockingTransparentPayload
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 3440.00,1392.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:

BeginChild When ImGuiChildFlags_ResizeX is enabled, should the separator line be overlaid on the project element foreground?

Screenshots/Video:

无标题2

Minimal, Complete and Verifiable Example code:

    ImGui::SetNextWindowSize(ImVec2(100, 200));
    ImGui::Begin("##Main");
        ImGui::PushStyleColor(ImGuiCol_ChildBg,ImGui::GetColorU32(ImGuiCol_MenuBarBg));
        ImGui::BeginChild("##Child", ImVec2(45.0f, .0f), ImGuiChildFlags_ResizeX);
            ImGui::Text("LONG LONG LONG TEXT");
        ImGui::EndChild();
        ImGui::PopStyleColor();
    ImGui::End();
ocornut commented 1 month ago

This is essentially a byproduct of #7887 #7888 : border size don't affect layout and so a thick border (as the child window resizing border is) would overlap content.

In addition to that, windowing decorations are rendered first. (They are also displayed in parent window when possible to reduce amount of draw calls as the decoration needs same clipping rect as parent, but there is a mechanism to control that, we could set back render_decorations_in_parent=false in Begin() when borders are hovered. But it won't solve the problem enough)

I acknowledge this is an issue but it seems very minor and due to the complexity of the changes required it's unlikely to be a priority and it's unlikely to be fixed soon.

o-3-o commented 1 month ago

ok, I haven't read the internal code in depth, so I think using the foreground draw list to draw the border should solve the problem, but I don't know if there will be any side effects?

But it's actually harmless, there are still many ways to solve this small problem at the user level.

ocornut commented 1 month ago

ok, I haven't read the internal code in depth, so I think using the foreground draw list to draw the border should solve the problem, but I don't know if there will be any side effects?

Well that's pretty wrong, as it means e.g. hovering a border of a partially covered window would display the border over all other windows.

ocornut commented 1 month ago

I suppose that drawing specific window decorations at the end of the frame would also fit #2856.