using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; namespace ImGuiNET { public unsafe partial struct ImGuiIO { public ImGuiConfigFlags ConfigFlags; public ImGuiBackendFlags BackendFlags; public Vector2 DisplaySize; public float DeltaTime; public float IniSavingRate; public byte* IniFilename; public byte* LogFilename; public float MouseDoubleClickTime; public float MouseDoubleClickMaxDist; public float MouseDragThreshold; public fixed int KeyMap[22]; public float KeyRepeatDelay; public float KeyRepeatRate; public void* UserData; public ImFontAtlas* Fonts; public float FontGlobalScale; public byte FontAllowUserScaling; public ImFont* FontDefault; public Vector2 DisplayFramebufferScale; public byte MouseDrawCursor; public byte ConfigMacOSXBehaviors; public byte ConfigInputTextCursorBlink; public byte ConfigWindowsResizeFromEdges; public byte ConfigWindowsMoveFromTitleBarOnly; public byte* BackendPlatformName; public byte* BackendRendererName; public void* BackendPlatformUserData; public void* BackendRendererUserData; public void* BackendLanguageUserData; public IntPtr GetClipboardTextFn; public IntPtr SetClipboardTextFn; public void* ClipboardUserData; public IntPtr ImeSetInputScreenPosFn; public void* ImeWindowHandle; public void* RenderDrawListsFnUnused; public Vector2 MousePos; public fixed byte MouseDown[5]; public float MouseWheel; public float MouseWheelH; public byte KeyCtrl; public byte KeyShift; public byte KeyAlt; public byte KeySuper; public fixed byte KeysDown[512]; public fixed float NavInputs[22]; public byte WantCaptureMouse; public byte WantCaptureKeyboard; public byte WantTextInput; public byte WantSetMousePos; public byte WantSaveIniSettings; public byte NavActive; public byte NavVisible; public float Framerate; public int MetricsRenderVertices; public int MetricsRenderIndices; public int MetricsRenderWindows; public int MetricsActiveWindows; public int MetricsActiveAllocations; public Vector2 MouseDelta; public Vector2 MousePosPrev; public Vector2 MouseClickedPos_0; public Vector2 MouseClickedPos_1; public Vector2 MouseClickedPos_2; public Vector2 MouseClickedPos_3; public Vector2 MouseClickedPos_4; public fixed double MouseClickedTime[5]; public fixed byte MouseClicked[5]; public fixed byte MouseDoubleClicked[5]; public fixed byte MouseReleased[5]; public fixed byte MouseDownOwned[5]; public fixed byte MouseDownWasDoubleClick[5]; public fixed float MouseDownDuration[5]; public fixed float MouseDownDurationPrev[5]; public Vector2 MouseDragMaxDistanceAbs_0; public Vector2 MouseDragMaxDistanceAbs_1; public Vector2 MouseDragMaxDistanceAbs_2; public Vector2 MouseDragMaxDistanceAbs_3; public Vector2 MouseDragMaxDistanceAbs_4; public fixed float MouseDragMaxDistanceSqr[5]; public fixed float KeysDownDuration[512]; public fixed float KeysDownDurationPrev[512]; public fixed float NavInputsDownDuration[22]; public fixed float NavInputsDownDurationPrev[22]; public ImVector InputQueueCharacters; } public unsafe partial struct ImGuiIOPtr { public ImGuiIO* NativePtr { get; } public ImGuiIOPtr(ImGuiIO* nativePtr) => NativePtr = nativePtr; public ImGuiIOPtr(IntPtr nativePtr) => NativePtr = (ImGuiIO*)nativePtr; public static implicit operator ImGuiIOPtr(ImGuiIO* nativePtr) => new ImGuiIOPtr(nativePtr); public static implicit operator ImGuiIO* (ImGuiIOPtr wrappedPtr) => wrappedPtr.NativePtr; public static implicit operator ImGuiIOPtr(IntPtr nativePtr) => new ImGuiIOPtr(nativePtr); public ref ImGuiConfigFlags ConfigFlags => ref Unsafe.AsRef(&NativePtr->ConfigFlags); public ref ImGuiBackendFlags BackendFlags => ref Unsafe.AsRef(&NativePtr->BackendFlags); public ref Vector2 DisplaySize => ref Unsafe.AsRef(&NativePtr->DisplaySize); public ref float DeltaTime => ref Unsafe.AsRef(&NativePtr->DeltaTime); public ref float IniSavingRate => ref Unsafe.AsRef(&NativePtr->IniSavingRate); public NullTerminatedString IniFilename => new NullTerminatedString(NativePtr->IniFilename); public NullTerminatedString LogFilename => new NullTerminatedString(NativePtr->LogFilename); public ref float MouseDoubleClickTime => ref Unsafe.AsRef(&NativePtr->MouseDoubleClickTime); public ref float MouseDoubleClickMaxDist => ref Unsafe.AsRef(&NativePtr->MouseDoubleClickMaxDist); public ref float MouseDragThreshold => ref Unsafe.AsRef(&NativePtr->MouseDragThreshold); public RangeAccessor KeyMap => new RangeAccessor(NativePtr->KeyMap, 22); public ref float KeyRepeatDelay => ref Unsafe.AsRef(&NativePtr->KeyRepeatDelay); public ref float KeyRepeatRate => ref Unsafe.AsRef(&NativePtr->KeyRepeatRate); public IntPtr UserData { get => (IntPtr)NativePtr->UserData; set => NativePtr->UserData = (void*)value; } public ImFontAtlasPtr Fonts => new ImFontAtlasPtr(NativePtr->Fonts); public ref float FontGlobalScale => ref Unsafe.AsRef(&NativePtr->FontGlobalScale); public ref bool FontAllowUserScaling => ref Unsafe.AsRef(&NativePtr->FontAllowUserScaling); public ImFontPtr FontDefault => new ImFontPtr(NativePtr->FontDefault); public ref Vector2 DisplayFramebufferScale => ref Unsafe.AsRef(&NativePtr->DisplayFramebufferScale); public ref bool MouseDrawCursor => ref Unsafe.AsRef(&NativePtr->MouseDrawCursor); public ref bool ConfigMacOSXBehaviors => ref Unsafe.AsRef(&NativePtr->ConfigMacOSXBehaviors); public ref bool ConfigInputTextCursorBlink => ref Unsafe.AsRef(&NativePtr->ConfigInputTextCursorBlink); public ref bool ConfigWindowsResizeFromEdges => ref Unsafe.AsRef(&NativePtr->ConfigWindowsResizeFromEdges); public ref bool ConfigWindowsMoveFromTitleBarOnly => ref Unsafe.AsRef(&NativePtr->ConfigWindowsMoveFromTitleBarOnly); public NullTerminatedString BackendPlatformName => new NullTerminatedString(NativePtr->BackendPlatformName); public NullTerminatedString BackendRendererName => new NullTerminatedString(NativePtr->BackendRendererName); public IntPtr BackendPlatformUserData { get => (IntPtr)NativePtr->BackendPlatformUserData; set => NativePtr->BackendPlatformUserData = (void*)value; } public IntPtr BackendRendererUserData { get => (IntPtr)NativePtr->BackendRendererUserData; set => NativePtr->BackendRendererUserData = (void*)value; } public IntPtr BackendLanguageUserData { get => (IntPtr)NativePtr->BackendLanguageUserData; set => NativePtr->BackendLanguageUserData = (void*)value; } public ref IntPtr GetClipboardTextFn => ref Unsafe.AsRef(&NativePtr->GetClipboardTextFn); public ref IntPtr SetClipboardTextFn => ref Unsafe.AsRef(&NativePtr->SetClipboardTextFn); public IntPtr ClipboardUserData { get => (IntPtr)NativePtr->ClipboardUserData; set => NativePtr->ClipboardUserData = (void*)value; } public ref IntPtr ImeSetInputScreenPosFn => ref Unsafe.AsRef(&NativePtr->ImeSetInputScreenPosFn); public IntPtr ImeWindowHandle { get => (IntPtr)NativePtr->ImeWindowHandle; set => NativePtr->ImeWindowHandle = (void*)value; } public IntPtr RenderDrawListsFnUnused { get => (IntPtr)NativePtr->RenderDrawListsFnUnused; set => NativePtr->RenderDrawListsFnUnused = (void*)value; } public ref Vector2 MousePos => ref Unsafe.AsRef(&NativePtr->MousePos); public RangeAccessor MouseDown => new RangeAccessor(NativePtr->MouseDown, 5); public ref float MouseWheel => ref Unsafe.AsRef(&NativePtr->MouseWheel); public ref float MouseWheelH => ref Unsafe.AsRef(&NativePtr->MouseWheelH); public ref bool KeyCtrl => ref Unsafe.AsRef(&NativePtr->KeyCtrl); public ref bool KeyShift => ref Unsafe.AsRef(&NativePtr->KeyShift); public ref bool KeyAlt => ref Unsafe.AsRef(&NativePtr->KeyAlt); public ref bool KeySuper => ref Unsafe.AsRef(&NativePtr->KeySuper); public RangeAccessor KeysDown => new RangeAccessor(NativePtr->KeysDown, 512); public RangeAccessor NavInputs => new RangeAccessor(NativePtr->NavInputs, 22); public ref bool WantCaptureMouse => ref Unsafe.AsRef(&NativePtr->WantCaptureMouse); public ref bool WantCaptureKeyboard => ref Unsafe.AsRef(&NativePtr->WantCaptureKeyboard); public ref bool WantTextInput => ref Unsafe.AsRef(&NativePtr->WantTextInput); public ref bool WantSetMousePos => ref Unsafe.AsRef(&NativePtr->WantSetMousePos); public ref bool WantSaveIniSettings => ref Unsafe.AsRef(&NativePtr->WantSaveIniSettings); public ref bool NavActive => ref Unsafe.AsRef(&NativePtr->NavActive); public ref bool NavVisible => ref Unsafe.AsRef(&NativePtr->NavVisible); public ref float Framerate => ref Unsafe.AsRef(&NativePtr->Framerate); public ref int MetricsRenderVertices => ref Unsafe.AsRef(&NativePtr->MetricsRenderVertices); public ref int MetricsRenderIndices => ref Unsafe.AsRef(&NativePtr->MetricsRenderIndices); public ref int MetricsRenderWindows => ref Unsafe.AsRef(&NativePtr->MetricsRenderWindows); public ref int MetricsActiveWindows => ref Unsafe.AsRef(&NativePtr->MetricsActiveWindows); public ref int MetricsActiveAllocations => ref Unsafe.AsRef(&NativePtr->MetricsActiveAllocations); public ref Vector2 MouseDelta => ref Unsafe.AsRef(&NativePtr->MouseDelta); public ref Vector2 MousePosPrev => ref Unsafe.AsRef(&NativePtr->MousePosPrev); public RangeAccessor MouseClickedPos => new RangeAccessor(&NativePtr->MouseClickedPos_0, 5); public RangeAccessor MouseClickedTime => new RangeAccessor(NativePtr->MouseClickedTime, 5); public RangeAccessor MouseClicked => new RangeAccessor(NativePtr->MouseClicked, 5); public RangeAccessor MouseDoubleClicked => new RangeAccessor(NativePtr->MouseDoubleClicked, 5); public RangeAccessor MouseReleased => new RangeAccessor(NativePtr->MouseReleased, 5); public RangeAccessor MouseDownOwned => new RangeAccessor(NativePtr->MouseDownOwned, 5); public RangeAccessor MouseDownWasDoubleClick => new RangeAccessor(NativePtr->MouseDownWasDoubleClick, 5); public RangeAccessor MouseDownDuration => new RangeAccessor(NativePtr->MouseDownDuration, 5); public RangeAccessor MouseDownDurationPrev => new RangeAccessor(NativePtr->MouseDownDurationPrev, 5); public RangeAccessor MouseDragMaxDistanceAbs => new RangeAccessor(&NativePtr->MouseDragMaxDistanceAbs_0, 5); public RangeAccessor MouseDragMaxDistanceSqr => new RangeAccessor(NativePtr->MouseDragMaxDistanceSqr, 5); public RangeAccessor KeysDownDuration => new RangeAccessor(NativePtr->KeysDownDuration, 512); public RangeAccessor KeysDownDurationPrev => new RangeAccessor(NativePtr->KeysDownDurationPrev, 512); public RangeAccessor NavInputsDownDuration => new RangeAccessor(NativePtr->NavInputsDownDuration, 22); public RangeAccessor NavInputsDownDurationPrev => new RangeAccessor(NativePtr->NavInputsDownDurationPrev, 22); public ImVector InputQueueCharacters => new ImVector(NativePtr->InputQueueCharacters); public void AddInputCharacter(uint c) { ImGuiNative.ImGuiIO_AddInputCharacter(NativePtr, c); } public void AddInputCharactersUTF8(string str) { byte* native_str; int str_byteCount = 0; if (str != null) { str_byteCount = Encoding.UTF8.GetByteCount(str); if (str_byteCount > Util.StackAllocationSizeLimit) { native_str = Util.Allocate(str_byteCount + 1); } else { byte* native_str_stackBytes = stackalloc byte[str_byteCount + 1]; native_str = native_str_stackBytes; } int native_str_offset = Util.GetUtf8(str, native_str, str_byteCount); native_str[native_str_offset] = 0; } else { native_str = null; } ImGuiNative.ImGuiIO_AddInputCharactersUTF8(NativePtr, native_str); if (str_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_str); } } public void ClearInputCharacters() { ImGuiNative.ImGuiIO_ClearInputCharacters(NativePtr); } public void Destroy() { ImGuiNative.ImGuiIO_destroy(NativePtr); } } }