-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add a user-accessible BackgroundDrawList #545
Comments
Not answering the full question, FYI your code above for a naked window can be shortened:
I wouldn't mind some helper combination flag, e.g |
Thanks, the (...)_Naked flags combination would be helpful but could just be done on the user side I guess. |
… pattern it'll be easier to consider adding more (e.g. background draw list). (#545)
@esquellington Also note that 1.66 also introduced helper flags |
That's awesome, thanks! |
A simple feature request: having an API method ImGui::GetBackgroundDrawList() that returns an internal ImDrawList that is always rendered first at full display size, without any window overhead (context, scrollbars, alpha, etc...) just a list of primitives guaranteed to be rendered before any ImGui window.
The BackgroundDrawList would act as a global overlay on the user-drawn scene, but always remain behind ImGui windows and mouse cursor (the internal OverlayDrawList). There's a few use cases for this:
It was pointed out to me by @ocornut that the same effect can be achieved with a "naked window" (code below), however, this requires draw commands to be issued inside the specific Begin/End block, or switching to/from the "naked window" in the middle of user code that may want to issue both global background text/primitives and normal ImGui windows.
bool bOpened(true);
ImGui::PushStyleColor( ImGuiCol_WindowBg, ImVec4(0,0,0,0) );
ImGui::Begin("BCKGND",&bOpened, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus );
ImGui::SetWindowPos( ImVec2(0,0), ImGuiSetCond_FirstUseEver );
ImGui::SetWindowSize( ImGui::GetIO().DisplaySize );
ImGui::SetWindowCollapsed( false );
ImGui::GetWindowDrawList()->AddText( ImVec2(400,400), ImColor(1.0f,1.0f,1.0f,1.0f), "Text in Background Layer" );
ImGui::End();
ImGui::PopStyleColor();
As a generalization, instead of a single BackgroundDrawList, it might be better to have an array of ordered background layers 0...N, retrieved with ImGui::GetLayerDrawList( int layer_id ), to which draw commands can be directly sent regardless of the current window stack state.
I have implemented basic ImGui::GetBackgroundDrawList() feature successfully in my local branch, and could work on the ImGui::GetLayerDrawList() generalization if it's considered better, but first I'd like to know if there's any interest/drawbacks on this becoming part of the ImGui API.
The text was updated successfully, but these errors were encountered: