Skip to content

Commit

Permalink
ImGui: Added ImGuiCol_SKIF_Icon for styling icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed Feb 26, 2024
1 parent 8082f91 commit 56d93c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/imgui/imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
8 changes: 8 additions & 0 deletions src/imgui/imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 56d93c0

Please sign in to comment.