From 56d93c083ae881fcb026e3d566a933337f1a5a98 Mon Sep 17 00:00:00 2001 From: aemony Date: Mon, 26 Feb 2024 22:42:46 +0100 Subject: [PATCH] ImGui: Added ImGuiCol_SKIF_Icon for styling icons --- include/imgui/imgui.h | 1 + src/imgui/imgui_widgets.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/imgui/imgui.h b/include/imgui/imgui.h index 3859284d..f4e6364d 100644 --- a/include/imgui/imgui.h +++ b/include/imgui/imgui.h @@ -1626,6 +1626,7 @@ enum ImGuiCol_ ImGuiCol_SKIF_Failure, // Red ImGuiCol_SKIF_Info, // Blue ImGuiCol_SKIF_Yellow, // Yellow + ImGuiCol_SKIF_Icon, // Used for icons in BeginMenuEx and MenuItemEx ImGuiCol_COUNT }; diff --git a/src/imgui/imgui_widgets.cpp b/src/imgui/imgui_widgets.cpp index 9d8cf165..f835e74f 100644 --- a/src/imgui/imgui_widgets.cpp +++ b/src/imgui/imgui_widgets.cpp @@ -7524,7 +7524,11 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y)); RenderText(text_pos, label); if (icon_w > 0.0f) + { + PushStyleColor (ImGuiCol_Text, GetColorU32(ImGuiCol_SKIF_Icon)); RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon); + PopStyleColor ( ); + } RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right); } if (!enabled) @@ -7731,7 +7735,11 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut { RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label); if (icon_w > 0.0f) + { + PushStyleColor (ImGuiCol_Text, GetColorU32(ImGuiCol_SKIF_Icon)); RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon); + PopStyleColor ( ); + } if (shortcut_w > 0.0f) { PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);