Work on manual bindings

This commit is contained in:
Soreepeong 2025-07-23 01:18:48 +09:00
parent f391ac57d3
commit 3381ac1c7d
37 changed files with 2596 additions and 48072 deletions

View file

@ -348,7 +348,7 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
case WM.WM_CHAR:
if (io.WantTextInput)
{
io.AddInputCharacter((uint)wParam);
io.AddInputCharacter(new Rune((uint)wParam));
return nint.Zero;
}

View file

@ -61,58 +61,25 @@ internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
public unsafe void Draw()
{
ImGui.AlignTextToFramePadding();
if (ImGui.Combo("Global Scale per Font", ref this.fontScaleMode, FontScaleModes, FontScaleModes.Length))
if (ImGui.Combo("Global Scale per Font"u8, ref this.fontScaleMode, FontScaleModes, FontScaleModes.Length))
this.ClearAtlas();
if (ImGui.Checkbox("Global Scale for Atlas"u8, ref this.atlasScaleMode))
this.ClearAtlas();
fixed (byte* labelPtr = "Global Scale for Atlas"u8)
{
var v = this.atlasScaleMode;
if (ImGui.Checkbox(labelPtr, ref v))
{
this.atlasScaleMode = v;
this.ClearAtlas();
}
}
ImGui.SameLine();
fixed (byte* labelPtr = "Word Wrap"u8)
{
var v = this.useWordWrap;
if (ImGui.Checkbox(labelPtr, &v))
this.useWordWrap = v;
}
ImGui.Checkbox("Word Wrap"u8, ref this.useWordWrap);
ImGui.SameLine();
fixed (byte* labelPtr = "Italic"u8)
{
var v = this.useItalic;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useItalic = v;
this.ClearAtlas();
}
}
if (ImGui.Checkbox("Italic"u8, ref this.useItalic))
this.ClearAtlas();
ImGui.SameLine();
fixed (byte* labelPtr = "Bold"u8)
{
var v = this.useBold;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useBold = v;
this.ClearAtlas();
}
}
if (ImGui.Checkbox("Bold"u8, ref this.useBold))
this.ClearAtlas();
ImGui.SameLine();
fixed (byte* labelPtr = "Minimum Range"u8)
{
var v = this.useMinimumBuild;
if (ImGui.Checkbox(labelPtr, &v))
{
this.useMinimumBuild = v;
this.ClearAtlas();
}
}
if (ImGui.Checkbox("Minimum Range"u8, ref this.useMinimumBuild))
this.ClearAtlas();
ImGui.SameLine();
if (ImGui.Button("Reset Text") || this.testStringBuffer.IsDisposed)

View file

@ -225,13 +225,13 @@ public static partial class ImRaii
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label));
public static unsafe IEndObject TabItem(byte* label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
public static unsafe IEndObject TabItem(string label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
public static unsafe IEndObject TabItem(ReadOnlySpan<byte> label, ImGuiTabItemFlags flags)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, null, flags));
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, flags));
public static IEndObject TabItem(string label, ref bool open)
=> new EndConditionally(ImGui.EndTabItem, ImGui.BeginTabItem(label, ref open));

View file

@ -12958,22 +12958,6 @@ namespace Dalamud.Bindings.ImGui
{
Data = data;
}
public unsafe void** GetVoidPtrRef(uint key, void* defaultVal)
{
fixed (ImGuiStorage* @this = &this)
{
void** ret = ImGuiNative.GetVoidPtrRef(@this, key, defaultVal);
return ret;
}
}
public unsafe void** GetVoidPtrRef(uint key)
{
fixed (ImGuiStorage* @this = &this)
{
void** ret = ImGuiNative.GetVoidPtrRef(@this, key, (void*)(default));
return ret;
}
}
}
[DebuggerDisplay("{DebuggerDisplay,nq}")]
@ -12997,16 +12981,6 @@ namespace Dalamud.Bindings.ImGui
private string DebuggerDisplay => string.Format("ImGuiStoragePtr [0x{0}]", ((nuint)Handle).ToString("X"));
public ref ImVector<ImGuiStoragePair> Data => ref Unsafe.AsRef<ImVector<ImGuiStoragePair>>(&Handle->Data);
public unsafe void** GetVoidPtrRef(uint key, void* defaultVal)
{
void** ret = ImGuiNative.GetVoidPtrRef(Handle, key, defaultVal);
return ret;
}
public unsafe void** GetVoidPtrRef(uint key)
{
void** ret = ImGuiNative.GetVoidPtrRef(Handle, key, (void*)(default));
return ret;
}
}
}
/* ImGuiStoragePair.cs */

File diff suppressed because it is too large Load diff

View file

@ -18,75 +18,6 @@ public unsafe partial struct ImGuiIO
ImGuiNative.AddFocusEvent(@this, focused ? (byte)1 : (byte)0);
}
}
public unsafe void AddInputCharacter(uint c)
{
fixed (ImGuiIO* @this = &this)
{
ImGuiNative.AddInputCharacter(@this, c);
}
}
public unsafe void AddInputCharactersUTF8(byte* str)
{
fixed (ImGuiIO* @this = &this)
{
ImGuiNative.AddInputCharactersUTF8(@this, str);
}
}
public unsafe void AddInputCharactersUTF8(ref byte str)
{
fixed (ImGuiIO* @this = &this)
{
fixed (byte* pstr = &str)
{
ImGuiNative.AddInputCharactersUTF8(@this, (byte*)pstr);
}
}
}
public unsafe void AddInputCharactersUTF8(ReadOnlySpan<byte> str)
{
fixed (ImGuiIO* @this = &this)
{
fixed (byte* pstr = str)
{
ImGuiNative.AddInputCharactersUTF8(@this, (byte*)pstr);
}
}
}
public unsafe void AddInputCharactersUTF8(string str)
{
fixed (ImGuiIO* @this = &this)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (str != null)
{
pStrSize0 = Utils.GetByteCountUTF8(str);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(str, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
ImGuiNative.AddInputCharactersUTF8(@this, pStr0);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
}
}
public unsafe void AddInputCharacterUTF16(ushort c)
{
fixed (ImGuiIO* @this = &this)
{
ImGuiNative.AddInputCharacterUTF16(@this, c);
}
}
public unsafe void AddKeyAnalogEvent(ImGuiKey key, bool down, float v)
{
fixed (ImGuiIO* @this = &this)
@ -172,4 +103,7 @@ public unsafe partial struct ImGuiIO
}
}
}
// DISCARDED: AddInputCharacter
// DISCARDED: AddInputCharactersUTF8
// DISCARDED: AddInputCharacterUTF16

View file

@ -15,57 +15,6 @@ public unsafe partial struct ImGuiIOPtr
{
ImGuiNative.AddFocusEvent(Handle, focused ? (byte)1 : (byte)0);
}
public unsafe void AddInputCharacter(uint c)
{
ImGuiNative.AddInputCharacter(Handle, c);
}
public unsafe void AddInputCharactersUTF8(byte* str)
{
ImGuiNative.AddInputCharactersUTF8(Handle, str);
}
public unsafe void AddInputCharactersUTF8(ref byte str)
{
fixed (byte* pstr = &str)
{
ImGuiNative.AddInputCharactersUTF8(Handle, (byte*)pstr);
}
}
public unsafe void AddInputCharactersUTF8(ReadOnlySpan<byte> str)
{
fixed (byte* pstr = str)
{
ImGuiNative.AddInputCharactersUTF8(Handle, (byte*)pstr);
}
}
public unsafe void AddInputCharactersUTF8(string str)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (str != null)
{
pStrSize0 = Utils.GetByteCountUTF8(str);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(str, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
ImGuiNative.AddInputCharactersUTF8(Handle, pStr0);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
}
public unsafe void AddInputCharacterUTF16(ushort c)
{
ImGuiNative.AddInputCharacterUTF16(Handle, c);
}
public unsafe void AddKeyAnalogEvent(ImGuiKey key, bool down, float v)
{
ImGuiNative.AddKeyAnalogEvent(Handle, key, down ? (byte)1 : (byte)0, v);
@ -115,4 +64,7 @@ public unsafe partial struct ImGuiIOPtr
ImGuiNative.SetKeyEventNativeData(Handle, key, nativeKeycode, nativeScancode, (int)(-1));
}
}
// DISCARDED: AddInputCharacter
// DISCARDED: AddInputCharactersUTF8
// DISCARDED: AddInputCharacterUTF16

File diff suppressed because it is too large Load diff

View file

@ -25,65 +25,6 @@ public unsafe partial struct ImGuiPayload
ImGuiNative.Destroy(@this);
}
}
public unsafe bool IsDataType(byte* type)
{
fixed (ImGuiPayload* @this = &this)
{
byte ret = ImGuiNative.IsDataType(@this, type);
return ret != 0;
}
}
public unsafe bool IsDataType(ref byte type)
{
fixed (ImGuiPayload* @this = &this)
{
fixed (byte* ptype = &type)
{
byte ret = ImGuiNative.IsDataType(@this, (byte*)ptype);
return ret != 0;
}
}
}
public unsafe bool IsDataType(ReadOnlySpan<byte> type)
{
fixed (ImGuiPayload* @this = &this)
{
fixed (byte* ptype = type)
{
byte ret = ImGuiNative.IsDataType(@this, (byte*)ptype);
return ret != 0;
}
}
}
public unsafe bool IsDataType(string type)
{
fixed (ImGuiPayload* @this = &this)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (type != null)
{
pStrSize0 = Utils.GetByteCountUTF8(type);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(type, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.IsDataType(@this, pStr0);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
}
public unsafe bool IsDelivery()
{
fixed (ImGuiPayload* @this = &this)
@ -101,4 +42,5 @@ public unsafe partial struct ImGuiPayload
}
}
}
// DISCARDED: IsDataType

View file

@ -19,53 +19,6 @@ public unsafe partial struct ImGuiPayloadPtr
{
ImGuiNative.Destroy(Handle);
}
public unsafe bool IsDataType(byte* type)
{
byte ret = ImGuiNative.IsDataType(Handle, type);
return ret != 0;
}
public unsafe bool IsDataType(ref byte type)
{
fixed (byte* ptype = &type)
{
byte ret = ImGuiNative.IsDataType(Handle, (byte*)ptype);
return ret != 0;
}
}
public unsafe bool IsDataType(ReadOnlySpan<byte> type)
{
fixed (byte* ptype = type)
{
byte ret = ImGuiNative.IsDataType(Handle, (byte*)ptype);
return ret != 0;
}
}
public unsafe bool IsDataType(string type)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (type != null)
{
pStrSize0 = Utils.GetByteCountUTF8(type);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(type, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.IsDataType(Handle, pStr0);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
public unsafe bool IsDelivery()
{
byte ret = ImGuiNative.IsDelivery(Handle);
@ -77,4 +30,5 @@ public unsafe partial struct ImGuiPayloadPtr
return ret != 0;
}
}
// DISCARDED: IsDataType

View file

@ -32,140 +32,6 @@ public unsafe partial struct ImGuiTextFilter
ImGuiNative.Destroy(@this);
}
}
public unsafe bool Draw(byte* label, float width)
{
fixed (ImGuiTextFilter* @this = &this)
{
byte ret = ImGuiNative.Draw(@this, label, width);
return ret != 0;
}
}
public unsafe bool Draw(byte* label)
{
fixed (ImGuiTextFilter* @this = &this)
{
byte ret = ImGuiNative.Draw(@this, label, (float)(0.0f));
return ret != 0;
}
}
public unsafe bool Draw()
{
fixed (ImGuiTextFilter* @this = &this)
{
bool ret = ImGui.Draw(@this, (string)"Filter(inc,-exc)", (float)(0.0f));
return ret;
}
}
public unsafe bool Draw(float width)
{
fixed (ImGuiTextFilter* @this = &this)
{
bool ret = ImGui.Draw(@this, (string)"Filter(inc,-exc)", width);
return ret;
}
}
public unsafe bool Draw(ref byte label, float width)
{
fixed (ImGuiTextFilter* @this = &this)
{
fixed (byte* plabel = &label)
{
byte ret = ImGuiNative.Draw(@this, (byte*)plabel, width);
return ret != 0;
}
}
}
public unsafe bool Draw(ref byte label)
{
fixed (ImGuiTextFilter* @this = &this)
{
fixed (byte* plabel = &label)
{
byte ret = ImGuiNative.Draw(@this, (byte*)plabel, (float)(0.0f));
return ret != 0;
}
}
}
public unsafe bool Draw(ReadOnlySpan<byte> label, float width)
{
fixed (ImGuiTextFilter* @this = &this)
{
fixed (byte* plabel = label)
{
byte ret = ImGuiNative.Draw(@this, (byte*)plabel, width);
return ret != 0;
}
}
}
public unsafe bool Draw(ReadOnlySpan<byte> label)
{
fixed (ImGuiTextFilter* @this = &this)
{
fixed (byte* plabel = label)
{
byte ret = ImGuiNative.Draw(@this, (byte*)plabel, (float)(0.0f));
return ret != 0;
}
}
}
public unsafe bool Draw(string label, float width)
{
fixed (ImGuiTextFilter* @this = &this)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (label != null)
{
pStrSize0 = Utils.GetByteCountUTF8(label);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(label, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.Draw(@this, pStr0, width);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
}
public unsafe bool Draw(string label)
{
fixed (ImGuiTextFilter* @this = &this)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (label != null)
{
pStrSize0 = Utils.GetByteCountUTF8(label);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(label, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.Draw(@this, pStr0, (float)(0.0f));
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
}
public unsafe bool IsActive()
{
fixed (ImGuiTextFilter* @this = &this)
@ -175,5 +41,6 @@ public unsafe partial struct ImGuiTextFilter
}
}
}
// DISCARDED: Draw
// DISCARDED: PassFilter

View file

@ -23,115 +23,12 @@ public unsafe partial struct ImGuiTextFilterPtr
{
ImGuiNative.Destroy(Handle);
}
public unsafe bool Draw(byte* label, float width)
{
byte ret = ImGuiNative.Draw(Handle, label, width);
return ret != 0;
}
public unsafe bool Draw(byte* label)
{
byte ret = ImGuiNative.Draw(Handle, label, (float)(0.0f));
return ret != 0;
}
public unsafe bool Draw()
{
bool ret = ImGui.Draw(Handle, (string)"Filter(inc,-exc)", (float)(0.0f));
return ret;
}
public unsafe bool Draw(float width)
{
bool ret = ImGui.Draw(Handle, (string)"Filter(inc,-exc)", width);
return ret;
}
public unsafe bool Draw(ref byte label, float width)
{
fixed (byte* plabel = &label)
{
byte ret = ImGuiNative.Draw(Handle, (byte*)plabel, width);
return ret != 0;
}
}
public unsafe bool Draw(ref byte label)
{
fixed (byte* plabel = &label)
{
byte ret = ImGuiNative.Draw(Handle, (byte*)plabel, (float)(0.0f));
return ret != 0;
}
}
public unsafe bool Draw(ReadOnlySpan<byte> label, float width)
{
fixed (byte* plabel = label)
{
byte ret = ImGuiNative.Draw(Handle, (byte*)plabel, width);
return ret != 0;
}
}
public unsafe bool Draw(ReadOnlySpan<byte> label)
{
fixed (byte* plabel = label)
{
byte ret = ImGuiNative.Draw(Handle, (byte*)plabel, (float)(0.0f));
return ret != 0;
}
}
public unsafe bool Draw(string label, float width)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (label != null)
{
pStrSize0 = Utils.GetByteCountUTF8(label);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(label, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.Draw(Handle, pStr0, width);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
public unsafe bool Draw(string label)
{
byte* pStr0 = null;
int pStrSize0 = 0;
if (label != null)
{
pStrSize0 = Utils.GetByteCountUTF8(label);
if (pStrSize0 >= Utils.MaxStackallocSize)
{
pStr0 = Utils.Alloc<byte>(pStrSize0 + 1);
}
else
{
byte* pStrStack0 = stackalloc byte[pStrSize0 + 1];
pStr0 = pStrStack0;
}
int pStrOffset0 = Utils.EncodeStringUTF8(label, pStr0, pStrSize0);
pStr0[pStrOffset0] = 0;
}
byte ret = ImGuiNative.Draw(Handle, pStr0, (float)(0.0f));
if (pStrSize0 >= Utils.MaxStackallocSize)
{
Utils.Free(pStr0);
}
return ret != 0;
}
public unsafe bool IsActive()
{
byte ret = ImGuiNative.IsActive(Handle);
return ret != 0;
}
}
// DISCARDED: Draw
// DISCARDED: PassFilter

View file

@ -1,36 +1,37 @@
using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImDrawList
{
public void AddText(Vector2 pos, uint col, AutoUtf8Buffer text)
public void AddText(Vector2 pos, uint col, Utf8Buffer text)
{
fixed (ImDrawList* thisPtr = &this) ImGui.AddText(thisPtr, pos, col, text);
fixed (ImDrawList* thisPtr = &this)
ImGui.AddText(thisPtr, pos, col, text);
}
public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth,
ImFontPtr font, float fontSize, Vector2 pos, uint col, Utf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect)
{
fixed (ImDrawList* thisPtr =
&this) ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth, cpuFineClipRect);
fixed (ImDrawList* thisPtr = &this)
ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth, cpuFineClipRect);
}
public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth = 0f)
ImFontPtr font, float fontSize, Vector2 pos, uint col, Utf8Buffer text, float wrapWidth = 0f)
{
fixed (ImDrawList* thisPtr = &this) ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth);
fixed (ImDrawList* thisPtr = &this)
ImGui.AddText(thisPtr, font, fontSize, pos, col, text, wrapWidth);
}
}
public partial struct ImDrawListPtr
{
public void AddText(Vector2 pos, uint col, AutoUtf8Buffer text) => ImGui.AddText(this, pos, col, text);
public void AddText(Vector2 pos, uint col, Utf8Buffer text) => ImGui.AddText(this, pos, col, text);
public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth,
ImFontPtr font, float fontSize, Vector2 pos, uint col, Utf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect) => ImGui.AddText(
this,
font,
@ -42,6 +43,6 @@ public partial struct ImDrawListPtr
cpuFineClipRect);
public void AddText(
ImFontPtr font, float fontSize, Vector2 pos, uint col, AutoUtf8Buffer text, float wrapWidth = 0f) =>
ImFontPtr font, float fontSize, Vector2 pos, uint col, Utf8Buffer text, float wrapWidth = 0f) =>
ImGui.AddText(this, font, fontSize, pos, col, text, wrapWidth);
}

