Some formatting changes and cleanup

internals
Eric Mellino 9 years ago
parent 8e8c2c0cde
commit 206770ccd1
  1. 5
      src/ImGui.NET.SampleProgram/Program.cs
  2. 38
      src/ImGui.NET.SampleProgram/SampleWindow.cs
  3. 12
      src/ImGui.NET/Align.cs
  4. 8
      src/ImGui.NET/ColorEditMode.cs
  5. 1
      src/ImGui.NET/ColorTarget.cs
  6. 36
      src/ImGui.NET/DrawCmd.cs
  7. 14
      src/ImGui.NET/DrawData.cs
  8. 2
      src/ImGui.NET/DrawList.cs
  9. 2
      src/ImGui.NET/DrawVert.cs
  10. 2
      src/ImGui.NET/Font.cs
  11. 9
      src/ImGui.NET/FontAtlas.cs
  12. 2
      src/ImGui.NET/FontConfig.cs
  13. 306
      src/ImGui.NET/IO.cs
  14. 28
      src/ImGui.NET/ImDrawCmd.cs
  15. 22
      src/ImGui.NET/ImGui.NET.csproj
  16. 2
      src/ImGui.NET/ImGui.cs
  17. 202
      src/ImGui.NET/ImGuiIO.cs
  18. 53
      src/ImGui.NET/ImGuiNative.cs
  19. 36
      src/ImGui.NET/ImGuiTextEditCallbackData.cs
  20. 0
      src/ImGui.NET/Storage.cs
  21. 14
      src/ImGui.NET/Style.cs

