ocornut / imgui

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

Disabling window management #7324

Open katemonster33 opened 9 months ago

katemonster33 commented 9 months ago

Version/Branch of Dear ImGui:

1.89.6

Back-ends:

imgui_impl_sdl2.cpp +imgui_impl_sdlrenderer2.cpp, imtui-impl-ncurses.cpp + imtui-impl-text.cpp

Compiler, OS:

MSVC, mac os/clang, linux/clang, linux/gcc

Full config/build information:

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=1934
define: _MSVC_LANG=201703
--------------------------------
io.BackendPlatformName: imgui_impl_sdl2
io.BackendRendererName: imgui_impl_sdlrenderer2
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: 1024,1024
io.DisplaySize: 1920.00,1137.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:

I want to disable window management. I want my windows to display in the order of the Begin() statements, and not allow mouse movements or Shift+Tab to change the order. I tried using BeginDisabled, and ImGuiWindowFlags_NoInput on windows that are not on top, but still I am able to use the mouse to put the disabled window over top of the enabled window. I understand what I am describing sounds ideal for Popups, but the way the game I am working on is coded, sometimes the "Popup" would be the only window shown. Is this possible currently?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
ocornut commented 9 months ago

There are multiple questions there.

I am not sure you can satisfy all your needs precisely but you can start there.

PathogenDavid commented 9 months ago

(Edit: Omar beat me to it 😅)

This feels very XY problem and feels like a very odd things to do, it'd help to know what exactly you're trying to accomplish (from a user perspective) and why.

That being said, if I am understanding you correctly you can accomplish most of what you want by passing ImGuiWindowFlags_NoBringToFrontOnFocus to ImGui::Begin.

However windows with that flag will automatically appear behind all other windows (which sounds like the opposite of what you're wanting.) You can manually bring them to the front as a workaround:

if (ImGui::IsWindowAppearing())
    ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());

(Note that BringWindowToDisplayFront and GetCurrentWindow are internal functions and require including imgui_internal.h)

katemonster33 commented 9 months ago

@PathogenDavid I am working on Cataclysm: Dark Days Ahead. My specific branch is here: https://github.com/katemonster33/Cataclysm-DDA/tree/imgui-integration we are overhauling the old ncurses based (terminal) UI with ImGui and there are lots of weird use cases I am trying to account for. For instance, the basic "dialog" window (a.k.a. a "yes/no/cancel/etc" dialog) can show the "keybindings" screen over itself if the user types the '?' key (the shortcut for keybindings) - this is in case the user needs to know which keybindings are supported on that particular dialog. The keybindings UI can also show a dialog. For this reason I implemented Cataclysm's dialog as a Window rather than a Popup.

The specific use case here is that the keybindings screen shows a dialog asking the user if they are sure they want to change a keybinding. The dialog displays at the center of the screen, and as a regular ImGui window, and because the windows are marked as not resizable or movable (by design), if the user clicks the keybindings screen while the popup is shown, the popup goes behind the keybindings screen and is not able to be re-focused.

ocornut commented 8 months ago

It might also correlate to manual z-order manipulation (#983 #1328) but we don't have a good solution for that yet. I think at some point we will as I've seen some orders using windows to track on-screen 3D object and they want to control their relative depth.

katemonster33 commented 8 months ago

We were able to solve the issue enough with the ImGuiWindowFlags_NoBringToFrontOnFocus flag .

We were actually able to get ImGui support merged into Cataclysm and you can see it in latest experimental builds on GH :) uses ImTui on Linux curses builds to draw using ncurses in a terminal, and SDL backend on everything else.

I think in a perfect world, what we would like is to set a boolean in ImGui to freeze the Z order of all windows to the order they are created in using Begin(). But, what we have right now works just fine.