View file

@ -1,5 +1,4 @@
using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui;
@ -11,7 +10,7 @@ public unsafe partial struct ImFont
}
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, Utf8Buffer text,
float wrapWidth = 0.0f, bool cpuFineClip = false)
{
fixed (ImFont* thisPtr =
@ -21,11 +20,11 @@ public unsafe partial struct ImFont
public partial struct ImFontPtr
{
public readonly int CalcWordWrapPositionA(float scale, AutoUtf8Buffer text, float wrapWidth) =>
public readonly int CalcWordWrapPositionA(float scale, Utf8Buffer text, float wrapWidth) =>
ImGui.CalcWordWrapPositionA(this, scale, text, wrapWidth);
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, Utf8Buffer text,
float wrapWidth = 0.0f, bool cpuFineClip = false) => ImGui.RenderText(
this,
drawList,

View file

@ -0,0 +1,78 @@
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImFontAtlas
{
public ImFontPtr AddFontFromFileTTF(
Utf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default, ushort* glyphRanges = null)
{
fixed (ImFontAtlas* thisPtr = &this)
return ImGui.AddFontFromFileTTF(thisPtr, filename, sizePixels, fontCfg, glyphRanges);
}
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(
Utf8Buffer compressedFontDatabase85, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null)
{
fixed (ImFontAtlas* thisPtr = &this)
{
return ImGui.AddFontFromMemoryCompressedBase85TTF(
thisPtr,
compressedFontDatabase85,
sizePixels,
fontCfg,
glyphRanges);
}
}
public ImFontPtr AddFontFromMemoryCompressedTTF(
ReadOnlySpan<byte> compressedFontData, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null)
{
fixed (ImFontAtlas* thisPtr = &this)
{
return ImGui.AddFontFromMemoryCompressedTTF(
thisPtr,
compressedFontData,
sizePixels,
fontCfg,
glyphRanges);
}
}
public ImFontPtr AddFontFromMemoryTTF(
ReadOnlySpan<byte> fontData, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null)
{
fixed (ImFontAtlas* thisPtr = &this)
{
return ImGui.AddFontFromMemoryTTF(
thisPtr,
fontData,
sizePixels,
fontCfg,
glyphRanges);
}
}
}
public unsafe partial struct ImFontAtlasPtr
{
public ImFontPtr AddFontFromFileTTF(
Utf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default, ushort* glyphRanges = null) =>
ImGui.AddFontFromFileTTF(this, filename, sizePixels, fontCfg, glyphRanges);
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(
Utf8Buffer compressedFontDatabase85, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null) =>
ImGui.AddFontFromMemoryCompressedBase85TTF(this, compressedFontDatabase85, sizePixels, fontCfg, glyphRanges);
public ImFontPtr AddFontFromMemoryCompressedTTF(
ReadOnlySpan<byte> compressedFontData, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null) =>
ImGui.AddFontFromMemoryCompressedTTF(this, compressedFontData, sizePixels, fontCfg, glyphRanges);
public ImFontPtr AddFontFromMemoryTTF(
ReadOnlySpan<byte> fontData, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null) =>
ImGui.AddFontFromMemoryTTF(this, fontData, sizePixels, fontCfg, glyphRanges);
}

View file

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

View file

@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui;
@ -8,9 +7,9 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui
{
public static bool ColorEdit3(
AutoUtf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
Utf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector3* colPtr = &col)
{
var res = ImGuiNative.ColorEdit3(labelPtr, &colPtr->X, flags) != 0;
@ -20,9 +19,9 @@ public static unsafe partial class ImGui
}
public static bool ColorEdit4(
AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
Utf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector4* colPtr = &col)
{
var res = ImGuiNative.ColorEdit4(labelPtr, &colPtr->X, flags) != 0;
@ -32,9 +31,9 @@ public static unsafe partial class ImGui
}
public static bool ColorPicker3(
AutoUtf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
Utf8Buffer label, scoped ref Vector3 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector3* colPtr = &col)
{
var res = ImGuiNative.ColorPicker3(labelPtr, &colPtr->X, flags) != 0;
@ -44,9 +43,9 @@ public static unsafe partial class ImGui
}
public static bool ColorPicker4(
AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
Utf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector4* colPtr = &col)
{
var res = ImGuiNative.ColorPicker4(labelPtr, &colPtr->X, flags, null) != 0;
@ -56,9 +55,9 @@ public static unsafe partial class ImGui
}
public static bool ColorPicker4(
AutoUtf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags, scoped in Vector4 refCol)
Utf8Buffer label, scoped ref Vector4 col, ImGuiColorEditFlags flags, scoped in Vector4 refCol)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector4* colPtr = &col)
fixed (Vector4* refColPtr = &refCol)
{
@ -68,9 +67,9 @@ public static unsafe partial class ImGui
}
}
public static bool ColorPicker4(AutoUtf8Buffer label, scoped ref Vector4 col, scoped in Vector4 refCol)
public static bool ColorPicker4(Utf8Buffer label, scoped ref Vector4 col, scoped in Vector4 refCol)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (Vector4* colPtr = &col)
fixed (Vector4* refColPtr = &refCol)
{

View file

@ -0,0 +1,222 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public delegate bool PopulateAutoUtf8BufferDelegate(int index, out Utf8Buffer outText);
public delegate bool PopulateAutoUtf8BufferDelegate<T>(scoped in T context, int index, out Utf8Buffer outText);
public static bool Combo<T>(
Utf8Buffer label, ref int currentItem, scoped in T items, int popupMaxHeightInItems = -1)
where T : IList<string> =>
Combo(
label,
ref currentItem,
static (scoped in T items, int index, out Utf8Buffer outText) =>
{
outText = items[index];
return true;
},
items,
items.Count,
popupMaxHeightInItems);
public static bool Combo(
Utf8Buffer label, ref int currentItem, IReadOnlyList<string> items, int popupMaxHeightInItems = -1) =>
Combo(
label,
ref currentItem,
static (scoped in IReadOnlyList<string> items, int index, out Utf8Buffer outText) =>
{
outText = items[index];
return true;
},
items,
items.Count,
popupMaxHeightInItems);
public static bool Combo(
Utf8Buffer label, ref int currentItem, Utf8Buffer itemsSeparatedByZeros, int popupMaxHeightInItems = -1)
{
if (!itemsSeparatedByZeros.Span.EndsWith("\0\0"u8))
itemsSeparatedByZeros.AppendFormatted("\0\0"u8);
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (int* currentItemPtr = &currentItem)
fixed (byte* itemsSeparatedByZerosPtr = itemsSeparatedByZeros.Span)
{
var r = ImGuiNative.Combo(labelPtr, currentItemPtr, itemsSeparatedByZerosPtr, popupMaxHeightInItems) != 0;
label.Dispose();
itemsSeparatedByZeros.Dispose();
return r;
}
}
public static bool Combo<TContext>(
Utf8Buffer label, ref int currentItem, PopulateAutoUtf8BufferDelegate<TContext> itemsGetter,
scoped in TContext context, int itemsCount, int popupMaxHeightInItems = -1)
{
Utf8Buffer textBuffer = default;
var dataBuffer = stackalloc void*[3];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (int* currentItemPtr = &currentItem)
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
fixed (TContext* contextPtr = &context)
{
dataBuffer[0] = &textBuffer;
dataBuffer[1] = &itemsGetter;
dataBuffer[2] = contextPtr;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiNative.Combo(
labelPtr,
currentItemPtr,
(delegate*<byte*, int*, delegate*<void*, int, byte**, bool>, void*, int, int, bool>)
(nint)(delegate* unmanaged<void*, int, byte**, bool>)&PopulateUtf8BufferDelegateWithContext,
dataBuffer,
itemsCount,
popupMaxHeightInItems) != 0;
label.Dispose();
textBuffer.Dispose();
return r;
}
}
public static bool Combo(
Utf8Buffer label, ref int currentItem, PopulateAutoUtf8BufferDelegate itemsGetter, int itemsCount,
int popupMaxHeightInItems = -1)
{
Utf8Buffer textBuffer = default;
var dataBuffer = stackalloc void*[2];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (int* currentItemPtr = &currentItem)
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
dataBuffer[0] = &textBuffer;
dataBuffer[1] = &itemsGetter;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiNative.Combo(
labelPtr,
currentItemPtr,
(delegate*<byte*, int*, delegate*<void*, int, byte**, bool>, void*, int, int, bool>)
(nint)(delegate* unmanaged<void*, int, byte**, bool>)&PopulateUtf8BufferDelegateWithoutContext,
dataBuffer,
itemsCount,
popupMaxHeightInItems) != 0;
label.Dispose();
textBuffer.Dispose();
return r;
}
}
public static bool ListBox<T>(
Utf8Buffer label, ref int currentItem, scoped in T items, int popupMaxHeightInItems = -1)
where T : IList<string> =>
ListBox(
label,
ref currentItem,
static (scoped in T items, int index, out Utf8Buffer outText) =>
{
outText = items[index];
return true;
},
items,
items.Count,
popupMaxHeightInItems);
public static bool ListBox(
Utf8Buffer label, ref int currentItem, IReadOnlyList<string> items, int popupMaxHeightInItems = -1) =>
ListBox(
label,
ref currentItem,
static (scoped in IReadOnlyList<string> items, int index, out Utf8Buffer outText) =>
{
outText = items[index];
return true;
},
items,
items.Count,
popupMaxHeightInItems);
public static bool ListBox<TContext>(
Utf8Buffer label, ref int currentItem, PopulateAutoUtf8BufferDelegate<TContext> itemsGetter,
scoped in TContext context, int itemsCount, int popupMaxHeightInItems = -1)
{
Utf8Buffer textBuffer = default;
var dataBuffer = stackalloc void*[3];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (int* currentItemPtr = &currentItem)
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
fixed (TContext* contextPtr = &context)
{
dataBuffer[0] = &textBuffer;
dataBuffer[1] = &itemsGetter;
dataBuffer[2] = contextPtr;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiNative.ListBox(
labelPtr,
currentItemPtr,
(delegate*<byte*, int*, delegate*<void*, int, byte**, bool>, void*, int, int, bool>)
(nint)(delegate* unmanaged<void*, int, byte**, bool>)&PopulateUtf8BufferDelegateWithContext,
dataBuffer,
itemsCount,
popupMaxHeightInItems) != 0;
label.Dispose();
textBuffer.Dispose();
return r;
}
}
public static bool ListBox(
Utf8Buffer label, ref int currentItem, PopulateAutoUtf8BufferDelegate itemsGetter, int itemsCount,
int popupMaxHeightInItems = -1)
{
Utf8Buffer textBuffer = default;
var dataBuffer = stackalloc void*[2];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (int* currentItemPtr = &currentItem)
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
dataBuffer[0] = &textBuffer;
dataBuffer[1] = &itemsGetter;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiNative.ListBox(
labelPtr,
currentItemPtr,
(delegate*<byte*, int*, delegate*<void*, int, byte**, bool>, void*, int, int, bool>)
(nint)(delegate* unmanaged<void*, int, byte**, bool>)&PopulateUtf8BufferDelegateWithoutContext,
dataBuffer,
itemsCount,
popupMaxHeightInItems) != 0;
label.Dispose();
textBuffer.Dispose();
return r;
}
}
[UnmanagedCallersOnly]
private static bool PopulateUtf8BufferDelegateWithContext(void* data, int index, byte** text)
{
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ref var textBuffer = ref *(Utf8Buffer*)((void**)data)[0];
return ((PopulateAutoUtf8BufferDelegate<object>*)((void**)data)[1])->Invoke(
*(object*)((void**)data)[2],
index,
out textBuffer);
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
}
[UnmanagedCallersOnly]
private static bool PopulateUtf8BufferDelegateWithoutContext(void* data, int index, byte** text)
{
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ref var textBuffer = ref *(Utf8Buffer*)((void**)data)[0];
return ((PopulateAutoUtf8BufferDelegate*)((void**)data)[1])->Invoke(
index,
out textBuffer);
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
}
}

View file

@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
@ -9,8 +8,8 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui
{
public static bool DragSByte(
AutoUtf8Buffer label, scoped ref sbyte v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, scoped ref sbyte v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S8,
ref v,
@ -21,8 +20,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragSByte(
AutoUtf8Buffer label, Span<sbyte> v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, Span<sbyte> v, float vSpeed = 1.0f, sbyte vMin = 0, sbyte vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S8,
v,
@ -33,8 +32,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragByte(
AutoUtf8Buffer label, scoped ref byte v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, scoped ref byte v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U8,
ref v,
@ -45,8 +44,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragByte(
AutoUtf8Buffer label, Span<byte> v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, Span<byte> v, float vSpeed = 1.0f, byte vMin = 0, byte vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U8,
v,
@ -57,8 +56,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragShort(
AutoUtf8Buffer label, scoped ref short v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, scoped ref short v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S16,
ref v,
@ -69,8 +68,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragShort(
AutoUtf8Buffer label, Span<short> v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, Span<short> v, float vSpeed = 1.0f, short vMin = 0, short vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S16,
v,
@ -81,8 +80,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragUShort(
AutoUtf8Buffer label, scoped ref ushort v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, scoped ref ushort v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U16,
ref v,
@ -93,8 +92,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragUShort(
AutoUtf8Buffer label, Span<ushort> v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, Span<ushort> v, float vSpeed = 1.0f, ushort vMin = 0, ushort vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U16,
v,
@ -105,8 +104,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragInt(
AutoUtf8Buffer label, scoped ref int v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
Utf8Buffer label, scoped ref int v, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S32,
ref v,
@ -117,8 +116,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragInt(
AutoUtf8Buffer label, Span<int> v, float vSpeed = 1.0f, int vMin = 0,
int vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<int> v, float vSpeed = 1.0f, int vMin = 0,
int vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S32,
@ -130,8 +129,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragUInt(
AutoUtf8Buffer label, scoped ref uint v, float vSpeed = 1.0f, uint vMin = 0,
uint vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref uint v, float vSpeed = 1.0f, uint vMin = 0,
uint vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U32,
@ -143,8 +142,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragUInt(
AutoUtf8Buffer label, Span<uint> v, float vSpeed = 1.0f, uint vMin = 0,
uint vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<uint> v, float vSpeed = 1.0f, uint vMin = 0,
uint vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U32,
@ -156,8 +155,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragLong(
AutoUtf8Buffer label, scoped ref long v, float vSpeed = 1.0f, long vMin = 0,
long vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref long v, float vSpeed = 1.0f, long vMin = 0,
long vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S64,
@ -169,8 +168,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragLong(
AutoUtf8Buffer label, Span<long> v, float vSpeed = 1.0f, long vMin = 0,
long vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<long> v, float vSpeed = 1.0f, long vMin = 0,
long vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.S64,
@ -182,8 +181,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragULong(
AutoUtf8Buffer label, scoped ref ulong v, float vSpeed = 1.0f,
ulong vMin = 0, ulong vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref ulong v, float vSpeed = 1.0f,
ulong vMin = 0, ulong vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U64,
@ -195,8 +194,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragULong(
AutoUtf8Buffer label, Span<ulong> v, float vSpeed = 1.0f, ulong vMin = 0,
ulong vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<ulong> v, float vSpeed = 1.0f, ulong vMin = 0,
ulong vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.U64,
@ -208,8 +207,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragFloat(
AutoUtf8Buffer label, scoped ref float v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref float v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Float,
@ -221,8 +220,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragFloat(
AutoUtf8Buffer label, Span<float> v, float vSpeed = 1.0f, float vMin = 0.0f,
float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<float> v, float vSpeed = 1.0f, float vMin = 0.0f,
float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Float,
@ -234,8 +233,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragFloat2(
AutoUtf8Buffer label, scoped ref Vector2 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref Vector2 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Float,
@ -247,8 +246,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragFloat3(
AutoUtf8Buffer label, scoped ref Vector3 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref Vector3 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Float,
@ -260,8 +259,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragFloat4(
AutoUtf8Buffer label, scoped ref Vector4 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref Vector4 v, float vSpeed = 1.0f,
float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Float,
@ -273,8 +272,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragDouble(
AutoUtf8Buffer label, scoped ref double v, float vSpeed = 1.0f,
double vMin = 0.0f, double vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref double v, float vSpeed = 1.0f,
double vMin = 0.0f, double vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Double,
@ -286,8 +285,8 @@ public static unsafe partial class ImGui
flags);
public static bool DragDouble(
AutoUtf8Buffer label, Span<double> v, float vSpeed = 1.0f,
double vMin = 0.0f, double vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<double> v, float vSpeed = 1.0f,
double vMin = 0.0f, double vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => DragScalar(
label,
ImGuiDataType.Double,
@ -299,12 +298,12 @@ public static unsafe partial class ImGui
flags);
public static bool DragScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T v, float vSpeed,
scoped in T vMin, scoped in T vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, ImGuiDataType dataType, scoped ref T v, float vSpeed,
scoped in T vMin, scoped in T vMax, Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* vPtr = &v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
@ -317,12 +316,12 @@ public static unsafe partial class ImGui
}
public static bool DragScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> v, float vSpeed,
scoped in T vMin, scoped in T vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, ImGuiDataType dataType, Span<T> v, float vSpeed,
scoped in T vMin, scoped in T vMax, Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* vPtr = v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
@ -344,17 +343,17 @@ public static unsafe partial class ImGui
}
public static bool DragFloatRange2(
AutoUtf8Buffer label, scoped ref float vCurrentMin,
Utf8Buffer label, scoped ref float vCurrentMin,
scoped ref float vCurrentMax, float vSpeed = 1.0f, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default,
AutoUtf8Buffer formatMax = default,
Utf8Buffer format = default,
Utf8Buffer formatMax = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
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)
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference("%.3f"u8))
fixed (byte* formatMaxPtr = &formatMax.GetPinnableNullTerminatedReference())
{
var res = ImGuiNative.DragFloatRange2(
labelPtr,
@ -374,17 +373,17 @@ public static unsafe partial class ImGui
}
public static bool DragIntRange2(
AutoUtf8Buffer label, scoped ref int vCurrentMin,
Utf8Buffer label, scoped ref int vCurrentMin,
scoped ref int vCurrentMax, float vSpeed = 1.0f, int vMin = 0, int vMax = 0,
AutoUtf8Buffer format = default,
AutoUtf8Buffer formatMax = default,
Utf8Buffer format = default,
Utf8Buffer formatMax = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
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)
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference("%d"u8))
fixed (byte* formatMaxPtr = &formatMax.GetPinnableNullTerminatedReference())
{
var res = ImGuiNative.DragIntRange2(
labelPtr,

View file

@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
@ -9,8 +8,8 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui
{
public static bool InputSByte(
AutoUtf8Buffer label, scoped ref sbyte data, sbyte step = 0, sbyte stepFast = 0,
AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
Utf8Buffer label, scoped ref sbyte data, sbyte step = 0, sbyte stepFast = 0,
Utf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S8,
ref data,
@ -20,7 +19,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputSByte(
AutoUtf8Buffer label, Span<sbyte> data, sbyte step = 0, sbyte stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<sbyte> data, sbyte step = 0, sbyte stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S8,
@ -31,7 +30,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputByte(
AutoUtf8Buffer label, scoped ref byte data, byte step = 0, byte stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref byte data, byte step = 0, byte stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U8,
@ -42,7 +41,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputByte(
AutoUtf8Buffer label, Span<byte> data, byte step = 0, byte stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<byte> data, byte step = 0, byte stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U8,
@ -53,8 +52,8 @@ public static unsafe partial class ImGui
flags);
public static bool InputShort(
AutoUtf8Buffer label, scoped ref short data, short step = 0, short stepFast = 0,
AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
Utf8Buffer label, scoped ref short data, short step = 0, short stepFast = 0,
Utf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S16,
ref data,
@ -64,7 +63,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputShort(
AutoUtf8Buffer label, Span<short> data, short step = 0, short stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<short> data, short step = 0, short stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S16,
@ -75,8 +74,8 @@ public static unsafe partial class ImGui
flags);
public static bool InputUShort(
AutoUtf8Buffer label, scoped ref ushort data, ushort step = 0, ushort stepFast = 0,
AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
Utf8Buffer label, scoped ref ushort data, ushort step = 0, ushort stepFast = 0,
Utf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U16,
ref data,
@ -86,7 +85,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputUShort(
AutoUtf8Buffer label, Span<ushort> data, ushort step = 0, ushort stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<ushort> data, ushort step = 0, ushort stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U16,
@ -97,7 +96,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputInt(
AutoUtf8Buffer label, scoped ref int data, int step = 0, int stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref int data, int step = 0, int stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S32,
@ -108,7 +107,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputInt(
AutoUtf8Buffer label, Span<int> data, int step = 0, int stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<int> data, int step = 0, int stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S32,
@ -119,7 +118,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputUInt(
AutoUtf8Buffer label, scoped ref uint data, uint step = 0, uint stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref uint data, uint step = 0, uint stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U32,
@ -130,7 +129,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputUInt(
AutoUtf8Buffer label, Span<uint> data, uint step = 0, uint stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<uint> data, uint step = 0, uint stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U32,
@ -141,7 +140,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputLong(
AutoUtf8Buffer label, scoped ref long data, long step = 0, long stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref long data, long step = 0, long stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S64,
@ -152,7 +151,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputLong(
AutoUtf8Buffer label, Span<long> data, long step = 0, long stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<long> data, long step = 0, long stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.S64,
@ -163,8 +162,8 @@ public static unsafe partial class ImGui
flags);
public static bool InputULong(
AutoUtf8Buffer label, scoped ref ulong data, ulong step = 0, ulong stepFast = 0,
AutoUtf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
Utf8Buffer label, scoped ref ulong data, ulong step = 0, ulong stepFast = 0,
Utf8Buffer format = default, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U64,
ref data,
@ -174,7 +173,7 @@ public static unsafe partial class ImGui
flags);
public static bool InputULong(
AutoUtf8Buffer label, Span<ulong> data, ulong step = 0, ulong stepFast = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<ulong> data, ulong step = 0, ulong stepFast = 0, Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) => InputScalar(
label,
ImGuiDataType.U64,
@ -185,23 +184,23 @@ public static unsafe partial class ImGui
flags);
public static bool InputFloat(
AutoUtf8Buffer label, scoped ref float data, float step = 0.0f,
Utf8Buffer label, scoped ref float data, float step = 0.0f,
float stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Float, ref data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputFloat(
AutoUtf8Buffer label, Span<float> data, float step = 0.0f,
Utf8Buffer label, Span<float> data, float step = 0.0f,
float stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Float, data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputFloat2(
AutoUtf8Buffer label, scoped ref Vector2 data, float step = 0.0f,
Utf8Buffer label, scoped ref Vector2 data, float step = 0.0f,
float stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
@ -213,9 +212,9 @@ public static unsafe partial class ImGui
flags);
public static bool InputFloat3(
AutoUtf8Buffer label, scoped ref Vector3 data, float step = 0.0f,
Utf8Buffer label, scoped ref Vector3 data, float step = 0.0f,
float stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
@ -227,9 +226,9 @@ public static unsafe partial class ImGui
flags);
public static bool InputFloat4(
AutoUtf8Buffer label, scoped ref Vector4 data, float step = 0.0f,
Utf8Buffer label, scoped ref Vector4 data, float step = 0.0f,
float stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(
label,
@ -241,28 +240,28 @@ public static unsafe partial class ImGui
flags);
public static bool InputDouble(
AutoUtf8Buffer label, scoped ref double data, double step = 0.0f,
Utf8Buffer label, scoped ref double data, double step = 0.0f,
double stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Double, ref data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputDouble(
AutoUtf8Buffer label, Span<double> data, double step = 0.0f,
Utf8Buffer label, Span<double> data, double step = 0.0f,
double stepFast = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) =>
InputScalar(label, ImGuiDataType.Double, data, step, stepFast, format.MoveOrDefault("%.3f"u8), flags);
public static bool InputScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T data,
Utf8Buffer label, ImGuiDataType dataType, scoped ref T data,
scoped in T step, scoped in T stepFast,
AutoUtf8Buffer format = default,
Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* dataPtr = &data)
fixed (T* stepPtr = &step)
fixed (T* stepFastPtr = &stepFast)
@ -282,14 +281,14 @@ public static unsafe partial class ImGui
}
public static bool InputScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> data,
Utf8Buffer label, ImGuiDataType dataType, Span<T> data,
scoped in T step, scoped in T stepFast,
AutoUtf8Buffer format = default,
Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* dataPtr = data)
fixed (T* stepPtr = &step)
fixed (T* stepFastPtr = &stepFast)

View file

@ -1,18 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public static ImGuiPayloadPtr AcceptDragDropPayload(
Utf8Buffer type, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None)
{
fixed (byte* typePtr = &type.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.AcceptDragDropPayload(typePtr, flags);
type.Dispose();
return r;
}
}
public static ImFontPtr AddFontFromFileTTF(
ImFontAtlasPtr self, AutoUtf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default,
ImFontAtlasPtr self, Utf8Buffer filename, float sizePixels, ImFontConfigPtr fontCfg = default,
ushort* glyphRanges = null)
{
fixed (byte* filenamePtr = filename.NullTerminatedSpan)
fixed (byte* filenamePtr = &filename.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.AddFontFromFileTTF(self, filenamePtr, sizePixels, fontCfg, glyphRanges);
filename.Dispose();
@ -21,10 +30,10 @@ public static unsafe partial class ImGui
}
public static ImFontPtr AddFontFromMemoryCompressedBase85TTF(
ImFontAtlasPtr self, AutoUtf8Buffer compressedFontDatabase85, float sizePixels,
ImFontAtlasPtr self, Utf8Buffer compressedFontDatabase85, float sizePixels,
ImFontConfigPtr fontCfg = default, ushort* glyphRanges = null)
{
fixed (byte* compressedFontDatabase85Ptr = compressedFontDatabase85.NullTerminatedSpan)
fixed (byte* compressedFontDatabase85Ptr = &compressedFontDatabase85.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.AddFontFromMemoryCompressedBase85TTF(
self,
@ -65,6 +74,15 @@ public static unsafe partial class ImGui
glyphRanges);
}
public static void AddInputCharacter(ImGuiIOPtr self, char c) => ImGuiNative.AddInputCharacter(self, c);
public static void AddInputCharacter(ImGuiIOPtr self, Rune c) => ImGuiNative.AddInputCharacter(self, (uint)c.Value);
public static void AddInputCharacters(ImGuiIOPtr self, Utf8Buffer str)
{
fixed (byte* strPtr = &str.GetPinnableNullTerminatedReference())
ImGuiNative.AddInputCharactersUTF8(self.Handle, strPtr);
str.Dispose();
}
public static ref bool GetBoolRef(ImGuiStoragePtr self, uint key, bool defaultValue = false) =>
ref *ImGuiNative.GetBoolRef(self.Handle, key, defaultValue ? (byte)1 : (byte)0);
@ -86,7 +104,7 @@ public static unsafe partial class ImGui
return ref *(T*)ImGuiNative.GetVoidPtrRef(self.Handle, key, *(void**)&defaultValue);
}
public static uint GetID(AutoUtf8Buffer strId)
public static uint GetID(Utf8Buffer strId)
{
fixed (byte* strIdPtr = strId.Span)
{
@ -100,7 +118,7 @@ public static unsafe partial class ImGui
public static uint GetID(nuint ptrId) => ImGuiNative.GetID((void*)ptrId);
public static uint GetID(void* ptrId) => ImGuiNative.GetID(ptrId);
public static void PushID(AutoUtf8Buffer strId)
public static void PushID(Utf8Buffer strId)
{
fixed (byte* strIdPtr = strId.Span)
{
@ -115,6 +133,3 @@ public static unsafe partial class ImGui
public static void PushID(void* ptrId) =>
ImGuiNative.PushID(ptrId);
}
// DISCARDED: PlotHistogram
// DISCARDED: PlotLines

View file

@ -0,0 +1,193 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public delegate float GetFloatDelegate(int index);
public delegate float GetFloatDelegate<T>(scoped in T context, int index);
public static void PlotHistogram(
Utf8Buffer label, ReadOnlySpan<float> values, int valuesOffset = 0, Utf8Buffer overlayText = default,
float scaleMin = float.MaxValue, float scaleMax = float.MaxValue, Vector2 graphSize = default,
int stride = sizeof(float))
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (float* valuesPtr = values)
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
{
ImGuiNative.PlotHistogram(
labelPtr,
valuesPtr,
values.Length,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize,
stride);
}
label.Dispose();
overlayText.Dispose();
}
public static void PlotHistogram<TContext>(
Utf8Buffer label, GetFloatDelegate<TContext> valuesGetter, scoped in TContext context, int valuesCount,
int valuesOffset = 0, Utf8Buffer overlayText = default, float scaleMin = float.MaxValue,
float scaleMax = float.MaxValue, Vector2 graphSize = default)
{
var dataBuffer = stackalloc void*[2];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
fixed (TContext* contextPtr = &context)
{
dataBuffer[0] = &valuesGetter;
dataBuffer[1] = contextPtr;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ImGuiNative.PlotHistogram(
labelPtr,
(delegate*<byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float, Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize);
}
label.Dispose();
overlayText.Dispose();
}
public static void PlotHistogram(
Utf8Buffer label, GetFloatDelegate valuesGetter, int valuesCount,
int valuesOffset = 0, Utf8Buffer overlayText = default, float scaleMin = float.MaxValue,
float scaleMax = float.MaxValue, Vector2 graphSize = default)
{
var dataBuffer = stackalloc void*[1];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
dataBuffer[0] = &valuesGetter;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ImGuiNative.PlotHistogram(
labelPtr,
(delegate*<byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float, Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize);
}
label.Dispose();
overlayText.Dispose();
}
public static void PlotLines(
Utf8Buffer label, ReadOnlySpan<float> values, int valuesOffset = 0, Utf8Buffer overlayText = default,
float scaleMin = float.MaxValue, float scaleMax = float.MaxValue, Vector2 graphSize = default,
int stride = sizeof(float))
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (float* valuesPtr = values)
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
{
ImGuiNative.PlotLines(
labelPtr,
valuesPtr,
values.Length,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize,
stride);
}
label.Dispose();
overlayText.Dispose();
}
public static void PlotLines<TContext>(
Utf8Buffer label, GetFloatDelegate<TContext> valuesGetter, scoped in TContext context, int valuesCount,
int valuesOffset = 0, Utf8Buffer overlayText = default, float scaleMin = float.MaxValue,
float scaleMax = float.MaxValue, Vector2 graphSize = default)
{
var dataBuffer = stackalloc void*[2];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
fixed (TContext* contextPtr = &context)
{
dataBuffer[0] = &valuesGetter;
dataBuffer[1] = contextPtr;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ImGuiNative.PlotLines(
labelPtr,
(delegate*<byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float, Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize);
}
label.Dispose();
overlayText.Dispose();
}
public static void PlotLines(
Utf8Buffer label, GetFloatDelegate valuesGetter, int valuesCount,
int valuesOffset = 0, Utf8Buffer overlayText = default, float scaleMin = float.MaxValue,
float scaleMax = float.MaxValue, Vector2 graphSize = default)
{
var dataBuffer = stackalloc void*[1];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
dataBuffer[0] = &valuesGetter;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
ImGuiNative.PlotLines(
labelPtr,
(delegate*<byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float, Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
graphSize);
}
label.Dispose();
overlayText.Dispose();
}
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
[UnmanagedCallersOnly]
private static float GetFloatWithContext(void* data, int index) =>
((GetFloatDelegate<object>*)((void**)data)[0])->Invoke(*(object*)((void**)data)[1], index);
[UnmanagedCallersOnly]
private static float GetFloatWithoutContext(void* data, int index) =>
((GetFloatDelegate*)((void**)data)[0])->Invoke(index);
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
}

View file

@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
@ -9,7 +8,7 @@ namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGui
{
public static bool SliderSByte(
AutoUtf8Buffer label, scoped ref sbyte v, sbyte vMin = 0, sbyte vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref sbyte v, sbyte vMin = 0, sbyte vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S8,
@ -20,7 +19,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderSByte(
AutoUtf8Buffer label, Span<sbyte> v, sbyte vMin = 0, sbyte vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<sbyte> v, sbyte vMin = 0, sbyte vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S8,
@ -31,7 +30,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderByte(
AutoUtf8Buffer label, scoped ref byte v, byte vMin = 0, byte vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref byte v, byte vMin = 0, byte vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U8,
@ -42,7 +41,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderByte(
AutoUtf8Buffer label, Span<byte> v, byte vMin = 0, byte vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<byte> v, byte vMin = 0, byte vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U8,
@ -53,7 +52,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderShort(
AutoUtf8Buffer label, scoped ref short v, short vMin = 0, short vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref short v, short vMin = 0, short vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S16,
@ -64,7 +63,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderShort(
AutoUtf8Buffer label, Span<short> v, short vMin = 0, short vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<short> v, short vMin = 0, short vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S16,
@ -75,7 +74,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderUShort(
AutoUtf8Buffer label, scoped ref ushort v, ushort vMin = 0, ushort vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref ushort v, ushort vMin = 0, ushort vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U16,
@ -86,7 +85,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderUShort(
AutoUtf8Buffer label, Span<ushort> v, ushort vMin = 0, ushort vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<ushort> v, ushort vMin = 0, ushort vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U16,
@ -97,7 +96,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderInt(
AutoUtf8Buffer label, scoped ref int v, int vMin = 0, int vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref int v, int vMin = 0, int vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S32,
@ -108,7 +107,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderInt(
AutoUtf8Buffer label, Span<int> v, int vMin = 0, int vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<int> v, int vMin = 0, int vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S32,
@ -119,7 +118,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderUInt(
AutoUtf8Buffer label, scoped ref uint v, uint vMin = 0, uint vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref uint v, uint vMin = 0, uint vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U32,
@ -130,7 +129,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderUInt(
AutoUtf8Buffer label, Span<uint> v, uint vMin = 0, uint vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<uint> v, uint vMin = 0, uint vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U32,
@ -141,7 +140,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderLong(
AutoUtf8Buffer label, scoped ref long v, long vMin = 0, long vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref long v, long vMin = 0, long vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S64,
@ -152,7 +151,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderLong(
AutoUtf8Buffer label, Span<long> v, long vMin = 0, long vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<long> v, long vMin = 0, long vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.S64,
@ -163,7 +162,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderULong(
AutoUtf8Buffer label, scoped ref ulong v, ulong vMin = 0, ulong vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref ulong v, ulong vMin = 0, ulong vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U64,
@ -174,7 +173,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderULong(
AutoUtf8Buffer label, Span<ulong> v, ulong vMin = 0, ulong vMax = 0, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<ulong> v, ulong vMin = 0, ulong vMax = 0, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.U64,
@ -185,7 +184,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderFloat(
AutoUtf8Buffer label, scoped ref float v, float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, scoped ref float v, float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.Float,
@ -196,7 +195,7 @@ public static unsafe partial class ImGui
flags);
public static bool SliderFloat(
AutoUtf8Buffer label, Span<float> v, float vMin = 0.0f, float vMax = 0.0f, AutoUtf8Buffer format = default,
Utf8Buffer label, Span<float> v, float vMin = 0.0f, float vMax = 0.0f, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.Float,
@ -207,8 +206,8 @@ public static unsafe partial class ImGui
flags);
public static bool SliderFloat2(
AutoUtf8Buffer label, scoped ref Vector2 v, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
Utf8Buffer label, scoped ref Vector2 v, float vMin = 0.0f, float vMax = 0.0f,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) => SliderScalar(
label,
ImGuiDataType.Float,
MemoryMarshal.Cast<Vector2, float>(new(ref v)),
@ -218,8 +217,8 @@ public static unsafe partial class ImGui
flags);
public static bool SliderFloat3(
AutoUtf8Buffer label, scoped ref Vector3 v, float vMin = 0.0f, float vMax = 0.0f,
AutoUtf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
Utf8Buffer label, scoped ref Vector3 v, float vMin = 0.0f, float vMax = 0.0f,
Utf8Buffer format = default, ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(
label,
ImGuiDataType.Float,
@ -230,9 +229,9 @@ public static unsafe partial class ImGui
flags);
public static bool SliderFloat4(
AutoUtf8Buffer label, scoped ref Vector4 v, float vMin = 0.0f,
Utf8Buffer label, scoped ref Vector4 v, float vMin = 0.0f,
float vMax = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(
label,
@ -244,28 +243,28 @@ public static unsafe partial class ImGui
flags);
public static bool SliderDouble(
AutoUtf8Buffer label, scoped ref double v, double vMin = 0.0f,
Utf8Buffer label, scoped ref double v, double vMin = 0.0f,
double vMax = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Double, ref v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderDouble(
AutoUtf8Buffer label, Span<double> v, double vMin = 0.0f,
Utf8Buffer label, Span<double> v, double vMin = 0.0f,
double vMax = 0.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
SliderScalar(label, ImGuiDataType.Double, v, vMin, vMax, format.MoveOrDefault("%.3f"u8), flags);
public static bool SliderScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, scoped ref T v,
Utf8Buffer label, ImGuiDataType dataType, scoped ref T v,
scoped in T vMin, scoped in T vMax,
AutoUtf8Buffer format = default,
Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* vPtr = &v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
@ -285,14 +284,14 @@ public static unsafe partial class ImGui
}
public static bool SliderScalar<T>(
AutoUtf8Buffer label, ImGuiDataType dataType, Span<T> v, scoped in T vMin,
Utf8Buffer label, ImGuiDataType dataType, Span<T> v, scoped in T vMin,
scoped in T vMax,
AutoUtf8Buffer format = default,
Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* vPtr = v)
fixed (T* vMinPtr = &vMin)
fixed (T* vMaxPtr = &vMax)
@ -313,13 +312,13 @@ public static unsafe partial class ImGui
}
public static bool SliderAngle(
AutoUtf8Buffer label, ref float vRad, float vDegreesMin = -360.0f,
Utf8Buffer label, ref float vRad, float vDegreesMin = -360.0f,
float vDegreesMax = +360.0f,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None)
{
fixed (byte* labelPtr = label.NullTerminatedSpan)
fixed (byte* formatPtr = format.IsInitialized ? format.NullTerminatedSpan : "%.0f deg"u8)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference("%.0f deg"u8))
fixed (float* vRadPtr = &vRad)
{
var res = ImGuiNative.SliderAngle(
@ -336,76 +335,76 @@ public static unsafe partial class ImGui
}
public static bool VSliderSByte(
AutoUtf8Buffer label, Vector2 size, scoped ref sbyte v, sbyte vMin,
sbyte vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref sbyte v, sbyte vMin,
sbyte vMax, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S8, ref v, vMin, vMax, format.MoveOrDefault("%hhd"), flags);
public static bool VSliderByte(
AutoUtf8Buffer label, Vector2 size, scoped ref byte v, byte vMin, byte vMax,
AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref byte v, byte vMin, byte vMax,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U8, ref v, vMin, vMax, format.MoveOrDefault("%hhu"), flags);
public static bool VSliderShort(
AutoUtf8Buffer label, Vector2 size, scoped ref short v, short vMin,
short vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref short v, short vMin,
short vMax, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S16, ref v, vMin, vMax, format.MoveOrDefault("%hd"), flags);
public static bool VSliderUShort(
AutoUtf8Buffer label, Vector2 size, scoped ref ushort v, ushort vMin,
Utf8Buffer label, Vector2 size, scoped ref ushort v, ushort vMin,
ushort vMax,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U16, ref v, vMin, vMax, format.MoveOrDefault("%hu"), flags);
public static bool VSliderInt(
AutoUtf8Buffer label, Vector2 size, scoped ref int v, int vMin, int vMax,
AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref int v, int vMin, int vMax,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S32, ref v, vMin, vMax, format.MoveOrDefault("%d"), flags);
public static bool VSliderUInt(
AutoUtf8Buffer label, Vector2 size, scoped ref uint v, uint vMin, uint vMax,
AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref uint v, uint vMin, uint vMax,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U32, ref v, vMin, vMax, format.MoveOrDefault("%u"), flags);
public static bool VSliderLong(
AutoUtf8Buffer label, Vector2 size, scoped ref long v, long vMin, long vMax,
AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref long v, long vMin, long vMax,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.S32, ref v, vMin, vMax, format.MoveOrDefault("%I64d"), flags);
public static bool VSliderULong(
AutoUtf8Buffer label, Vector2 size, scoped ref ulong v, ulong vMin,
ulong vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref ulong v, ulong vMin,
ulong vMax, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.U32, ref v, vMin, vMax, format.MoveOrDefault("%I64u"), flags);
public static bool VSliderFloat(
AutoUtf8Buffer label, Vector2 size, scoped ref float v, float vMin,
float vMax, AutoUtf8Buffer format = default,
Utf8Buffer label, Vector2 size, scoped ref float v, float vMin,
float vMax, Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.Float, ref v, vMin, vMax, format.MoveOrDefault("%.03f"), flags);
public static bool VSliderDouble(
AutoUtf8Buffer label, Vector2 size, scoped ref double v, double vMin,
Utf8Buffer label, Vector2 size, scoped ref double v, double vMin,
double vMax,
AutoUtf8Buffer format = default,
Utf8Buffer format = default,
ImGuiSliderFlags flags = ImGuiSliderFlags.None) =>
VSliderScalar(label, size, ImGuiDataType.Double, ref v, vMin, vMax, format.MoveOrDefault("%.03f"), flags);
public static bool VSliderScalar<T>(
AutoUtf8Buffer label, Vector2 size, ImGuiDataType dataType,
Utf8Buffer label, Vector2 size, ImGuiDataType dataType,
scoped ref T data, scoped in T min, scoped in T max,
AutoUtf8Buffer format = default,
Utf8Buffer 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 (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* dataPtr = &data)
fixed (T* minPtr = &min)
fixed (T* maxPtr = &max)

View file

@ -6,20 +6,20 @@ namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public static void AddText(ImFontGlyphRangesBuilderPtr self, AutoUtf8Buffer text)
public static void AddText(ImFontGlyphRangesBuilderPtr self, Utf8Buffer text)
{
fixed (byte* textPtr = text.Span) ImGuiNative.AddText(self.Handle, textPtr, textPtr + text.Length);
text.Dispose();
}
public static void AddText(ImDrawListPtr self, Vector2 pos, uint col, AutoUtf8Buffer text)
public static void AddText(ImDrawListPtr self, Vector2 pos, uint col, Utf8Buffer text)
{
fixed (byte* textPtr = text.Span) ImGuiNative.AddText(self.Handle, pos, col, textPtr, textPtr + text.Length);
text.Dispose();
}
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, Utf8Buffer text, float wrapWidth,
scoped in Vector4 cpuFineClipRect)
{
fixed (byte* textPtr = text.Span)
@ -38,7 +38,7 @@ public static unsafe partial class ImGui
}
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, Utf8Buffer text,
float wrapWidth = 0f)
{
fixed (byte* textPtr = text.Span)
@ -46,13 +46,13 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void append(ImGuiTextBufferPtr self, AutoUtf8Buffer str)
public static void append(ImGuiTextBufferPtr self, Utf8Buffer str)
{
fixed (byte* strPtr = str.Span) ImGuiNative.append(self.Handle, strPtr, strPtr + str.Length);
str.Dispose();
}
public static void BulletText(AutoUtf8Buffer text)
public static void BulletText(Utf8Buffer text)
{
ImGuiWindow* window = ImGuiP.GetCurrentWindow();
if (window->SkipItems != 0) return;
@ -79,7 +79,7 @@ public static unsafe partial class ImGui
}
public static Vector2 CalcTextSize(
AutoUtf8Buffer text, bool hideTextAfterDoubleHash = false, float wrapWidth = -1.0f)
Utf8Buffer text, bool hideTextAfterDoubleHash = false, float wrapWidth = -1.0f)
{
var @out = Vector2.Zero;
fixed (byte* textPtr = text.Span)
@ -94,7 +94,7 @@ public static unsafe partial class ImGui
}
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, Utf8Buffer text, out int remaining)
{
var @out = Vector2.Zero;
fixed (byte* textPtr = text.Span)
@ -117,7 +117,7 @@ public static unsafe partial class ImGui
}
public static int CalcWordWrapPositionA(
ImFontPtr font, float scale, AutoUtf8Buffer text, float wrapWidth)
ImFontPtr font, float scale, Utf8Buffer text, float wrapWidth)
{
fixed (byte* ptr = text.Span)
{
@ -129,7 +129,7 @@ public static unsafe partial class ImGui
}
public static void InsertChars(
ImGuiInputTextCallbackDataPtr self, int pos, AutoUtf8Buffer text)
ImGuiInputTextCallbackDataPtr self, int pos, Utf8Buffer text)
{
fixed (byte* ptr = text.Span)
ImGuiNative.InsertChars(self.Handle, pos, ptr, ptr + text.Length);
@ -137,8 +137,8 @@ public static unsafe partial class ImGui
}
public static void LabelText(
AutoUtf8Buffer label,
AutoUtf8Buffer text)
Utf8Buffer label,
Utf8Buffer text)
{
var window = ImGuiP.GetCurrentWindow().Handle;
if (window->SkipItems != 0)
@ -183,7 +183,7 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void LogText(AutoUtf8Buffer text)
public static void LogText(Utf8Buffer text)
{
var g = GetCurrentContext();
if (!g.LogFile.IsNull)
@ -201,7 +201,7 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void PassFilter(ImGuiTextFilterPtr self, AutoUtf8Buffer text)
public static void PassFilter(ImGuiTextFilterPtr self, Utf8Buffer text)
{
fixed (byte* textPtr = text.Span)
ImGuiNative.PassFilter(self.Handle, textPtr, textPtr + text.Length);
@ -210,7 +210,7 @@ public static unsafe partial class ImGui
public static void RenderText(
ImFontPtr self, ImDrawListPtr drawList, float size, Vector2 pos, uint col, Vector4 clipRect,
AutoUtf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false)
Utf8Buffer text, float wrapWidth = 0.0f, bool cpuFineClip = false)
{
fixed (byte* textPtr = text.Span)
ImGuiNative.RenderText(
@ -227,7 +227,7 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void SetTooltip(AutoUtf8Buffer text)
public static void SetTooltip(Utf8Buffer text)
{
ImGuiP.BeginTooltipEx(ImGuiTooltipFlags.OverridePreviousTooltip, ImGuiWindowFlags.None);
Text(text.Span);
@ -235,14 +235,14 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void Text(AutoUtf8Buffer text)
public static void Text(Utf8Buffer text)
{
fixed (byte* ptr = text.Span)
ImGuiNative.TextUnformatted(ptr, ptr + text.Length);
text.Dispose();
}
public static void TextColored(uint col, AutoUtf8Buffer text)
public static void TextColored(uint col, Utf8Buffer text)
{
PushStyleColor(ImGuiCol.Text, col);
Text(text.Span);
@ -250,7 +250,7 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void TextColored(scoped in Vector4 col, AutoUtf8Buffer text)
public static void TextColored(scoped in Vector4 col, Utf8Buffer text)
{
PushStyleColor(ImGuiCol.Text, col);
Text(text.Span);
@ -258,19 +258,19 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static void TextDisabled(AutoUtf8Buffer text)
public static void TextDisabled(Utf8Buffer text)
{
TextColored(*GetStyleColorVec4(ImGuiCol.TextDisabled), text.Span);
text.Dispose();
}
public static void TextUnformatted(AutoUtf8Buffer text)
public static void TextUnformatted(Utf8Buffer text)
{
Text(text.Span);
text.Dispose();
}
public static void TextWrapped(AutoUtf8Buffer text)
public static void TextWrapped(Utf8Buffer text)
{
scoped ref var g = ref *GetCurrentContext().Handle;
var needBackup = g.CurrentWindow->DC.TextWrapPos < 0.0f; // Keep existing wrap position if one is already set
@ -282,7 +282,7 @@ public static unsafe partial class ImGui
text.Dispose();
}
public static bool TreeNode(AutoUtf8Buffer label)
public static bool TreeNode(Utf8Buffer label)
{
var window = ImGuiP.GetCurrentWindow();
if (window.SkipItems)
@ -291,21 +291,17 @@ public static unsafe partial class ImGui
return false;
}
fixed (byte* labelPtr = label.Span)
{
var res = ImGuiP.TreeNodeBehavior(
window.Handle->GetID(label.Span),
ImGuiTreeNodeFlags.None,
labelPtr,
labelPtr + ImGuiP.FindRenderedTextEnd(label.Span, out _, out _));
label.Dispose();
return res;
}
var res = ImGuiP.TreeNodeBehavior(
window.Handle->GetID(label.Span),
ImGuiTreeNodeFlags.None,
label.Span[..ImGuiP.FindRenderedTextEnd(label.Span, out _, out _)]);
label.Dispose();
return res;
}
public static bool TreeNodeEx(
AutoUtf8Buffer id, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None,
AutoUtf8Buffer label = default)
Utf8Buffer id, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None,
Utf8Buffer label = default)
{
var window = ImGuiP.GetCurrentWindow();
bool res;
@ -313,21 +309,16 @@ public static unsafe partial class ImGui
{
res = false;
}
else if (label.IsEmpty)
else if (label.IsNull)
{
fixed (byte* ptr = id.Span)
{
res = ImGuiP.TreeNodeBehavior(
window.Handle->GetID(id.Span),
flags,
ptr,
ptr + ImGuiP.FindRenderedTextEnd(id.Span, out _, out _));
}
res = ImGuiP.TreeNodeBehavior(
window.Handle->GetID(id.Span),
flags,
id.Span[..ImGuiP.FindRenderedTextEnd(id.Span, out _, out _)]);
}
else
{
fixed (byte* ptr = label.Span)
res = ImGuiP.TreeNodeBehavior(window.Handle->GetID(id.Span), flags, ptr, ptr + label.Length);
res = ImGuiP.TreeNodeBehavior(window.Handle->GetID(id.Span), flags, label.Span[..label.Length]);
}
id.Dispose();

View file

@ -0,0 +1,654 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public static bool Begin(Utf8Buffer name, ref bool open, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
fixed (bool* openPtr = &open)
{
var r = ImGuiNative.Begin(namePtr, openPtr, flags) != 0;
name.Dispose();
return r;
}
}
public static bool Begin(Utf8Buffer name, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.Begin(namePtr, null, flags) != 0;
name.Dispose();
return r;
}
}
public static bool BeginChild(Utf8Buffer strId, Vector2 size = default, bool border = false, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginChild(strIdPtr, size, border ? (byte)1 : (byte)0, flags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginChild(uint id, Vector2 size = default, bool border = false, ImGuiWindowFlags flags = ImGuiWindowFlags.None) =>
ImGuiNative.BeginChild(id, size, border ? (byte)1 : (byte)0, flags) != 0;
public static bool BeginCombo(Utf8Buffer label, Utf8Buffer previewValue, ImGuiComboFlags flags = ImGuiComboFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* previewValuePtr = &previewValue.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginCombo(labelPtr, previewValuePtr, flags) != 0;
label.Dispose();
previewValue.Dispose();
return r;
}
}
public static bool BeginListBox(Utf8Buffer label, Vector2 size = default)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginListBox(labelPtr, size) != 0;
label.Dispose();
return r;
}
}
public static bool BeginMenu(Utf8Buffer label, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginMenu(labelPtr, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
return r;
}
}
public static bool BeginPopup(Utf8Buffer strId, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginPopup(strIdPtr, flags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginPopupContextItem(Utf8Buffer strId, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.MouseButtonDefault)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginPopupContextItem(strIdPtr, popupFlags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginPopupContextWindow(Utf8Buffer strId, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.MouseButtonDefault)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginPopupContextWindow(strIdPtr, popupFlags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginPopupContextVoid(Utf8Buffer strId, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.MouseButtonDefault)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginPopupContextVoid(strIdPtr, popupFlags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginPopupModal(
Utf8Buffer name, ref bool open, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
fixed (bool* openPtr = &open)
{
var r = ImGuiNative.BeginPopupModal(namePtr, openPtr, flags) != 0;
name.Dispose();
return r;
}
}
public static bool BeginPopupModal(Utf8Buffer name, ImGuiWindowFlags flags = ImGuiWindowFlags.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginPopupModal(namePtr, null, flags) != 0;
name.Dispose();
return r;
}
}
public static bool BeginTabBar(Utf8Buffer strId, ImGuiTabBarFlags flags = ImGuiTabBarFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginTabBar(strIdPtr, flags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginTabItem(
Utf8Buffer label, ref bool pOpen, ImGuiTabItemFlags flags = ImGuiTabItemFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* pOpenPtr = &pOpen)
{
var r = ImGuiNative.BeginTabItem(labelPtr, pOpenPtr, flags) != 0;
label.Dispose();
return r;
}
}
public static bool BeginTabItem(Utf8Buffer label, ImGuiTabItemFlags flags = ImGuiTabItemFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginTabItem(labelPtr, null, flags) != 0;
label.Dispose();
return r;
}
}
public static bool BeginTable(
Utf8Buffer strId, int column, ImGuiTableFlags flags = ImGuiTableFlags.None, Vector2 outerSize = default,
float innerWidth = 0.0f)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.BeginTable(strIdPtr, column, flags, outerSize, innerWidth) != 0;
strId.Dispose();
return r;
}
}
public static bool Button(Utf8Buffer label, Vector2 size = default)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.Button(labelPtr, size) != 0;
label.Dispose();
return r;
}
}
public static bool Checkbox(Utf8Buffer label, ref bool v)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* vPtr = &v)
{
var r = ImGuiNative.Checkbox(labelPtr, vPtr) != 0;
label.Dispose();
return r;
}
}
public static bool CheckboxFlags<T>(Utf8Buffer label, ref T flags, T flagsValue)
where T : IBinaryInteger<T>
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var allOn = (flags & flagsValue) == flagsValue;
var anyOn = !T.IsZero(flags & flagsValue);
bool pressed;
if (!allOn && anyOn)
{
var g = GetCurrentContext();
var backupItemFlags = g.CurrentItemFlags;
g.CurrentItemFlags |= ImGuiItemFlags.MixedValue;
pressed = ImGuiNative.Checkbox(labelPtr, &allOn) != 0;
g.CurrentItemFlags = backupItemFlags;
}
else
{
pressed = ImGuiNative.Checkbox(labelPtr, &allOn) != 0;
}
if (pressed)
{
if (allOn)
flags |= flagsValue;
else
flags &= ~flagsValue;
}
label.Dispose();
return pressed;
}
}
public static bool CollapsingHeader(
Utf8Buffer label, ref bool visible, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* visiblePtr = &visible)
{
var r = ImGuiNative.CollapsingHeader(labelPtr, visiblePtr, flags) != 0;
label.Dispose();
return r;
}
}
public static bool CollapsingHeader(Utf8Buffer label, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.CollapsingHeader(labelPtr, null, flags) != 0;
label.Dispose();
return r;
}
}
public static bool ColorButton(
Utf8Buffer descId, in Vector4 col, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None,
Vector2 size = default)
{
fixed (byte* descIdPtr = &descId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.ColorButton(descIdPtr, col, flags, size) != 0;
descId.Dispose();
return r;
}
}
public static void Columns(int count = 1, Utf8Buffer id = default, bool border = true)
{
fixed (byte* idPtr = &id.GetPinnableNullTerminatedReference())
ImGuiNative.Columns(count, idPtr, border ? (byte)1 : (byte)0);
id.Dispose();
}
public static bool DebugCheckVersionAndDataLayout(
Utf8Buffer versionStr, nuint szIo, nuint szStyle, nuint szVec2, nuint szVec4, nuint szDrawVert,
nuint szDrawIdx)
{
fixed (byte* versionPtr = &versionStr.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.DebugCheckVersionAndDataLayout(versionPtr, szIo, szStyle, szVec2, szVec4, szDrawVert, szDrawIdx) != 0;
versionStr.Dispose();
return r;
}
}
public static void DebugTextEncoding(Utf8Buffer text)
{
fixed (byte* textPtr = &text.GetPinnableNullTerminatedReference())
{
ImGuiNative.DebugTextEncoding(textPtr);
text.Dispose();
}
}
public static bool Draw(ImGuiTextFilterPtr self, Utf8Buffer label = default, float width = 0.0f)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference("Filter (inc,-exc)"u8))
{
var r = ImGuiNative.Draw(self.Handle, labelPtr, width) != 0;
label.Dispose();
return r;
}
}
public static ImGuiTextFilterPtr ImGuiTextFilter(Utf8Buffer defaultFilter = default)
{
fixed (byte* defaultFilterPtr = &defaultFilter.GetPinnableNullTerminatedReference("\0"u8))
{
var r = ImGuiNative.ImGuiTextFilter(defaultFilterPtr);
defaultFilter.Dispose();
return r;
}
}
public static ImGuiTextRangePtr ImGuiTextRange() => ImGuiNative.ImGuiTextRange();
public static ImGuiTextRangePtr ImGuiTextRange(ReadOnlySpan<byte> text)
{
fixed (byte* textPtr = text)
return ImGuiNative.ImGuiTextRange(textPtr, textPtr + text.Length);
}
public static bool InvisibleButton(
Utf8Buffer strId, Vector2 size, ImGuiButtonFlags flags = ImGuiButtonFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.InvisibleButton(strIdPtr, size, flags) != 0;
strId.Dispose();
return r;
}
}
public static bool IsDataType(ImGuiPayloadPtr self, Utf8Buffer type)
{
fixed (byte* typePtr = &type.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.IsDataType(self.Handle, typePtr) != 0;
type.Dispose();
return r;
}
}
public static bool IsPopupOpen(Utf8Buffer strId, ImGuiPopupFlags flags = ImGuiPopupFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.IsPopupOpen(strIdPtr, flags) != 0;
strId.Dispose();
return r;
}
}
public static void LoadIniSettingsFromDisk(Utf8Buffer iniFilename)
{
fixed (byte* iniFilenamePtr = &iniFilename.GetPinnableNullTerminatedReference())
ImGuiNative.LoadIniSettingsFromDisk(iniFilenamePtr);
iniFilename.Dispose();
}
public static void LoadIniSettingsFromMemory(Utf8Buffer iniData)
{
fixed (byte* iniDataPtr = iniData.Span)
ImGuiNative.LoadIniSettingsFromMemory(iniDataPtr, (nuint)iniData.Length);
iniData.Dispose();
}
public static void LogToFile(int autoOpenDepth = -1, Utf8Buffer filename = default)
{
fixed (byte* filenamePtr = &filename.GetPinnableNullTerminatedReference())
ImGuiNative.LogToFile(autoOpenDepth, filenamePtr);
filename.Dispose();
}
public static bool MenuItem(
Utf8Buffer label, Utf8Buffer shortcut, bool selected = false, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* shortcutPtr = &shortcut.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.MenuItem(labelPtr, shortcutPtr, selected ? (byte)1 : (byte)0, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
shortcut.Dispose();
return r;
}
}
public static bool MenuItem(Utf8Buffer label, Utf8Buffer shortcut, ref bool selected, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* shortcutPtr = &shortcut.GetPinnableNullTerminatedReference())
fixed (bool* selectedPtr = &selected)
{
var r = ImGuiNative.MenuItem(labelPtr, shortcutPtr, selectedPtr, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
shortcut.Dispose();
return r;
}
}
public static bool MenuItem(Utf8Buffer label, ref bool selected, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* selectedPtr = &selected)
{
var r = ImGuiNative.MenuItem(labelPtr, null, selectedPtr, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
return r;
}
}
public static bool MenuItem(Utf8Buffer label, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.MenuItem(labelPtr, null, null, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
return r;
}
}
public static void OpenPopup(Utf8Buffer strId, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
ImGuiNative.OpenPopup(strIdPtr, popupFlags);
strId.Dispose();
}
public static void OpenPopup(uint id, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.None) => ImGuiNative.OpenPopup(id, popupFlags);
public static void OpenPopupOnItemClick(
Utf8Buffer strId, ImGuiPopupFlags popupFlags = ImGuiPopupFlags.MouseButtonDefault)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
ImGuiNative.OpenPopupOnItemClick(strIdPtr, popupFlags);
strId.Dispose();
}
public static void ProgressBar(float fraction, Vector2 sizeArg, Utf8Buffer overlay = default)
{
fixed (byte* overlayPtr = &overlay.GetPinnableNullTerminatedReference())
ImGuiNative.ProgressBar(fraction, sizeArg, overlayPtr);
overlay.Dispose();
}
public static void ProgressBar(float fraction, Utf8Buffer overlay = default)
{
fixed (byte* overlayPtr = &overlay.GetPinnableNullTerminatedReference())
ImGuiNative.ProgressBar(fraction, new(-float.MinValue, 0), overlayPtr);
overlay.Dispose();
}
public static bool RadioButton(Utf8Buffer label, bool active)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.RadioButton(labelPtr, active ? (byte)1:(byte)0) != 0;
label.Dispose();
return r;
}
}
public static bool RadioButton<T>(Utf8Buffer label, ref T v, T vButton)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var pressed = ImGuiNative.RadioButton(
labelPtr,
EqualityComparer<T>.Default.Equals(v, vButton) ? (byte)1 : (byte)0) != 0;
if (pressed)
v = vButton;
return pressed;
}
}
public static void SaveIniSettingsToDisk(Utf8Buffer iniFilename)
{
fixed (byte* iniPtr = &iniFilename.GetPinnableNullTerminatedReference())
ImGuiNative.SaveIniSettingsToDisk(iniPtr);
}
public static bool Selectable(
Utf8Buffer label, bool selected = false, ImGuiSelectableFlags flags = ImGuiSelectableFlags.None, Vector2 size = default)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.Selectable(labelPtr, selected ?(byte)1:(byte)0, flags, size)!=0;
label.Dispose();
return r;
}
}
public static bool Selectable(Utf8Buffer label, ref bool selected, ImGuiSelectableFlags flags = ImGuiSelectableFlags.None, Vector2 size = default)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* selectedPtr = &selected)
{
var r = ImGuiNative.Selectable(labelPtr, selectedPtr, flags, size)!=0;
label.Dispose();
return r;
}
}
public static void SetClipboardText(Utf8Buffer text)
{
fixed (byte* textPtr = &text.GetPinnableNullTerminatedReference())
ImGuiNative.SetClipboardText(textPtr);
text.Dispose();
}
public static bool SetDragDropPayload(Utf8Buffer type, ReadOnlySpan<byte> data, ImGuiCond cond)
{
fixed (byte* typePtr = &type.GetPinnableNullTerminatedReference())
fixed (byte* dataPtr = data)
{
var r = ImGuiNative.SetDragDropPayload(typePtr, dataPtr, (nuint)data.Length, cond)!=0;
type.Dispose();
return r;
}
}
public static void SetTabItemClosed(Utf8Buffer tabOrDockedWindowLabel)
{
fixed (byte* tabItemPtr = &tabOrDockedWindowLabel.GetPinnableNullTerminatedReference())
ImGuiNative.SetTabItemClosed(tabItemPtr);
tabOrDockedWindowLabel.Dispose();
}
public static void SetWindowCollapsed(bool collapsed, ImGuiCond cond = ImGuiCond.None) => ImGuiNative.SetWindowCollapsed(collapsed ? (byte)1 : (byte)0, cond);
public static void SetWindowCollapsed(Utf8Buffer name, bool collapsed, ImGuiCond cond = ImGuiCond.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
ImGuiNative.SetWindowCollapsed(namePtr, collapsed ? (byte)1 : (byte)0, cond);
name.Dispose();
}
public static void SetWindowFocus() => ImGuiNative.SetWindowFocus();
public static void SetWindowFocus(Utf8Buffer name)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
ImGuiNative.SetWindowFocus(namePtr);
name.Dispose();
}
public static void SetWindowPos(Vector2 pos, ImGuiCond cond = ImGuiCond.None) => ImGuiNative.SetWindowPos(pos, cond);
public static void SetWindowPos(Utf8Buffer name, Vector2 pos, ImGuiCond cond = ImGuiCond.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
ImGuiNative.SetWindowPos(namePtr, pos, cond);
name.Dispose();
}
public static void SetWindowSize(Vector2 size, ImGuiCond cond = ImGuiCond.None) => ImGuiNative.SetWindowSize(size, cond);
public static void SetWindowSize(Utf8Buffer name, Vector2 size, ImGuiCond cond = ImGuiCond.None)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
ImGuiNative.SetWindowSize(namePtr, size, cond);
name.Dispose();
}
public static void ShowFontSelector(Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiNative.ShowFontSelector(labelPtr);
label.Dispose();
}
public static bool ShowStyleSelector(Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.ShowStyleSelector(labelPtr) != 0;
label.Dispose();
return r;
}
}
public static bool SmallButton(Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.SmallButton(labelPtr) != 0;
label.Dispose();
return r;
}
}
public static bool TabItemButton(Utf8Buffer label, ImGuiTabItemFlags flags = ImGuiTabItemFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiNative.TabItemButton(labelPtr, flags) != 0;
label.Dispose();
return r;
}
}
public static void TableHeader(Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiNative.TableHeader(labelPtr);
label.Dispose();
}
public static void TableSetupColumn(
Utf8Buffer label, ImGuiTableColumnFlags flags = ImGuiTableColumnFlags.None, float initWidthOrWeight = 0.0f,
uint userId = 0)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiNative.TableSetupColumn(labelPtr, flags, initWidthOrWeight, userId);
label.Dispose();
}
public static void TreePush(Utf8Buffer strId)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
ImGuiNative.TreePush(strIdPtr);
strId.Dispose();
}
public static void TreePush(nint ptrId) => ImGuiNative.TreePush((void*)ptrId);
public static void TreePush(void* ptrId) => ImGuiNative.TreePush(ptrId);
public static void Value<T>(Utf8Buffer prefix, in T value)
{
prefix.AppendLiteral(": ");
prefix.AppendFormatted(value);
fixed (byte* prefixPtr = prefix.Span)
{
ImGuiNative.TextUnformatted(prefixPtr, prefixPtr + prefix.Length);
prefix.Dispose();
}
}
// public static void Value(AutoUtf8Buffer prefix, float value) => Value(prefix, value, default);
public static void Value(Utf8Buffer prefix, float value, Utf8Buffer floatFormat = default)
{
fixed (byte* prefixPtr = &prefix.GetPinnableNullTerminatedReference())
fixed (byte* floatPtr = &floatFormat.GetPinnableNullTerminatedReference())
{
ImGuiNative.Value(prefixPtr, value, floatPtr);
prefix.Dispose();
floatFormat.Dispose();
}
}
}

View file

@ -0,0 +1,33 @@
using System.Text;
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiIO
{
public void AddInputCharacter(char c)
{
fixed (ImGuiIO* thisPtr = &this)
ImGui.AddInputCharacter(thisPtr, c);
}
public void AddInputCharacter(Rune c)
{
fixed (ImGuiIO* thisPtr = &this)
ImGui.AddInputCharacter(thisPtr, c);
}
public void AddInputCharacters(Utf8Buffer str)
{
fixed (ImGuiIO* thisPtr = &this)
ImGui.AddInputCharacters(thisPtr, str);
}
}
public partial struct ImGuiIOPtr
{
public void AddInputCharacter(char c) => ImGui.AddInputCharacter(this, c);
public void AddInputCharacter(Rune c) => ImGui.AddInputCharacter(this, c);
public void AddInputCharacters(Utf8Buffer str) => ImGui.AddInputCharacters(this, str);
}

View file

@ -1,16 +1,15 @@
using System.Runtime.CompilerServices;
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiInputTextCallbackData
{
public void InsertChars(int pos, AutoUtf8Buffer text)
public void InsertChars(int pos, Utf8Buffer text)
{
fixed (ImGuiInputTextCallbackData* thisPtr = &this) ImGui.InsertChars(thisPtr, pos, text);
fixed (ImGuiInputTextCallbackData* thisPtr = &this)
ImGui.InsertChars(thisPtr, pos, text);
}
}
public partial struct ImGuiInputTextCallbackDataPtr
{
public void InsertChars(int pos, AutoUtf8Buffer text) => ImGui.InsertChars(this, pos, text);
public void InsertChars(int pos, Utf8Buffer text) => ImGui.InsertChars(this, pos, text);
}

View file

@ -0,0 +1,496 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public unsafe partial class ImGuiP
{
public static bool ArrowButtonEx(
Utf8Buffer strId, ImGuiDir dir, Vector2 sizeArg, ImGuiButtonFlags flags = ImGuiButtonFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.ArrowButtonEx(strIdPtr, dir, sizeArg, flags) != 0;
strId.Dispose();
return r;
}
}
public static bool BeginChildEx(Utf8Buffer name, uint id, Vector2 sizeArg, bool border, ImGuiWindowFlags flags)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.BeginChildEx(namePtr, id, sizeArg, border ? (byte)1 : (byte)0, flags) != 0;
name.Dispose();
return r;
}
}
public static void BeginColumns(Utf8Buffer strId, int count, ImGuiOldColumnFlags flags = ImGuiOldColumnFlags.None)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
ImGuiPNative.BeginColumns(strIdPtr, count, flags);
strId.Dispose();
}
public static bool BeginMenuEx(Utf8Buffer label, Utf8Buffer icon = default, bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* iconPtr = &icon.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.BeginMenuEx(labelPtr, iconPtr, enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
icon.Dispose();
return r;
}
}
public static bool BeginTableEx(
Utf8Buffer name, uint id, int columnsCount, ImGuiTableFlags flags = ImGuiTableFlags.None,
Vector2 outerSize = default, float innerWidth = 0.0f)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.BeginTableEx(namePtr, id, columnsCount, flags, outerSize, innerWidth) != 0;
name.Dispose();
return r;
}
}
public static bool BeginViewportSideBar(
Utf8Buffer name, ImGuiViewportPtr viewport, ImGuiDir dir, float size, ImGuiWindowFlags windowFlags)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.BeginViewportSideBar(namePtr, viewport, dir, size, windowFlags) != 0;
name.Dispose();
return r;
}
}
public static bool ButtonEx(
Utf8Buffer label, Vector2 sizeArg = default, ImGuiButtonFlags flags = ImGuiButtonFlags.None)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.ButtonEx(labelPtr, sizeArg, flags) != 0;
label.Dispose();
return r;
}
}
public static void ColorEditOptionsPopup(ReadOnlySpan<float> col, ImGuiColorEditFlags flags)
{
fixed (float* colPtr = col)
ImGuiPNative.ColorEditOptionsPopup(colPtr, flags);
}
public static void ColorPickerOptionsPopup(ReadOnlySpan<float> refCol, ImGuiColorEditFlags flags)
{
fixed (float* refColPtr = refCol)
ImGuiPNative.ColorPickerOptionsPopup(refColPtr, flags);
}
public static void ColorTooltip(Utf8Buffer text, ReadOnlySpan<float> col, ImGuiColorEditFlags flags)
{
fixed (byte* textPtr = &text.GetPinnableNullTerminatedReference())
fixed (float* colPtr = col)
ImGuiPNative.ColorTooltip(textPtr, colPtr, flags);
text.Dispose();
}
public static ImGuiWindowSettingsPtr CreateNewWindowSettings(Utf8Buffer name)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.CreateNewWindowSettings(namePtr);
name.Dispose();
return r;
}
}
public static void Custom_StbTextMakeUndoReplace(
ImGuiInputTextStatePtr str, int where, int oldLength, int newLength) =>
ImGuiPNative.Custom_StbTextMakeUndoReplace(str, where, oldLength, newLength);
public static void Custom_StbTextUndo(ImGuiInputTextStatePtr str) => ImGuiPNative.Custom_StbTextUndo(str);
public static bool DataTypeApplyFromText<T>(Utf8Buffer buf, ImGuiDataType dataType, T data, Utf8Buffer format)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* bufPtr = &buf.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.DataTypeApplyFromText(bufPtr, dataType, &data, formatPtr) != 0;
format.Dispose();
buf.Dispose();
return r;
}
}
public static void DebugNodeDockNode(ImGuiDockNodePtr node, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeDockNode(node, labelPtr);
label.Dispose();
}
public static void DebugNodeDrawList(
ImGuiWindowPtr window, ImGuiViewportPPtr viewport, ImDrawListPtr drawList, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeDrawList(window, viewport, drawList, labelPtr);
label.Dispose();
}
public static void DebugNodeStorage(ImGuiStoragePtr storage, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeStorage(storage, labelPtr);
label.Dispose();
}
public static void DebugNodeTabBar(ImGuiTabBarPtr tabBar, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeTabBar(tabBar, labelPtr);
label.Dispose();
}
public static void DebugNodeWindow(ImGuiWindowPtr window, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeWindow(window, labelPtr);
label.Dispose();
}
public static void DebugNodeWindowsList(scoped in ImVector<ImGuiWindowPtr> windows, Utf8Buffer label)
{
fixed (ImVector<ImGuiWindowPtr>* windowsPtr = &windows)
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
ImGuiPNative.DebugNodeWindowsList(windowsPtr, labelPtr);
label.Dispose();
}
public static void DockBuilderCopyWindowSettings(Utf8Buffer srcName, Utf8Buffer dstName)
{
fixed (byte* srcNamePtr = &srcName.GetPinnableNullTerminatedReference())
fixed (byte* dstNamePtr = &dstName.GetPinnableNullTerminatedReference())
ImGuiPNative.DockBuilderCopyWindowSettings(srcNamePtr, dstNamePtr);
srcName.Dispose();
dstName.Dispose();
}
public static void DockBuilderDockWindow(Utf8Buffer windowName, uint nodeId)
{
fixed (byte* windowNamePtr = &windowName.GetPinnableNullTerminatedReference())
ImGuiPNative.DockBuilderDockWindow(windowNamePtr, nodeId);
windowName.Dispose();
}
public static bool DragBehavior(
uint id, ImGuiDataType dataType, void* pV, float vSpeed, void* pMin, void* pMax, Utf8Buffer format,
ImGuiSliderFlags flags)
{
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.DragBehavior(id, dataType, pV, vSpeed, pMin, pMax, formatPtr, flags) != 0;
format.Dispose();
return r;
}
}
public static ImGuiWindowSettingsPtr FindOrCreateWindowSettings(Utf8Buffer name)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.FindOrCreateWindowSettings(namePtr);
name.Dispose();
return r;
}
}
public static ImGuiSettingsHandlerPtr FindSettingsHandler(Utf8Buffer typeName)
{
fixed (byte* typeNamePtr = &typeName.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.FindSettingsHandler(typeNamePtr);
typeName.Dispose();
return r;
}
}
public static ImGuiWindowPtr FindWindowByName(Utf8Buffer name)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.FindWindowByName(namePtr);
name.Dispose();
return r;
}
}
public static uint GetColumnsID(Utf8Buffer strId, int count)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.GetColumnsID(strIdPtr, count);
strId.Dispose();
return r;
}
}
public static uint GetIDWithSeed(Utf8Buffer strId, uint seed)
{
fixed (byte* strIdPtr = &strId.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.GetIDWithSeed(strIdPtr, strIdPtr + strId.Length, seed);
strId.Dispose();
return r;
}
}
public static void* ImFileLoadToMemory(
Utf8Buffer filename, Utf8Buffer mode, out nuint outFileSize, int paddingBytes = 0)
{
fixed (byte* filenamePtr = &filename.GetPinnableNullTerminatedReference())
fixed (byte* modePtr = &mode.GetPinnableNullTerminatedReference())
fixed (nuint* outFileSizePtr = &outFileSize)
{
var r = ImGuiPNative.ImFileLoadToMemory(filenamePtr, modePtr, outFileSizePtr, paddingBytes);
filename.Dispose();
mode.Dispose();
return r;
}
}
public static void* ImFileLoadToMemory(Utf8Buffer filename, Utf8Buffer mode, int paddingBytes = 0)
{
fixed (byte* filenamePtr = &filename.GetPinnableNullTerminatedReference())
fixed (byte* modePtr = &mode.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.ImFileLoadToMemory(filenamePtr, modePtr, null, paddingBytes);
filename.Dispose();
mode.Dispose();
return r;
}
}
public static ImFileHandle ImFileOpen(Utf8Buffer filename, Utf8Buffer mode)
{
fixed (byte* filenamePtr = &filename.GetPinnableNullTerminatedReference())
fixed (byte* modePtr = &mode.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.ImFileOpen(filenamePtr, modePtr);
filename.Dispose();
mode.Dispose();
return r;
}
}
public static void ImFontAtlasBuildMultiplyRectAlpha8(
ReadOnlySpan<byte> table, ReadOnlySpan<byte> pixels, int x, int y, int w, int h, int stride)
{
fixed (byte* tablePtr = table)
fixed (byte* pixelsPtr = pixels)
ImGuiPNative.ImFontAtlasBuildMultiplyRectAlpha8(tablePtr, pixelsPtr, x, y, w, h, stride);
}
public static void ImFontAtlasBuildRender32bppRectFromString(
ImFontAtlasPtr atlas, int textureIndex, int x, int y, int w, int h, ReadOnlySpan<byte> inStr, byte inMarkerChar,
uint inMarkerPixelValue)
{
fixed (byte* inStrPtr = inStr)
{
ImGuiPNative.ImFontAtlasBuildRender32bppRectFromString(
atlas,
textureIndex,
x,
y,
w,
h,
inStrPtr,
inMarkerChar,
inMarkerPixelValue);
}
}
public static void ImFontAtlasBuildRender8bppRectFromString(
ImFontAtlasPtr atlas, int textureIndex, int x, int y, int w, int h, ReadOnlySpan<byte> inStr, byte inMarkerChar,
byte inMarkerPixelValue)
{
fixed (byte* inStrPtr = inStr)
{
ImGuiPNative.ImFontAtlasBuildRender8bppRectFromString(
atlas,
textureIndex,
x,
y,
w,
h,
inStrPtr,
inMarkerChar,
inMarkerPixelValue);
}
}
public static void ImFormatStringToTempBuffer(byte** outBuf, byte** outBufEnd, Utf8Buffer fmt)
{
fixed (byte* fmtPtr = &fmt.GetPinnableNullTerminatedReference())
ImGuiPNative.ImFormatStringToTempBuffer(outBuf, outBufEnd, fmtPtr);
fmt.Dispose();
}
public static ImGuiWindowPtr ImGuiWindow(ImGuiContextPtr context, Utf8Buffer name)
{
fixed (byte* namePtr = &name.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.ImGuiWindow(context, namePtr);
name.Dispose();
return r;
}
}
// public static byte* ImParseFormatFindEnd(byte* format)
// public static byte* ImParseFormatFindStart(byte* format)
// public static int ImParseFormatPrecision(byte* format, int defaultValue)
// public static byte* ImStrchrRange(byte* strBegin, byte* strEnd, byte c)
// public static byte* ImStrdup(byte* str)
// public static byte* ImStrdupcpy(byte* dst, nuint* pDstSize, byte* str)
// public static int ImStricmp(byte* str1, byte* str2)
// public static byte* ImStristr(byte* haystack, byte* haystackEnd, byte* needle, byte* needleEnd)
// public static int ImStrlenW(ushort* str)
// public static void ImStrncpy(byte* dst, byte* src, nuint count)
// public static int ImStrnicmp(byte* str1, byte* str2, nuint count)
// public static byte* ImStrSkipBlank(byte* str)
// public static void ImStrTrimBlanks(byte* str)
// public static int ImTextCharFromUtf8(uint* outChar, byte* inText, byte* inTextEnd)
// public static int ImTextCountCharsFromUtf8(byte* inText, byte* inTextEnd)
// public static int ImTextCountUtf8BytesFromChar(byte* inText, byte* inTextEnd)
public static void LogSetNextTextDecoration(byte* prefix, byte* suffix) =>
ImGuiPNative.LogSetNextTextDecoration(prefix, suffix);
public static bool MenuItemEx(
Utf8Buffer label, Utf8Buffer icon = default, Utf8Buffer shortcut = default, bool selected = false,
bool enabled = true)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* iconPtr = &icon.GetPinnableNullTerminatedReference())
fixed (byte* shortcutPtr = &shortcut.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.MenuItemEx(
labelPtr,
iconPtr,
shortcutPtr,
selected ? (byte)1 : (byte)0,
enabled ? (byte)1 : (byte)0) != 0;
label.Dispose();
icon.Dispose();
shortcut.Dispose();
return r;
}
}
public static void RemoveSettingsHandler(Utf8Buffer typeName)
{
fixed (byte* typeNamePtr = &typeName.GetPinnableNullTerminatedReference())
ImGuiPNative.RemoveSettingsHandler(typeNamePtr);
typeName.Dispose();
}
public static bool SliderBehavior<T>(
ImRect bb, uint id, ImGuiDataType dataType, scoped ref T value, T min, T max, Utf8Buffer format,
ImGuiSliderFlags flags, ImRectPtr outGrabBb)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* valuePtr = &value)
{
var r = ImGuiPNative.SliderBehavior(
bb,
id,
dataType,
valuePtr,
&min,
&max,
formatPtr,
flags,
outGrabBb) != 0;
format.Dispose();
return r;
}
}
public static Vector2 TabItemCalcSize(Utf8Buffer label, bool hasCloseButton)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
Vector2 v;
ImGuiPNative.TabItemCalcSize(&v, labelPtr, hasCloseButton ? (byte)1 : (byte)0);
return v;
}
}
public static bool TabItemEx(
ImGuiTabBarPtr tabBar, Utf8Buffer label, ref bool open, ImGuiTabItemFlags flags, ImGuiWindowPtr dockedWindow)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* openPtr = &open)
{
var r = ImGuiPNative.TabItemEx(tabBar, labelPtr, openPtr, flags, dockedWindow) != 0;
label.Dispose();
return r;
}
}
public static void TabItemLabelAndCloseButton(
ImDrawListPtr drawList, ImRect bb, ImGuiTabItemFlags flags, Vector2 framePadding, Utf8Buffer label, uint tabId,
uint closeButtonId, bool isContentsVisible, out bool justClosed, out bool textClipped)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (bool* justClosedPtr = &justClosed)
fixed (bool* textClippedPtr = &textClipped)
{
ImGuiPNative.TabItemLabelAndCloseButton(
drawList,
bb,
flags,
framePadding,
labelPtr,
tabId,
closeButtonId,
isContentsVisible ? (byte)1 : (byte)0,
justClosedPtr,
textClippedPtr);
}
label.Dispose();
}
public static bool TempInputScalar<T>(
ImRect bb, uint id, Utf8Buffer label, ImGuiDataType dataType, scoped ref T data, Utf8Buffer format, T min,
T max)
where T : unmanaged, IBinaryNumber<T>
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* formatPtr = &format.GetPinnableNullTerminatedReference())
fixed (T* dataPtr = &data)
{
var r = ImGuiPNative.TempInputScalar(bb, id, labelPtr, dataType, dataPtr, formatPtr, &min, &max) != 0;
label.Dispose();
return r;
}
}
public static bool TreeNodeBehavior(uint id, ImGuiTreeNodeFlags flags, Utf8Buffer label)
{
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
{
var r = ImGuiPNative.TreeNodeBehavior(id, flags, labelPtr, labelPtr + label.Length) != 0;
label.Dispose();
return r;
}
}
}

View file

@ -0,0 +1,85 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGuiP
{
public delegate float GetFloatDelegate(int index);
public delegate float GetFloatDelegate<T>(scoped in T context, int index);
public static int PlotEx(
ImGuiPlotType plotType, Utf8Buffer label, GetFloatDelegate valuesGetter,
int valuesCount, int valuesOffset, Utf8Buffer overlayText, float scaleMin, float scaleMax, Vector2 frameSize)
{
var dataBuffer = stackalloc void*[1];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
dataBuffer[0] = &valuesGetter;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiPNative.PlotEx(
plotType,
labelPtr,
(delegate*<ImGuiPlotType, byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float,
Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithoutContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
frameSize);
label.Dispose();
overlayText.Dispose();
return r;
}
}
public static int PlotEx<TContext>(
ImGuiPlotType plotType, Utf8Buffer label, GetFloatDelegate<TContext> valuesGetter, scoped in TContext context,
int valuesCount, int valuesOffset, Utf8Buffer overlayText, float scaleMin, float scaleMax, Vector2 frameSize)
{
var dataBuffer = stackalloc void*[2];
fixed (byte* labelPtr = &label.GetPinnableNullTerminatedReference())
fixed (byte* overlayTextPtr = &overlayText.GetPinnableNullTerminatedReference())
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
fixed (TContext* contextPtr = &context)
{
dataBuffer[0] = &valuesGetter;
dataBuffer[1] = contextPtr;
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
var r = ImGuiPNative.PlotEx(
plotType,
labelPtr,
(delegate*<ImGuiPlotType, byte*, delegate*<void*, int, float>, void*, int, int, byte*, float, float,
Vector2, float>)
(nint)(delegate* unmanaged<void*, int, float>)&GetFloatWithContext,
dataBuffer,
valuesCount,
valuesOffset,
overlayTextPtr,
scaleMin,
scaleMax,
frameSize);
label.Dispose();
overlayText.Dispose();
return r;
}
}
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
[UnmanagedCallersOnly]
private static float GetFloatWithContext(void* data, int index) =>
((GetFloatDelegate<object>*)((void**)data)[0])->Invoke(*(object*)((void**)data)[1], index);
[UnmanagedCallersOnly]
private static float GetFloatWithoutContext(void* data, int index) =>
((GetFloatDelegate*)((void**)data)[0])->Invoke(index);
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
}

