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

Bug with Experimental Feature: BeginComboPreview #6501

Closed
BobbyAnguelov opened this issue Jun 9, 2023 · 1 comment
Closed

Bug with Experimental Feature: BeginComboPreview #6501

BobbyAnguelov opened this issue Jun 9, 2023 · 1 comment
Labels

Comments

@BobbyAnguelov
Copy link

(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)

Version/Branch of Dear ImGui:

Dear ImGui 1.89.6 (18960)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1936
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00000443
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
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: 1264.00,761.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

Operating System: Windows11

My Issue/Question:

So this is super weird, but using the code below:

ImGui::Begin( "Repro" );
if ( ImGui::BeginChild( "DAS", ImVec2( -1, ImGui::GetFrameHeightWithSpacing() ) ) )
{
    ImGui::SetNextItemWidth( -1 );
    if ( ImGui::BeginCombo( "##Test", "", ImGuiComboFlags_CustomPreview ) )
    {
        ImGui::EndCombo();
    }

    if ( ImGui::BeginComboPreview() )
    {
        ImGui::Text( "Preview" );
        ImGui::EndComboPreview();
    }
}
ImGui::EndChild();
ImGui::End();

This works when the imgui window is on my main monitor but if I move it to a secondary monitor (to the left so negative x coords), then preview stops displaying due to the narrow test on line 1838 in imgui_widgets.cpp failing. Shouldn't that line read:

if (!window->ClipRect.Overlaps(preview_data->PreviewRect))

instead of

if (!window->ClipRect.Contains(preview_data->PreviewRect))

Changing that fixes the issue. Also this only seems to occur when you put the combo inside of a child window.

@ocornut
Copy link
Owner

ocornut commented Jun 9, 2023

You are correct. I have pushed your fix as a134892
(It's not merged in docking until a few days but I have confirmed it cherry-pick fines on docking, if you need a merge sooner let me know) merfged in docking since I had another fix pushed for something else.

Thank you for reporting and fixing!

PS: To clarify, it's not due to negative coordinates per se, but happened if the preview rectangle was not entirely contained within the parent window current clipping rectangle.

@ocornut ocornut closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants