Skip to content

Update ImGuiExt's custom styling to support - #2707

Open
shewitt-au wants to merge 14 commits into
WerWolv:masterfrom
shewitt-au:imguiext-param-stack
Open

Update ImGuiExt's custom styling to support#2707
shewitt-au wants to merge 14 commits into
WerWolv:masterfrom
shewitt-au:imguiext-param-stack

Conversation

@shewitt-au

@shewitt-au shewitt-au commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Desciption

Update ImGuiExt's custom styling to support the ImGui Push* and Pop* methods for custom colours and styling.

Dependencies

libwolv
pattern_language

Example

You can now do this:

ImGuiExt::PushCustomColor(ImGuiCustomCol_DescButton, IM_COL32(255, 0, 0, 255)); // Added
if (ImGuiExt::BeginSubWindow("hex.builtin.welcome.header.customize"_lang, nullptr, ImVec2(ImGui::GetContentRegionAvail().x - windowPadding, 0), ImGuiChildFlags_AutoResizeX)) {
    if (ImGuiExt::DescriptionButton("hex.builtin.welcome.customize.settings.title"_lang, "hex.builtin.welcome.customize.settings.desc"_lang, ICON_VS_SETTINGS_GEAR, ImVec2(ImGui::GetContentRegionAvail().x, 0)))
        RequestOpenWindow::post("Settings");
}
ImGuiExt::EndSubWindow();
ImGuiExt::PopCustomColor(); // Added

And get this ugliness:

image

Implementaion Details

The following functions have been added to ImGuiExt. They behave as you would expect:

void PushCustomColor(ImGuiCustomCol idx, ImU32 col);
void PushCustomColor(ImGuiCustomCol idx, const ImVec4& col);
void PopCustomColor(int count = 1);

void PushStyle(ImGuiCustomStyle idx, float val);
void PushStyle(ImGuiCustomStyle idx, const ImVec2 &val);
void PopStyle(int count = 1);

For the custom colour functions the code was lifted and adapted from ImGui's.

The styling functions diverge from ImGui's. ImGui's implementaion is very low level and not easily extended. Instead I used std::variant as the storage in the style stack with some template voodoo. The voodoo was from previous PR I made that was merged, but I moved it into LibWolv. It can be easily extended to support types beyond float and ImVec2.

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

Successfully merging this pull request may close these issues.

1 participant