View file

@ -1,13 +1,12 @@
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
namespace Dalamud.Bindings.ImGui;
public static unsafe partial class ImGuiP
{
public static void DebugLog(AutoUtf8Buffer text)
public static void DebugLog(Utf8Buffer text)
{
var g = ImGui.GetCurrentContext().Handle;
ImGui.append(&g->DebugLogBuf, $"[{g->FrameCount:00000}] ");
@ -32,7 +31,7 @@ public static unsafe partial class ImGuiP
public static int FindRenderedTextEnd(
ReadOnlySpan<char> text, out ReadOnlySpan<char> before, out ReadOnlySpan<char> after)
{
var textBuf = new AutoUtf8Buffer(text);
var textBuf = new Utf8Buffer(text);
FindRenderedTextEnd(textBuf.Span, out var beforeBytes, out var afterBytes);
before = text[..Encoding.UTF8.GetCharCount(beforeBytes)];
after = text[before.Length..];
@ -40,7 +39,7 @@ public static unsafe partial class ImGuiP
return before.Length;
}
public static uint GetID(ImGuiWindowPtr self, AutoUtf8Buffer str)
public static uint GetID(ImGuiWindowPtr self, Utf8Buffer str)
{
fixed (byte* strPtr = str.Span)
{
@ -62,7 +61,7 @@ public static unsafe partial class ImGuiP
fixed (byte* ptr = data) return ImGuiPNative.ImHashData(ptr, (nuint)data.Length, seed);
}
public static uint ImHashStr(AutoUtf8Buffer data, uint seed = 0)
public static uint ImHashStr(Utf8Buffer data, uint seed = 0)
{
fixed (byte* ptr = data.Span)
{
@ -131,7 +130,7 @@ public static unsafe partial class ImGuiP
return i;
}
public static void LogRenderedText(scoped in Vector2 refPos, AutoUtf8Buffer text)
public static void LogRenderedText(scoped in Vector2 refPos, Utf8Buffer text)
{
fixed (Vector2* refPosPtr = &refPos)
fixed (byte* textPtr = text.Span)
@ -139,7 +138,7 @@ public static unsafe partial class ImGuiP
text.Dispose();
}
public static void RenderText(Vector2 pos, AutoUtf8Buffer text, bool hideTextAfterHash = true)
public static void RenderText(Vector2 pos, Utf8Buffer text, bool hideTextAfterHash = true)
{
fixed (byte* textPtr = text.Span)
ImGuiPNative.RenderText(pos, textPtr, textPtr + text.Length, hideTextAfterHash ? (byte)1 : (byte)0);
@ -147,7 +146,7 @@ public static unsafe partial class ImGuiP
}
public static void RenderTextWrapped(
Vector2 pos, AutoUtf8Buffer text, float wrapWidth)
Vector2 pos, Utf8Buffer text, float wrapWidth)
{
fixed (byte* textPtr = text.Span)
ImGuiPNative.RenderTextWrapped(pos, textPtr, textPtr + text.Length, wrapWidth);
@ -155,7 +154,7 @@ public static unsafe partial class ImGuiP
}
public static void RenderTextClipped(
scoped in Vector2 posMin, scoped in Vector2 posMax, AutoUtf8Buffer text,
scoped in Vector2 posMin, scoped in Vector2 posMax, Utf8Buffer text,
scoped in Vector2? textSizeIfKnown = null,
scoped in Vector2 align = default, scoped in ImRect? clipRect = null)
{
@ -175,7 +174,7 @@ public static unsafe partial class ImGuiP
public static void RenderTextClippedEx(
ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax,
AutoUtf8Buffer text,
Utf8Buffer text,
scoped in Vector2? textSizeIfKnown = null, scoped in Vector2 align = default, scoped in ImRect? clipRect = null)
{
var textSizeIfKnownOrDefault = textSizeIfKnown ?? default;
@ -195,7 +194,7 @@ public static unsafe partial class ImGuiP
public static void RenderTextEllipsis(
ImDrawListPtr drawList, scoped in Vector2 posMin, scoped in Vector2 posMax, float clipMaxX, float ellipsisMaxX,
AutoUtf8Buffer text, scoped in Vector2? textSizeIfKnown = null)
Utf8Buffer text, scoped in Vector2? textSizeIfKnown = null)
{
var textSizeIfKnownOrDefault = textSizeIfKnown ?? default;
fixed (byte* textPtr = text.Span)

View file

@ -0,0 +1,17 @@
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiPayload
{
public readonly Span<byte> DataSpan => new(this.Data, this.DataSize);
public readonly bool IsDataType(Utf8Buffer type)
{
fixed (ImGuiPayload* ptr = &this)
return ImGui.IsDataType(ptr, type);
}
}
public partial struct ImGuiPayloadPtr
{
public readonly bool IsDataType(Utf8Buffer type) => ImGui.IsDataType(this, type);
}

View file

@ -0,0 +1,60 @@
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiStorage
{
public readonly ref bool GetBoolRef(uint key, bool defaultValue = false)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetBoolRef(thisPtr, key, defaultValue);
}
public readonly ref float GetFloatRef(uint key, float defaultValue = 0.0f)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetFloatRef(thisPtr, key, defaultValue);
}
public readonly ref int GetIntRef(uint key, int defaultValue = 0)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetIntRef(thisPtr, key, defaultValue);
}
public readonly ref void* GetVoidPtrRef(uint key, void* defaultValue = null)
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetVoidPtrRef(thisPtr, key, defaultValue);
}
public readonly ref T* GetPtrRef<T>(uint key, T* defaultValue = null) where T : unmanaged
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetPtrRef(thisPtr, key, defaultValue);
}
public readonly ref T GetRef<T>(uint key, T defaultValue = default) where T : unmanaged
{
fixed (ImGuiStorage* thisPtr = &this)
return ref ImGui.GetRef(thisPtr, key, defaultValue);
}
}
public unsafe partial struct ImGuiStoragePtr
{
public readonly ref bool GetBoolRef(uint key, bool defaultValue = false) =>
ref ImGui.GetBoolRef(this, key, defaultValue);
public readonly ref float GetFloatRef(uint key, float defaultValue = 0.0f) =>
ref ImGui.GetFloatRef(this, key, defaultValue);
public readonly ref int GetIntRef(uint key, int defaultValue = 0) => ref ImGui.GetIntRef(this, key, defaultValue);
public readonly ref void* GetVoidPtrRef(uint key, void* defaultValue = null) =>
ref ImGui.GetVoidPtrRef(this, key, defaultValue);
public readonly ref T* GetPtrRef<T>(uint key, T* defaultValue = null) where T : unmanaged =>
ref ImGui.GetPtrRef(this, key, defaultValue);
public readonly ref T GetRef<T>(uint key, T defaultValue = default) where T : unmanaged =>
ref ImGui.GetRef(this, key, defaultValue);
}

