mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-26 10:29:18 +01:00
feat: add ScaledRelativeSameLine(), ScaledDummy() to ImGuiHelpers
This commit is contained in:
parent
63a289f769
commit
9621cb5428
1 changed files with 28 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface
|
||||
|
|
@ -9,6 +10,11 @@ namespace Dalamud.Interface
|
|||
{
|
||||
private static uint mainViewportId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global Dalamud scale.
|
||||
/// </summary>
|
||||
public static float GlobalScale { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Force this ImGui window to stay inside the main game window.
|
||||
/// </summary>
|
||||
|
|
@ -25,5 +31,27 @@ namespace Dalamud.Interface
|
|||
|
||||
return mainViewportId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a dummy scaled by the global Dalamud scale.
|
||||
/// </summary>
|
||||
/// <param name="size">The size of the dummy.</param>
|
||||
public static void ScaledDummy(Vector2 size) => ImGui.Dummy(size * GlobalScale);
|
||||
|
||||
/// <summary>
|
||||
/// Use a relative ImGui.SameLine() from your current cursor position, scaled by the Dalamud global scale.
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset from your current cursor position.</param>
|
||||
/// <param name="spacing">The spacing to use.</param>
|
||||
public static void ScaledRelativeSameLine(float offset, float spacing = -1.0f) =>
|
||||
ImGui.SameLine(ImGui.GetCursorPosX() + (offset * GlobalScale));
|
||||
|
||||
/// <summary>
|
||||
/// Get data needed for each new frame.
|
||||
/// </summary>
|
||||
internal static void NewFrame()
|
||||
{
|
||||
GlobalScale = ImGui.GetIO().FontGlobalScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue