feat: Add HelpMarker with custom icon (#1588)

This commit is contained in:
KazWolfe 2024-03-25 04:22:44 -07:00 committed by GitHub
parent eb5fa24101
commit d36106fa30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,11 +11,18 @@ public static partial class ImGuiComponents
/// HelpMarker component to add a help icon with text on hover. /// HelpMarker component to add a help icon with text on hover.
/// </summary> /// </summary>
/// <param name="helpText">The text to display on hover.</param> /// <param name="helpText">The text to display on hover.</param>
public static void HelpMarker(string helpText) public static void HelpMarker(string helpText) => HelpMarker(helpText, FontAwesomeIcon.InfoCircle);
/// <summary>
/// HelpMarker component to add a custom icon with text on hover.
/// </summary>
/// <param name="helpText">The text to display on hover.</param>
/// <param name="icon">The icon to use.</param>
public static void HelpMarker(string helpText, FontAwesomeIcon icon)
{ {
ImGui.SameLine(); ImGui.SameLine();
ImGui.PushFont(UiBuilder.IconFont); ImGui.PushFont(UiBuilder.IconFont);
ImGui.TextDisabled(FontAwesomeIcon.InfoCircle.ToIconString()); ImGui.TextDisabled(icon.ToIconString());
ImGui.PopFont(); ImGui.PopFont();
if (!ImGui.IsItemHovered()) return; if (!ImGui.IsItemHovered()) return;
ImGui.BeginTooltip(); ImGui.BeginTooltip();