Skip to content

What is the best place to temporary change ImGuiCol_ModalWindowDimBg ? #7340

Closed
@pozemka

Description

Version/Branch of Dear ImGui:

v1.90.2 WIP

Back-ends:

imgui_impl_win32.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows 10

Full config/build information:

No response

Details:

Hello I am trying to create modal popup that disable interaction with the rest of the application elements but keep them perfectly visible for preview purposes. My first idea was to use following code:

ImGui::PushStyleColor(ImGuiCol_ModalWindowDimBg, ImVec4(0, 0, 0, 0));
if (ImGui::BeginPopupModal("MyPopup", nullptr) {
    ImGui::Text("Hello");
    if (ImGui::Button("OK")) { 
        ImGui::CloseCurrentPopup(); 
    }
    ImGui::EndPopup();
}
ImGui::PopStyleColor();

But it seems that dimmed background is drawn outside of popup's begin-end and not affected by this PushStyleColor.

If I change color in style globally it does work but I want to other popups to have dimmed background.

ImGuiStyle& style = ImGui::GetStyle();
style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0, 0, 0, 0);

So the question is how to change ImGuiCol_ModalWindowDimBg only for one popup?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions