Fix labels appearing where unwanted.

This commit is contained in:
Ottermandias 2023-12-29 18:31:59 +01:00
parent ff6905d45e
commit 53388739ca

View file

@ -47,14 +47,20 @@ public static class UiHelpers
public static bool DrawCheckbox(string label, string tooltip, bool value, out bool on, bool locked) public static bool DrawCheckbox(string label, string tooltip, bool value, out bool on, bool locked)
{ {
var startsWithHash = label.StartsWith("##");
bool ret; bool ret;
using (var disabled = ImRaii.Disabled(locked)) using (_ = ImRaii.Disabled(locked))
{ {
ret = ImGuiUtil.Checkbox("##" + label, string.Empty, value, v => value = v); ret = ImGuiUtil.Checkbox(startsWithHash ? label : "##" + label, string.Empty, value, v => value = v);
} }
if (!startsWithHash)
{
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(label); ImGui.TextUnformatted(label);
}
ImGuiUtil.HoverTooltip(tooltip, ImGuiHoveredFlags.AllowWhenDisabled); ImGuiUtil.HoverTooltip(tooltip, ImGuiHoveredFlags.AllowWhenDisabled);
on = value; on = value;
return ret; return ret;