ocornut / imgui

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

Viewports: Unexpected Modal/Popup/Viewport Behavior #2937

Open eclbtownsend opened 4 years ago

eclbtownsend commented 4 years ago
Dear ImGui 1.73 (17300)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: _WIN32
define: _WIN64
define: _MSC_VER=1912
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000441
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMemoryCompactTimer = 60.0f
io.BackendFlags: 0x0000140A
 HasMouseCursors
 PlatformHasViewports
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 6 fonts, Flags: 0x00000000, TexSize: 2048,2048
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 12.00,12.00
style.WindowBorderSize: 1.00
style.FramePadding: 8.00,4.00
style.FrameRounding: 2.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

My Issue/Question:

When a modal window is hosted within a shared viewport, everything works fine. However, if the modal window escapes into a single-window viewport, two main issues begin to happen:

Screenshots/Video

modalproblems

Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)

   if(ImGui::Begin("Modal Test")){
      if (ImGui::Button("Open a modal popup")) {
         ImGui::OpenPopup("dlginline");
      }
      if (ImGui::BeginPopupModal("dlginline")) {
         ImGui::Text("popup!");
         if (ImGui::BeginCombo("test", "combooooooooo")) {
            for (int i = 0; i < 100; ++i) {
               ImGui::MenuItem("item");
            }
            ImGui::EndCombo();
         }
         if (ImGui::Button("close")) ImGui::CloseCurrentPopup();
         ImGui::EndPopup();
      }
   }
   ImGui::End();
eclbtownsend commented 4 years ago

Some additional testing notes (because i'm always skeptical of SDL2), This issue was first noticed on SDL2 backend with OpenGL3 Renderer but I decided to try this out in the latest revision of the docking branch on different renderer/platform combinations in the examples folder:

ocornut commented 4 years ago

Thank you Brandon for the report, I have confirmed those now. It looks like they are two very different issues.

Issue 1: Modal going behind The Win32 back-end honor parent<>child relationship which are applied at the OS level. I don't have GLFW/SDL expose this so one solution would be to hardcode workaround on a per OS basis (it wouldn't be tempting to do it for Windows).

Regardless of this, the secondary issue at hand is that we are not able to move/resize the whitened window or select the underlying windows with ALT-TAB.

Issue 2: Gray overlay on child popup Should hopefully be easier to fix.

eclbtownsend commented 4 years ago

Thanks for taking a look!