Updates for v9, begin ui rework
This commit is contained in:
@@ -4,7 +4,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Craftimizer.Plugin;
|
||||
|
||||
internal static class ImGuiUtils
|
||||
@@ -158,4 +157,24 @@ internal static class ImGuiUtils
|
||||
ImGui.SetTooltip("Open in Browser");
|
||||
}
|
||||
}
|
||||
|
||||
public static void AlignCentered(float width)
|
||||
{
|
||||
var availWidth = ImGui.GetContentRegionAvail().X;
|
||||
if (availWidth > width)
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPos().X + (availWidth - width) / 2);
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/67855985
|
||||
public static void TextCentered(string text)
|
||||
{
|
||||
AlignCentered(ImGui.CalcTextSize(text).X);
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
|
||||
public static bool ButtonCentered(string text)
|
||||
{
|
||||
AlignCentered(ImGui.CalcTextSize(text).X + ImGui.GetStyle().FramePadding.Y * 2);
|
||||
return ImGui.Button(text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user