@ -1,8 +1,3 @@
using OpenTK;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ImGui namespace ImGui
{ {
public class Program public class Program

@ -38,7 +38,7 @@ namespace ImGui
_nativeWindow.KeyUp += OnKeyUp; _nativeWindow.KeyUp += OnKeyUp;
_nativeWindow.KeyPress += OnKeyPress; _nativeWindow.KeyPress += OnKeyPress;
ImGuiIO* io = ImGuiNative.igGetIO(); IO* io = ImGuiNative.igGetIO();
ImGuiNative.ImFontAtlas_AddFontDefault(io->FontAtlas); ImGuiNative.ImFontAtlas_AddFontDefault(io->FontAtlas);
SetOpenTKKeyMappings(io); SetOpenTKKeyMappings(io);
@ -59,7 +59,7 @@ namespace ImGui
ImGuiNative.ImGuiIO_AddInputCharacter(e.KeyChar); 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.Tab] = (int)Key.Tab;
io->KeyMap[(int)GuiKey.LeftArrow] = (int)Key.Left; io->KeyMap[(int)GuiKey.LeftArrow] = (int)Key.Left;
@ -96,7 +96,7 @@ namespace ImGui
UpdateModifiers(e, ptr); 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->KeyAlt = e.Alt ? (byte)1 : (byte)0;
ptr->KeyCtrl = e.Control ? (byte)1 : (byte)0; ptr->KeyCtrl = e.Control ? (byte)1 : (byte)0;
@ -105,7 +105,7 @@ namespace ImGui
private unsafe void CreateDeviceObjects() private unsafe void CreateDeviceObjects()
{ {
ImGuiIO* io = ImGuiNative.igGetIO(); IO* io = ImGuiNative.igGetIO();
// Build texture atlas // Build texture atlas
byte* pixels; byte* pixels;
@ -139,7 +139,7 @@ namespace ImGui
private unsafe void RenderFrame() private unsafe void RenderFrame()
{ {
ImGuiIO* io = ImGuiNative.igGetIO(); IO* io = ImGuiNative.igGetIO();
io->DisplaySize = new System.Numerics.Vector2(_nativeWindow.Width, _nativeWindow.Height); io->DisplaySize = new System.Numerics.Vector2(_nativeWindow.Width, _nativeWindow.Height);
io->DisplayFramebufferScale = new System.Numerics.Vector2(1, 1); io->DisplayFramebufferScale = new System.Numerics.Vector2(1, 1);
io->DeltaTime = (1f / 60f); io->DeltaTime = (1f / 60f);
@ -152,7 +152,7 @@ namespace ImGui
ImGuiNative.igRender(); ImGuiNative.igRender();
ImDrawData* data = ImGuiNative.igGetDrawData(); DrawData* data = ImGuiNative.igGetDrawData();
RenderImDrawData(data); RenderImDrawData(data);
} }
@ -179,8 +179,8 @@ namespace ImGui
ImGuiNative.igText("World!"); ImGuiNative.igText("World!");
ImGuiNative.igText("From ImGui.NET. ...Did that work?"); ImGuiNative.igText("From ImGui.NET. ...Did that work?");
var pos = ImGuiNative.igGetIO()->MousePos; var pos = ImGuiNative.igGetIO()->MousePos;
var leftPressed = ImGuiNative.igGetIO()->MouseDown[0] == 1; //bool leftPressed = ImGuiNative.igGetIO()->MouseDown[0];
ImGuiNative.igText("Current mouse position: " + pos + ". Pressed=" + leftPressed); //ImGuiNative.igText("Current mouse position: " + pos + ". Pressed=" + leftPressed);
if (ImGuiNative.igButton("Press me!", new System.Numerics.Vector2(120, 30))) if (ImGuiNative.igButton("Press me!", new System.Numerics.Vector2(120, 30)))
{ {
@ -227,7 +227,7 @@ namespace ImGui
return 0; return 0;
} }
private unsafe void UpdateImGuiInput(ImGuiIO* io) private unsafe void UpdateImGuiInput(IO* io)
{ {
MouseState cursorState = OpenTK.Input.Mouse.GetCursorState(); MouseState cursorState = OpenTK.Input.Mouse.GetCursorState();
MouseState mouseState = Mouse.GetState(); MouseState mouseState = Mouse.GetState();
@ -252,7 +252,7 @@ namespace ImGui
io->MouseWheel = delta; io->MouseWheel = delta;
} }
private unsafe void RenderImDrawData(ImDrawData* draw_data) private unsafe void RenderImDrawData(DrawData* draw_data)
{ {
// Rendering // Rendering
int display_w, display_h; int display_w, display_h;
@ -283,7 +283,7 @@ namespace ImGui
GL.UseProgram(0); GL.UseProgram(0);
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays) // 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; float fb_height = io->DisplaySize.Y * io->DisplayFramebufferScale.Y;
// Can implement the below in C#. // Can implement the below in C#.
@ -303,24 +303,24 @@ namespace ImGui
for (int n = 0; n < draw_data->CmdListsCount; n++) 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; byte* vtx_buffer = (byte*)cmd_list->VtxBuffer.Data;
ushort* idx_buffer = (ushort*)cmd_list->IdxBuffer.Data; ushort* idx_buffer = (ushort*)cmd_list->IdxBuffer.Data;
ImDrawVert vert0 = *((ImDrawVert*)vtx_buffer); DrawVert vert0 = *((DrawVert*)vtx_buffer);
ImDrawVert vert1 = *(((ImDrawVert*)vtx_buffer) + 1); DrawVert vert1 = *(((DrawVert*)vtx_buffer) + 1);
ImDrawVert vert2 = *(((ImDrawVert*)vtx_buffer) + 2); DrawVert vert2 = *(((DrawVert*)vtx_buffer) + 2);
//glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF("pos"))); //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"))); //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"))); //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++) 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) if (pcmd->UserCallback != IntPtr.Zero)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

@ -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
}
}

@ -1,10 +1,4 @@
using System; namespace ImGui
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{ {
/// <summary> /// <summary>
/// Enumeration for ColorEditMode() /// Enumeration for ColorEditMode()

@ -54,5 +54,6 @@
/// darken entire screen when a modal window is active /// darken entire screen when a modal window is active
/// </summary> /// </summary>
ModalWindowDarkening, ModalWindowDarkening,
Count,
}; };
} }

@ -0,0 +1,36 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
namespace ImGui
{
/// <summary>
/// Typically, 1 command = 1 gpu draw call (unless command is a callback)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct DrawCmd
{
/// <summary>
/// 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[].
/// </summary>
public uint ElemCount;
/// <summary>
/// Clipping rectangle (x1, y1, x2, y2)
/// </summary>
public Vector4 ClipRect;
/// <summary>
/// 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.
/// </summary>
public IntPtr TextureId;
/// <summary>
/// If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
/// </summary>
public IntPtr UserCallback;
/// <summary>
/// The draw callback code can access this.
/// </summary>
public IntPtr UserCallbackData;
};
}

