Closed pozemka closed 8 months ago
As far as I know there is no intended way to do this. You could add your own wrapper function to get the last window if you don't mind poking around in ImGui internals. If you want to do this, you will find the CurrentWindowStack
in the context structure. If a window has been ended and no new window has begun yet, you will find the window at the end iterator. You should add a few safeguards as well (check if stack size is smaller than capacity, check the last active frame of the window you find, check its parent against the current window), otherwise your function will give "random" results if used at a time other than between ending a window and beginning a new one.
Answer seems radically too literal. I think realistically the user shouldn't mind referring to that window identifier, so you can do:
ImGuiWindow* tool_window = ImGui::FindWindowByName("My Tools Window");
// then use tool_window->Pos, tool_window->Size.
I don't think it would be wise that we recorded the pointer/id of the "last" window:
showTools()
tool and break on potential reorganization of said function. So querying by identifier/name is better IMHO.
Version/Branch of Dear ImGui:
dear imgui, v1.90.2 WIP docking
Back-ends:
imgui_impl_win32.h + imgui_impl_dx11.h
Compiler, OS:
Windows 10 + MSVC 2022
Full config/build information:
No response
Details:
Hello I am experimenting with docking branch and trying to position one window next to another. Intent is to show window with help text next to related window.
Ideally I want something like this:
Question is how to get position and size of the last Begin-End displayed window? Sorry if I've missed something obvious.
For now my workaround is to save current window position (
ImGui::GetWindowPos()
) inside Begin-End and then reuse it later to position next window.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response