Use ImGuiWindow from gen, support AddCallback

This commit is contained in:
Soreepeong 2025-08-02 20:21:11 +09:00
parent f7749237ee
commit 1a15600a8f
9 changed files with 91 additions and 87 deletions

View file

@ -0,0 +1,15 @@
namespace Dalamud.Bindings.ImGui;
public enum ImDrawCallbackEnum
{
Empty,
/// <summary>
/// Special Draw callback value to request renderer backend to reset the graphics/render state.
/// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at
/// this address. This is useful for example if you submitted callbacks which you know have altered the render
/// state, and you want it to be restored. It is not done by default because they are many perfectly useful way of
/// altering render state for imgui contents (e.g. changing shader/blending settings before an Image call).
/// </summary>
ResetRenderState = -1,
}

View file

@ -1,6 +1,3 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Dalamud.Bindings.ImGui;
public unsafe partial class ImGui

View file

@ -6,6 +6,26 @@ namespace Dalamud.Bindings.ImGui;
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static unsafe partial class ImGui
{
public static void AddCallback(
ImDrawListPtr self, delegate*<ImDrawList*, ImDrawCmd*, void> callback, void* callbackData = null) =>
((delegate* unmanaged[Cdecl]<ImDrawList*, delegate*<ImDrawList*, ImDrawCmd*, void>, void*, void>)funcTable
[540])(self, callback, callbackData);
public static void AddCallback(
ImDrawListPtr self, delegate*<ImDrawListPtr, ImDrawCmdPtr, void> callback, void* callbackData = null) =>
AddCallback(self, (delegate*<ImDrawList*, ImDrawCmd*, void>)callback, callbackData);
public static void AddCallback(
ImDrawListPtr self, delegate*<ref ImDrawList, ref ImDrawCmd, void> callback, void* callbackData = null) =>
AddCallback(self, (delegate*<ImDrawList*, ImDrawCmd*, void>)callback, callbackData);
public static void AddCallback(ImDrawListPtr self, ImDrawCallbackEnum presetCallback)
{
if (!Enum.IsDefined(presetCallback))
throw new ArgumentOutOfRangeException(nameof(presetCallback), presetCallback, null);
AddCallback(self, (delegate*<ImDrawList*, ImDrawCmd*, void>)(nint)presetCallback);
}
public static ImGuiPayloadPtr AcceptDragDropPayload(
ImU8String type, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None)
{

View file

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=custom/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -28,7 +28,7 @@ namespace Dalamud.Bindings.ImGui
public ImTextureID(void* handle) { Handle = (ulong)handle; }
public ulong Handle { get; }
public bool IsNull => Handle == 0;
public static ImTextureID Null => new ImTextureID(0);
public static ImTextureID Null => default;
public static implicit operator ImTextureID(ulong handle) => new ImTextureID(handle);
public static bool operator ==(ImTextureID left, ImTextureID right) => left.Handle == right.Handle;
public static bool operator !=(ImTextureID left, ImTextureID right) => left.Handle != right.Handle;