diff --git a/Dalamud/Interface/Components/ComponentDemoWindow.cs b/Dalamud/Interface/Components/ComponentDemoWindow.cs index 3751ddffa..6d5618bbd 100644 --- a/Dalamud/Interface/Components/ComponentDemoWindow.cs +++ b/Dalamud/Interface/Components/ComponentDemoWindow.cs @@ -27,6 +27,7 @@ namespace Dalamud.Interface.Components Demo("Test", ImGuiComponents.Test), Demo("HelpMarker", HelpMarkerDemo), Demo("IconButton", IconButtonDemo), + Demo("TextWithLabel", TextWithLabelDemo), }; } @@ -72,6 +73,11 @@ namespace Dalamud.Interface.Components ImGui.EndPopup(); } + private static void TextWithLabelDemo() + { + ImGuiComponents.TextWithLabel("Label", "Hover to see more", "more"); + } + private static KeyValuePair Demo(string name, Action func) { return new KeyValuePair(name, func); diff --git a/Dalamud/Interface/Components/ImGuiComponents.TextWithLabel.cs b/Dalamud/Interface/Components/ImGuiComponents.TextWithLabel.cs new file mode 100644 index 000000000..feb127d2a --- /dev/null +++ b/Dalamud/Interface/Components/ImGuiComponents.TextWithLabel.cs @@ -0,0 +1,32 @@ +using ImGuiNET; + +namespace Dalamud.Interface.Components +{ + /// + /// Class containing various methods providing ImGui components. + /// + public static partial class ImGuiComponents + { + /// + /// TextWithLabel component to show labeled text. + /// + /// The label for text. + /// The text value. + /// The hint to show on hover. + public static void TextWithLabel( + string label, string value, string hint = "") + { + ImGui.Text(label + ": "); + ImGui.SameLine(); + if (string.IsNullOrEmpty(hint)) + { + ImGui.Text(value); + } + else + { + ImGui.Text(value + "*"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip(hint); + } + } + } +}