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

Disabling window management #7324

Open
katemonster33 opened this issue Feb 16, 2024 · 5 comments
Open

Disabling window management #7324

katemonster33 opened this issue Feb 16, 2024 · 5 comments

Comments

@katemonster33
Copy link

katemonster33 commented Feb 16, 2024

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
Copy link
Owner

ocornut commented Feb 16, 2024

There are multiple questions there.

  • _NoBringToFrontOnFocus will prevent some of it.
  • You can steal ownership or Ctrl-Tab shortcut away from nav system by calling Shortcut(ImGuiMod_Ctrl | ImGuiKey_Tab);

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

@PathogenDavid
Copy link
Contributor

PathogenDavid commented Feb 16, 2024

(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
Copy link
Author

katemonster33 commented Feb 16, 2024

@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
Copy link
Owner

ocornut commented Mar 4, 2024

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants