Implement AutoUtf8Buffer

This commit is contained in:
Soreepeong 2025-07-22 03:47:13 +09:00
parent 51a20300d8
commit 11aef2f4d6
20 changed files with 926 additions and 232 deletions

View file

@ -87,7 +87,7 @@ internal unsafe class UiDebug
var addonName = atkUnitBase->NameString; var addonName = atkUnitBase->NameString;
var agent = Service<GameGui>.Get().FindAgentInterface(atkUnitBase); var agent = Service<GameGui>.Get().FindAgentInterface(atkUnitBase);
ImGui.Text($"{addonName}"); ImGui.Text(addonName);
ImGui.SameLine(); ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Text, isVisible ? 0xFF00FF00 : 0xFF0000FF); ImGui.PushStyleColor(ImGuiCol.Text, isVisible ? 0xFF00FF00 : 0xFF0000FF);
ImGui.Text(isVisible ? "Visible" : "Not Visible"); ImGui.Text(isVisible ? "Visible" : "Not Visible");

View file

@ -107,7 +107,7 @@ internal class NounProcessorWidget : IDataWindowWidget
var sheet = dataManager.Excel.GetSheet<RawRow>(Language.English, sheetType.Name); var sheet = dataManager.Excel.GetSheet<RawRow>(Language.English, sheetType.Name);
var minRowId = (int)sheet.FirstOrDefault().RowId; var minRowId = (int)sheet.FirstOrDefault().RowId;
var maxRowId = (int)sheet.LastOrDefault().RowId; var maxRowId = (int)sheet.LastOrDefault().RowId;
if (ImGui.InputInt("RowId###RowId", ref this.rowId, 1, 10, ImGuiInputTextFlags.AutoSelectAll)) if (ImGui.InputInt("RowId###RowId", ref this.rowId, 1, 10, flags: ImGuiInputTextFlags.AutoSelectAll))
{ {
if (this.rowId < minRowId) if (this.rowId < minRowId)
this.rowId = minRowId; this.rowId = minRowId;
@ -120,7 +120,7 @@ internal class NounProcessorWidget : IDataWindowWidget
ImGui.TextUnformatted($"(Range: {minRowId} - {maxRowId})"); ImGui.TextUnformatted($"(Range: {minRowId} - {maxRowId})");
ImGui.SetNextItemWidth(120); ImGui.SetNextItemWidth(120);
if (ImGui.InputInt("Amount###Amount", ref this.amount, 1, 10, ImGuiInputTextFlags.AutoSelectAll)) if (ImGui.InputInt("Amount###Amount", ref this.amount, 1, 10, flags: ImGuiInputTextFlags.AutoSelectAll))
{ {
if (this.amount <= 0) if (this.amount <= 0)
this.amount = 1; this.amount = 1;

View file

@ -850,9 +850,9 @@ internal class TexWidget : IDataWindowWidget
Span<int> wh = stackalloc int[2]; Span<int> wh = stackalloc int[2];
wh[0] = this.textureModificationArgs.NewWidth; wh[0] = this.textureModificationArgs.NewWidth;
wh[1] = this.textureModificationArgs.NewHeight; wh[1] = this.textureModificationArgs.NewHeight;
if (ImGui.InputInt2( if (ImGui.InputInt(
$"{nameof(this.textureModificationArgs.NewWidth)}/{nameof(this.textureModificationArgs.NewHeight)}", $"{nameof(this.textureModificationArgs.NewWidth)}/{nameof(this.textureModificationArgs.NewHeight)}",
ref wh[0])) wh))
{ {
this.textureModificationArgs.NewWidth = wh[0]; this.textureModificationArgs.NewWidth = wh[0];
this.textureModificationArgs.NewHeight = wh[1]; this.textureModificationArgs.NewHeight = wh[1];

View file

@ -16,7 +16,7 @@ internal sealed unsafe class UnknownTextureWrap : IDalamudTextureWrap, IDeferred
/// <summary>Initializes a new instance of the <see cref="UnknownTextureWrap"/> class.</summary> /// <summary>Initializes a new instance of the <see cref="UnknownTextureWrap"/> class.</summary>
/// <param name="unknown">The pointer to <see cref="IUnknown"/> that is suitable for use with /// <param name="unknown">The pointer to <see cref="IUnknown"/> that is suitable for use with
/// <see cref="IDalamudTextureWrap.ImGuiHandle"/>.</param> /// <see cref="IDalamudTextureWrap.Handle"/>.</param>
/// <param name="width">The width of the texture.</param> /// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param> /// <param name="height">The height of the texture.</param>
/// <param name="callAddRef">If <c>true</c>, call <see cref="IUnknown.AddRef"/>.</param> /// <param name="callAddRef">If <c>true</c>, call <see cref="IUnknown.AddRef"/>.</param>

View file

@ -161,12 +161,10 @@ public readonly ref struct ImGuiId
ImGui.PushID((void*)this.Numeric); ImGui.PushID((void*)this.Numeric);
return true; return true;
case Type.U16: case Type.U16:
fixed (void* p = this.U16) ImGui.PushID(this.U16);
ImGui.PushID((byte*)p, (byte*)p + (this.U16.Length * 2));
return true; return true;
case Type.U8: case Type.U8:
fixed (void* p = this.U8) ImGui.PushID(this.U8);
ImGui.PushID((byte*)p, (byte*)p + this.U8.Length);
return true; return true;
case Type.None: case Type.None:
default: default:

View file

@ -25,7 +25,7 @@ public unsafe struct ImVectorWrapper<T> : IList<T>, IList, IReadOnlyList<T>, IDi
/// Initializes a new instance of the <see cref="ImVectorWrapper{T}"/> struct.<br /> /// Initializes a new instance of the <see cref="ImVectorWrapper{T}"/> struct.<br />
/// If <paramref name="ownership"/> is set to true, you must call <see cref="Dispose"/> after use, /// If <paramref name="ownership"/> is set to true, you must call <see cref="Dispose"/> after use,
/// and the underlying memory for <see cref="ImVector"/> must have been allocated using /// and the underlying memory for <see cref="ImVector"/> must have been allocated using
/// <see cref="ImGui.MemAlloc(ulong)"/>. Otherwise, it will crash. /// <see cref="ImGui.MemAlloc(nuint)"/>. Otherwise, it will crash.
/// </summary> /// </summary>
/// <param name="vector">The underlying vector.</param> /// <param name="vector">The underlying vector.</param>
/// <param name="destroyer">The destroyer function to call on item removal.</param> /// <param name="destroyer">The destroyer function to call on item removal.</param>

View file

@ -2,25 +2,46 @@ using System.Buffers;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.Unicode;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, Size = TotalBufferSize)]
[InterpolatedStringHandler]
public ref struct AutoUtf8Buffer : IDisposable public ref struct AutoUtf8Buffer : IDisposable
{ {
private const int StackBufferSize = 1024 - 1 - 8 - 8; private const int TotalBufferSize = 1024;
private const int FixedBufferSize = TotalBufferSize - 8 - 8 - 8 - 1;
private const int MinimumRentSize = TotalBufferSize * 2;
private byte[]? RentedBuffer; private byte[]? rentedBuffer;
private ReadOnlySpan<byte> span; private ReadOnlySpan<byte> span;
private IFormatProvider? formatProvider;
private State state; private State state;
private unsafe fixed byte buffer[StackBufferSize]; private unsafe fixed byte fixedBuffer[FixedBufferSize];
[Flags] [Flags]
private enum State private enum State : byte
{ {
None = 0, None = 0,
Initialized = 1 << 0, Initialized = 1 << 0,
NullTerminated = 1 << 1, NullTerminated = 1 << 1,
Interpolation = 1 << 2,
OwnedSpan = 1 << 3,
}
public AutoUtf8Buffer(int literalLength, int formattedCount) : this(ReadOnlySpan<byte>.Empty)
{
this.state |= State.Interpolation;
literalLength += formattedCount * 4;
if (literalLength >= FixedBufferSize)
IncreaseBuffer(out _, literalLength);
}
public AutoUtf8Buffer(int literalLength, int formattedCount, IFormatProvider? formatProvider)
: this(literalLength, formattedCount)
{
this.formatProvider = formatProvider;
} }
public AutoUtf8Buffer(ReadOnlySpan<byte> text) public AutoUtf8Buffer(ReadOnlySpan<byte> text)
@ -30,11 +51,11 @@ public ref struct AutoUtf8Buffer : IDisposable
{ {
unsafe unsafe
{ {
this.span = MemoryMarshal.CreateSpan(ref this.buffer[0], 0); this.span = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], 0);
this.buffer[0] = 0; this.fixedBuffer[0] = 0;
} }
this.state |= State.NullTerminated; this.state |= State.NullTerminated | State.OwnedSpan;
} }
else else
{ {
@ -48,27 +69,25 @@ public ref struct AutoUtf8Buffer : IDisposable
{ {
} }
public AutoUtf8Buffer(ReadOnlySpan<char> text) public unsafe AutoUtf8Buffer(ReadOnlySpan<char> text)
{ {
this.state = State.Initialized | State.NullTerminated; this.state = State.Initialized | State.NullTerminated;
var cb = Encoding.UTF8.GetByteCount(text); var cb = Encoding.UTF8.GetByteCount(text);
if (cb + 1 < StackBufferSize) if (cb + 1 < FixedBufferSize)
{ {
unsafe var newSpan = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], cb);
{ this.span = newSpan;
var newSpan = MemoryMarshal.CreateSpan(ref this.buffer[0], cb); Encoding.UTF8.GetBytes(text, newSpan);
this.span = newSpan; this.fixedBuffer[cb] = 0;
Encoding.UTF8.GetBytes(text, newSpan); this.state |= State.OwnedSpan;
this.buffer[cb] = 0;
}
} }
else else
{ {
this.RentedBuffer = ArrayPool<byte>.Shared.Rent(cb + 1); this.rentedBuffer = ArrayPool<byte>.Shared.Rent(cb + 1);
var newSpan = this.RentedBuffer.AsSpan(0, cb); var newSpan = this.rentedBuffer.AsSpan(0, cb);
this.span = newSpan; this.span = newSpan;
Encoding.UTF8.GetBytes(text, newSpan); Encoding.UTF8.GetBytes(text, newSpan);
this.RentedBuffer[cb] = 0; this.rentedBuffer[cb] = 0;
} }
} }
@ -91,34 +110,37 @@ public ref struct AutoUtf8Buffer : IDisposable
public readonly bool IsInitialized => (this.state & State.Initialized) != 0; public readonly bool IsInitialized => (this.state & State.Initialized) != 0;
public readonly ReadOnlySpan<byte> Span => this.span; public readonly unsafe ReadOnlySpan<byte> Span =>
(this.state & State.OwnedSpan) != 0
? MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.fixedBuffer[0]), this.span.Length)
: this.span;
public readonly int Length => this.span.Length; public readonly int Length => this.span.Length;
public readonly bool IsEmpty => this.span.IsEmpty; public readonly bool IsEmpty => this.span.IsEmpty;
public ReadOnlySpan<byte> NullTerminatedSpan public unsafe ReadOnlySpan<byte> NullTerminatedSpan
{ {
get get
{ {
if ((this.state & State.NullTerminated) != 0) if ((this.state & State.OwnedSpan) != 0)
this.span = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], this.span.Length);
if ((this.state & State.NullTerminated) == 0)
{ {
if (this.Span.Length + 1 < StackBufferSize) if (this.span.Length + 1 < FixedBufferSize)
{ {
unsafe var newSpan = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], this.span.Length);
{ this.span.CopyTo(newSpan);
var newSpan = MemoryMarshal.CreateSpan(ref this.buffer[0], this.span.Length); this.fixedBuffer[newSpan.Length] = 0;
this.span.CopyTo(newSpan); this.span = newSpan;
this.buffer[newSpan.Length] = 0;
this.span = newSpan;
}
} }
else else
{ {
this.RentedBuffer = ArrayPool<byte>.Shared.Rent(this.span.Length + 1); this.rentedBuffer = ArrayPool<byte>.Shared.Rent(this.span.Length + 1);
var newSpan = this.RentedBuffer.AsSpan(0, this.span.Length); var newSpan = this.rentedBuffer.AsSpan(0, this.span.Length);
this.span.CopyTo(newSpan); this.span.CopyTo(newSpan);
this.RentedBuffer[newSpan.Length] = 0; this.rentedBuffer[newSpan.Length] = 0;
} }
this.state |= State.NullTerminated; this.state |= State.NullTerminated;
@ -128,19 +150,30 @@ public ref struct AutoUtf8Buffer : IDisposable
} }
} }
private unsafe Span<byte> EffectiveBuffer =>
this.rentedBuffer is { } rentedBuffer
? rentedBuffer.AsSpan()
: MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], FixedBufferSize);
private Span<byte> RemainingBuffer => this.EffectiveBuffer[this.span.Length..];
public static implicit operator AutoUtf8Buffer(ReadOnlySpan<byte> text) => new(text); public static implicit operator AutoUtf8Buffer(ReadOnlySpan<byte> text) => new(text);
public static implicit operator AutoUtf8Buffer(ReadOnlyMemory<byte> text) => new(text); public static implicit operator AutoUtf8Buffer(ReadOnlyMemory<byte> text) => new(text);
public static implicit operator AutoUtf8Buffer(Span<byte> text) => new(text);
public static implicit operator AutoUtf8Buffer(Memory<byte> text) => new(text);
public static implicit operator AutoUtf8Buffer(ReadOnlySpan<char> text) => new(text); public static implicit operator AutoUtf8Buffer(ReadOnlySpan<char> text) => new(text);
public static implicit operator AutoUtf8Buffer(ReadOnlyMemory<char> text) => new(text); public static implicit operator AutoUtf8Buffer(ReadOnlyMemory<char> text) => new(text);
public static implicit operator AutoUtf8Buffer(Span<char> text) => new(text);
public static implicit operator AutoUtf8Buffer(Memory<char> text) => new(text);
public static implicit operator AutoUtf8Buffer(string? text) => new(text); public static implicit operator AutoUtf8Buffer(string? text) => new(text);
public static unsafe implicit operator AutoUtf8Buffer(byte* text) => new(text); public static unsafe implicit operator AutoUtf8Buffer(byte* text) => new(text);
public static unsafe implicit operator AutoUtf8Buffer(char* text) => new(text); public static unsafe implicit operator AutoUtf8Buffer(char* text) => new(text);
public void Dispose() public void Dispose()
{ {
if (this.RentedBuffer is { } rentedBuffer) if (this.rentedBuffer is { } rentedBuffer)
{ {
this.RentedBuffer = null; this.rentedBuffer = null;
this.span = default; this.span = default;
ArrayPool<byte>.Shared.Return(rentedBuffer); ArrayPool<byte>.Shared.Return(rentedBuffer);
} }
@ -148,7 +181,7 @@ public ref struct AutoUtf8Buffer : IDisposable
this.state = State.None; this.state = State.None;
} }
public AutoUtf8Buffer MoveOrDefault(AutoUtf8Buffer other) public AutoUtf8Buffer MoveOrDefault([InterpolatedStringHandlerArgument] AutoUtf8Buffer other)
{ {
if (this.IsInitialized) if (this.IsInitialized)
{ {
@ -161,5 +194,87 @@ public ref struct AutoUtf8Buffer : IDisposable
return other; return other;
} }
public override readonly string ToString() => Encoding.UTF8.GetString(this.span); public override readonly string ToString() => Encoding.UTF8.GetString(this.Span);
public void AppendLiteral(string value)
{
if (string.IsNullOrEmpty(value))
return;
var remaining = this.RemainingBuffer;
var len = Encoding.UTF8.GetByteCount(value);
if (remaining.Length <= len)
this.IncreaseBuffer(out remaining, this.span.Length + len + 1);
Encoding.UTF8.GetBytes(value.AsSpan(), remaining);
var newSpan = this.EffectiveBuffer[..(this.span.Length + len + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
}
public void AppendFormatted<T>(T value) => this.AppendFormatted(value, null);
public void AppendFormatted<T>(T value, string? format)
{
var remaining = this.RemainingBuffer;
int written;
while (!Utf8.TryWrite(remaining, this.formatProvider, $"{value}", out written))
this.IncreaseBuffer(out remaining);
var newSpan = this.EffectiveBuffer[..(this.span.Length + written + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
}
public void AppendFormatted<T>(T value, int alignment) => this.AppendFormatted(value, alignment, null);
public void AppendFormatted<T>(T value, int alignment, string? format)
{
var startingPos = this.span.Length;
this.AppendFormatted(value, format);
var appendedLength = this.span.Length - startingPos;
var leftAlign = alignment < 0;
if (leftAlign)
alignment = -alignment;
var fillLength = alignment - appendedLength;
if (fillLength <= 0)
return;
var destination = this.EffectiveBuffer;
if (fillLength > destination.Length - this.span.Length)
{
this.IncreaseBuffer(out _, fillLength + 1);
destination = this.EffectiveBuffer;
}
if (leftAlign)
{
destination.Slice(this.span.Length, fillLength).Fill((byte)' ');
}
else
{
destination.Slice(startingPos, appendedLength).CopyTo(destination[(startingPos + fillLength)..]);
destination.Slice(startingPos, fillLength).Fill((byte)' ');
}
var newSpan = destination[..(this.span.Length + fillLength + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
}
private void IncreaseBuffer(out Span<byte> remaining, int minCapacity = 0)
{
minCapacity = Math.Max(minCapacity, Math.Max(this.EffectiveBuffer.Length * 2, MinimumRentSize));
var newBuffer = ArrayPool<byte>.Shared.Rent(minCapacity);
this.Span.CopyTo(newBuffer);
newBuffer[this.span.Length] = 0;
this.span = newBuffer.AsSpan(0, this.span.Length);
if (this.rentedBuffer is not null)
ArrayPool<byte>.Shared.Return(this.rentedBuffer);
this.rentedBuffer = newBuffer;
this.state &= ~State.OwnedSpan;
remaining = newBuffer.AsSpan(this.span.Length);
}
} }

View file

@ -1,17 +1,18 @@
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImDrawList public unsafe partial struct ImDrawList
{ {
public void AddText(Vector2 pos, uint col, AutoUtf8Buffer text) public void AddText(Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (ImDrawList* thisPtr = &this) fixed (ImDrawList* thisPtr = &this)
ImGui.AddText(thisPtr, pos, col, text); ImGui.AddText(thisPtr, pos, col, text);
} }
public void AddText( public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth, ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect) scoped in Vector4 cpuFineClipRect)
{ {
fixed (ImDrawList* thisPtr = &this) fixed (ImDrawList* thisPtr = &this)
@ -19,7 +20,7 @@ public unsafe partial struct ImDrawList
} }
public void AddText( public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth = 0f) ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth = 0f)
{ {
fixed (ImDrawList* thisPtr = &this) fixed (ImDrawList* thisPtr = &this)
ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth); ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth);
@ -28,15 +29,15 @@ public unsafe partial struct ImDrawList
public partial struct ImDrawListPtr public partial struct ImDrawListPtr
{ {
public void AddText(Vector2 pos, uint col, AutoUtf8Buffer text) => public void AddText(Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text) =>
ImGui.AddText(this, pos, col, text); ImGui.AddText(this, pos, col, text);
public void AddText( public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth, ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect) => scoped in Vector4 cpuFineClipRect) =>
ImGui.AddText(this, font, fontSize, pos, col, text, wrapWidth, cpuFineClipRect); ImGui.AddText(this, font, fontSize, pos, col, text, wrapWidth, cpuFineClipRect);
public void AddText( public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth = 0f) => ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth = 0f) =>
ImGui.AddText(this, font, fontSize, pos, col, text, wrapWidth); ImGui.AddText(this, font, fontSize, pos, col, text, wrapWidth);
} }

View file

@ -1,4 +1,5 @@
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
@ -13,7 +14,7 @@ public unsafe partial struct ImFont
public readonly void RenderText( public readonly void RenderText(
ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect, ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect,
AutoUtf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false) [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false)
{ {
fixed (ImFont* thisPtr = &this) fixed (ImFont* thisPtr = &this)
ImGui.RenderText(thisPtr, drawList, size, pos, col, clipRect, text, wrapWidth, cpuFineClip); ImGui.RenderText(thisPtr, drawList, size, pos, col, clipRect, text, wrapWidth, cpuFineClip);
@ -22,11 +23,11 @@ public unsafe partial struct ImFont
public partial struct ImFontPtr public partial struct ImFontPtr
{ {
public readonly int CalcWordWrapPositionA(float scale, AutoUtf8Buffer text, float wrapWidth) => public readonly int CalcWordWrapPositionA(float scale, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth) =>
ImGui.CalcWordWrapPositionA(this, scale, text, wrapWidth); ImGui.CalcWordWrapPositionA(this, scale, text, wrapWidth);
public readonly void RenderText( public readonly void RenderText(
ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect, AutoUtf8Buffer text, ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text,
float wrapWidth = 0.0f, bool cpuFineClip = false) => float wrapWidth = 0.0f, bool cpuFineClip = false) =>
ImGui.RenderText(this, drawList, size, pos, col, clipRect, text, wrapWidth, cpuFineClip); ImGui.RenderText(this, drawList, size, pos, col, clipRect, text, wrapWidth, cpuFineClip);
} }

View file

@ -1,8 +1,10 @@
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImFontGlyphRangesBuilder public unsafe partial struct ImFontGlyphRangesBuilder
{ {
public void AddText(AutoUtf8Buffer text) public void AddText([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (ImFontGlyphRangesBuilder* thisPtr = &this) fixed (ImFontGlyphRangesBuilder* thisPtr = &this)
ImGui.AddText(thisPtr, text); ImGui.AddText(thisPtr, text);
@ -11,5 +13,5 @@ public unsafe partial struct ImFontGlyphRangesBuilder
public partial struct ImFontGlyphRangesBuilderPtr public partial struct ImFontGlyphRangesBuilderPtr
{ {
public void AddText(AutoUtf8Buffer text) => ImGui.AddText(this, text); public void AddText([InterpolatedStringHandlerArgument] AutoUtf8Buffer text) => ImGui.AddText(this, text);
} }

View file

@ -1,14 +1,82 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
// DISCARDED: ColorEdit3 public static bool ColorEdit3(
// DISCARDED: ColorEdit4 [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
// DISCARDED: ColorPicker3 {
// DISCARDED: ColorPicker4 fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector3* colPtr = &col)
{
var res = ImGuiNative.ColorEdit3(labelPtr, &colPtr->X, flags) != 0;
label.Dispose();
return res;
}
}
public static bool ColorEdit4(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector4* colPtr = &col)
{
var res = ImGuiNative.ColorEdit4(labelPtr, &colPtr->X, flags) != 0;
label.Dispose();
return res;
}
}
public static bool ColorPicker3(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector3* colPtr = &col)
{
var res = ImGuiNative.ColorPicker3(labelPtr, &colPtr->X, flags) != 0;
label.Dispose();
return res;
}
}
public static bool ColorPicker4(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector4* colPtr = &col)
{
var res = ImGuiNative.ColorPicker4(labelPtr, &colPtr->X, flags, null) != 0;
label.Dispose();
return res;
}
}
public static bool ColorPicker4(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags, scoped in Vector4 refCol)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector4* colPtr = &col)
fixed (Vector4* refColPtr = &refCol)
{
var res = ImGuiNative.ColorPicker4(labelPtr, &colPtr->X, flags, &refColPtr->X) != 0;
label.Dispose();
return res;
}
}
public static bool ColorPicker4([InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 col, scoped in Vector4 refCol)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (Vector4* colPtr = &col)
fixed (Vector4* refColPtr = &refCol)
{
var res = ImGuiNative.ColorPicker4(labelPtr, &colPtr->X, ImGuiColorEditFlags.None, &refColPtr->X) != 0;
label.Dispose();
return res;
}
}
} }

View file

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
@ -8,98 +9,98 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
public static bool DragSByte( public static bool DragSByte(
AutoUtf8Buffer label, scoped ref sbyte v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref sbyte v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S8, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags); DragScalar(label, ImGuiDataType.S8, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags);
public static bool DragSByte( public static bool DragSByte(
AutoUtf8Buffer label, Span<sbyte> v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<sbyte> v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S8, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags); DragScalar(label, ImGuiDataType.S8, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags);
public static bool DragByte( public static bool DragByte(
AutoUtf8Buffer label, scoped ref byte v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref byte v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U8, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags); DragScalar(label, ImGuiDataType.U8, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags);
public static bool DragByte( public static bool DragByte(
AutoUtf8Buffer label, Span<byte> v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<byte> v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U8, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags); DragScalar(label, ImGuiDataType.U8, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags);
public static bool DragShort( public static bool DragShort(
AutoUtf8Buffer label, scoped ref short v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref short v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S16, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hd"u8), flags); DragScalar(label, ImGuiDataType.S16, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hd"u8), flags);
public static bool DragShort( public static bool DragShort(
AutoUtf8Buffer label, Span<short> v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<short> v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S16, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hd"u8), flags); DragScalar(label, ImGuiDataType.S16, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hd"u8), flags);
public static bool DragUShort( public static bool DragUShort(
AutoUtf8Buffer label, scoped ref ushort v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ushort v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U16, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hu"u8), flags); DragScalar(label, ImGuiDataType.U16, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%hu"u8), flags);
public static bool DragUShort( public static bool DragUShort(
AutoUtf8Buffer label, Span<ushort> v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ushort> v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U16, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hu"u8), flags); DragScalar(label, ImGuiDataType.U16, v, vSpeed, vMin, vMax, format.MoveOrDefault("%hu"u8), flags);
public static bool DragInt( public static bool DragInt(
AutoUtf8Buffer label, scoped ref int v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref int v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S32, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%d"u8), flags); DragScalar(label, ImGuiDataType.S32, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%d"u8), flags);
public static bool DragInt( public static bool DragInt(
AutoUtf8Buffer label, Span<int> v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<int> v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S32, v, vSpeed, vMin, vMax, format.MoveOrDefault("%d"u8), flags); DragScalar(label, ImGuiDataType.S32, v, vSpeed, vMin, vMax, format.MoveOrDefault("%d"u8), flags);
public static bool DragUInt( public static bool DragUInt(
AutoUtf8Buffer label, scoped ref uint v, float vSpeed = 1.0f, uint vMin = 0, uint vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref uint v, float vSpeed = 1.0f, uint vMin = 0, uint vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U32, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%u"u8), flags); DragScalar(label, ImGuiDataType.U32, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%u"u8), flags);
public static bool DragUInt( public static bool DragUInt(
AutoUtf8Buffer label, Span<uint> v, float vSpeed = 1.0f, uint vMin = 0, uint vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<uint> v, float vSpeed = 1.0f, uint vMin = 0, uint vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U32, v, vSpeed, vMin, vMax, format.MoveOrDefault("%u"u8), flags); DragScalar(label, ImGuiDataType.U32, v, vSpeed, vMin, vMax, format.MoveOrDefault("%u"u8), flags);
public static bool DragLong( public static bool DragLong(
AutoUtf8Buffer label, scoped ref long v, float vSpeed = 1.0f, long vMin = 0, long vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref long v, float vSpeed = 1.0f, long vMin = 0, long vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S64, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags); DragScalar(label, ImGuiDataType.S64, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags);
public static bool DragLong( public static bool DragLong(
AutoUtf8Buffer label, Span<long> v, float vSpeed = 1.0f, long vMin = 0, long vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<long> v, float vSpeed = 1.0f, long vMin = 0, long vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.S64, v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags); DragScalar(label, ImGuiDataType.S64, v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags);
public static bool DragULong( public static bool DragULong(
AutoUtf8Buffer label, scoped ref ulong v, float vSpeed = 1.0f, ulong vMin = 0, ulong vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ulong v, float vSpeed = 1.0f, ulong vMin = 0, ulong vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U64, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags); DragScalar(label, ImGuiDataType.U64, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags);
public static bool DragULong( public static bool DragULong(
AutoUtf8Buffer label, Span<ulong> v, float vSpeed = 1.0f, ulong vMin = 0, ulong vMax = 0, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ulong> v, float vSpeed = 1.0f, ulong vMin = 0, ulong vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.U64, v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags); DragScalar(label, ImGuiDataType.U64, v, vSpeed, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags);
public static bool DragFloat( public static bool DragFloat(
AutoUtf8Buffer label, scoped ref float v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref float v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.Float, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags); DragScalar(label, ImGuiDataType.Float, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool DragFloat( public static bool DragFloat(
AutoUtf8Buffer label, Span<float> v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<float> v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.Float, v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags); DragScalar(label, ImGuiDataType.Float, v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool DragFloat2( public static bool DragFloat2(
AutoUtf8Buffer label, scoped ref Vector2 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector2 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar( DragScalar(
label, label,
ImGuiDataType.Float, ImGuiDataType.Float,
@ -111,8 +112,8 @@ public static unsafe partial class ImGui
flags); flags);
public static bool DragFloat3( public static bool DragFloat3(
AutoUtf8Buffer label, scoped ref Vector3 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector3 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar( DragScalar(
label, label,
ImGuiDataType.Float, ImGuiDataType.Float,
@ -124,8 +125,8 @@ public static unsafe partial class ImGui
flags); flags);
public static bool DragFloat4( public static bool DragFloat4(
AutoUtf8Buffer label, scoped ref Vector4 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 v, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar( DragScalar(
label, label,
ImGuiDataType.Float, ImGuiDataType.Float,
@ -137,22 +138,22 @@ public static unsafe partial class ImGui
flags); flags);
public static bool DragDouble( public static bool DragDouble(
AutoUtf8Buffer label, scoped ref double v, float vSpeed = 1.0f, double vMin = 0.0f, double vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref double v, float vSpeed = 1.0f, double vMin = 0.0f, double vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.Double, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags); DragScalar(label, ImGuiDataType.Double, ref v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool DragDouble( public static bool DragDouble(
AutoUtf8Buffer label, Span<double> v, float vSpeed = 1.0f, double vMin = 0.0f, double vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<double> v, float vSpeed = 1.0f, double vMin = 0.0f, double vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
DragScalar(label, ImGuiDataType.Double, v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags); DragScalar(label, ImGuiDataType.Double, v, vSpeed, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool DragScalar<T>( public static bool DragScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T v, float vSpeed, scoped in T vMin, scoped in T vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T v, float vSpeed, scoped in T vMin, scoped in T vMax,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
where T : unmanaged, INumber<T>, IBinaryNumber<T> where T : unmanaged, INumber<T>, IBinaryNumber<T>
{ {
fixed (byte* labelPtr = label.Span) fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.Span : null) fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* vPtr = &v) fixed (T* vPtr = &v)
fixed (T* vMinPtr = &vMin) fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax) fixed (T* vMaxPtr = &vMax)
@ -173,12 +174,12 @@ public static unsafe partial class ImGui
} }
public static bool DragScalar<T>( public static bool DragScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> v, float vSpeed, scoped in T vMin, scoped in T vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> v, float vSpeed, scoped in T vMin, scoped in T vMax,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
where T : unmanaged, INumber<T>, IBinaryNumber<T> where T : unmanaged, INumber<T>, IBinaryNumber<T>
{ {
fixed (byte* labelPtr = label.Span) fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.Span : null) fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* vPtr = v) fixed (T* vPtr = v)
fixed (T* vMinPtr = &vMin) fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax) fixed (T* vMaxPtr = &vMax)
@ -199,6 +200,59 @@ public static unsafe partial class ImGui
} }
} }
// DISCARDED: DragFloatRange2 public static bool DragFloatRange2(
// DISCARDED: DragIntRange2 [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ref float vCurrentMin, ref float vCurrentMax, float vSpeed = 1.0f, float vMin = 0.0f,
float vMax = 0.0f, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, [InterpolatedStringHandlerArgument] AutoUtf8Buffer formatMax = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (float* vCurrentMinPtr = &vCurrentMin)
fixed (float* vCurrentMaxPtr = &vCurrentMax)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : "%.3f"u8)
fixed (byte* formatMaxPtr = formatMax.IsInitialized ? formatMax.NullTerminatedSpan : null)
{
var res = ImGuiNative.DragFloatRange2(
labelPtr,
vCurrentMinPtr,
vCurrentMaxPtr,
vSpeed,
vMin,
vMax,
formatPtr,
formatMaxPtr,
flags);
label.Dispose();
format.Dispose();
formatMax.Dispose();
return res != 0;
}
}
public static bool DragIntRange2(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ref int vCurrentMin, ref int vCurrentMax, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, [InterpolatedStringHandlerArgument] AutoUtf8Buffer formatMax = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (int* vCurrentMinPtr = &vCurrentMin)
fixed (int* vCurrentMaxPtr = &vCurrentMax)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : "%d"u8)
fixed (byte* formatMaxPtr = formatMax.IsInitialized ? formatMax.NullTerminatedSpan : null)
{
var res = ImGuiNative.DragIntRange2(
labelPtr,
vCurrentMinPtr,
vCurrentMaxPtr,
vSpeed,
vMin,
vMax,
formatPtr,
formatMaxPtr,
flags);
label.Dispose();
format.Dispose();
formatMax.Dispose();
return res != 0;
}
}
} }

View file

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
@ -7,15 +8,190 @@ namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
// DISCARDED: InputDouble public static bool InputSByte(
// DISCARDED: InputFloat [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref sbyte data, sbyte step = 0, sbyte stepFast = 0,
// DISCARDED: InputFloat2 [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
// DISCARDED: InputFloat3 InputScalar(label, ImGuiDataType.S8, ref data, step, stepFast, format.MoveOrDefault("%hhd"u8), flags);
// DISCARDED: InputFloat4
// DISCARDED: InputInt public static bool InputSByte(
// DISCARDED: InputInt2 [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<sbyte> data, sbyte step = 0, sbyte stepFast = 0,
// DISCARDED: InputInt3 [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
// DISCARDED: InputInt4 InputScalar(label, ImGuiDataType.S8, data, step, stepFast, format.MoveOrDefault("%hhd"u8), flags);
// DISCARDED: InputScalar
// DISCARDED: InputScalarN public static bool InputByte(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref byte data, byte step = 0, byte stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U8, ref data, step, stepFast, format.MoveOrDefault("%hhu"u8), flags);
public static bool InputByte(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<byte> data, byte step = 0, byte stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U8, data, step, stepFast, format.MoveOrDefault("%hhu"u8), flags);
public static bool InputShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref short data, short step = 0, short stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S16, ref data, step, stepFast, format.MoveOrDefault("%hd"u8), flags);
public static bool InputShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<short> data, short step = 0, short stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S16, data, step, stepFast, format.MoveOrDefault("%hd"u8), flags);
public static bool InputUShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ushort data, ushort step = 0, ushort stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U16, ref data, step, stepFast, format.MoveOrDefault("%hu"u8), flags);
public static bool InputUShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ushort> data, ushort step = 0, ushort stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U16, data, step, stepFast, format.MoveOrDefault("%hu"u8), flags);
public static bool InputInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref int data, int step = 0, int stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S32, ref data, step, stepFast, format.MoveOrDefault("%d"u8), flags);
public static bool InputInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<int> data, int step = 0, int stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S32, data, step, stepFast, format.MoveOrDefault("%d"u8), flags);
public static bool InputUInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref uint data, uint step = 0, uint stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U32, ref data, step, stepFast, format.MoveOrDefault("%u"u8), flags);
public static bool InputUInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<uint> data, uint step = 0, uint stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U32, data, step, stepFast, format.MoveOrDefault("%u"u8), flags);
public static bool InputLong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref long data, long step = 0, long stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S64, ref data, step, stepFast, format.MoveOrDefault("%I64d"u8), flags);
public static bool InputLong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<long> data, long step = 0, long stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.S64, data, step, stepFast, format.MoveOrDefault("%I64d"u8), flags);
public static bool InputULong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ulong data, ulong step = 0, ulong stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U64, ref data, step, stepFast, format.MoveOrDefault("%I64u"u8), flags);
public static bool InputULong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ulong> data, ulong step = 0, ulong stepFast = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.U64, data, step, stepFast, format.MoveOrDefault("%I64u"u8), flags);
public static bool InputFloat(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref float data, float step = 0.0f, float stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Float, ref data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputFloat(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<float> data, float step = 0.0f, float stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Float, data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputFloat2(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector2 data, float step = 0.0f, float stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector2, float>(new(ref data)),
step,
stepFast,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool InputFloat3(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector3 data, float step = 0.0f, float stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector3, float>(new(ref data)),
step,
stepFast,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool InputFloat4(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 data, float step = 0.0f, float stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector4, float>(new(ref data)),
step,
stepFast,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool InputDouble(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref double data, double step = 0.0f, double stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Double, ref data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputDouble(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<double> data, double step = 0.0f, double stepFast = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Double, data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputScalar<T>(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T data, scoped in T step, scoped in T stepFast,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* dataPtr = &data)
fixed (T* stepPtr = &step)
fixed (T* stepFastPtr = &stepFast)
{
var res = ImGuiNative.InputScalar(
labelPtr,
dataType,
dataPtr,
stepPtr,
stepFastPtr,
formatPtr,
flags) != 0;
label.Dispose();
format.Dispose();
return res;
}
}
public static bool InputScalar<T>(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> data, scoped in T step, scoped in T stepFast,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None)
where T : unmanaged, INumber<T>, IBinaryNumber<T>
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* dataPtr = data)
fixed (T* stepPtr = &step)
fixed (T* stepFastPtr = &stepFast)
{
var res = ImGuiNative.InputScalarN(
labelPtr,
dataType,
dataPtr,
data.Length,
stepPtr,
stepFastPtr,
formatPtr,
flags) != 0;
label.Dispose();
format.Dispose();
return res;
}
}
} }

View file

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
@ -8,7 +9,7 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
public static ImFontPtr AddFontFromFileTTF( public static ImFontPtr AddFontFromFileTTF(
ImFontAtlasPtr self, AutoUtf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default, ImFontAtlasPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null) ushort* glyphRanges = null)
{ {
fixed (byte* filenamePtr = filename.NullTerminatedSpan) fixed (byte* filenamePtr = filename.NullTerminatedSpan)
@ -20,7 +21,7 @@ public static unsafe partial class ImGui
} }
public static ImFontPtr AddFontFromMemoryCompressedBase85TTF( public static ImFontPtr AddFontFromMemoryCompressedBase85TTF(
ImFontAtlasPtr self, AutoUtf8Buffer compressedFontDatabase85, float sizePixels, ImFontAtlasPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer compressedFontDatabase85, float sizePixels,
ImFontConfigPtr fontCfg = default, ushort* glyphRanges = null) ImFontConfigPtr fontCfg = default, ushort* glyphRanges = null)
{ {
fixed (byte* compressedFontDatabase85Ptr = compressedFontDatabase85.NullTerminatedSpan) fixed (byte* compressedFontDatabase85Ptr = compressedFontDatabase85.NullTerminatedSpan)
@ -64,6 +65,62 @@ public static unsafe partial class ImGui
glyphRanges); glyphRanges);
} }
public static ref bool GetBoolRef(ImGuiStoragePtr self, uint key, bool defaultValue = false) =>
ref *ImGuiNative.GetBoolRef(self.Handle, key, defaultValue ? (byte)1 : (byte)0);
public static ref float GetFloatRef(ImGuiStoragePtr self, uint key, float defaultValue = 0.0f) =>
ref *ImGuiNative.GetFloatRef(self.Handle, key, defaultValue);
public static ref int GetIntRef(ImGuiStoragePtr self, uint key, int defaultValue = 0) =>
ref *ImGuiNative.GetIntRef(self.Handle, key, defaultValue);
public static ref void* GetVoidPtrRef(ImGuiStoragePtr self, uint key, void* defaultValue = null) =>
ref *ImGuiNative.GetVoidPtrRef(self.Handle, key, defaultValue);
public static ref T* GetPtrRef<T>(ImGuiStoragePtr self, uint key, T* defaultValue = null)
where T : unmanaged =>
ref *(T**)ImGuiNative.GetVoidPtrRef(self.Handle, key, defaultValue);
public static ref T GetRef<T>(ImGuiStoragePtr self, uint key, T defaultValue = default)
where T : unmanaged
{
if (sizeof(T) > sizeof(void*))
throw new ArgumentOutOfRangeException(nameof(T), typeof(T), null);
return ref *(T*)ImGuiNative.GetVoidPtrRef(self.Handle, key, *(void**)&defaultValue);
}
public static uint GetID([InterpolatedStringHandlerArgument] AutoUtf8Buffer strId)
{
fixed (byte* strIdPtr = strId.Span)
{
var r = ImGuiNative.GetID(strIdPtr, strIdPtr + strId.Length);
strId.Dispose();
return r;
}
}
public static uint GetID(nint ptrId) => ImGuiNative.GetID((void*)ptrId);
public static uint GetID(nuint ptrId) => ImGuiNative.GetID((void*)ptrId);
public static uint GetID(void* ptrId) => ImGuiNative.GetID(ptrId);
public static void PushID([InterpolatedStringHandlerArgument] AutoUtf8Buffer strId)
{
fixed (byte* strIdPtr = strId.Span)
{
ImGuiNative.PushID(strIdPtr, strIdPtr + strId.Length);
strId.Dispose();
}
}
public static void PushID(nint ptrId) => ImGuiNative.PushID((void*)ptrId);
public static void PushID(nuint ptrId) => ImGuiNative.PushID((void*)ptrId);
public static void PushID(void* ptrId) => ImGuiNative.PushID(ptrId);
// DISCARDED: PlotHistogram // DISCARDED: PlotHistogram
// DISCARDED: PlotLines // DISCARDED: PlotLines
} }

View file

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
@ -7,18 +8,281 @@ namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
// DISCARDED: SliderAngle public static bool SliderSByte(
// DISCARDED: SliderFloat [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref sbyte v, sbyte vMin = 0, sbyte vMax = 0,
// DISCARDED: SliderFloat2 [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
// DISCARDED: SliderFloat3 SliderScalar(label, ImGuiDataType.S8, ref v, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags);
// DISCARDED: SliderFloat4
// DISCARDED: SliderInt public static bool SliderSByte(
// DISCARDED: SliderInt2 [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<sbyte> v, sbyte vMin = 0, sbyte vMax = 0,
// DISCARDED: SliderInt3 [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
// DISCARDED: SliderInt4 SliderScalar(label, ImGuiDataType.S8, v, vMin, vMax, format.MoveOrDefault("%hhd"u8), flags);
// DISCARDED: SliderScalar
// DISCARDED: SliderScalarN public static bool SliderByte(
// DISCARDED: VSliderFloat [InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref byte v, byte vMin = 0, byte vMax = 0,
// DISCARDED: VSliderInt [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
// DISCARDED: VSliderScalar SliderScalar(label, ImGuiDataType.U8, ref v, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags);
public static bool SliderByte(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<byte> v, byte vMin = 0, byte vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U8, v, vMin, vMax, format.MoveOrDefault("%hhu"u8), flags);
public static bool SliderShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref short v, short vMin = 0, short vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S16, ref v, vMin, vMax, format.MoveOrDefault("%hd"u8), flags);
public static bool SliderShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<short> v, short vMin = 0, short vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S16, v, vMin, vMax, format.MoveOrDefault("%hd"u8), flags);
public static bool SliderUShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ushort v, ushort vMin = 0, ushort vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U16, ref v, vMin, vMax, format.MoveOrDefault("%hu"u8), flags);
public static bool SliderUShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ushort> v, ushort vMin = 0, ushort vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U16, v, vMin, vMax, format.MoveOrDefault("%hu"u8), flags);
public static bool SliderInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref int v, int vMin = 0, int vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S32, ref v, vMin, vMax, format.MoveOrDefault("%d"u8), flags);
public static bool SliderInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<int> v, int vMin = 0, int vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S32, v, vMin, vMax, format.MoveOrDefault("%d"u8), flags);
public static bool SliderUInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref uint v, uint vMin = 0, uint vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U32, ref v, vMin, vMax, format.MoveOrDefault("%u"u8), flags);
public static bool SliderUInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<uint> v, uint vMin = 0, uint vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U32, v, vMin, vMax, format.MoveOrDefault("%u"u8), flags);
public static bool SliderLong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref long v, long vMin = 0, long vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S64, ref v, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags);
public static bool SliderLong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<long> v, long vMin = 0, long vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.S64, v, vMin, vMax, format.MoveOrDefault("%I64d"u8), flags);
public static bool SliderULong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref ulong v, ulong vMin = 0, ulong vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U64, ref v, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags);
public static bool SliderULong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<ulong> v, ulong vMin = 0, ulong vMax = 0,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.U64, v, vMin, vMax, format.MoveOrDefault("%I64u"u8), flags);
public static bool SliderFloat(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref float v, float vMin = 0.0f, float vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Float, ref v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderFloat(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<float> v, float vMin = 0.0f, float vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Float, v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderFloat2(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector2 v, float vMin = 0.0f, float vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector2, float>(new(ref v)),
vMin,
vMax,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool SliderFloat3(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector3 v, float vMin = 0.0f, float vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector3, float>(new(ref v)),
vMin,
vMax,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool SliderFloat4(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref Vector4 v, float vMin = 0.0f, float vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector4, float>(new(ref v)),
vMin,
vMax,
format.MoveOrDefault("%.3f"u8),
flags);
public static bool SliderDouble(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, scoped ref double v, double vMin = 0.0f, double vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Double, ref v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderDouble(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Span<double> v, double vMin = 0.0f, double vMax = 0.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Double, v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderScalar<T>(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T v, scoped in T vMin, scoped in T vMax,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* vPtr = &v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
{
var res = ImGuiNative.SliderScalar(
labelPtr,
dataType,
vPtr,
vMinPtr,
vMaxPtr,
formatPtr,
flags) != 0;
label.Dispose();
format.Dispose();
return res;
}
}
public static bool SliderScalar<T>(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> v, scoped in T vMin, scoped in T vMax,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
where T : unmanaged, INumber<T>, IBinaryNumber<T>
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* vPtr = v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
{
var res = ImGuiNative.SliderScalarN(
labelPtr,
dataType,
vPtr,
v.Length,
vMinPtr,
vMaxPtr,
formatPtr,
flags) != 0;
label.Dispose();
format.Dispose();
return res;
}
}
public static bool SliderAngle(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, ref float vRad, float vDegreesMin = -360.0f, float vDegreesMax = +360.0f,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : "%.0f deg"u8)
fixed (float* vRadPtr = &vRad)
{
var res = ImGuiNative.SliderAngle(
labelPtr,
vRadPtr,
vDegreesMin,
vDegreesMax,
formatPtr,
flags) != 0;
label.Dispose();
format.Dispose();
return res;
}
}
public static bool VSliderSByte(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref sbyte v, sbyte vMin, sbyte vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S8, ref v, vMin, vMax, format.MoveOrDefault("%hhd"), flags);
public static bool VSliderByte(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref byte v, byte vMin, byte vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U8, ref v, vMin, vMax, format.MoveOrDefault("%hhu"), flags);
public static bool VSliderShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref short v, short vMin, short vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S16, ref v, vMin, vMax, format.MoveOrDefault("%hd"), flags);
public static bool VSliderUShort(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref ushort v, ushort vMin, ushort vMax,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U16, ref v, vMin, vMax, format.MoveOrDefault("%hu"), flags);
public static bool VSliderInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref int v, int vMin, int vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S32, ref v, vMin, vMax, format.MoveOrDefault("%d"), flags);
public static bool VSliderUInt(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref uint v, uint vMin, uint vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U32, ref v, vMin, vMax, format.MoveOrDefault("%u"), flags);
public static bool VSliderLong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref long v, long vMin, long vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S32, ref v, vMin, vMax, format.MoveOrDefault("%I64d"), flags);
public static bool VSliderULong(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref ulong v, ulong vMin, ulong vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U32, ref v, vMin, vMax, format.MoveOrDefault("%I64u"), flags);
public static bool VSliderFloat(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref float v, float vMin, float vMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.Float, ref v, vMin, vMax, format.MoveOrDefault("%.03f"), flags);
public static bool VSliderDouble(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, scoped ref double v, double vMin, double vMax,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.Double, ref v, vMin, vMax, format.MoveOrDefault("%.03f"), flags);
public static bool VSliderScalar<T>(
[InterpolatedStringHandlerArgument] AutoUtf8Buffer label, Vector2 size, ImGuiDataType dataType, scoped ref T data, scoped in T min, scoped in T max,
[InterpolatedStringHandlerArgument] AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : null)
fixed (T* dataPtr = &data)
fixed (T* minPtr = &min)
fixed (T* maxPtr = &max)
{
var res = ImGuiNative.VSliderScalar(labelPtr, size, dataType, dataPtr, minPtr, maxPtr, formatPtr, flags) !=
0;
label.Dispose();
format.Dispose();
return res;
}
}
} }

View file

@ -1,48 +0,0 @@
using System.Diagnostics.CodeAnalysis;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public static ref bool GetBoolRef(ImGuiStoragePtr self, uint key, bool defaultValue = false) =>
ref *ImGuiNative.GetBoolRef(self.Handle, key, defaultValue ? (byte)1 : (byte)0);
public static ref float GetFloatRef(ImGuiStoragePtr self, uint key, float defaultValue = 0.0f) =>
ref *ImGuiNative.GetFloatRef(self.Handle, key, defaultValue);
public static ref int GetIntRef(ImGuiStoragePtr self, uint key, int defaultValue = 0) =>
ref *ImGuiNative.GetIntRef(self.Handle, key, defaultValue);
public static ref void* GetVoidPtrRef(ImGuiStoragePtr self, uint key, void* defaultValue = null) =>
ref *ImGuiNative.GetVoidPtrRef(self.Handle, key, defaultValue);
public static ref T* GetPtrRef<T>(ImGuiStoragePtr self, uint key, T* defaultValue = null)
where T : unmanaged =>
ref *(T**)ImGuiNative.GetVoidPtrRef(self.Handle, key, defaultValue);
public static ref T GetRef<T>(ImGuiStoragePtr self, uint key, T defaultValue = default)
where T : unmanaged
{
if (sizeof(T) > sizeof(void*))
throw new ArgumentOutOfRangeException(nameof(T), typeof(T), null);
return ref *(T*)ImGuiNative.GetVoidPtrRef(self.Handle, key, *(void**)&defaultValue);
}
public static uint GetID(AutoUtf8Buffer strId)
{
fixed (byte* strIdPtr = strId.Span)
{
var r = ImGuiNative.GetID(strIdPtr, strIdPtr + strId.Length);
strId.Dispose();
return r;
}
}
public static uint GetID(nint ptrId) => ImGuiNative.GetID((void*)ptrId);
public static uint GetID(nuint ptrId) => ImGuiNative.GetID((void*)ptrId);
public static uint GetID(void* ptrId) => ImGuiNative.GetID(ptrId);
}

