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

Menu window size is erroneously clamped to main viewport size #7730

Closed
arnaud-neny opened this issue Jun 24, 2024 · 4 comments
Closed

Menu window size is erroneously clamped to main viewport size #7730

arnaud-neny opened this issue Jun 24, 2024 · 4 comments
Labels

Comments

@arnaud-neny
Copy link

Version/Branch of Dear ImGui:

Version 1.90.8, Branch: docking

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx12.cpp

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

Dear ImGui 1.90.8 (19080)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1940
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx12
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: 120.00,11.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:

Hi!

There is an issue related only to the docking branch with the function CalcWindowAutoFitSize
It's always using the main viewport to define the size_max in some cases. One at least is happening here:

  • pop out the "Dear ImGui Demo" window
  • resize the main window until it has the smallest size possible
  • open "Menu" in the "Dear ImGui Demo"
  • go to any menu item with context such "Open Recent"

Thank you!

Screenshots/Video:

imgui

Minimal, Complete and Verifiable Example code:

No response

@arnaud-neny
Copy link
Author

This issue has been introduced in the 1.90.3

@ocornut ocornut changed the title Cropped popup/context from a menu Menu window size is erroneously clamped to main viewport size Jun 24, 2024
@ocornut
Copy link
Owner

ocornut commented Jun 24, 2024

Related to #7287, #7063

@ocornut
Copy link
Owner

ocornut commented Jun 24, 2024

I think the fix may be to use:

        const bool is_child_not_popup = (window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup);
        ImVec2 size_min = CalcWindowMinSize(window);
        ImVec2 size_max = (window->ViewportOwned || is_child_not_popup) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
        const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
        if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size && !is_child_not_popup)
            size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;

But I would need to add more tests for the past cases were stumbled into before validating this is good. It's currently too complex/subtle to understand the reasons behind that logic.

ocornut added a commit that referenced this issue Jun 27, 2024
…n viewport would be erroneously clamped to the size of main viewport. (#7730)

Amend #7287, #7063
@ocornut
Copy link
Owner

ocornut commented Jun 27, 2024

Should be fixed by a028c2d. Thanks for reporting!

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