From 206770ccd13daa1c8e8dde7020faa04f64e89664 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Sun, 1 Nov 2015 01:19:31 -0700 Subject: [PATCH] Some formatting changes and cleanup --- src/ImGui.NET.SampleProgram/Program.cs | 5 - src/ImGui.NET.SampleProgram/SampleWindow.cs | 38 +-- src/ImGui.NET/Align.cs | 12 + src/ImGui.NET/ColorEditMode.cs | 8 +- src/ImGui.NET/ColorTarget.cs | 1 + src/ImGui.NET/DrawCmd.cs | 36 +++ src/ImGui.NET/{ImDrawData.cs => DrawData.cs} | 14 +- src/ImGui.NET/{ImDrawList.cs => DrawList.cs} | 2 +- src/ImGui.NET/{ImDrawVert.cs => DrawVert.cs} | 2 +- src/ImGui.NET/{ImFont.cs => Font.cs} | 2 +- .../{ImFontAtlas.cs => FontAtlas.cs} | 9 +- .../{ImFontConfig.cs => FontConfig.cs} | 2 +- src/ImGui.NET/IO.cs | 306 ++++++++++++++++++ src/ImGui.NET/ImDrawCmd.cs | 28 -- src/ImGui.NET/ImGui.NET.csproj | 22 +- src/ImGui.NET/ImGui.cs | 2 +- src/ImGui.NET/ImGuiIO.cs | 202 ------------ src/ImGui.NET/ImGuiNative.cs | 53 +-- src/ImGui.NET/ImGuiTextEditCallbackData.cs | 36 --- src/ImGui.NET/{ImGuiStorage.cs => Storage.cs} | 0 src/ImGui.NET/{ImGuiStyle.cs => Style.cs} | 14 +- 21 files changed, 430 insertions(+), 364 deletions(-) create mode 100644 src/ImGui.NET/Align.cs create mode 100644 src/ImGui.NET/DrawCmd.cs rename src/ImGui.NET/{ImDrawData.cs => DrawData.cs} (80%) rename src/ImGui.NET/{ImDrawList.cs => DrawList.cs} (99%) rename src/ImGui.NET/{ImDrawVert.cs => DrawVert.cs} (90%) rename src/ImGui.NET/{ImFont.cs => Font.cs} (99%) rename src/ImGui.NET/{ImFontAtlas.cs => FontAtlas.cs} (95%) rename src/ImGui.NET/{ImFontConfig.cs => FontConfig.cs} (98%) create mode 100644 src/ImGui.NET/IO.cs delete mode 100644 src/ImGui.NET/ImDrawCmd.cs delete mode 100644 src/ImGui.NET/ImGuiIO.cs delete mode 100644 src/ImGui.NET/ImGuiTextEditCallbackData.cs rename src/ImGui.NET/{ImGuiStorage.cs => Storage.cs} (100%) rename src/ImGui.NET/{ImGuiStyle.cs => Style.cs} (88%) diff --git a/src/ImGui.NET.SampleProgram/Program.cs b/src/ImGui.NET.SampleProgram/Program.cs index 464ea39..9930369 100644 --- a/src/ImGui.NET.SampleProgram/Program.cs +++ b/src/ImGui.NET.SampleProgram/Program.cs @@ -1,8 +1,3 @@ -using OpenTK; -using System; -using System.Diagnostics; -using System.Threading.Tasks; - namespace ImGui { public class Program diff --git a/src/ImGui.NET.SampleProgram/SampleWindow.cs b/src/ImGui.NET.SampleProgram/SampleWindow.cs index 943e1ef..efa416b 100644 --- a/src/ImGui.NET.SampleProgram/SampleWindow.cs +++ b/src/ImGui.NET.SampleProgram/SampleWindow.cs @@ -38,7 +38,7 @@ namespace ImGui _nativeWindow.KeyUp += OnKeyUp; _nativeWindow.KeyPress += OnKeyPress; - ImGuiIO* io = ImGuiNative.igGetIO(); + IO* io = ImGuiNative.igGetIO(); ImGuiNative.ImFontAtlas_AddFontDefault(io->FontAtlas); SetOpenTKKeyMappings(io); @@ -59,7 +59,7 @@ namespace ImGui ImGuiNative.ImGuiIO_AddInputCharacter(e.KeyChar); } - private static unsafe void SetOpenTKKeyMappings(ImGuiIO* io) + private static unsafe void SetOpenTKKeyMappings(IO* io) { io->KeyMap[(int)GuiKey.Tab] = (int)Key.Tab; io->KeyMap[(int)GuiKey.LeftArrow] = (int)Key.Left; @@ -96,7 +96,7 @@ namespace ImGui UpdateModifiers(e, ptr); } - private static unsafe void UpdateModifiers(KeyboardKeyEventArgs e, ImGuiIO* ptr) + private static unsafe void UpdateModifiers(KeyboardKeyEventArgs e, IO* ptr) { ptr->KeyAlt = e.Alt ? (byte)1 : (byte)0; ptr->KeyCtrl = e.Control ? (byte)1 : (byte)0; @@ -105,7 +105,7 @@ namespace ImGui private unsafe void CreateDeviceObjects() { - ImGuiIO* io = ImGuiNative.igGetIO(); + IO* io = ImGuiNative.igGetIO(); // Build texture atlas byte* pixels; @@ -139,7 +139,7 @@ namespace ImGui private unsafe void RenderFrame() { - ImGuiIO* io = ImGuiNative.igGetIO(); + IO* io = ImGuiNative.igGetIO(); io->DisplaySize = new System.Numerics.Vector2(_nativeWindow.Width, _nativeWindow.Height); io->DisplayFramebufferScale = new System.Numerics.Vector2(1, 1); io->DeltaTime = (1f / 60f); @@ -152,7 +152,7 @@ namespace ImGui ImGuiNative.igRender(); - ImDrawData* data = ImGuiNative.igGetDrawData(); + DrawData* data = ImGuiNative.igGetDrawData(); RenderImDrawData(data); } @@ -179,8 +179,8 @@ namespace ImGui ImGuiNative.igText("World!"); ImGuiNative.igText("From ImGui.NET. ...Did that work?"); var pos = ImGuiNative.igGetIO()->MousePos; - var leftPressed = ImGuiNative.igGetIO()->MouseDown[0] == 1; - ImGuiNative.igText("Current mouse position: " + pos + ". Pressed=" + leftPressed); + //bool leftPressed = ImGuiNative.igGetIO()->MouseDown[0]; + //ImGuiNative.igText("Current mouse position: " + pos + ". Pressed=" + leftPressed); if (ImGuiNative.igButton("Press me!", new System.Numerics.Vector2(120, 30))) { @@ -227,7 +227,7 @@ namespace ImGui return 0; } - private unsafe void UpdateImGuiInput(ImGuiIO* io) + private unsafe void UpdateImGuiInput(IO* io) { MouseState cursorState = OpenTK.Input.Mouse.GetCursorState(); MouseState mouseState = Mouse.GetState(); @@ -252,7 +252,7 @@ namespace ImGui io->MouseWheel = delta; } - private unsafe void RenderImDrawData(ImDrawData* draw_data) + private unsafe void RenderImDrawData(DrawData* draw_data) { // Rendering int display_w, display_h; @@ -283,7 +283,7 @@ namespace ImGui GL.UseProgram(0); // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays) - ImGuiIO* io = ImGuiNative.igGetIO(); + IO* io = ImGuiNative.igGetIO(); float fb_height = io->DisplaySize.Y * io->DisplayFramebufferScale.Y; // Can implement the below in C#. @@ -303,24 +303,24 @@ namespace ImGui for (int n = 0; n < draw_data->CmdListsCount; n++) { - ImDrawList* cmd_list = draw_data->CmdLists[n]; + DrawList* cmd_list = draw_data->CmdLists[n]; byte* vtx_buffer = (byte*)cmd_list->VtxBuffer.Data; ushort* idx_buffer = (ushort*)cmd_list->IdxBuffer.Data; - ImDrawVert vert0 = *((ImDrawVert*)vtx_buffer); - ImDrawVert vert1 = *(((ImDrawVert*)vtx_buffer) + 1); - ImDrawVert vert2 = *(((ImDrawVert*)vtx_buffer) + 2); + DrawVert vert0 = *((DrawVert*)vtx_buffer); + DrawVert vert1 = *(((DrawVert*)vtx_buffer) + 1); + DrawVert vert2 = *(((DrawVert*)vtx_buffer) + 2); //glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF("pos"))); - GL.VertexPointer(2, VertexPointerType.Float, sizeof(ImDrawVert), new IntPtr(vtx_buffer + ImDrawVert.PosOffset)); + GL.VertexPointer(2, VertexPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.PosOffset)); //glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF("uv"))); - GL.TexCoordPointer(2, TexCoordPointerType.Float, sizeof(ImDrawVert), new IntPtr(vtx_buffer + ImDrawVert.UVOffset)); + GL.TexCoordPointer(2, TexCoordPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.UVOffset)); //glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF("col"))); - GL.ColorPointer(4, ColorPointerType.UnsignedByte, sizeof(ImDrawVert), new IntPtr(vtx_buffer + ImDrawVert.ColOffset)); + GL.ColorPointer(4, ColorPointerType.UnsignedByte, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.ColOffset)); for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) { - ImDrawCmd* pcmd = &(((ImDrawCmd*)cmd_list->CmdBuffer.Data)[cmd_i]); + DrawCmd* pcmd = &(((DrawCmd*)cmd_list->CmdBuffer.Data)[cmd_i]); if (pcmd->UserCallback != IntPtr.Zero) { throw new NotImplementedException(); diff --git a/src/ImGui.NET/Align.cs b/src/ImGui.NET/Align.cs new file mode 100644 index 0000000..6f380a0 --- /dev/null +++ b/src/ImGui.NET/Align.cs @@ -0,0 +1,12 @@ +namespace ImGui +{ + public enum Align + { + Left = 1 << 0, + Center = 1 << 1, + Right = 1 << 2, + Top = 1 << 3, + VCenter = 1 << 4, + Default = Left | Top + } +} diff --git a/src/ImGui.NET/ColorEditMode.cs b/src/ImGui.NET/ColorEditMode.cs index fac76ce..4681e61 100644 --- a/src/ImGui.NET/ColorEditMode.cs +++ b/src/ImGui.NET/ColorEditMode.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ImGui +namespace ImGui { /// /// Enumeration for ColorEditMode() diff --git a/src/ImGui.NET/ColorTarget.cs b/src/ImGui.NET/ColorTarget.cs index 53f5841..cbcdfaf 100644 --- a/src/ImGui.NET/ColorTarget.cs +++ b/src/ImGui.NET/ColorTarget.cs @@ -54,5 +54,6 @@ /// darken entire screen when a modal window is active /// ModalWindowDarkening, + Count, }; } diff --git a/src/ImGui.NET/DrawCmd.cs b/src/ImGui.NET/DrawCmd.cs new file mode 100644 index 0000000..2de631c --- /dev/null +++ b/src/ImGui.NET/DrawCmd.cs @@ -0,0 +1,36 @@ +using System; +using System.Numerics; +using System.Runtime.InteropServices; + +namespace ImGui +{ + /// + /// Typically, 1 command = 1 gpu draw call (unless command is a callback) + /// + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DrawCmd + { + /// + /// Number of indices (multiple of 3) to be rendered as triangles. + /// Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. + /// + public uint ElemCount; + /// + /// Clipping rectangle (x1, y1, x2, y2) + /// + public Vector4 ClipRect; + /// + /// User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. + /// Ignore if never using images or multiple fonts atlas. + /// + public IntPtr TextureId; + /// + /// If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. + /// + public IntPtr UserCallback; + /// + /// The draw callback code can access this. + /// + public IntPtr UserCallbackData; + }; +} diff --git a/src/ImGui.NET/ImDrawData.cs b/src/ImGui.NET/DrawData.cs similarity index 80% rename from src/ImGui.NET/ImDrawData.cs rename to src/ImGui.NET/DrawData.cs index 53a4128..c729b24 100644 --- a/src/ImGui.NET/ImDrawData.cs +++ b/src/ImGui.NET/DrawData.cs @@ -1,19 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using ImVec2 = System.Numerics.Vector2; +using System.Runtime.InteropServices; namespace ImGui { // All draw data to render an ImGui frame [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImDrawData + public unsafe struct DrawData { public byte Valid; // Only valid after Render() is called and before the next NewFrame() is called. - public ImDrawList** CmdLists; + public DrawList** CmdLists; public int CmdListsCount; public int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size public int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size @@ -24,5 +18,5 @@ namespace ImGui IMGUI_API void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. */ -}; + }; } diff --git a/src/ImGui.NET/ImDrawList.cs b/src/ImGui.NET/DrawList.cs similarity index 99% rename from src/ImGui.NET/ImDrawList.cs rename to src/ImGui.NET/DrawList.cs index a5726a2..fbc1518 100644 --- a/src/ImGui.NET/ImDrawList.cs +++ b/src/ImGui.NET/DrawList.cs @@ -11,7 +11,7 @@ namespace ImGui // All positions are in screen coordinates (0,0=top-left, 1 pixel per unit). Primitives are always added to the list and not culled (culling is done at render time and at a higher-level by ImGui:: functions). // Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImDrawList + public unsafe struct DrawList { // This is what you have to render // ImVector CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call. diff --git a/src/ImGui.NET/ImDrawVert.cs b/src/ImGui.NET/DrawVert.cs similarity index 90% rename from src/ImGui.NET/ImDrawVert.cs rename to src/ImGui.NET/DrawVert.cs index 6bc480c..91ac7ec 100644 --- a/src/ImGui.NET/ImDrawVert.cs +++ b/src/ImGui.NET/DrawVert.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; namespace ImGui { [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImDrawVert + public unsafe struct DrawVert { public ImVec2 pos; public ImVec2 uv; diff --git a/src/ImGui.NET/ImFont.cs b/src/ImGui.NET/Font.cs similarity index 99% rename from src/ImGui.NET/ImFont.cs rename to src/ImGui.NET/Font.cs index d88b72f..817deb7 100644 --- a/src/ImGui.NET/ImFont.cs +++ b/src/ImGui.NET/Font.cs @@ -7,7 +7,7 @@ namespace ImGui // Font runtime data and rendering // ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImFont + public unsafe struct Font { // Members: Settings public float FontSize; // // Height of characters, set during loading (don't change after loading) diff --git a/src/ImGui.NET/ImFontAtlas.cs b/src/ImGui.NET/FontAtlas.cs similarity index 95% rename from src/ImGui.NET/ImFontAtlas.cs rename to src/ImGui.NET/FontAtlas.cs index df7f9b1..26d1794 100644 --- a/src/ImGui.NET/ImFontAtlas.cs +++ b/src/ImGui.NET/FontAtlas.cs @@ -1,7 +1,6 @@ -using ImWchar = System.UInt16; -using ImVec2 = System.Numerics.Vector2; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using System; +using System.Numerics; namespace ImGui { @@ -14,7 +13,7 @@ namespace ImGui // 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture. // 5. Call ClearTexData() to free textures memory on the heap. [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImFontAtlas + public unsafe struct FontAtlas { /* public ImFont* AddFont(ImFontConfig* font_cfg) { } @@ -54,7 +53,7 @@ namespace ImGui public IntPtr TexWidth; // Texture width calculated during Build(). public IntPtr TexHeight; // Texture height calculated during Build(). public IntPtr TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. - public ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block) + public Vector2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block) /// /// (ImVector(ImFont*) diff --git a/src/ImGui.NET/ImFontConfig.cs b/src/ImGui.NET/FontConfig.cs similarity index 98% rename from src/ImGui.NET/ImFontConfig.cs rename to src/ImGui.NET/FontConfig.cs index 0df3081..1a05fc5 100644 --- a/src/ImGui.NET/ImFontConfig.cs +++ b/src/ImGui.NET/FontConfig.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; namespace ImGui { [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImFontConfig + public unsafe struct FontConfig { /// /// TTF data diff --git a/src/ImGui.NET/IO.cs b/src/ImGui.NET/IO.cs new file mode 100644 index 0000000..63dbb7b --- /dev/null +++ b/src/ImGui.NET/IO.cs @@ -0,0 +1,306 @@ +using System; +using System.Numerics; +using System.Runtime.InteropServices; + +namespace ImGui +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct IO + { + //------------------------------------------------------------------ + // Settings (fill once) + //------------------------------------------------------------------ + + /// + /// Display size, in pixels. For clamping windows positions. + /// Default value: [unset] + /// + public Vector2 DisplaySize; + /// + /// Time elapsed since last frame, in seconds. + /// Default value: 1.0f / 10.0f. + /// + public float DeltaTime; + /// + /// Maximum time between saving positions/sizes to .ini file, in seconds. + /// Default value: 5.0f. + /// + public float IniSavingRate; + /// + /// Path to .ini file. NULL to disable .ini saving. + /// Default value: "imgui.ini" + /// + public IntPtr IniFilename; + /// + /// Path to .log file (default parameter to ImGui::LogToFile when no file is specified). + /// Default value: "imgui_log.txt" + /// + public IntPtr LogFilename; + /// + /// Time for a double-click, in seconds. + /// Default value: 0.30f. + /// + public float MouseDoubleClickTime; + /// + /// Distance threshold to stay in to validate a double-click, in pixels. + /// Default Value: 6.0f. + /// + public float MouseDoubleClickMaxDist; + /// + /// Distance threshold before considering we are dragging. + /// Default Value: 6.0f. + /// + public float MouseDragThreshold; + + /// + /// Map of indices into the KeysDown[512] entries array. + /// Default values: [unset] + /// + public fixed int KeyMap[(int)GuiKey.Count]; + /// + /// When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active). + /// Default value: 0.250f. + /// + public float KeyRepeatDelay; + /// + /// When holding a key/button, rate at which it repeats, in seconds. + /// Default value: 0.020f. + /// + public float KeyRepeatRate; + /// + /// Store your own data for retrieval by callbacks. + /// Default value; IntPtr.Zero. + /// + public IntPtr UserData; + + /// + /// Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. + /// Default value: [auto] + /// + public FontAtlas* FontAtlas; + /// + /// Global scale all fonts. + /// Default value: 1.0f. + /// + public float FontGlobalScale; + /// + /// Allow user scaling text of individual window with CTRL+Wheel. + /// Default value: false. + /// + public byte FontAllowUserScaling; + /// + /// For retina display or other situations where window coordinates are different from framebuffer coordinates. + /// User storage only, presently not used by ImGui. + /// Default value: (1.0f, 1.0f). + /// + public Vector2 DisplayFramebufferScale; + /// + /// If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area. + /// Default value: (0.0f, 0.0f) + /// + public Vector2 DisplayVisibleMin; + /// + /// If the values are the same, we defaults to Min=0.0f) and Max=DisplaySize. + /// Default value: (0.0f, 0.0f). + /// + public Vector2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize + + //------------------------------------------------------------------ + // User Functions + //------------------------------------------------------------------ + + /// + /// Rendering function, will be called in Render(). + /// Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer. + /// + public IntPtr RenderDrawListsFn; + + /// + /// Optional: access OS clipboard + /// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) + /// + public IntPtr GetClipboardTextFn; + /// + /// Optional: access OS clipboard + /// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) + /// + public IntPtr SetClipboardTextFn; + + /// + /// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer. + /// (default to posix malloc/free) + /// + public IntPtr MemAllocFn; + /// + /// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer. + /// (default to posix malloc/free) + /// + public IntPtr MemFreeFn; + + /// + /// Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows) + /// (default to use native imm32 api on Windows) + /// + public IntPtr ImeSetInputScreenPosFn; + /// + /// (Windows) Set this to your HWND to get automatic IME cursor positioning. + /// + public IntPtr ImeWindowHandle; + + //------------------------------------------------------------------ + // Input - Fill before calling NewFrame() + //------------------------------------------------------------------ + + /// + /// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.). + /// + public Vector2 MousePos; + /// + /// Mouse buttons: left, right, middle + extras. + /// ImGui itself mostly only uses left button (BeginPopupContext** are using right button). + /// Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. + /// + [MarshalAs(UnmanagedType.I1)] + public fixed byte MouseDown[5]; + /// + /// Mouse wheel: 1 unit scrolls about 5 lines text. + /// + public float MouseWheel; + /// + /// Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). + /// + public byte MouseDrawCursor; + /// + /// Keyboard modifier pressed: Control. + /// + public byte KeyCtrl; + /// + /// Keyboard modifier pressed: Shift + /// + public byte KeyShift; + /// + /// Keyboard modifier pressed: Alt + /// + public byte KeyAlt; + /// + /// Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data) + /// + public fixed byte KeysDown[512]; + /// + /// List of characters input (translated by user from keypress+keyboard state). + /// Fill using AddInputCharacter() helper. + /// + public fixed ushort InputCharacters[16 + 1]; + + //------------------------------------------------------------------ + // Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application + //------------------------------------------------------------------ + + /// + /// Mouse is hovering a window or widget is active (= ImGui will use your mouse input). + /// + public byte WantCaptureMouse; + /// + /// Widget is active (= ImGui will use your keyboard input). + /// + public byte WantCaptureKeyboard; + /// + /// Some text input widget is active, which will read input characters from the InputCharacters array. + /// + public byte WantTextInput; + /// + /// Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames. + /// + public float Framerate; + /// + /// Number of active memory allocations. + /// + public int MetricsAllocs; + /// + /// Vertices output during last call to Render(). + /// + public int MetricsRenderVertices; + /// + /// Indices output during last call to Render() = number of triangles * 3 + /// + public int MetricsRenderIndices; + /// + /// Number of visible windows (exclude child windows) + /// + public int MetricsActiveWindows; + + //------------------------------------------------------------------ + // [Internal] ImGui will maintain those fields for you + //------------------------------------------------------------------ + + /// + /// Previous mouse position + /// + public Vector2 MousePosPrev; + /// + /// Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling. + /// + public Vector2 MouseDelta; + /// + /// Mouse button went from !Down to Down + /// + public fixed byte MouseClicked[5]; + /// + /// Position at time of clicking + /// + public Vector2 MouseClickedPos0; + /// + /// Position at time of clicking + /// + public Vector2 MouseClickedPos1; + /// + /// Position at time of clicking + /// + public Vector2 MouseClickedPos2; + /// + /// Position at time of clicking + /// + public Vector2 MouseClickedPos3; + /// + /// Position at time of clicking + /// + public Vector2 MouseClickedPos4; + /// + /// Time of last click (used to figure out double-click) + /// + public fixed float MouseClickedTime[5]; + /// + /// Has mouse button been double-clicked? + /// + public fixed byte MouseDoubleClicked[5]; + /// + /// Mouse button went from Down to !Down + /// + public fixed byte MouseReleased[5]; + /// + /// Track if button was clicked inside a window. + /// We don't request mouse capture from the application if click started outside ImGui bounds. + /// + public fixed byte MouseDownOwned[5]; + /// + /// Duration the mouse button has been down (0.0f == just clicked). + /// + public fixed float MouseDownDuration[5]; + /// + /// Previous time the mouse button has been down + /// + public fixed float MouseDownDurationPrev[5]; + /// + /// Squared maximum distance of how much mouse has traveled from the click point + /// + public fixed float MouseDragMaxDistanceSqr[5]; + /// + /// Duration the keyboard key has been down (0.0f == just pressed) + /// + public fixed float KeysDownDuration[512]; + /// + /// Previous duration the key has been down + /// + public fixed float KeysDownDurationPrev[512]; + } +} diff --git a/src/ImGui.NET/ImDrawCmd.cs b/src/ImGui.NET/ImDrawCmd.cs deleted file mode 100644 index 21c65eb..0000000 --- a/src/ImGui.NET/ImDrawCmd.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using ImVec4 = System.Numerics.Vector4; -using System.Runtime.InteropServices; - -namespace ImGui -{ - // Typically, 1 command = 1 gpu draw call (unless command is a callback) - [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImDrawCmd - { - public uint ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. - public ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2) - public IntPtr TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas. - - // typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); - public IntPtr UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. - public IntPtr UserCallbackData; // The draw callback code can access this. - - /* - public ImDrawCmd() { ElemCount = 0; ClipRect.X = ClipRect.Y = -8192.0f; ClipRect.Z = ClipRect.W = +8192.0f; TextureId = ImTextureID.Zero; UserCallback = null; UserCallbackData = null; } - */ - }; -} diff --git a/src/ImGui.NET/ImGui.NET.csproj b/src/ImGui.NET/ImGui.NET.csproj index dfeee07..d10458a 100644 --- a/src/ImGui.NET/ImGui.NET.csproj +++ b/src/ImGui.NET/ImGui.NET.csproj @@ -10,6 +10,7 @@ true + @@ -17,18 +18,17 @@ - - - - - - - + + + + + + + - - - - + + + diff --git a/src/ImGui.NET/ImGui.cs b/src/ImGui.NET/ImGui.cs index 2f90c6d..89f8c78 100644 --- a/src/ImGui.NET/ImGui.cs +++ b/src/ImGui.NET/ImGui.cs @@ -17,7 +17,7 @@ namespace ImGui public static unsafe void LoadDefaultFont() { - ImGuiIO* ioPtr = ImGuiNative.igGetIO(); + IO* ioPtr = ImGuiNative.igGetIO(); ImGuiNative.ImFontAtlas_AddFontDefault(ioPtr->FontAtlas); } diff --git a/src/ImGui.NET/ImGuiIO.cs b/src/ImGui.NET/ImGuiIO.cs deleted file mode 100644 index 79a64ea..0000000 --- a/src/ImGui.NET/ImGuiIO.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using ImVec2 = System.Numerics.Vector2; -using ImWchar = System.UInt16; - -namespace ImGui -{ - //void (* RenderDrawListsFn)(ImDrawData* data); - // [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal unsafe delegate void RenderDrawListsFn(ImDrawData* data); - - [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImGuiIO - { - //------------------------------------------------------------------ - // Settings (fill once) // Default value: - //------------------------------------------------------------------ - - public ImVec2 DisplaySize; // // Display size, in pixels. For clamping windows positions. - public float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. - public float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds. - public IntPtr IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving. - public IntPtr LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified). - public float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. - public float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. - public float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging - - public fixed int KeyMap[(int)GuiKey.Count]; // // Map of indices into the KeysDown[512] entries array - public float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active) - public float KeyRepeatRate; // = 0.020f // When holding a key/button, rate at which it repeats, in seconds. - public IntPtr UserData; // = NULL // Store your own data for retrieval by callbacks. - - public ImFontAtlas* FontAtlas; // // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. - public float FontGlobalScale; // = 1.0f // Global scale all fonts - public byte FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. - public ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui. - public ImVec2 DisplayVisibleMin; // (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area. - public ImVec2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize - - //------------------------------------------------------------------ - // User Functions - //------------------------------------------------------------------ - - // Rendering function, will be called in Render(). - // Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer. - // See example applications if you are unsure of how to implement this. - - //public RenderDrawListsFn RenderFunction; - public IntPtr RenderDrawListsFn; - - // Optional: access OS clipboard - // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) - // const char* (*GetClipboardTextFn)(); - public IntPtr GetClipboardTextFn; - // void (*SetClipboardTextFn)(const char* text); - public IntPtr SetClipboardTextFn; - - // Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer. - // (default to posix malloc/free) - // void* (*MemAllocFn)(size_t sz); - public IntPtr MemAllocFn; - // void (*MemFreeFn)(void* ptr); - public IntPtr MemFreeFn; - - // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows) - // (default to use native imm32 api on Windows) - //void (*ImeSetInputScreenPosFn)(int x, int y); - public IntPtr ImeSetInputScreenPosFn; - public IntPtr ImeWindowHandle; // (Windows) Set this to your HWND to get automatic IME cursor positioning. - - //------------------------------------------------------------------ - // Input - Fill before calling NewFrame() - //------------------------------------------------------------------ - - public ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) - public fixed byte MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. - /// - /// Mouse wheel: 1 unit scrolls about 5 lines text. - /// - public float MouseWheel; - public byte MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). - public byte KeyCtrl; // Keyboard modifier pressed: Control - public byte KeyShift; // Keyboard modifier pressed: Shift - public byte KeyAlt; // Keyboard modifier pressed: Alt - public fixed byte KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data) - public fixed ImWchar InputCharacters[16 + 1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper. - - // Functions - /* - IMGUI_API void AddInputCharacter(ImWchar c); // Helper to add a new character into InputCharacters[] - IMGUI_API void AddInputCharactersUTF8(const char* utf8_chars); // Helper to add new characters into InputCharacters[] from an UTF-8 string - */ - - //------------------------------------------------------------------ - // Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application - //------------------------------------------------------------------ - - public byte WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input) - public byte WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input) - public byte WantTextInput; // Some text input widget is active, which will read input characters from the InputCharacters array. - public float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames - public int MetricsAllocs; // Number of active memory allocations - public int MetricsRenderVertices; // Vertices output during last call to Render() - public int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 - public int MetricsActiveWindows; // Number of visible windows (exclude child windows) - - //------------------------------------------------------------------ - // [Internal] ImGui will maintain those fields for you - //------------------------------------------------------------------ - - public ImVec2 MousePosPrev; // Previous mouse position - public ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling. - public fixed byte MouseClicked[5]; // Mouse button went from !Down to Down - //fixed ImVec2 MouseClickedPos[5]; // Position at time of clicking - public ImVec2 MouseClickedPos0, MouseClickedPos1, MouseClickedPos2, MouseClickedPos3, MouseClickedPos4; - public fixed float MouseClickedTime[5]; // Time of last click (used to figure out double-click) - public fixed byte MouseDoubleClicked[5]; // Has mouse button been double-clicked? - public fixed byte MouseReleased[5]; // Mouse button went from Down to !Down - public fixed byte MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds. - public fixed float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) - public fixed float MouseDownDurationPrev[5]; // Previous time the mouse button has been down - public fixed float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the click point - public fixed float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed) - public fixed float KeysDownDurationPrev[512]; // Previous duration the key has been down - /* - IMGUI_API ImGuiIO(); - */ - } - - public static class Constants - { - public const int intImGuiKey_Tab = 0; // for tabbing through fields - public const int ImGuiKey_LeftArrow = 1; // for text edit - public const int ImGuiKey_RightArrow = 2; // for text edit - public const int ImGuiKey_UpArrow = 3; // for text edit - public const int ImGuiKey_DownArrow = 4; // for text edit - public const int ImGuiKey_PageUp = 5; - public const int ImGuiKey_PageDown = 6; - public const int ImGuiKey_Home = 7; // for text edit - public const int ImGuiKey_End = 8; // for text edit - public const int ImGuiKey_Delete = 9; // for text edit - public const int ImGuiKey_Backspace = 10; // for text edit - public const int ImGuiKey_Enter = 11; // for text edit - public const int ImGuiKey_Escape = 12; // for text edit - public const int ImGuiKey_A = 13; // for text edit CTRL+A: select all - public const int ImGuiKey_C = 14; // for text edit CTRL+C: copy - public const int ImGuiKey_V = 15; // for text edit CTRL+V: paste - public const int ImGuiKey_X = 16; // for text edit CTRL+X: cut - public const int ImGuiKey_Y = 17; // for text edit CTRL+Y: redo - public const int ImGuiKey_Z = 18; // for text edit CTRL+Z: undo - public const int ImGuiKey_COUNT = 19; - - - public static class ImGuiCol - { - public const int ImGuiCol_Text = 0; - public const int ImGuiCol_TextDisabled = 1; - public const int ImGuiCol_WindowBg = 2; - public const int ImGuiCol_ChildWindowBg = 3; - public const int ImGuiCol_Border = 4; - public const int ImGuiCol_BorderShadow = 5; - public const int ImGuiCol_FrameBg = 6; // Background of checkbox = 0; radio button = 0; plot = 0; slider = 0; text input - public const int ImGuiCol_FrameBgHovered = 7; - public const int ImGuiCol_FrameBgActive = 8; - public const int ImGuiCol_TitleBg = 9; - public const int ImGuiCol_TitleBgCollapsed = 10; - public const int ImGuiCol_TitleBgActive = 11; - public const int ImGuiCol_MenuBarBg = 12; - public const int ImGuiCol_ScrollbarBg = 13; - public const int ImGuiCol_ScrollbarGrab = 14; - public const int ImGuiCol_ScrollbarGrabHovered = 15; - public const int ImGuiCol_ScrollbarGrabActive = 16; - public const int ImGuiCol_ComboBg = 17; - public const int ImGuiCol_CheckMark = 18; - public const int ImGuiCol_SliderGrab = 19; - public const int ImGuiCol_SliderGrabActive = 20; - public const int ImGuiCol_Button = 21; - public const int ImGuiCol_ButtonHovered = 22; - public const int ImGuiCol_ButtonActive = 23; - public const int ImGuiCol_Header = 24; - public const int ImGuiCol_HeaderHovered = 25; - public const int ImGuiCol_HeaderActive = 26; - public const int ImGuiCol_Column = 27; - public const int ImGuiCol_ColumnHovered = 28; - public const int ImGuiCol_ColumnActive = 29; - public const int ImGuiCol_ResizeGrip = 30; - public const int ImGuiCol_ResizeGripHovered = 31; - public const int ImGuiCol_ResizeGripActive = 32; - public const int ImGuiCol_CloseButton = 33; - public const int ImGuiCol_CloseButtonHovered = 34; - public const int ImGuiCol_CloseButtonActive = 35; - public const int ImGuiCol_PlotLines = 36; - public const int ImGuiCol_PlotLinesHovered = 37; - public const int ImGuiCol_PlotHistogram = 38; - public const int ImGuiCol_PlotHistogramHovered = 39; - public const int ImGuiCol_TextSelectedBg = 40; - public const int ImGuiCol_TooltipBg = 41; - public const int ImGuiCol_ModalWindowDarkening = 42; // darken entire screen when a modal window is active - public const int ImGuiCol_COUNT = 43; - } - } -} diff --git a/src/ImGui.NET/ImGuiNative.cs b/src/ImGui.NET/ImGuiNative.cs index 81b6a6b..3b180fa 100644 --- a/src/ImGui.NET/ImGuiNative.cs +++ b/src/ImGui.NET/ImGuiNative.cs @@ -10,14 +10,15 @@ namespace ImGui public static unsafe class ImGuiNative { private const string cimguiLib = "cimgui"; + [DllImport(cimguiLib)] - public static extern ImGuiIO* igGetIO(); + public static extern IO* igGetIO(); /* { return (IO*)igGetIO_Raw().ToPointer(); } */ [DllImport(cimguiLib)] - public static extern ImGuiStyle* igGetStyle(); + public static extern Style* igGetStyle(); [DllImport(cimguiLib)] - public static extern ImDrawData* igGetDrawData(); + public static extern DrawData* igGetDrawData(); [DllImport(cimguiLib)] public static extern void igNewFrame(); @@ -28,7 +29,7 @@ namespace ImGui [DllImport(cimguiLib)] public static extern void igShowUserGuide(); [DllImport(cimguiLib)] - public static extern void igShowStyleEditor(ref ImGuiStyle @ref); + public static extern void igShowStyleEditor(ref Style @ref); [DllImport(cimguiLib)] public static extern void igShowTestWindow(ref bool opened); [DllImport(cimguiLib)] @@ -60,9 +61,9 @@ namespace ImGui [DllImport(cimguiLib)] public static extern float igGetWindowContentRegionWidth(); [DllImport(cimguiLib)] - public static extern ImDrawList* igGetWindowDrawList(); + public static extern DrawList* igGetWindowDrawList(); [DllImport(cimguiLib)] - public static extern ImFont* igGetWindowFont(); + public static extern Font* igGetWindowFont(); [DllImport(cimguiLib)] public static extern float igGetWindowFontSize(); [DllImport(cimguiLib)] @@ -137,7 +138,7 @@ namespace ImGui // Parameters stacks (shared) [DllImport(cimguiLib)] - public static extern void igPushFont(ImFont* font); + public static extern void igPushFont(Font* font); [DllImport(cimguiLib)] public static extern void igPopFont(); [DllImport(cimguiLib)] @@ -641,34 +642,34 @@ namespace ImGui [DllImport(cimguiLib)] - public static extern void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel); + public static extern void ImFontAtlas_GetTexDataAsRGBA32(FontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel); [DllImport(cimguiLib)] - public static extern void ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel); + public static extern void ImFontAtlas_GetTexDataAsAlpha8(FontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel); [DllImport(cimguiLib)] - public static extern void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex); + public static extern void ImFontAtlas_SetTexID(FontAtlas* atlas, void* tex); [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFont(ImFontAtlas* atlas, ref ImFontConfig font_cfg); + public static extern Font* ImFontAtlas_AddFont(FontAtlas* atlas, ref FontConfig font_cfg); [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* atlas, IntPtr font_cfg); - public static ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* atlas) { return ImFontAtlas_AddFontDefault(atlas, IntPtr.Zero); } + public static extern Font* ImFontAtlas_AddFontDefault(FontAtlas* atlas, IntPtr font_cfg); + public static Font* ImFontAtlas_AddFontDefault(FontAtlas* atlas) { return ImFontAtlas_AddFontDefault(atlas, IntPtr.Zero); } [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFontFromFileTTF(ImFontAtlas* atlas, string filename, float size_pixels, IntPtr font_cfg, char* glyph_ranges); + public static extern Font* ImFontAtlas_AddFontFromFileTTF(FontAtlas* atlas, string filename, float size_pixels, IntPtr font_cfg, char* glyph_ranges); [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas* atlas, void* ttf_data, int ttf_size, float size_pixels, IntPtr font_cfg, char* glyph_ranges); + public static extern Font* ImFontAtlas_AddFontFromMemoryTTF(FontAtlas* atlas, void* ttf_data, int ttf_size, float size_pixels, IntPtr font_cfg, char* glyph_ranges); [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFontFromMemoryCompressedTTF(ImFontAtlas* atlas, void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, ImFontConfig* font_cfg, char* glyph_ranges); + public static extern Font* ImFontAtlas_AddFontFromMemoryCompressedTTF(FontAtlas* atlas, void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, FontConfig* font_cfg, char* glyph_ranges); [DllImport(cimguiLib)] - public static extern ImFont* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas* atlas, string compressed_ttf_data_base85, float size_pixels, ImFontConfig* font_cfg, char* glyph_ranges); + public static extern Font* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(FontAtlas* atlas, string compressed_ttf_data_base85, float size_pixels, FontConfig* font_cfg, char* glyph_ranges); [DllImport(cimguiLib)] - public static extern void ImFontAtlas_ClearTexData(ImFontAtlas* atlas); + public static extern void ImFontAtlas_ClearTexData(FontAtlas* atlas); [DllImport(cimguiLib)] - public static extern void ImFontAtlas_Clear(ImFontAtlas* atlas); + public static extern void ImFontAtlas_Clear(FontAtlas* atlas); [DllImport(cimguiLib)] @@ -677,19 +678,19 @@ namespace ImGui public static extern void ImGuiIO_AddInputCharactersUTF8(string utf8_chars); [DllImport(cimguiLib)] - public static extern int ImDrawList_GetVertexBufferSize(ImDrawList* list); + public static extern int ImDrawList_GetVertexBufferSize(DrawList* list); [DllImport(cimguiLib)] - public static extern ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n); + public static extern DrawVert* ImDrawList_GetVertexPtr(DrawList* list, int n); [DllImport(cimguiLib)] - public static extern int ImDrawList_GetIndexBufferSize(ImDrawList* list); + public static extern int ImDrawList_GetIndexBufferSize(DrawList* list); [DllImport(cimguiLib)] - public static extern ushort* ImDrawList_GetIndexPtr(ImDrawList* list, int n); + public static extern ushort* ImDrawList_GetIndexPtr(DrawList* list, int n); [DllImport(cimguiLib)] - public static extern int ImDrawList_GetCmdSize(ImDrawList* list); + public static extern int ImDrawList_GetCmdSize(DrawList* list); [DllImport(cimguiLib)] - public static extern ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n); + public static extern DrawCmd* ImDrawList_GetCmdPtr(DrawList* list, int n); [DllImport(cimguiLib)] - public static extern void ImDrawData_DeIndexAllBuffers(ImDrawData* drawData); + public static extern void ImDrawData_DeIndexAllBuffers(DrawData* drawData); } [StructLayout(LayoutKind.Sequential)] diff --git a/src/ImGui.NET/ImGuiTextEditCallbackData.cs b/src/ImGui.NET/ImGuiTextEditCallbackData.cs deleted file mode 100644 index 63b4c88..0000000 --- a/src/ImGui.NET/ImGuiTextEditCallbackData.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ImGuiInputTextFlags = System.Int32; -using ImWchar = System.UInt16; -using ImGuiKey = System.Int32; -using System.Runtime.InteropServices; - -namespace ImGui -{ - // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used. - [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImGuiTextEditCallbackData - { - //ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only - //ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only - //IntPtr UserData; // What user passed to InputText() // Read-only - //bool ReadOnly; // Read-only mode // Read-only - - //// CharFilter event: - //ImWchar EventChar; // Character input // Read-write (replace character or set to zero) - - //// Completion,History,Always events: - //ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only - //char* Buf; // Current text // Read-write (pointed data only) - //int BufSize; // // Read-only - bool BufDirty; // Must set if you modify Buf directly // Write - int CursorPos; // // Read-write - int SelectionStart; // // Read-write (== to SelectionEnd when no selection) - int SelectionEnd; // // Read-write - - // NB: calling those function loses selection. - /* - void DeleteChars(int pos, int bytes_count); - void InsertChars(int pos, const char* text, const char* text_end = NULL); - bool HasSelection() const { return SelectionStart != SelectionEnd; } - */ - } -} diff --git a/src/ImGui.NET/ImGuiStorage.cs b/src/ImGui.NET/Storage.cs similarity index 100% rename from src/ImGui.NET/ImGuiStorage.cs rename to src/ImGui.NET/Storage.cs diff --git a/src/ImGui.NET/ImGuiStyle.cs b/src/ImGui.NET/Style.cs similarity index 88% rename from src/ImGui.NET/ImGuiStyle.cs rename to src/ImGui.NET/Style.cs index e638826..efc7e8c 100644 --- a/src/ImGui.NET/ImGuiStyle.cs +++ b/src/ImGui.NET/Style.cs @@ -1,17 +1,16 @@ -using ImGuiAlign = System.Int32; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using System.Numerics; namespace ImGui { [StructLayout(LayoutKind.Sequential)] - public unsafe struct ImGuiStyle + public unsafe struct Style { public float Alpha; // Global alpha applies to everything in ImGui public Vector2 WindowPadding; // Padding within a window public Vector2 WindowMinSize; // Minimum window size public float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows - public ImGuiAlign WindowTitleAlign; // Alignment for title bar text + public Align WindowTitleAlign; // Alignment for title bar text public float ChildWindowRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows public Vector2 FramePadding; // Padding within a framed rectangle (used by most widgets) public float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets). @@ -30,11 +29,6 @@ namespace ImGui public byte AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU. public byte AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) public float CurveTessellationTol; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. - //fixed ImVec4 Colors[Constants.ImGuiCol.ImGuiCol_COUNT]; - public fixed float Colors[Constants.ImGuiCol.ImGuiCol_COUNT * 4]; - - /* - IMGUI_API ImGuiStyle(); - */ + public fixed float Colors[(int)ColorTarget.Count * 4]; }; }