using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Dalamud.Bindings.ImGui; namespace QuestionableCompanion.Helpers; public static class ImGuiDragDrop { public static void SetDragDropPayload(string type, T data, ImGuiCond cond = ImGuiCond.None) where T : struct { ReadOnlySpan span = MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(in data, 1)); ImGui.SetDragDropPayload(type, span, cond); } public unsafe static bool AcceptDragDropPayload(string type, out T payload, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None) where T : struct { ImGuiPayload* pload = ImGui.AcceptDragDropPayload(type, flags); payload = ((pload != null) ? Unsafe.Read(pload->Data) : default(T)); return pload != null; } }