Skip to content

Commit

Permalink
Add DrawColoredText.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Apr 21, 2023
1 parent 51c350b commit ee7815a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ public static void TextShadowed(ImDrawListPtr drawList, Vector2 position, string
drawList.AddText(position, foregroundColor, text);
}

/// <summary> Draw a group of texts with colors without additional spacing between them in the same line. </summary>
public static void DrawColoredText(params (string, uint)[] data)
{
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
foreach (var (text, color) in data)
{
if (color == 0)
ImGui.TextUnformatted(text);
else
TextColored(color, text);
ImGui.SameLine();
}

ImGui.NewLine();
}


// Go to the next column, then enter text.
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
Expand Down

0 comments on commit ee7815a

Please sign in to comment.