-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Labels
Description
Using ImGui v1.50.
For example,
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, ImColor(255, 0, 0));
ImGui::BeginChildFrame(123, ImVec2(300, 200));
ImGui::EndChildFrame();
ImGui::PopStyleColor();
The result is still a child frame with the default background color. Because the pushed style color is overridden in ImGui::BeginChildFrame
:
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
{
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]); //<---Here
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
return ImGui::BeginChild(id, size, (g.CurrentWindow->Flags & ImGuiWindowFlags_ShowBorders) ? true : false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags);
}
That's unexpected. And sure it will also happen when user trying to push ImGuiStyleVar_ChildWindowRounding
and ImGuiStyleVar_WindowPadding
. I think this is a pitfall of Push/Pop style APIs.
I know we can directly change Colors[ImGuiCol_ChildWindowBg]
to set the default background color. But what if one want to set different colors for several child frames?
IgorAherne