View file

@ -0,0 +1,15 @@
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiTextBuffer
{
public void append(Utf8Buffer str)
{
fixed (ImGuiTextBuffer* thisPtr = &this)
ImGui.append(thisPtr, str);
}
}
public partial struct ImGuiTextBufferPtr
{
public void append(Utf8Buffer str) => ImGui.append(this, str);
}

View file

@ -0,0 +1,22 @@
namespace Dalamud.Bindings.ImGui;
public unsafe partial struct ImGuiTextFilter
{
public void Draw(Utf8Buffer label = default, float width = 0.0f)
{
fixed (ImGuiTextFilter* thisPtr = &this)
ImGui.Draw(thisPtr, label, width);
}
public void PassFilter(Utf8Buffer text)
{
fixed (ImGuiTextFilter* thisPtr = &this)
ImGui.PassFilter(thisPtr, text);
}
}
public partial struct ImGuiTextFilterPtr
{
public void Draw(Utf8Buffer label = default, float width = 0.0f) => ImGui.Draw(this, label, width);
public void PassFilter(Utf8Buffer text) => ImGui.PassFilter(this, text);
}

View file

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

View file

@ -8,7 +8,7 @@ namespace Dalamud.Bindings.ImGui;
[StructLayout(LayoutKind.Sequential, Size = TotalBufferSize)]
[InterpolatedStringHandler]
public ref struct AutoUtf8Buffer : IDisposable
public ref struct Utf8Buffer : IDisposable
{
private const int TotalBufferSize = 1024;
private const int FixedBufferSize = TotalBufferSize - 8 - 8 - 8 - 1;
@ -29,7 +29,7 @@ public ref struct AutoUtf8Buffer : IDisposable
OwnedSpan = 1 << 3,
}
public AutoUtf8Buffer(int literalLength, int formattedCount) : this(ReadOnlySpan<byte>.Empty)
public Utf8Buffer(int literalLength, int formattedCount) : this(ReadOnlySpan<byte>.Empty)
{
this.state |= State.Interpolation;
literalLength += formattedCount * 4;
@ -37,14 +37,14 @@ public ref struct AutoUtf8Buffer : IDisposable
IncreaseBuffer(out _, literalLength);
}
public AutoUtf8Buffer(int literalLength, int formattedCount, IFormatProvider? formatProvider) : this(
public Utf8Buffer(int literalLength, int formattedCount, IFormatProvider? formatProvider) : this(
literalLength,
formattedCount)
{
this.formatProvider = formatProvider;
}
public unsafe AutoUtf8Buffer(ReadOnlySpan<byte> text)
public unsafe Utf8Buffer(ReadOnlySpan<byte> text)
{
this.state = State.Initialized;
if (text.IsEmpty)
@ -60,11 +60,11 @@ public ref struct AutoUtf8Buffer : IDisposable
}
}
public AutoUtf8Buffer(ReadOnlyMemory<byte> text) : this(text.Span)
public Utf8Buffer(ReadOnlyMemory<byte> text) : this(text.Span)
{
}
public unsafe AutoUtf8Buffer(ReadOnlySpan<char> text)
public unsafe Utf8Buffer(ReadOnlySpan<char> text)
{
this.state = State.Initialized | State.NullTerminated;
var cb = Encoding.UTF8.GetByteCount(text);
@ -86,24 +86,24 @@ public ref struct AutoUtf8Buffer : IDisposable
}
}
public AutoUtf8Buffer(ReadOnlyMemory<char> text) : this(text.Span)
public Utf8Buffer(ReadOnlyMemory<char> text) : this(text.Span)
{
}
public AutoUtf8Buffer(string? text) : this(text.AsSpan())
public Utf8Buffer(string? text) : this(text.AsSpan())
{
}
public unsafe AutoUtf8Buffer(byte* text) : this(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(text))
public unsafe Utf8Buffer(byte* text) : this(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(text))
{
this.state |= State.NullTerminated;
}
public unsafe AutoUtf8Buffer(char* text) : this(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(text))
public unsafe Utf8Buffer(char* text) : this(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(text))
{
}
public readonly bool IsInitialized => (this.state & State.Initialized) != 0;
public static Utf8Buffer Empty => default;
public readonly unsafe ReadOnlySpan<byte> Span =>
(this.state & State.OwnedSpan) != 0
@ -112,36 +112,45 @@ public ref struct AutoUtf8Buffer : IDisposable
public readonly int Length => this.span.Length;
public readonly bool IsNull => (this.state & State.Initialized) == 0;
public readonly bool IsEmpty => this.span.IsEmpty;
public unsafe ReadOnlySpan<byte> NullTerminatedSpan
public unsafe ref readonly byte GetPinnableNullTerminatedReference(ReadOnlySpan<byte> defaultValue = default)
{
get
{
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 < FixedBufferSize)
{
var newSpan = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], this.span.Length);
this.span.CopyTo(newSpan);
this.fixedBuffer[newSpan.Length] = 0;
this.span = newSpan;
}
else
{
this.rentedBuffer = ArrayPool<byte>.Shared.Rent(this.span.Length + 1);
var newSpan = this.rentedBuffer.AsSpan(0, this.span.Length);
this.span.CopyTo(newSpan);
this.rentedBuffer[newSpan.Length] = 0;
}
if (this.IsNull)
return ref defaultValue.GetPinnableReference();
this.state |= State.NullTerminated;
if (this.IsEmpty)
{
this.fixedBuffer[0] = 0;
return ref this.fixedBuffer[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 < FixedBufferSize)
{
var newSpan = MemoryMarshal.CreateSpan(ref this.fixedBuffer[0], this.span.Length);
this.span.CopyTo(newSpan);
this.fixedBuffer[newSpan.Length] = 0;
this.span = newSpan;
}
else
{
this.rentedBuffer = ArrayPool<byte>.Shared.Rent(this.span.Length + 1);
var newSpan = this.rentedBuffer.AsSpan(0, this.span.Length);
this.span.CopyTo(newSpan);
this.rentedBuffer[newSpan.Length] = 0;
}
return this.span;
this.state |= State.NullTerminated;
}
return ref this.span[0];
}
private unsafe Span<byte> EffectiveBuffer =>
@ -151,17 +160,19 @@ public ref struct AutoUtf8Buffer : IDisposable
private Span<byte> RemainingBuffer => this.EffectiveBuffer[this.span.Length..];
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(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(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 unsafe implicit operator AutoUtf8Buffer(byte* text) => new(text);
public static unsafe implicit operator AutoUtf8Buffer(char* text) => new(text);
public static implicit operator Utf8Buffer(ReadOnlySpan<byte> text) => new(text);
public static implicit operator Utf8Buffer(ReadOnlyMemory<byte> text) => new(text);
public static implicit operator Utf8Buffer(Span<byte> text) => new(text);
public static implicit operator Utf8Buffer(Memory<byte> text) => new(text);
public static implicit operator Utf8Buffer(byte[]? text) => new(text.AsSpan());
public static implicit operator Utf8Buffer(ReadOnlySpan<char> text) => new(text);
public static implicit operator Utf8Buffer(ReadOnlyMemory<char> text) => new(text);
public static implicit operator Utf8Buffer(Span<char> text) => new(text);
public static implicit operator Utf8Buffer(Memory<char> text) => new(text);
public static implicit operator Utf8Buffer(char[]? text) => new(text.AsSpan());
public static implicit operator Utf8Buffer(string? text) => new(text);
public static unsafe implicit operator Utf8Buffer(byte* text) => new(text);
public static unsafe implicit operator Utf8Buffer(char* text) => new(text);
public void Dispose()
{
@ -175,9 +186,9 @@ public ref struct AutoUtf8Buffer : IDisposable
this.state = State.None;
}
public AutoUtf8Buffer MoveOrDefault(AutoUtf8Buffer other)
public Utf8Buffer MoveOrDefault(Utf8Buffer other)
{
if (this.IsInitialized)
if (!this.IsNull)
{
other.Dispose();
var res = this;
@ -205,18 +216,62 @@ public ref struct AutoUtf8Buffer : IDisposable
this.span = newSpan[..^1];
}
public void AppendFormatted(ReadOnlySpan<byte> value) => this.AppendFormatted(value, null);
public void AppendFormatted(ReadOnlySpan<byte> value, string? format)
{
var remaining = this.RemainingBuffer;
if (remaining.Length < value.Length + 1)
this.IncreaseBuffer(out remaining, this.span.Length + value.Length + 1);
value.CopyTo(remaining);
var newSpan = this.EffectiveBuffer[..(this.span.Length + value.Length + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
}
public void AppendFormatted(ReadOnlySpan<byte> value, int alignment) => this.AppendFormatted(value, alignment, null);
public void AppendFormatted(ReadOnlySpan<byte> value, int alignment, string? format)
{
var startingPos = this.span.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
}
public void AppendFormatted(ReadOnlySpan<char> value) => this.AppendFormatted(value, null);
public void AppendFormatted(ReadOnlySpan<char> value, string? format)
{
var remaining = this.RemainingBuffer;
var len = Encoding.UTF8.GetByteCount(value);
if (remaining.Length < len + 1)
this.IncreaseBuffer(out remaining, this.span.Length + len + 1);
Encoding.UTF8.GetBytes(value, remaining);
var newSpan = this.EffectiveBuffer[..(this.span.Length + len + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
}
public void AppendFormatted(ReadOnlySpan<char> value, int alignment) => this.AppendFormatted(value, alignment, null);
public void AppendFormatted(ReadOnlySpan<char> value, int alignment, string? format)
{
var startingPos = this.span.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
}
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))
while (!Utf8.TryWrite(remaining, this.formatProvider, $"{value}\0", out written))
this.IncreaseBuffer(out remaining);
var newSpan = this.EffectiveBuffer[..(this.span.Length + written + 1)];
newSpan[^1] = 0;
this.span = newSpan[..^1];
this.span = this.EffectiveBuffer[..(this.span.Length + written - 1)];
}
public void AppendFormatted<T>(T value, int alignment) => this.AppendFormatted(value, alignment, null);
@ -225,6 +280,11 @@ public ref struct AutoUtf8Buffer : IDisposable
{
var startingPos = this.span.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
}
private void FixAlignment(int startingPos, int alignment)
{
var appendedLength = this.span.Length - startingPos;
var leftAlign = alignment < 0;

View file

@ -8,7 +8,7 @@ $lines = New-Object -TypeName "System.Collections.Generic.List[string]"
$namespaceDefPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^\s*)namespace\s+(?<namespace>[\w.]+)\b', 'Compiled,Multiline,Singleline'
$usingPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^|;)\s*using\s+(?<using>\w+)\s*;', 'Compiled,Multiline,Singleline'
$classDefPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?<indent>^\s*)(?<visibility>public\s+|internal\s+|protected\s+|private\s+)?(?<static>static\s+)?(?<unsafe>unsafe\s+)?(?<partial>partial\s+)?(?<type>class\s+|struct\s+)(?<name>\w+)\b', 'Compiled,Multiline,Singleline'
$methodPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^\s+?\[.*?\](?:\r\n|\r|\n))?(?<indent>^\s*)(?<visibility>public\s+|internal\s+|protected\s+|private\s+)?(?<static>static\s+)?(?<unsafe>unsafe\s+)?(?<return>(?!public|internal|protected|private|static|unsafe)\w+(?:\s*<\s*\w+?(?:<\s*\w+\s*>?)?\s*>)?(?:\s*\*)?\s+)(?<name>\w+)(?<args>\s*\([^)]*\))(?:\r\n|\r|\n)[\s\S]+?(?:^\k<indent>}(?:\r\n|\r|\n))', 'Compiled,Multiline,Singleline'
$methodPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^\s+?\[.*?\](?:\r\n|\r|\n))?(?<indent>^\s*)(?<prototype>(?<visibility>public\s+|internal\s+|protected\s+|private\s+)?(?<static>static\s+)?(?<unsafe>unsafe\s+)?(?<return>(?!public|internal|protected|private|static|unsafe)\w+(?:\s*<\s*\w+?(?:<\s*\w+\s*>?)?\s*>)?(?:\s*\*)?\s+)(?<name>\w+)(?<args>\s*\([^)]*\)))(?:\r\n|\r|\n)[\s\S]+?(?:^\k<indent>}(?:\r\n|\r|\n))', 'Compiled,Multiline,Singleline'
$emptyClassPattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^\s+?\[.*?\](?:\r\n|\r|\n))?(?<indent>^\s*)(?<visibility>public\s+|internal\s+|protected\s+|private\s+)?(?<static>static\s+)?(?<unsafe>unsafe\s+)?(?<partial>partial\s+)?(?<type>class\s+|struct\s+)(?<name>\w+)\s*\{\s*\}', 'Compiled,Multiline,Singleline'
$emptyNamespacePattern = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?:^\s*)namespace\s+(?<namespace>\w+)\b\s*\{\s*\}', 'Compiled,Multiline,Singleline'
$referNativeFunction = New-Object -TypeName System.Text.RegularExpressions.Regex -ArgumentList '(?<!\.\s*)\b(\w+)Native(?=\()', 'Compiled'
@ -160,6 +160,14 @@ foreach ($targetPath in $targetPaths)
continue
}
# discard specific functions
if ($methodName.StartsWith("ImGuiTextRange") -or
$methodName.StartsWith("AddInputCharacter"))
{
$null = $discardMethods.Add($methodName)
continue
}
# discard Get...Ref functions
if ($methodName.StartsWith("Get") -And
$methodName.EndsWith("Ref"))
@ -172,10 +180,18 @@ foreach ($targetPath in $targetPaths)
{
# discard formatting functions or functions accepting (begin, end) or (data, size) pairs
$argDef = $overload.Groups["args"].Value
if ($argDef.Contains("byte* fmt") -or
$argDef.Contains("byte* textEnd") -or
$argDef.Contains("byte* strEnd") -or
$argDef.Contains("byte* strIdEnd") -or
if ($argDef.Contains("fmt") -or
$argDef -match "\btext\b" -or
# $argDef.Contains("byte* textEnd") -or
$argDef.Contains("str") -or
# $argDef.Contains("byte* strEnd") -or
# $argDef.Contains("byte* strIdEnd") -or
$argDef.Contains("label") -or
$argDef.Contains("name") -or
$argDef.Contains("prefix") -or
$argDef.Contains("byte* shortcut") -or
$argDef.Contains("byte* type") -or
$argDef.Contains("byte* iniData") -or
$argDef.Contains("int dataSize") -or
$argDef.Contains("values, int valuesCount") -or
$argDef.Contains("data, int itemCount") -or
@ -216,8 +232,27 @@ foreach ($targetPath in $targetPaths)
$null = $sb.Append("}`r`n")
$nativeMethods = $null
if (!$classes.TryGetValue($classDef + "Native", [ref]$nativeMethods))
{
$nativeMethods = $null
}
foreach ($methodName in $discardMethods)
{
if ($nativeMethods -ne $null)
{
$overloads = $null
if ($nativeMethods.TryGetValue($methodName + "Native", [ref]$overloads))
{
foreach ($overload in $overloads)
{
$null = $sb.Append("// DISCARDED: $( $overload.Groups["prototype"].Value )`r`n")
}
continue
}
}
$null = $sb.Append("// DISCARDED: $methodName`r`n")
}