@ -1,19 +1,13 @@
using System; using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using ImVec2 = System.Numerics.Vector2;
namespace ImGui namespace ImGui
{ {
// All draw data to render an ImGui frame // All draw data to render an ImGui frame
[StructLayout(LayoutKind.Sequential)] [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 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 CmdListsCount;
public int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size 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 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 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. 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.
*/ */
}; };
} }

@ -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). // 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 // 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)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImDrawList public unsafe struct DrawList
{ {
// This is what you have to render // This is what you have to render
// ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call. // ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace ImGui namespace ImGui
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImDrawVert public unsafe struct DrawVert
{ {
public ImVec2 pos; public ImVec2 pos;
public ImVec2 uv; public ImVec2 uv;

@ -7,7 +7,7 @@ namespace ImGui
// Font runtime data and rendering // Font runtime data and rendering
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). // ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImFont public unsafe struct Font
{ {
// Members: Settings // Members: Settings
public float FontSize; // <user set> // Height of characters, set during loading (don't change after loading) public float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)

@ -1,7 +1,6 @@
using ImWchar = System.UInt16; using System.Runtime.InteropServices;
using ImVec2 = System.Numerics.Vector2;
using System.Runtime.InteropServices;
using System; using System;
using System.Numerics;
namespace ImGui 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. // 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. // 5. Call ClearTexData() to free textures memory on the heap.
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImFontAtlas public unsafe struct FontAtlas
{ {
/* /*
public ImFont* AddFont(ImFontConfig* font_cfg) { } public ImFont* AddFont(ImFontConfig* font_cfg) { }
@ -54,7 +53,7 @@ namespace ImGui
public IntPtr TexWidth; // Texture width calculated during Build(). public IntPtr TexWidth; // Texture width calculated during Build().
public IntPtr TexHeight; // Texture height 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 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)
/// <summary> /// <summary>
/// (ImVector(ImFont*) /// (ImVector(ImFont*)

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
namespace ImGui namespace ImGui
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImFontConfig public unsafe struct FontConfig
{ {
/// <summary> /// <summary>
/// TTF data /// TTF data

@ -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)
//------------------------------------------------------------------
/// <summary>
/// Display size, in pixels. For clamping windows positions.
/// Default value: [unset]
/// </summary>
public Vector2 DisplaySize;
/// <summary>
/// Time elapsed since last frame, in seconds.
/// Default value: 1.0f / 10.0f.
/// </summary>
public float DeltaTime;
/// <summary>
/// Maximum time between saving positions/sizes to .ini file, in seconds.
/// Default value: 5.0f.
/// </summary>
public float IniSavingRate;
/// <summary>
/// Path to .ini file. NULL to disable .ini saving.
/// Default value: "imgui.ini"
/// </summary>
public IntPtr IniFilename;
/// <summary>
/// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
/// Default value: "imgui_log.txt"
/// </summary>
public IntPtr LogFilename;
/// <summary>
/// Time for a double-click, in seconds.
/// Default value: 0.30f.
/// </summary>
public float MouseDoubleClickTime;
/// <summary>
/// Distance threshold to stay in to validate a double-click, in pixels.
/// Default Value: 6.0f.
/// </summary>
public float MouseDoubleClickMaxDist;
/// <summary>
/// Distance threshold before considering we are dragging.
/// Default Value: 6.0f.
/// </summary>
public float MouseDragThreshold;
/// <summary>
/// Map of indices into the KeysDown[512] entries array.
/// Default values: [unset]
/// </summary>
public fixed int KeyMap[(int)GuiKey.Count];
/// <summary>
/// When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active).
/// Default value: 0.250f.
/// </summary>
public float KeyRepeatDelay;
/// <summary>
/// When holding a key/button, rate at which it repeats, in seconds.
/// Default value: 0.020f.
/// </summary>
public float KeyRepeatRate;
/// <summary>
/// Store your own data for retrieval by callbacks.
/// Default value; IntPtr.Zero.
/// </summary>
public IntPtr UserData;
/// <summary>
/// Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
/// Default value: [auto]
/// </summary>
public FontAtlas* FontAtlas;
/// <summary>
/// Global scale all fonts.
/// Default value: 1.0f.
/// </summary>
public float FontGlobalScale;
/// <summary>
/// Allow user scaling text of individual window with CTRL+Wheel.
/// Default value: false.
/// </summary>
public byte FontAllowUserScaling;
/// <summary>
/// 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).
/// </summary>
public Vector2 DisplayFramebufferScale;
/// <summary>
/// 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)
/// </summary>
public Vector2 DisplayVisibleMin;
/// <summary>
/// If the values are the same, we defaults to Min=0.0f) and Max=DisplaySize.
/// Default value: (0.0f, 0.0f).
/// </summary>
public Vector2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
//------------------------------------------------------------------
// User Functions
//------------------------------------------------------------------
/// <summary>
/// Rendering function, will be called in Render().
/// Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer.
/// </summary>
public IntPtr RenderDrawListsFn;
/// <summary>
/// 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)
/// </summary>
public IntPtr GetClipboardTextFn;
/// <summary>
/// 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)
/// </summary>
public IntPtr SetClipboardTextFn;
/// <summary>
/// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
/// (default to posix malloc/free)
/// </summary>
public IntPtr MemAllocFn;
/// <summary>
/// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
/// (default to posix malloc/free)
/// </summary>
public IntPtr MemFreeFn;
/// <summary>
/// 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)
/// </summary>
public IntPtr ImeSetInputScreenPosFn;
/// <summary>
/// (Windows) Set this to your HWND to get automatic IME cursor positioning.
/// </summary>
public IntPtr ImeWindowHandle;
//------------------------------------------------------------------
// Input - Fill before calling NewFrame()
//------------------------------------------------------------------
/// <summary>
/// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.).
/// </summary>
public Vector2 MousePos;
/// <summary>
/// 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.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public fixed byte MouseDown[5];
/// <summary>
/// Mouse wheel: 1 unit scrolls about 5 lines text.
/// </summary>
public float MouseWheel;
/// <summary>
/// Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
/// </summary>
public byte MouseDrawCursor;
/// <summary>
/// Keyboard modifier pressed: Control.
/// </summary>
public byte KeyCtrl;
/// <summary>
/// Keyboard modifier pressed: Shift
/// </summary>
public byte KeyShift;
/// <summary>
/// Keyboard modifier pressed: Alt
/// </summary>
public byte KeyAlt;
/// <summary>
/// Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
/// </summary>
public fixed byte KeysDown[512];
/// <summary>
/// List of characters input (translated by user from keypress+keyboard state).
/// Fill using AddInputCharacter() helper.
/// </summary>
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
//------------------------------------------------------------------
/// <summary>
/// Mouse is hovering a window or widget is active (= ImGui will use your mouse input).
/// </summary>
public byte WantCaptureMouse;
/// <summary>
/// Widget is active (= ImGui will use your keyboard input).
/// </summary>
public byte WantCaptureKeyboard;
/// <summary>
/// Some text input widget is active, which will read input characters from the InputCharacters array.
/// </summary>
public byte WantTextInput;
/// <summary>
/// Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames.
/// </summary>
public float Framerate;
/// <summary>
/// Number of active memory allocations.
/// </summary>
public int MetricsAllocs;
/// <summary>
/// Vertices output during last call to Render().
/// </summary>
public int MetricsRenderVertices;
/// <summary>
/// Indices output during last call to Render() = number of triangles * 3
/// </summary>
public int MetricsRenderIndices;
/// <summary>
/// Number of visible windows (exclude child windows)
/// </summary>
public int MetricsActiveWindows;
//------------------------------------------------------------------
// [Internal] ImGui will maintain those fields for you
//------------------------------------------------------------------
/// <summary>
/// Previous mouse position
/// </summary>
public Vector2 MousePosPrev;
/// <summary>
/// Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling.
/// </summary>
public Vector2 MouseDelta;
/// <summary>
/// Mouse button went from !Down to Down
/// </summary>
public fixed byte MouseClicked[5];
/// <summary>
/// Position at time of clicking
/// </summary>
public Vector2 MouseClickedPos0;
/// <summary>
/// Position at time of clicking
/// </summary>
public Vector2 MouseClickedPos1;
/// <summary>
/// Position at time of clicking
/// </summary>
public Vector2 MouseClickedPos2;
/// <summary>
/// Position at time of clicking
/// </summary>
public Vector2 MouseClickedPos3;
/// <summary>
/// Position at time of clicking
/// </summary>
public Vector2 MouseClickedPos4;
/// <summary>
/// Time of last click (used to figure out double-click)
/// </summary>
public fixed float MouseClickedTime[5];
/// <summary>
/// Has mouse button been double-clicked?
/// </summary>
public fixed byte MouseDoubleClicked[5];
/// <summary>
/// Mouse button went from Down to !Down
/// </summary>
public fixed byte MouseReleased[5];
/// <summary>
/// Track if button was clicked inside a window.
/// We don't request mouse capture from the application if click started outside ImGui bounds.
/// </summary>
public fixed byte MouseDownOwned[5];
/// <summary>
/// Duration the mouse button has been down (0.0f == just clicked).
/// </summary>
public fixed float MouseDownDuration[5];
/// <summary>
/// Previous time the mouse button has been down
/// </summary>
public fixed float MouseDownDurationPrev[5];
/// <summary>
/// Squared maximum distance of how much mouse has traveled from the click point
/// </summary>
public fixed float MouseDragMaxDistanceSqr[5];
/// <summary>
/// Duration the keyboard key has been down (0.0f == just pressed)
/// </summary>
public fixed float KeysDownDuration[512];
/// <summary>
/// Previous duration the key has been down
/// </summary>
public fixed float KeysDownDurationPrev[512];
}
}

@ -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; }
*/
};
}

@ -10,6 +10,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Align.cs" />
<Compile Include="ColorTarget.cs" /> <Compile Include="ColorTarget.cs" />
<Compile Include="MouseCursorKind.cs" /> <Compile Include="MouseCursorKind.cs" />
<Compile Include="SelectableFlags.cs" /> <Compile Include="SelectableFlags.cs" />
@ -17,18 +18,17 @@
<Compile Include="WindowFlags.cs" /> <Compile Include="WindowFlags.cs" />
<Compile Include="ColorEditMode.cs" /> <Compile Include="ColorEditMode.cs" />
<Compile Include="GuiKey.cs" /> <Compile Include="GuiKey.cs" />
<Compile Include="ImDrawCmd.cs" /> <Compile Include="DrawCmd.cs" />
<Compile Include="ImDrawData.cs" /> <Compile Include="DrawData.cs" />
<Compile Include="ImDrawList.cs" /> <Compile Include="DrawList.cs" />
<Compile Include="ImDrawVert.cs" /> <Compile Include="DrawVert.cs" />
<Compile Include="ImFont.cs" /> <Compile Include="Font.cs" />
<Compile Include="ImFontAtlas.cs" /> <Compile Include="FontAtlas.cs" />
<Compile Include="ImFontConfig.cs" /> <Compile Include="FontConfig.cs" />
<Compile Include="ImGui.cs" /> <Compile Include="ImGui.cs" />
<Compile Include="ImGuiIO.cs" /> <Compile Include="IO.cs" />
<Compile Include="ImGuiStorage.cs" /> <Compile Include="Storage.cs" />
<Compile Include="ImGuiStyle.cs" /> <Compile Include="Style.cs" />
<Compile Include="ImGuiTextEditCallbackData.cs" />
<Compile Include="ImVector.cs" /> <Compile Include="ImVector.cs" />
<Compile Include="InputTextFlags.cs" /> <Compile Include="InputTextFlags.cs" />
<Compile Include="ImGuiNative.cs" /> <Compile Include="ImGuiNative.cs" />

@ -17,7 +17,7 @@ namespace ImGui
public static unsafe void LoadDefaultFont() public static unsafe void LoadDefaultFont()
{ {
ImGuiIO* ioPtr = ImGuiNative.igGetIO(); IO* ioPtr = ImGuiNative.igGetIO();
ImGuiNative.ImFontAtlas_AddFontDefault(ioPtr->FontAtlas); ImGuiNative.ImFontAtlas_AddFontDefault(ioPtr->FontAtlas);
} }

@ -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; // <unset> // 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]; // <unset> // 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; // <auto> // 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; // <unset> (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; // <unset> (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.
/// <summary>
/// Mouse wheel: 1 unit scrolls about 5 lines text.
/// </summary>
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;
}
}
}

@ -10,14 +10,15 @@ namespace ImGui
public static unsafe class ImGuiNative public static unsafe class ImGuiNative
{ {
private const string cimguiLib = "cimgui"; private const string cimguiLib = "cimgui";
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImGuiIO* igGetIO(); public static extern IO* igGetIO(); /* { return (IO*)igGetIO_Raw().ToPointer(); } */
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImGuiStyle* igGetStyle(); public static extern Style* igGetStyle();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImDrawData* igGetDrawData(); public static extern DrawData* igGetDrawData();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igNewFrame(); public static extern void igNewFrame();
@ -28,7 +29,7 @@ namespace ImGui
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igShowUserGuide(); public static extern void igShowUserGuide();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igShowStyleEditor(ref ImGuiStyle @ref); public static extern void igShowStyleEditor(ref Style @ref);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igShowTestWindow(ref bool opened); public static extern void igShowTestWindow(ref bool opened);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
@ -60,9 +61,9 @@ namespace ImGui
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern float igGetWindowContentRegionWidth(); public static extern float igGetWindowContentRegionWidth();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImDrawList* igGetWindowDrawList(); public static extern DrawList* igGetWindowDrawList();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImFont* igGetWindowFont(); public static extern Font* igGetWindowFont();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern float igGetWindowFontSize(); public static extern float igGetWindowFontSize();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
@ -137,7 +138,7 @@ namespace ImGui
// Parameters stacks (shared) // Parameters stacks (shared)
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igPushFont(ImFont* font); public static extern void igPushFont(Font* font);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igPopFont(); public static extern void igPopFont();
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
@ -641,34 +642,34 @@ namespace ImGui
[DllImport(cimguiLib)] [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)] [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)] [DllImport(cimguiLib)]
public static extern void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex); public static extern void ImFontAtlas_SetTexID(FontAtlas* atlas, void* tex);
[DllImport(cimguiLib)] [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)] [DllImport(cimguiLib)]
public static extern ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* atlas, IntPtr font_cfg); public static extern Font* ImFontAtlas_AddFontDefault(FontAtlas* atlas, IntPtr font_cfg);
public static ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* atlas) { return ImFontAtlas_AddFontDefault(atlas, IntPtr.Zero); } public static Font* ImFontAtlas_AddFontDefault(FontAtlas* atlas) { return ImFontAtlas_AddFontDefault(atlas, IntPtr.Zero); }
[DllImport(cimguiLib)] [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)] [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)] [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)] [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)] [DllImport(cimguiLib)]
public static extern void ImFontAtlas_ClearTexData(ImFontAtlas* atlas); public static extern void ImFontAtlas_ClearTexData(FontAtlas* atlas);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImFontAtlas_Clear(ImFontAtlas* atlas); public static extern void ImFontAtlas_Clear(FontAtlas* atlas);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
@ -677,19 +678,19 @@ namespace ImGui
public static extern void ImGuiIO_AddInputCharactersUTF8(string utf8_chars); public static extern void ImGuiIO_AddInputCharactersUTF8(string utf8_chars);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern int ImDrawList_GetVertexBufferSize(ImDrawList* list); public static extern int ImDrawList_GetVertexBufferSize(DrawList* list);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n); public static extern DrawVert* ImDrawList_GetVertexPtr(DrawList* list, int n);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern int ImDrawList_GetIndexBufferSize(ImDrawList* list); public static extern int ImDrawList_GetIndexBufferSize(DrawList* list);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ushort* ImDrawList_GetIndexPtr(ImDrawList* list, int n); public static extern ushort* ImDrawList_GetIndexPtr(DrawList* list, int n);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern int ImDrawList_GetCmdSize(ImDrawList* list); public static extern int ImDrawList_GetCmdSize(DrawList* list);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n); public static extern DrawCmd* ImDrawList_GetCmdPtr(DrawList* list, int n);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImDrawData_DeIndexAllBuffers(ImDrawData* drawData); public static extern void ImDrawData_DeIndexAllBuffers(DrawData* drawData);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]

@ -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; }
*/
}
}

@ -1,17 +1,16 @@
using ImGuiAlign = System.Int32; using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Numerics; using System.Numerics;
namespace ImGui namespace ImGui
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe struct ImGuiStyle public unsafe struct Style
{ {
public float Alpha; // Global alpha applies to everything in ImGui public float Alpha; // Global alpha applies to everything in ImGui
public Vector2 WindowPadding; // Padding within a window public Vector2 WindowPadding; // Padding within a window
public Vector2 WindowMinSize; // Minimum window size public Vector2 WindowMinSize; // Minimum window size
public float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows 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 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 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). 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 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 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. 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[(int)ColorTarget.Count * 4];
public fixed float Colors[Constants.ImGuiCol.ImGuiCol_COUNT * 4];
/*
IMGUI_API ImGuiStyle();
*/
}; };
} }
Loading…
Cancel
Save