View file

@ -1,19 +1,20 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui public static unsafe partial class ImGui
{ {
public static void AddText(ImFontGlyphRangesBuilderPtr self, AutoUtf8Buffer text) public static void AddText(ImFontGlyphRangesBuilderPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiNative.AddText(self.Handle, textPtr, textPtr + text.Length); ImGuiNative.AddText(self.Handle, textPtr, textPtr + text.Length);
text.Dispose(); text.Dispose();
} }
public static void AddText(ImDrawListPtr self, Vector2 pos, uint col, AutoUtf8Buffer text) public static void AddText(ImDrawListPtr self, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiNative.AddText(self.Handle, pos, col, textPtr, textPtr + text.Length); ImGuiNative.AddText(self.Handle, pos, col, textPtr, textPtr + text.Length);
@ -21,7 +22,7 @@ public static unsafe partial class ImGui
} }
public static void AddText( public static void AddText(
ImDrawListPtr self, ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth, ImDrawListPtr self, ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect) scoped in Vector4 cpuFineClipRect)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
@ -40,7 +41,7 @@ public static unsafe partial class ImGui
} }
public static void AddText( public static void AddText(
ImDrawListPtr self, ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, ImDrawListPtr self, ImFontPtr font, float fontSize, Vector2 pos, uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text,
float wrapWidth = 0f) float wrapWidth = 0f)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
@ -57,14 +58,14 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void append(ImGuiTextBufferPtr self, AutoUtf8Buffer str) public static void append(ImGuiTextBufferPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer str)
{ {
fixed (byte* strPtr = str.Span) fixed (byte* strPtr = str.Span)
ImGuiNative.append(self.Handle, strPtr, strPtr + str.Length); ImGuiNative.append(self.Handle, strPtr, strPtr + str.Length);
str.Dispose(); str.Dispose();
} }
public static void BulletText(AutoUtf8Buffer text) public static void BulletText([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
ImGuiWindow* window = ImGuiP.GetCurrentWindow(); ImGuiWindow* window = ImGuiP.GetCurrentWindow();
if (window->SkipItems != 0) if (window->SkipItems != 0)
@ -94,7 +95,7 @@ public static unsafe partial class ImGui
} }
public static Vector2 CalcTextSize( public static Vector2 CalcTextSize(
AutoUtf8Buffer text, bool hideTextAfterDoubleHash = false, float wrapWidth = -1.0f) [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, bool hideTextAfterDoubleHash = false, float wrapWidth = -1.0f)
{ {
var @out = Vector2.Zero; var @out = Vector2.Zero;
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
@ -109,7 +110,7 @@ public static unsafe partial class ImGui
} }
public static Vector2 CalcTextSizeA( public static Vector2 CalcTextSizeA(
ImFontPtr self, float size, float maxWidth, float wrapWidth, AutoUtf8Buffer text, out int remaining) ImFontPtr self, float size, float maxWidth, float wrapWidth, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, out int remaining)
{ {
var @out = Vector2.Zero; var @out = Vector2.Zero;
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
@ -131,7 +132,7 @@ public static unsafe partial class ImGui
return @out; return @out;
} }
public static int CalcWordWrapPositionA(ImFontPtr font, float scale, AutoUtf8Buffer text, float wrapWidth) public static int CalcWordWrapPositionA(ImFontPtr font, float scale, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth)
{ {
fixed (byte* ptr = text.Span) fixed (byte* ptr = text.Span)
{ {
@ -142,14 +143,14 @@ public static unsafe partial class ImGui
} }
} }
public static void InsertChars(ImGuiInputTextCallbackDataPtr self, int pos, AutoUtf8Buffer text) public static void InsertChars(ImGuiInputTextCallbackDataPtr self, int pos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (byte* ptr = text.Span) fixed (byte* ptr = text.Span)
ImGuiNative.InsertChars(self.Handle, pos, ptr, ptr + text.Length); ImGuiNative.InsertChars(self.Handle, pos, ptr, ptr + text.Length);
text.Dispose(); text.Dispose();
} }
public static void LabelText(AutoUtf8Buffer label, AutoUtf8Buffer text) public static void LabelText([InterpolatedStringHandlerArgument] AutoUtf8Buffer label, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
var window = ImGuiP.GetCurrentWindow().Handle; var window = ImGuiP.GetCurrentWindow().Handle;
if (window->SkipItems != 0) if (window->SkipItems != 0)
@ -194,7 +195,7 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void LogText(AutoUtf8Buffer text) public static void LogText([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
var g = GetCurrentContext(); var g = GetCurrentContext();
if (!g.LogFile.IsNull) if (!g.LogFile.IsNull)
@ -212,7 +213,7 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void PassFilter(ImGuiTextFilterPtr self, AutoUtf8Buffer text) public static void PassFilter(ImGuiTextFilterPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiNative.PassFilter(self.Handle, textPtr, textPtr + text.Length); ImGuiNative.PassFilter(self.Handle, textPtr, textPtr + text.Length);
@ -221,7 +222,7 @@ public static unsafe partial class ImGui
public static void RenderText( public static void RenderText(
ImFontPtr self, ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect, ImFontPtr self, ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect,
AutoUtf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false) [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiNative.RenderText( ImGuiNative.RenderText(
@ -238,7 +239,7 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void SetTooltip(AutoUtf8Buffer text) public static void SetTooltip([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
ImGuiP.BeginTooltipEx(ImGuiTooltipFlags.OverridePreviousTooltip, ImGuiWindowFlags.None); ImGuiP.BeginTooltipEx(ImGuiTooltipFlags.OverridePreviousTooltip, ImGuiWindowFlags.None);
Text(text.Span); Text(text.Span);
@ -246,14 +247,14 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void Text(AutoUtf8Buffer text) public static void Text([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (byte* ptr = text.Span) fixed (byte* ptr = text.Span)
ImGuiNative.TextUnformatted(ptr, ptr + text.Length); ImGuiNative.TextUnformatted(ptr, ptr + text.Length);
text.Dispose(); text.Dispose();
} }
public static void TextColored(uint col, AutoUtf8Buffer text) public static void TextColored(uint col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
PushStyleColor(ImGuiCol.Text, col); PushStyleColor(ImGuiCol.Text, col);
Text(text.Span); Text(text.Span);
@ -261,7 +262,7 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void TextColored(scoped in Vector4 col, AutoUtf8Buffer text) public static void TextColored(scoped in Vector4 col, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
PushStyleColor(ImGuiCol.Text, col); PushStyleColor(ImGuiCol.Text, col);
Text(text.Span); Text(text.Span);
@ -269,19 +270,19 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static void TextDisabled(AutoUtf8Buffer text) public static void TextDisabled([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
TextColored(*GetStyleColorVec4(ImGuiCol.TextDisabled), text.Span); TextColored(*GetStyleColorVec4(ImGuiCol.TextDisabled), text.Span);
text.Dispose(); text.Dispose();
} }
public static void TextUnformatted(AutoUtf8Buffer text) public static void TextUnformatted([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
Text(text.Span); Text(text.Span);
text.Dispose(); text.Dispose();
} }
public static void TextWrapped(AutoUtf8Buffer text) public static void TextWrapped([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
scoped ref var g = ref *GetCurrentContext().Handle; scoped ref var g = ref *GetCurrentContext().Handle;
var needBackup = g.CurrentWindow->DC.TextWrapPos < 0.0f; // Keep existing wrap position if one is already set var needBackup = g.CurrentWindow->DC.TextWrapPos < 0.0f; // Keep existing wrap position if one is already set
@ -293,7 +294,7 @@ public static unsafe partial class ImGui
text.Dispose(); text.Dispose();
} }
public static bool TreeNode(AutoUtf8Buffer label) public static bool TreeNode([InterpolatedStringHandlerArgument] AutoUtf8Buffer label)
{ {
var window = ImGuiP.GetCurrentWindow(); var window = ImGuiP.GetCurrentWindow();
if (window.SkipItems) if (window.SkipItems)
@ -315,7 +316,7 @@ public static unsafe partial class ImGui
} }
public static bool TreeNodeEx( public static bool TreeNodeEx(
AutoUtf8Buffer id, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None, AutoUtf8Buffer label = default) [InterpolatedStringHandlerArgument] AutoUtf8Buffer id, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None, [InterpolatedStringHandlerArgument] AutoUtf8Buffer label = default)
{ {
var window = ImGuiP.GetCurrentWindow(); var window = ImGuiP.GetCurrentWindow();
bool res; bool res;

View file

@ -1,8 +1,10 @@
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiInputTextCallbackData public unsafe partial struct ImGuiInputTextCallbackData
{ {
public void InsertChars(int pos, AutoUtf8Buffer text) public void InsertChars(int pos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (ImGuiInputTextCallbackData* thisPtr = &this) fixed (ImGuiInputTextCallbackData* thisPtr = &this)
ImGui.InsertChars(thisPtr, pos, text); ImGui.InsertChars(thisPtr, pos, text);
@ -11,5 +13,5 @@ public unsafe partial struct ImGuiInputTextCallbackData
public partial struct ImGuiInputTextCallbackDataPtr public partial struct ImGuiInputTextCallbackDataPtr
{ {
public void InsertChars(int pos, AutoUtf8Buffer text) => ImGui.InsertChars(this, pos, text); public void InsertChars(int pos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text) => ImGui.InsertChars(this, pos, text);
} }

View file

@ -1,12 +1,13 @@
using System.Diagnostics; using System.Diagnostics;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGuiP public static unsafe partial class ImGuiP
{ {
public static void DebugLog(AutoUtf8Buffer text) public static void DebugLog([InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
var g = ImGui.GetCurrentContext().Handle; var g = ImGui.GetCurrentContext().Handle;
ImGui.append(&g->DebugLogBuf, $"[{g->FrameCount:00000}] "); ImGui.append(&g->DebugLogBuf, $"[{g->FrameCount:00000}] ");
@ -39,7 +40,7 @@ public static unsafe partial class ImGuiP
return before.Length; return before.Length;
} }
public static uint GetID(ImGuiWindowPtr self, AutoUtf8Buffer str) public static uint GetID(ImGuiWindowPtr self, [InterpolatedStringHandlerArgument] AutoUtf8Buffer str)
{ {
fixed (byte* strPtr = str.Span) fixed (byte* strPtr = str.Span)
{ {
@ -63,7 +64,7 @@ public static unsafe partial class ImGuiP
return ImGuiPNative.ImHashData(ptr, (nuint)data.Length, seed); return ImGuiPNative.ImHashData(ptr, (nuint)data.Length, seed);
} }
public static uint ImHashStr(AutoUtf8Buffer data, uint seed = 0) public static uint ImHashStr([InterpolatedStringHandlerArgument] AutoUtf8Buffer data, uint seed = 0)
{ {
fixed (byte* ptr = data.Span) fixed (byte* ptr = data.Span)
{ {
@ -132,7 +133,7 @@ public static unsafe partial class ImGuiP
return i; return i;
} }
public static void LogRenderedText(scoped in Vector2 refPos, AutoUtf8Buffer text) public static void LogRenderedText(scoped in Vector2 refPos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text)
{ {
fixed (Vector2* refPosPtr = &refPos) fixed (Vector2* refPosPtr = &refPos)
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
@ -140,14 +141,14 @@ public static unsafe partial class ImGuiP
text.Dispose(); text.Dispose();
} }
public static void RenderText(Vector2 pos, AutoUtf8Buffer text, bool hideTextAfterHash = true) public static void RenderText(Vector2 pos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, bool hideTextAfterHash = true)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiPNative.RenderText(pos, textPtr, textPtr + text.Length, hideTextAfterHash ? (byte)1 : (byte)0); ImGuiPNative.RenderText(pos, textPtr, textPtr + text.Length, hideTextAfterHash ? (byte)1 : (byte)0);
text.Dispose(); text.Dispose();
} }
public static void RenderTextWrapped(Vector2 pos, AutoUtf8Buffer text, float wrapWidth) public static void RenderTextWrapped(Vector2 pos, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, float wrapWidth)
{ {
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)
ImGuiPNative.RenderTextWrapped(pos, textPtr, textPtr + text.Length, wrapWidth); ImGuiPNative.RenderTextWrapped(pos, textPtr, textPtr + text.Length, wrapWidth);
@ -155,7 +156,7 @@ public static unsafe partial class ImGuiP
} }
public static void RenderTextClipped( public static void RenderTextClipped(
scoped in Vector2 posMin, scoped in Vector2 posMax, AutoUtf8Buffer text, scoped in Vector2? textSizeIfKnown = null, scoped in Vector2 posMin, scoped in Vector2 posMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, scoped in Vector2? textSizeIfKnown = null,
scoped in Vector2 align = default, scoped in ImRect? clipRect = null) scoped in Vector2 align = default, scoped in ImRect? clipRect = null)
{ {
var textSizeIfKnownOrDefault = textSizeIfKnown ?? default; var textSizeIfKnownOrDefault = textSizeIfKnown ?? default;
@ -173,7 +174,7 @@ public static unsafe partial class ImGuiP
} }
public static void RenderTextClippedEx( public static void RenderTextClippedEx(
ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax, AutoUtf8Buffer text, ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax, [InterpolatedStringHandlerArgument] AutoUtf8Buffer text,
scoped in Vector2? textSizeIfKnown = null, scoped in Vector2 align = default, scoped in ImRect? clipRect = null) scoped in Vector2? textSizeIfKnown = null, scoped in Vector2 align = default, scoped in ImRect? clipRect = null)
{ {
var textSizeIfKnownOrDefault = textSizeIfKnown ?? default; var textSizeIfKnownOrDefault = textSizeIfKnown ?? default;
@ -193,7 +194,7 @@ public static unsafe partial class ImGuiP
public static void RenderTextEllipsis( public static void RenderTextEllipsis(
ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax, float clipMaxX, float ellipsisMaxX, ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax, float clipMaxX, float ellipsisMaxX,
AutoUtf8Buffer text, scoped in Vector2? textSizeIfKnown = null) [InterpolatedStringHandlerArgument] AutoUtf8Buffer text, scoped in Vector2? textSizeIfKnown = null)
{ {
var textSizeIfKnownOrDefault = textSizeIfKnown ?? default; var textSizeIfKnownOrDefault = textSizeIfKnown ?? default;
fixed (byte* textPtr = text.Span) fixed (byte* textPtr = text.Span)

View file

@ -1,8 +1,10 @@
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui; namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiWindow public unsafe partial struct ImGuiWindow
{ {
public readonly uint GetID(AutoUtf8Buffer str) public readonly uint GetID([InterpolatedStringHandlerArgument] AutoUtf8Buffer str)
{ {
fixed (ImGuiWindow* thisPtr = &this) fixed (ImGuiWindow* thisPtr = &this)
return ImGuiP.GetID(thisPtr, str); return ImGuiP.GetID(thisPtr, str);
@ -23,7 +25,7 @@ public unsafe partial struct ImGuiWindow
public unsafe partial struct ImGuiWindowPtr public unsafe partial struct ImGuiWindowPtr
{ {
public readonly uint GetID(AutoUtf8Buffer str) => ImGuiP.GetID(this.Handle, str); public readonly uint GetID([InterpolatedStringHandlerArgument] AutoUtf8Buffer str) => ImGuiP.GetID(this.Handle, str);
public readonly uint GetID(void* ptr) => ImGuiP.GetID(this.Handle, ptr); public readonly uint GetID(void* ptr) => ImGuiP.GetID(this.Handle, ptr);