mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: add textwithlabel component
This commit is contained in:
parent
e5d89b2c32
commit
7d2a900832
2 changed files with 38 additions and 0 deletions
|
|
@ -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<string, Action> Demo(string name, Action func)
|
||||
{
|
||||
return new KeyValuePair<string, Action>(name, func);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing various methods providing ImGui components.
|
||||
/// </summary>
|
||||
public static partial class ImGuiComponents
|
||||
{
|
||||
/// <summary>
|
||||
/// TextWithLabel component to show labeled text.
|
||||
/// </summary>
|
||||
/// <param name="label">The label for text.</param>
|
||||
/// <param name="value">The text value.</param>
|
||||
/// <param name="hint">The hint to show on hover.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue