Initial commit

Contains all of my work thus far
internals
Eric Mellino 9 years ago
commit 3ab67fbdcf
  1. 250
      .gitignore
  2. 19
      README.md
  3. 20
      build.proj
  4. 72
      build/corebuild.props
  5. 10
      build/corebuild.targets
  6. 21
      build/coreconsole.targets
  7. 11
      build/vsdebug.targets
  8. BIN
      deps/OpenTK/OpenTK.dll
  9. 443128
      deps/OpenTK/OpenTK.xml
  10. 3
      dir.props
  11. 3
      dir.targets
  12. 28
      src/ImGui.NET.SampleProgram/ImDrawCmd.cs
  13. 28
      src/ImGui.NET.SampleProgram/ImDrawData.cs
  14. 119
      src/ImGui.NET.SampleProgram/ImDrawList.cs
  15. 17
      src/ImGui.NET.SampleProgram/ImDrawVert.cs
  16. 81
      src/ImGui.NET.SampleProgram/ImFont.cs
  17. 73
      src/ImGui.NET.SampleProgram/ImFontAtlas.cs
  18. 26
      src/ImGui.NET.SampleProgram/ImFontConfig.cs
  19. 42
      src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj
  20. 199
      src/ImGui.NET.SampleProgram/ImGuiIO.cs
  21. 46
      src/ImGui.NET.SampleProgram/ImGuiStyle.cs
  22. 36
      src/ImGui.NET.SampleProgram/ImGuiTextEditCallbackData.cs
  23. 16
      src/ImGui.NET.SampleProgram/ImVector.cs
  24. 778
      src/ImGui.NET.SampleProgram/Interop.ImGui.cs
  25. 15
      src/ImGui.NET.SampleProgram/Program.cs
  26. 363
      src/ImGui.NET.SampleProgram/SampleWindow.cs
  27. 13
      src/ImGui.NET.SampleProgram/project.json
  28. 92
      src/ImGui.NET.sln
  29. 20
      src/ImGui.NET/ColorEditMode.cs
  30. 58
      src/ImGui.NET/ColorTarget.cs
  31. 86
      src/ImGui.NET/GuiKey.cs
  32. 28
      src/ImGui.NET/ImDrawCmd.cs
  33. 28
      src/ImGui.NET/ImDrawData.cs
  34. 119
      src/ImGui.NET/ImDrawList.cs
  35. 17
      src/ImGui.NET/ImDrawVert.cs
  36. 74
      src/ImGui.NET/ImFont.cs
  37. 73
      src/ImGui.NET/ImFontAtlas.cs
  38. 77
      src/ImGui.NET/ImFontConfig.cs
  39. 87
      src/ImGui.NET/ImGui.NET.csproj
  40. 41
      src/ImGui.NET/ImGui.cs
  41. 202
      src/ImGui.NET/ImGuiIO.cs
  42. 714
      src/ImGui.NET/ImGuiNative.cs
  43. 50
      src/ImGui.NET/ImGuiStorage.cs
  44. 40
      src/ImGui.NET/ImGuiStyle.cs
  45. 36
      src/ImGui.NET/ImGuiTextEditCallbackData.cs
  46. 16
      src/ImGui.NET/ImVector.cs
  47. 74
      src/ImGui.NET/InputTextFlags.cs
  48. 40
      src/ImGui.NET/MouseCursorKind.cs
  49. 25
      src/ImGui.NET/SelectableFlags.cs
  50. 26
      src/ImGui.NET/SetCondition.cs
  51. 60
      src/ImGui.NET/StyleVar.cs
  52. 4
      src/ImGui.NET/TextEditCallback.cs
  53. 63
      src/ImGui.NET/TextEditCallbackData.cs
  54. 67
      src/ImGui.NET/WindowFlags.cs
  55. 13
      src/ImGui.NET/project.json

250
.gitignore vendored

@ -0,0 +1,250 @@
syntax: glob
#NuGet things
project.lock.json
### VisualStudio ###
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
msbuild.log
# Visual Studio 2015
.vs/
# Visual Studio 2015 Pre-CTP6
*.sln.ide
*.ide/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
#NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
**/packages/*
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
*.metaproj
*.metaproj.tmp
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
### MonoDevelop ###
*.pidb
*.userprefs
### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### Linux ###
*~
# KDE directory preferences
.directory
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# vim temporary files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

@ -0,0 +1,19 @@
#ImGui.NET
This is a wrapper for the immediate mode GUI library, ImGui (https://github.com/ocornut/imgui). This utilizes the C API, provided by the cimgui project (https://github.com/Extrawurst/cimgui). ImGui.NET lets you build graphical interfaces using a simple immediate-mode style. Included is a basic sample program that shows how to use the library, which renders the ImGui output using OpenGL via OpenTK.
#Building
Currently, you need VS 2015 to build this. Simply restore all of the NuGet packages (nuget.exe restore or similar) and run msbuild on the project files or solution. It is not necessary to build the SampleProgram project unless you wish to test it out.
The cimgui dependencies included in this repository are currently only built for x64 Windows. If you use this library from somewhere else, you will need to recompile the native assemblies for your target platform. The project home pages for the project is linked below, and the project is very easy to build. OpenTK is also included in the repository, using a version of the library ported to .NET Core.
#Usage
ImGui.NET currently provides a raw, thin wrapper around the ImGui native API, and does not attempt to apply any higher-level abstractions over it. It is currently very much like using the native library, which is very simple, flexible, and robust. The easiest way to figure out how to use the library is to read the documentation of imgui itself, mostly in the imgui.cpp, and imgui.h files, as well as the exported functions in cimgui.h. Looking at the sample program code will also give some indication about basic usage. In the future, I plan to create a more comprehensive C# wrapper with higher-level abstractions and better use of C#/.NET features.
#See Also
https://github.com/ocornut/imgui
> ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and self-contained (no external dependencies). It is based on an "immediate mode" graphical user interface paradigm which enables you to build user interfaces with ease.
https://github.com/Extrawurst/cimgui
> This is a thin c-api wrapper for the excellent C++ intermediate gui imgui. This library is intended as a intermediate layer to be able to use imgui from other languages that can interface with C .

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="dir.props" />
<ItemGroup>
<Project Include="src\**\*.csproj" />
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(Project)"
ContinueOnError="ErrorAndContinue" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(BinDir)" />
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>

@ -0,0 +1,72 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import Microsoft.Common.Props -->
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!-- Project targeting defaults -->
<PropertyGroup>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v5.0</TargetFrameworkVersion>
</PropertyGroup>
<!-- Common repo directories -->
<PropertyGroup>
<ProjectDir>$(MSBuildThisFileDirectory)..\</ProjectDir>
<SourceDir>$(ProjectDir)src/</SourceDir>
<DepsDir>$(ProjectDir)deps\</DepsDir>
</PropertyGroup>
<!-- Set default Configuration and Platform -->
<PropertyGroup>
<Platform Condition="'$(Platform)'=='' and '$(OutputType)' == 'Exe'">x64</Platform>
<Platform Condition="'$(Platform)'==''">AnyCPU</Platform>
<Configuration Condition="'$(Configuration)'=='' and '$(OutputType)' == 'Exe'">Windows_Debug</Configuration>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<ConfigurationGroup Condition="$(Configuration.EndsWith('Debug'))">Debug</ConfigurationGroup>
<ConfigurationGroup Condition="$(Configuration.EndsWith('Release'))">Release</ConfigurationGroup>
<ConfigurationGroup Condition="'$(ConfigurationGroup)'==''">$(Configuration)</ConfigurationGroup>
<TargetsWindows Condition="$(Configuration.StartsWith('Windows'))">true</TargetsWindows>
<TargetsUbuntu Condition="$(Configuration.StartsWith('Ubuntu'))">true</TargetsUbuntu>
<TargetsOSX Condition="$(Configuration.StartsWith('OSX'))">true</TargetsOSX>
</PropertyGroup>
<!-- Set up Default symbol and optimization for Configuration -->
<PropertyGroup Condition="'$(ConfigurationGroup)' == 'Debug'">
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
<Optimize Condition="'$(Optimize)' == ''">false</Optimize>
<DebugType Condition="'$(DebugType)' == ''">full</DebugType>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(ConfigurationGroup)' == 'Release'">
<DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
<Optimize Condition="'$(Optimize)' == ''">true</Optimize>
<DebugType Condition="'$(DebugType)' == ''">pdbonly</DebugType>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsWindows)' == 'true'">
<BaseNuGetRuntimeIdentifier>win10</BaseNuGetRuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsUbuntu)' == 'true'">
<BaseNuGetRuntimeIdentifier>ubuntu.14.04</BaseNuGetRuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsOSX)' == 'true'">
<BaseNuGetRuntimeIdentifier>osx.10.10</BaseNuGetRuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<!-- Output directories -->
<BinDir Condition="'$(BinDir)'==''">$(ProjectDir)bin/</BinDir>
<ObjDir Condition="'$(ObjDir)'==''">$(BinDir)obj/</ObjDir>
<OutputPath>$(BinDir)$(Platform)/$(Configuration)/$(MSBuildProjectName)</OutputPath>
<IntermediateOutputPath>$(ObjDir)$(Platform)/$(Configuration)/$(MSBuildProjectName)</IntermediateOutputPath>
</PropertyGroup>
</Project>

@ -0,0 +1,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import portable targets -->
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(MSBuildThisFileDirectory)\coreconsole.targets" />
<Import Project="$(MSBuildThisFileDirectory)\vsdebug.targets" />
<!-- Override this. -->
<PropertyGroup>
<NuGetTargetMoniker>DNXCore,Version=v5.0</NuGetTargetMoniker>
</PropertyGroup>
</Project>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="RenameCoreConsole" AfterTargets="CopyFilesToOutputDirectory"
Condition="'$(OutputType)' == 'Exe' ">
<CallTarget Targets="RenameCoreConsoleWindows" Condition="Exists('$(Outdir)CoreConsole.exe')" />
<CallTarget Targets="RenameCoreConsoleUnix" Condition="Exists('$(Outdir)CoreConsole')" />
</Target>
<!-- If CoreConsole.exe is being used, rename it and the actual project's exe to their correct names -->
<Target Name="RenameCoreConsoleWindows">
<Move SourceFiles="$(Outdir)$(AssemblyName).exe" DestinationFiles="$(Outdir)$(AssemblyName).dll" />
<Move SourceFiles="$(Outdir)CoreConsole.exe" DestinationFiles="$(Outdir)$(AssemblyName).exe" />
</Target>
<Target Name="RenameCoreConsoleUnix">
<Move SourceFiles="$(Outdir)$(AssemblyName).exe" DestinationFiles="$(Outdir)$(AssemblyName).dll" />
<Move SourceFiles="$(Outdir)CoreConsole" DestinationFiles="$(Outdir)$(AssemblyName)" />
</Target>
</Project>

@ -0,0 +1,11 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Set up the debug target for portable executables -->
<PropertyGroup Condition="'$(OutputType)'=='Exe'">
<StartWorkingDirectory Condition="'$(StartWorkingDirectory)' == ''">$(OutDir)</StartWorkingDirectory>
<StartAction Condition="'$(StartAction)' == ''">Program</StartAction>
<StartProgram Condition="'$(StartProgram)' == ''">$(TargetPath)</StartProgram>
<DebugEngines>{2E36F1D4-B23C-435D-AB41-18E608940038}</DebugEngines>
</PropertyGroup>
</Project>

Binary file not shown.

443128
deps/OpenTK/OpenTK.xml vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)\build\corebuild.props" />
</Project>

@ -0,0 +1,3 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)\build\corebuild.targets" />
</Project>

@ -0,0 +1,28 @@
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)]
internal 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; }
*/
};
}

@ -0,0 +1,28 @@
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;
namespace ImGui
{
// All draw data to render an ImGui frame
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ImDrawData
{
public byte Valid; // Only valid after Render() is called and before the next NewFrame() is called.
public ImDrawList** 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
// Functions
/*
ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
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.
*/
};
}

@ -0,0 +1,119 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
// Draw command list
// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
// 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)]
internal unsafe struct ImDrawList
{
// This is what you have to render
// ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
// ImVector<ImDrawIdx> IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
// ImVector<ImDrawVert> VtxBuffer; // Vertex buffer.
/// <summary>
/// ImVector(ImDrawCmd)
/// </summary>
public ImVector CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
/// <summary>
/// ImVector(ImDrawIdx)
/// </summary>
public ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
/// <summary>
/// ImVector(ImDrawVert)
/// </summary>
public ImVector VtxBuffer; // Vertex buffer.
// [Internal, used while building lists]
public IntPtr _OwnerName; // Pointer to owner window's name (if any) for debugging
public uint _VtxCurrentIdx; // [Internal] == VtxBuffer.Size
//ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
//ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
public IntPtr _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
public IntPtr _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
//ImVector<ImVec4> _ClipRectStack; // [Internal]
//ImVector<ImTextureID> _TextureIdStack; // [Internal]
//ImVector<ImVec2> _Path; // [Internal] current path building
public ImVector _ClipRectStack; // [Internal]
public ImVector _TextureIdStack; // [Internal]
public ImVector _Path; // [Internal] current path building
public int _ChannelsCurrent; // [Internal] current channel number (0)
public int _ChannelsCount; // [Internal] number of active channels (1+)
//ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
public ImVector _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
/*
ImDrawList() { _OwnerName = NULL; Clear(); }
~ImDrawList() { ClearFreeMemory(); }
IMGUI_API void Clear();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. The values are x1, y1, x2, y2.
IMGUI_API void PushClipRectFullScreen();
IMGUI_API void PopClipRect();
IMGUI_API void PushTextureID(const ImTextureID& texture_id);
IMGUI_API void PopTextureID();
// Primitives
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 col = 0xFFFFFFFF);
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
// Stateful path API, add points then finish with PathFill() or PathStroke()
inline void PathClear() { _Path.resize(0); }
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || _Path[_Path.Size - 1].x != pos.x || _Path[_Path.Size - 1].y != pos.y) _Path.push_back(pos); }
inline void PathFill(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col, true); PathClear(); }
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness, true); PathClear(); }
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners = 0x0F);
// Channels
// - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
IMGUI_API void ChannelsSplit(int channels_count);
IMGUI_API void ChannelsMerge();
IMGUI_API void ChannelsSetCurrent(int channel_index);
// Advanced
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
// Internal helpers
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col);
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
IMGUI_API void UpdateClipRect();
IMGUI_API void UpdateTextureID();
*/
};
}

@ -0,0 +1,17 @@
using ImVec2 = System.Numerics.Vector2;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ImDrawVert
{
public ImVec2 pos;
public ImVec2 uv;
public uint col;
public const int PosOffset = 0;
public const int UVOffset = 8;
public const int ColOffset = 16;
};
}

@ -0,0 +1,81 @@
using ImGuiWindowFlags = System.IntPtr;
using ImGuiSetCond = System.IntPtr;
using ImGuiColorEditMode = System.IntPtr;
using ImVec2 = System.Numerics.Vector2;
using ImVec4 = System.Numerics.Vector4;
using ImGuiID = System.UInt32;
using ImTextureID = System.IntPtr;
using ImWchar = System.UInt16;
using System;
using System.Runtime.InteropServices;
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)]
internal unsafe struct ImFont
{
// Members: Settings
public float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
public float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
public ImVec2 DisplayOffset; // = (0.0f,1.0f) // Offset font rendering by xx pixels
public ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
/// <summary>
/// ImFontConfig*
/// </summary>
public IntPtr ConfigData; // // Pointer within ImFontAtlas->ConfigData
public int ConfigDataCount; //
// Members: Runtime data
[StructLayout(LayoutKind.Sequential)]
internal struct Glyph
{
ImWchar Codepoint;
float XAdvance;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1; // Texture coordinates
};
public float Ascent, Descent; // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
/// <summary>
/// ImFontAtlas*
/// </summary>
public IntPtr ContainerAtlas; // What we has been loaded into
/// <summary>
/// ImVector(Glyph)
/// </summary>
public ImVector Glyphs;
public Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
public float FallbackXAdvance; //
//ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
//ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point.
public ImVector IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
public ImVector IndexLookup; // Sparse. Index glyphs by Unicode code-point.
// Methods
/*
IMGUI_API ImFont();
IMGUI_API ~ImFont();
IMGUI_API void Clear();
IMGUI_API void BuildLookupTable();
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
IMGUI_API void SetFallbackChar(ImWchar c);
float GetCharAdvance(unsigned short c) const { return ((int)c<IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
bool IsLoaded() const { return ContainerAtlas != NULL; }
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
*/
};
}

@ -0,0 +1,73 @@
using ImWchar = System.UInt16;
using ImVec2 = System.Numerics.Vector2;
using System.Runtime.InteropServices;
using System;
namespace ImGui
{
// Load and rasterize multiple TTF fonts into a same texture.
// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
// We also add custom graphic data into the texture that serves for ImGui.
// 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
// 3. Upload the pixels data into a texture within your graphics system.
// 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)]
internal unsafe struct ImFontAtlas
{
/*
public ImFont* AddFont(ImFontConfig* font_cfg) { }
public ImFont* AddFontDefault(ImFontConfig* font_cfg = null) { }
public ImFont* AddFontFromFileTTF(char* filename, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null) { }
public ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
public ImFont* AddFontFromMemoryCompressedTTF(void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // 'compressed_ttf_data' still owned by caller. Compress with binary_to_compressed_c.cpp
public ImFont* AddFontFromMemoryCompressedBase85TTF(char* compressed_ttf_data_base85, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // 'compressed_ttf_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 paramaeter
public void ClearTexData(); // Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory.
public void ClearInputData(); // Clear the input TTF data (inc sizes, glyph ranges)
public void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates)
public void Clear() { } // Clear all
// Retrieve texture data
// User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
// After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
// RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
// Pitch = Width * BytesPerPixels
public void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = null); // 1 byte per-pixel
public void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = null); // 4 bytes-per-pixel
void SetTexID(void* id) { TexID = id; }
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
// (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->)
public ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
public ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
public ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
public ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
public ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
*/
// Members
// (Access texture data via GetTexData*() calls which will setup a default font for you.)
public void* TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
public byte* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
public UIntPtr TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
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)
/// <summary>
/// (ImVector(ImFont*)
/// </summary>
public ImVector Fonts;
// Private
/// <summary>
/// ImVector(ImFontConfig)
/// </summary>
public ImVector ConfigData; // Internal data
/*
public bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
*/
}
}

@ -0,0 +1,26 @@
using System.Runtime.InteropServices;
using ImVec2 = System.Numerics.Vector2;
using ImWchar = System.UInt16;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ImFontConfig
{
public void* FontData; // // TTF data
public int FontDataSize; // // TTF data size
public bool FontDataOwnedByAtlas; // true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
public int FontNo; // 0 // Index of font within TTF file
public float SizePixels; // // Size in pixels for rasterizer
public int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
public bool PixelSnapH; // false // Align every character to pixel boundary (if enabled, set OversampleH/V to 1)
public ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
public ImWchar* GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
public bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
public bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
// [Internal]
public fixed char Name[32]; // Name (strictly for debugging)
public ImFont* DstFont;
};
}

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<ProjectGuid>{AE9BC745-284F-42F3-8236-C43F00000000}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ImGui</RootNamespace>
<AssemblyName>SampleGUIProgram</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="SampleWindow.cs" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Debug|x64' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows_Release|x64' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ubuntu_Debug|x64' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ubuntu_Release|x64' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Debug|x64' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Release|x64' " />
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Reference Include="$(DepsDir)OpenTK\OpenTK.dll" />
<ProjectReference Include="../ImGui.NET/ImGui.NET.csproj">
<Name>ImGUI.NET</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\deps\cimgui\x64\cimgui.dll">
<Link>cimgui.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\deps\cimgui\x64\cimgui.pdb">
<Link>cimgui.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

@ -0,0 +1,199 @@
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)]
internal 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[Constants.ImGuiKey_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* Fonts; // <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.
public float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
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;
}
}
}

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ImVec2 = System.Numerics.Vector2;
using ImVec4 = System.Numerics.Vector4;
using ImGuiAlign = System.Int32;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ImGuiStyle
{
float Alpha; // Global alpha applies to everything in ImGui
ImVec2 WindowPadding; // Padding within a window
ImVec2 WindowMinSize; // Minimum window size
float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
ImGuiAlign WindowTitleAlign; // Alignment for title bar text
float ChildWindowRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets)
float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
float ScrollbarRounding; // Radius of grab corners for scrollbar
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
bool AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
float CurveTessellationTol; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
//fixed ImVec4 Colors[Constants.ImGuiCol.ImGuiCol_COUNT];
fixed float Colors[Constants.ImGuiCol.ImGuiCol_COUNT * 4];
/*
IMGUI_API ImGuiStyle();
*/
};
}

@ -0,0 +1,36 @@
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)]
internal 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; }
*/
}
}

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ImVector
{
//[MarshalAs(UnmanagedType.SysInt)]
public int Size;
//[MarshalAs(UnmanagedType.SysInt)]
public int Capacity;
///<summary>T* Data</summary>
public void* Data;
}
}

@ -0,0 +1,778 @@
using System.Runtime.InteropServices;
using System.Numerics;
using ImGuiWindowFlags = System.IntPtr;
using ImGuiSetCond = System.IntPtr;
using ImGuiColorEditMode = System.IntPtr;
using ImVec2 = System.Numerics.Vector2;
using ImVec4 = System.Numerics.Vector4;
using ImGuiID = System.UInt32;
using ImTextureID = System.IntPtr;
using System;
using ImGuiStoragePtr = System.IntPtr;
using ImGuiCol = System.Int32;
using ImGuiStyleVar = System.Int32;
using size_t = System.UIntPtr;
using ImGuiInputTextFlags = System.Int32;
using ImGuiTextEditCallback = System.Func<System.IntPtr, System.IntPtr>;
// typedef int (* ImGuiTextEditCallback)(ImGuiTextEditCallbackData* data);
using ImGuiSelectableFlags = System.Int32;
using ImU32 = System.UInt32;
using ImGuiMouseCursor = System.Int32;
using ImDrawIdx = System.UInt16;
namespace ImGui
{
internal static unsafe class Interop
{
private const string LibName = "cimgui";
[DllImport(LibName)]
internal static extern IntPtr igGetIO();
internal static ImGuiIO* GetIOPtr() { return (ImGuiIO*)igGetIO().ToPointer(); }
[DllImport(LibName)]
internal static extern ImGuiStyle* igGetStyle();
[DllImport(LibName)]
internal static extern IntPtr igGetDrawData();
internal static ImDrawData* GetDrawDataPtr()
{
return (ImDrawData*)igGetDrawData().ToPointer();
}
[DllImport(LibName)]
internal static extern void igNewFrame();
[DllImport(LibName)]
internal static extern void igRender();
[DllImport(LibName)]
internal static extern void igShutdown();
[DllImport(LibName)]
internal static extern void igShowUserGuide();
[DllImport(LibName)]
internal static extern void igShowStyleEditor(ImGuiStyle* @ref);
[DllImport(LibName)]
internal static extern void igShowTestWindow(bool* opened);
[DllImport(LibName)]
internal static extern void igShowMetricsWindow(bool* opened);
// Window
[DllImport(LibName)]
internal static extern bool igBegin(string name, bool* p_opened, ImGuiWindowFlags flags);
[DllImport(LibName)]
internal static extern bool igBegin2(string name, bool* p_opened, ImVec2 size_on_first_use, float bg_alpha, ImGuiWindowFlags flags);
[DllImport(LibName)]
internal static extern void igEnd();
[DllImport(LibName)]
internal static extern bool igBeginChild(string str_id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igBeginChildEx(ImGuiID id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags);
[DllImport(LibName)]
internal static extern void igEndChild();
[DllImport(LibName)]
internal static extern void igGetContentRegionMax(ImVec2* @out);
[DllImport(LibName)]
internal static extern void igGetContentRegionAvail(ImVec2* @out);
[DllImport(LibName)]
internal static extern float igGetContentRegionAvailWidth(); //
[DllImport(LibName)]
internal static extern void igGetWindowContentRegionMin(ImVec2* @out);
[DllImport(LibName)]
internal static extern void igGetWindowContentRegionMax(ImVec2* @out);
[DllImport(LibName)]
internal static extern float igGetWindowContentRegionWidth(); //
[DllImport(LibName)]
internal static extern ImDrawList* igGetWindowDrawList();
[DllImport(LibName)]
internal static extern ImFont* igGetWindowFont();
[DllImport(LibName)]
internal static extern float igGetWindowFontSize();
[DllImport(LibName)]
internal static extern void igSetWindowFontScale(float scale);
[DllImport(LibName)]
internal static extern void igGetWindowPos(ImVec2* @out);
[DllImport(LibName)]
internal static extern void igGetWindowSize(ImVec2* @out);
[DllImport(LibName)]
internal static extern float igGetWindowWidth();
[DllImport(LibName)]
internal static extern float igGetWindowHeight();
[DllImport(LibName)]
internal static extern bool igIsWindowCollapsed();
[DllImport(LibName)]
internal static extern void igSetNextWindowPos(ImVec2 pos, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetNextWindowPosCenter(ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetNextWindowSize(ImVec2 size, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetNextWindowContentSize(ImVec2 size);
[DllImport(LibName)]
internal static extern void igSetNextWindowContentWidth(float width);
[DllImport(LibName)]
internal static extern void igSetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetNextWindowFocus();
[DllImport(LibName)]
internal static extern void igSetWindowPos(ImVec2 pos, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowSize(ImVec2 size, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowCollapsed(bool collapsed, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowFocus();
[DllImport(LibName)]
internal static extern void igSetWindowPosByName(string name, ImVec2 pos, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowSize2(string name, ImVec2 size, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowCollapsed2(string name, bool collapsed, ImGuiSetCond cond);
[DllImport(LibName)]
internal static extern void igSetWindowFocus2(string name);
[DllImport(LibName)]
internal static extern float igGetScrollX();
[DllImport(LibName)]
internal static extern float igGetScrollY();
[DllImport(LibName)]
internal static extern float igGetScrollMaxX();
[DllImport(LibName)]
internal static extern float igGetScrollMaxY();
[DllImport(LibName)]
internal static extern void igSetScrollX(float scroll_x);
[DllImport(LibName)]
internal static extern void igSetScrollY(float scroll_y);
[DllImport(LibName)]
internal static extern void igSetScrollHere(float center_y_ratio = 0.5f);
[DllImport(LibName)]
internal static extern void igSetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f);
[DllImport(LibName)]
internal static extern void igSetKeyboardFocusHere(int offset);
[DllImport(LibName)]
//internal static extern void igSetStateStorage(ImGuiStorage* tree);
internal static extern void igSetStateStorage(ImGuiStoragePtr tree);
[DllImport(LibName)]
internal static extern ImGuiStoragePtr* igGetStateStorage();
// Parameters stacks (shared)
[DllImport(LibName)]
internal static extern void igPushFont(ImFont* font);
[DllImport(LibName)]
internal static extern void igPopFont();
[DllImport(LibName)]
internal static extern void igPushStyleColor(ImGuiCol idx, ImVec4 col);
[DllImport(LibName)]
internal static extern void igPopStyleColor(int count);
[DllImport(LibName)]
internal static extern void igPushStyleVar(ImGuiStyleVar idx, float val);
[DllImport(LibName)]
internal static extern void igPushStyleVarVec(ImGuiStyleVar idx, ImVec2 val);
[DllImport(LibName)]
internal static extern void igPopStyleVar(int count);
// Parameters stacks (current window)
[DllImport(LibName)]
internal static extern void igPushItemWidth(float item_width);
[DllImport(LibName)]
internal static extern void igPopItemWidth();
[DllImport(LibName)]
internal static extern float igCalcItemWidth();
[DllImport(LibName)]
internal static extern void igPushTextWrapPos(float wrap_pos_x);
[DllImport(LibName)]
internal static extern void igPopTextWrapPos();
[DllImport(LibName)]
internal static extern void igPushAllowKeyboardFocus(bool v);
[DllImport(LibName)]
internal static extern void igPopAllowKeyboardFocus();
[DllImport(LibName)]
internal static extern void igPushButtonRepeat(bool repeat);
[DllImport(LibName)]
internal static extern void igPopButtonRepeat();
// Layout
[DllImport(LibName)]
internal static extern void igBeginGroup();
[DllImport(LibName)]
internal static extern void igEndGroup();
[DllImport(LibName)]
internal static extern void igSeparator();
[DllImport(LibName)]
internal static extern void igSameLine(float local_pos_x, float spacing_w);
[DllImport(LibName)]
internal static extern void igSpacing();
[DllImport(LibName)]
internal static extern void igDummy(ImVec2* size);
[DllImport(LibName)]
internal static extern void igIndent();
[DllImport(LibName)]
internal static extern void igUnindent();
[DllImport(LibName)]
internal static extern void igColumns(int count, string id, bool border);
[DllImport(LibName)]
internal static extern void igNextColumn();
[DllImport(LibName)]
internal static extern int igGetColumnIndex();
[DllImport(LibName)]
internal static extern float igGetColumnOffset(int column_index);
[DllImport(LibName)]
internal static extern void igSetColumnOffset(int column_index, float offset_x);
[DllImport(LibName)]
internal static extern float igGetColumnWidth(int column_index);
[DllImport(LibName)]
internal static extern int igGetColumnsCount();
[DllImport(LibName)]
internal static extern void igGetCursorPos(ImVec2* pOut);
[DllImport(LibName)]
internal static extern float igGetCursorPosX();
[DllImport(LibName)]
internal static extern float igGetCursorPosY();
[DllImport(LibName)]
internal static extern void igSetCursorPos(ImVec2 local_pos);
[DllImport(LibName)]
internal static extern void igSetCursorPosX(float x);
[DllImport(LibName)]
internal static extern void igSetCursorPosY(float y);
[DllImport(LibName)]
internal static extern void igGetCursorStartPos(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igGetCursorScreenPos(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igSetCursorScreenPos(ImVec2 pos);
[DllImport(LibName)]
internal static extern void igAlignFirstTextHeightToWidgets();
[DllImport(LibName)]
internal static extern float igGetTextLineHeight();
[DllImport(LibName)]
internal static extern float igGetTextLineHeightWithSpacing();
[DllImport(LibName)]
internal static extern float igGetItemsLineHeightWithSpacing();
// ID scopes
// If you are creating widgets @in a loop you most likely want to push a unique identifier so ImGui can differentiate them
// You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide')
[DllImport(LibName)]
internal static extern void igPushIdStr(string str_id);
[DllImport(LibName)]
internal static extern void igPushIdStrRange(string str_begin, string str_end);
[DllImport(LibName)]
internal static extern void igPushIdPtr(void* ptr_id);
[DllImport(LibName)]
internal static extern void igPushIdInt(int int_id);
[DllImport(LibName)]
internal static extern void igPopId();
[DllImport(LibName)]
internal static extern ImGuiID igGetIdStr(string str_id);
[DllImport(LibName)]
internal static extern ImGuiID igGetIdStrRange(string str_begin, string str_end);
[DllImport(LibName)]
internal static extern ImGuiID igGetIdPtr(void* ptr_id);
// Widgets
[DllImport(LibName)]
//internal static extern void igText(string fmt, ...);
internal static extern void igText(string fmt);
/*
[DllImport(LibName)]
internal static extern void igTextV(string fmt, va_list args);
*/
[DllImport(LibName)]
//internal static extern void igTextColored(ImVec4 col, string fmt, ...);
internal static extern void igTextColored(ImVec4 col, string fmt);
/*
[DllImport(LibName)]
internal static extern void igTextColoredV(ImVec4 col, string fmt, va_list args);
*/
[DllImport(LibName)]
//internal static extern void igTextDisabled(string fmt, ...);
internal static extern void igTextDisabled(string fmt);
/*
[DllImport(LibName)]
internal static extern void igTextDisabledV(string fmt, va_list args);
*/
[DllImport(LibName)]
//internal static extern void igTextWrapped(string fmt, ...);
internal static extern void igTextWrapped(string fmt);
/*
[DllImport(LibName)]
internal static extern void igTextWrappedV(string fmt, va_list args);
*/
[DllImport(LibName)]
internal static extern void igTextUnformatted(string text, string text_end);
[DllImport(LibName)]
//internal static extern void igLabelText(string label, string fmt, ...);
internal static extern void igLabelText(string label, string fmt);
/*
[DllImport(LibName)]
internal static extern void igLabelTextV(string label, string fmt, va_list args);
*/
[DllImport(LibName)]
internal static extern void igBullet();
[DllImport(LibName)]
//internal static extern void igBulletText(string fmt, ...);
internal static extern void igBulletText(string fmt);
/*
[DllImport(LibName)]
internal static extern void igBulletTextV(string fmt, va_list args);
*/
[DllImport(LibName)]
internal static extern bool igButton(string label, ImVec2 size);
[DllImport(LibName)]
internal static extern bool igSmallButton(string label);
[DllImport(LibName)]
internal static extern bool igInvisibleButton(string str_id, ImVec2 size);
[DllImport(LibName)]
internal static extern void igImage(ImTextureID user_texture_id, ImVec2 size, ImVec2 uv0, ImVec2 uv1, ImVec4 tint_col, ImVec4 border_col);
[DllImport(LibName)]
internal static extern bool igImageButton(ImTextureID user_texture_id, ImVec2 size, ImVec2 uv0, ImVec2 uv1, int frame_padding, ImVec4 bg_col, ImVec4 tint_col);
[DllImport(LibName)]
internal static extern bool igCollapsingHeader(string label, string str_id, bool display_frame, bool default_open);
[DllImport(LibName)]
internal static extern bool igCheckbox(string label, bool* v);
[DllImport(LibName)]
internal static extern bool igCheckboxFlags(string label, UIntPtr* flags, uint flags_value);
[DllImport(LibName)]
internal static extern bool igRadioButtonBool(string label, bool active);
[DllImport(LibName)]
internal static extern bool igRadioButton(string label, int* v, int v_button);
[DllImport(LibName)]
internal static extern bool igCombo(string label, int* current_item, char** items, int items_count, int height_in_items);
[DllImport(LibName)]
internal static extern bool igCombo2(string label, int* current_item, string items_separated_by_zeros, int height_in_items);
/*
[DllImport(LibName)]
internal static extern bool igCombo3(string label, int* current_item, bool(*items_getter)(void* data, int idx, string* out_text), void* data, int items_count, int height_in_items);
*/
[DllImport(LibName)]
internal static extern bool igColorButton(ImVec4 col, bool small_height, bool outline_border);
[DllImport(LibName)]
internal static extern bool igColorEdit3(string label, Vector3 col);
[DllImport(LibName)]
internal static extern bool igColorEdit4(string label, Vector4 col, bool show_alpha);
[DllImport(LibName)]
internal static extern void igColorEditMode(ImGuiColorEditMode mode);
[DllImport(LibName)]
internal static extern void igPlotLines(string label, float* values, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride);
/*
[DllImport(LibName)]
internal static extern void igPlotLines2(string label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
*/
[DllImport(LibName)]
internal static extern void igPlotHistogram(string label, float* values, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride);
/*
[DllImport(LibName)]
internal static extern void igPlotHistogram2(string label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
*/
// Widgets: Sliders (tip: ctrl+click on a slider to input text)
[DllImport(LibName)]
internal static extern bool igSliderFloat(string label, float* v, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igSliderFloat2(string label, Vector2 v, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igSliderFloat3(string label, Vector3 v, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igSliderFloat4(string label, Vector4 v, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igSliderAngle(string label, float* v_rad, float v_degrees_min, float v_degrees_max);
[DllImport(LibName)]
internal static extern bool igSliderInt(string label, int* v, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igSliderInt2(string label, Int2 v, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igSliderInt3(string label, Int3 v, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igSliderInt4(string label, Int4 v, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igVSliderFloat(string label, ImVec2 size, float* v, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igVSliderInt(string label, ImVec2 size, int* v, int v_min, int v_max, string display_format);
// Widgets: Drags (tip: ctrl+click on a drag box to input text)
[DllImport(LibName)]
internal static extern bool igDragFloat(string label, float* v, float v_speed, float v_min, float v_max, string display_format, float power); // If v_max >= v_max we have no bound
[DllImport(LibName)]
internal static extern bool igDragFloat2(string label, Vector2 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igDragFloat3(string label, Vector3 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igDragFloat4(string label, Vector4 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(LibName)]
internal static extern bool igDragFloatRange2(string label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, string display_format = "%.3f", string display_format_max = null, float power = 1.0f);
[DllImport(LibName)]
internal static extern bool igDragInt(string label, int* v, float v_speed, int v_min, int v_max, string display_format); // If v_max >= v_max we have no bound
[DllImport(LibName)]
internal static extern bool igDragInt2(string label, Int2 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igDragInt3(string label, Int3 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igDragInt4(string label, Int4 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(LibName)]
internal static extern bool igDragIntRange2(string label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, string display_format = "%.0f", string display_format_max = null);
// Widgets: Input
[DllImport(LibName)]
internal static extern bool igInputText(string label, string buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data);
[DllImport(LibName)]
internal static extern bool igInputTextMultiline(string label, string buf, size_t buf_size, ImVec2 size, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data);
[DllImport(LibName)]
internal static extern bool igInputFloat(string label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputFloat2(string label, Vector2 v, int decimal_precision, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputFloat3(string label, Vector3 v, int decimal_precision, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputFloat4(string label, Vector4 v, int decimal_precision, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputInt(string label, int* v, int step, int step_fast, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputInt2(string label, Int2 v, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputInt3(string label, Int3 v, ImGuiInputTextFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igInputInt4(string label, Int4 v, ImGuiInputTextFlags extra_flags);
// Widgets: Trees
[DllImport(LibName)]
internal static extern bool igTreeNode(string str_label_id);
[DllImport(LibName)]
//internal static extern bool igTreeNodeStr(string str_id, string fmt, ...);
internal static extern bool igTreeNodeStr(string str_id, string fmt);
[DllImport(LibName)]
//internal static extern bool igTreeNodePtr(void* ptr_id, string fmt, ...);
internal static extern bool igTreeNodePtr(void* ptr_id, string fmt);
/*
[DllImport(LibName)]
internal static extern bool igTreeNodeStrV(string str_id, string fmt, va_list args);
[DllImport(LibName)]
internal static extern bool igTreeNodePtrV(void* ptr_id, string fmt, va_list args);
*/
[DllImport(LibName)]
internal static extern void igTreePushStr(string str_id);
[DllImport(LibName)]
internal static extern void igTreePushPtr(void* ptr_id);
[DllImport(LibName)]
internal static extern void igTreePop();
[DllImport(LibName)]
internal static extern void igSetNextTreeNodeOpened(bool opened, ImGuiSetCond cond);
// Widgets: Selectable / Lists
[DllImport(LibName)]
internal static extern bool igSelectable(string label, bool selected, ImGuiSelectableFlags flags, ImVec2 size);
[DllImport(LibName)]
internal static extern bool igSelectableEx(string label, bool* p_selected, ImGuiSelectableFlags flags, ImVec2 size);
[DllImport(LibName)]
internal static extern bool igListBox(string label, int* current_item, char** items, int items_count, int height_in_items);
/*
[DllImport(LibName)]
internal static extern bool igListBox2(string label, int* current_item, bool(*items_getter)(void* data, int idx, string* out_text), void* data, int items_count, int height_in_items);
*/
[DllImport(LibName)]
internal static extern bool igListBoxHeader(string label, ImVec2 size);
[DllImport(LibName)]
internal static extern bool igListBoxHeader2(string label, int items_count, int height_in_items);
[DllImport(LibName)]
internal static extern void igListBoxFooter();
// Widgets: Value() Helpers. Output single value @in "name: value" format (tip: freely declare your own within the ImGui namespace!)
[DllImport(LibName)]
internal static extern void igValueBool(string prefix, bool b);
[DllImport(LibName)]
internal static extern void igValueInt(string prefix, int v);
[DllImport(LibName)]
internal static extern void igValueUInt(string prefix, uint v);
[DllImport(LibName)]
internal static extern void igValueFloat(string prefix, float v, string float_format);
[DllImport(LibName)]
internal static extern void igColor(string prefix, ImVec4 v);
[DllImport(LibName)]
internal static extern void igColor2(string prefix, uint v);
// Tooltip
[DllImport(LibName)]
//internal static extern void igSetTooltip(string fmt, ...);
internal static extern void igSetTooltip(string fmt);
/*
[DllImport(LibName)]
internal static extern void igSetTooltipV(string fmt, va_list args);
*/
[DllImport(LibName)]
internal static extern void igBeginTooltip();
[DllImport(LibName)]
internal static extern void igEndTooltip();
// Widgets: Menus
[DllImport(LibName)]
internal static extern bool igBeginMainMenuBar();
[DllImport(LibName)]
internal static extern void igEndMainMenuBar();
[DllImport(LibName)]
internal static extern bool igBeginMenuBar();
[DllImport(LibName)]
internal static extern void igEndMenuBar();
[DllImport(LibName)]
internal static extern bool igBeginMenu(string label, bool enabled);
[DllImport(LibName)]
internal static extern void igEndMenu();
[DllImport(LibName)]
internal static extern bool igMenuItem(string label, string shortcut, bool selected, bool enabled);
[DllImport(LibName)]
internal static extern bool igMenuItemPtr(string label, string shortcut, bool* p_selected, bool enabled);
// Popup
[DllImport(LibName)]
internal static extern void igOpenPopup(string str_id);
[DllImport(LibName)]
internal static extern bool igBeginPopup(string str_id);
[DllImport(LibName)]
internal static extern bool igBeginPopupModal(string name, bool* p_opened, ImGuiWindowFlags extra_flags);
[DllImport(LibName)]
internal static extern bool igBeginPopupContextItem(string str_id, int mouse_button);
[DllImport(LibName)]
internal static extern bool igBeginPopupContextWindow(bool also_over_items, string str_id, int mouse_button);
[DllImport(LibName)]
internal static extern bool igBeginPopupContextVoid(string str_id, int mouse_button);
[DllImport(LibName)]
internal static extern void igEndPopup();
[DllImport(LibName)]
internal static extern void igCloseCurrentPopup();
// Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened.
[DllImport(LibName)]
internal static extern void igLogToTTY(int max_depth);
[DllImport(LibName)]
internal static extern void igLogToFile(int max_depth, string filename);
[DllImport(LibName)]
internal static extern void igLogToClipboard(int max_depth);
[DllImport(LibName)]
internal static extern void igLogFinish();
[DllImport(LibName)]
internal static extern void igLogButtons();
[DllImport(LibName)]
//internal static extern void igLogText(string fmt, ...);
internal static extern void igLogText(string fmt);
// Utilities
[DllImport(LibName)]
internal static extern bool igIsItemHovered();
[DllImport(LibName)]
internal static extern bool igIsItemHoveredRect();
[DllImport(LibName)]
internal static extern bool igIsItemActive();
[DllImport(LibName)]
internal static extern bool igIsItemVisible();
[DllImport(LibName)]
internal static extern bool igIsAnyItemHovered();
[DllImport(LibName)]
internal static extern bool igIsAnyItemActive();
[DllImport(LibName)]
internal static extern void igGetItemRectMin(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igGetItemRectMax(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igGetItemRectSize(ImVec2* pOut);
[DllImport(LibName)]
internal static extern bool igIsWindowHovered();
[DllImport(LibName)]
internal static extern bool igIsWindowFocused();
[DllImport(LibName)]
internal static extern bool igIsRootWindowFocused();
[DllImport(LibName)]
internal static extern bool igIsRootWindowOrAnyChildFocused();
[DllImport(LibName)]
internal static extern bool igIsRectVisible(ImVec2 item_size);
[DllImport(LibName)]
internal static extern bool igIsPosHoveringAnyWindow(ImVec2 pos);
[DllImport(LibName)]
internal static extern float igGetTime();
[DllImport(LibName)]
internal static extern int igGetFrameCount();
[DllImport(LibName)]
internal static extern string igGetStyleColName(ImGuiCol idx);
[DllImport(LibName)]
internal static extern void igCalcItemRectClosestPoint(ImVec2* pOut, ImVec2 pos, bool on_edge, float outward);
[DllImport(LibName)]
internal static extern void igCalcTextSize(ImVec2* pOut, string text, string text_end, bool hide_text_after_double_hash, float wrap_width);
[DllImport(LibName)]
internal static extern void igCalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);
[DllImport(LibName)]
internal static extern bool igBeginChildFrame(ImGuiID id, ImVec2 size, ImGuiWindowFlags extra_flags);
[DllImport(LibName)]
internal static extern void igEndChildFrame();
[DllImport(LibName)]
internal static extern void igColorConvertU32ToFloat4(ImVec4* pOut, ImU32 @in);
[DllImport(LibName)]
internal static extern ImU32 igColorConvertFloat4ToU32(ImVec4 @in);
[DllImport(LibName)]
internal static extern void igColorConvertRGBtoHSV(float r, float g, float b, float* out_h, float* out_s, float* out_v);
[DllImport(LibName)]
internal static extern void igColorConvertHSVtoRGB(float h, float s, float v, float* out_r, float* out_g, float* out_b);
[DllImport(LibName)]
internal static extern bool igIsKeyDown(int key_index);
[DllImport(LibName)]
internal static extern bool igIsKeyPressed(int key_index, bool repeat);
[DllImport(LibName)]
internal static extern bool igIsKeyReleased(int key_index);
[DllImport(LibName)]
internal static extern bool igIsMouseDown(int button);
[DllImport(LibName)]
internal static extern bool igIsMouseClicked(int button, bool repeat);
[DllImport(LibName)]
internal static extern bool igIsMouseDoubleClicked(int button);
[DllImport(LibName)]
internal static extern bool igIsMouseReleased(int button);
[DllImport(LibName)]
internal static extern bool igIsMouseHoveringWindow();
[DllImport(LibName)]
internal static extern bool igIsMouseHoveringAnyWindow();
[DllImport(LibName)]
internal static extern bool igIsMouseHoveringRect(ImVec2 pos_min, ImVec2 pos_max, bool clip);
[DllImport(LibName)]
internal static extern bool igIsMouseDragging(int button, float lock_threshold);
[DllImport(LibName)]
internal static extern void igGetMousePos(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igGetMousePosOnOpeningCurrentPopup(ImVec2* pOut);
[DllImport(LibName)]
internal static extern void igGetMouseDragDelta(ImVec2* pOut, int button, float lock_threshold);
[DllImport(LibName)]
internal static extern void igResetMouseDragDelta(int button);
[DllImport(LibName)]
internal static extern ImGuiMouseCursor igGetMouseCursor();
[DllImport(LibName)]
internal static extern void igSetMouseCursor(ImGuiMouseCursor type);
[DllImport(LibName)]
internal static extern void igCaptureKeyboardFromApp();
[DllImport(LibName)]
internal static extern void igCaptureMouseFromApp();
// Helpers functions to access functions pointers @in ImGui::GetIO()
[DllImport(LibName)]
internal static extern void* igMemAlloc(size_t sz);
[DllImport(LibName)]
internal static extern void igMemFree(void* ptr);
[DllImport(LibName)]
internal static extern string igGetClipboardText();
[DllImport(LibName)]
internal static extern void igSetClipboardText(string text);
// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
[DllImport(LibName)]
internal static extern string igGetVersion();
[DllImport(LibName)]
internal static extern void* igGetInternalState();
[DllImport(LibName)]
internal static extern size_t igGetInternalStateSize();
[DllImport(LibName)]
internal static extern void igSetInternalState(void* state, bool construct);
[DllImport(LibName)]
internal static extern void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel);
[DllImport(LibName)]
internal static extern void ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* atlas, byte** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel);
[DllImport(LibName)]
internal static extern void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex);
/*
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFont(ImFontAtlas* atlas, ImFontConfig* font_cfg);
*/
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFontDefault(ImFontAtlas* atlas, IntPtr font_cfg);
/*
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFontFromFileTTF(ImFontAtlas* atlas, string filename, float size_pixels, ImFontConfig* font_cfg, ImWstring glyph_ranges);
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas* atlas, void* ttf_data, int ttf_size, float size_pixels, ImFontConfig* font_cfg, ImWstring glyph_ranges);
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFontFromMemoryCompressedTTF(ImFontAtlas* atlas, void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, ImFontConfig* font_cfg, ImWstring glyph_ranges);
[DllImport(LibName)]
internal static extern ImFont* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas* atlas, string compressed_ttf_data_base85, float size_pixels, ImFontConfig* font_cfg, ImWstring glyph_ranges);
*/
[DllImport(LibName)]
internal static extern void ImFontAtlas_ClearTexData(ImFontAtlas* atlas);
[DllImport(LibName)]
internal static extern void ImFontAtlas_Clear(ImFontAtlas* atlas);
[DllImport(LibName)]
internal static extern void ImGuiIO_AddInputCharacter(ushort c);
[DllImport(LibName)]
internal static extern void ImGuiIO_AddInputCharactersUTF8(string utf8_chars);
[DllImport(LibName)]
internal static extern int ImDrawList_GetVertexBufferSize(ImDrawList* list);
[DllImport(LibName)]
internal static extern ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n);
[DllImport(LibName)]
internal static extern int ImDrawList_GetIndexBufferSize(ImDrawList* list);
[DllImport(LibName)]
internal static extern ImDrawIdx* ImDrawList_GetIndexPtr(ImDrawList* list, int n);
[DllImport(LibName)]
internal static extern int ImDrawList_GetCmdSize(ImDrawList* list);
[DllImport(LibName)]
internal static extern ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n);
[DllImport(LibName)]
internal static extern void ImDrawData_DeIndexAllBuffers(ImDrawData* drawData);
}
[StructLayout(LayoutKind.Sequential)]
internal struct Int2
{
public readonly int X, Y;
}
[StructLayout(LayoutKind.Sequential)]
internal struct Int3
{
public readonly int X, Y, Z;
}
[StructLayout(LayoutKind.Sequential)]
internal struct Int4
{
public readonly int X, Y, Z, W;
}
}

@ -0,0 +1,15 @@
using OpenTK;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ImGui
{
public class Program
{
public static unsafe void Main(string[] args)
{
new SampleWindow().RunWindowLoop();
}
}
}

@ -0,0 +1,363 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using ImDrawIdx = System.UInt16;
namespace ImGui
{
public class SampleWindow
{
private NativeWindow _nativeWindow;
private GraphicsContext _graphicsContext;
private int s_fontTexture;
private int _pressCount;
private IntPtr _textInputBuffer;
private int _textInputBufferLength;
private float _wheelPosition;
private float _sliderVal;
private System.Numerics.Vector4 _buttonColor = new System.Numerics.Vector4(55f / 255f, 155f / 255f, 1f, 1f);
private bool _mainWindowOpened;
public unsafe SampleWindow()
{
_nativeWindow = new NativeWindow(960, 540, "ImGui.NET", GameWindowFlags.Default, OpenTK.Graphics.GraphicsMode.Default, DisplayDevice.Default);
_nativeWindow.WindowBorder = WindowBorder.Resizable;
GraphicsContextFlags flags = GraphicsContextFlags.Default;
_graphicsContext = new GraphicsContext(GraphicsMode.Default, _nativeWindow.WindowInfo, 3, 0, flags);
_graphicsContext.MakeCurrent(_nativeWindow.WindowInfo);
((IGraphicsContextInternal)_graphicsContext).LoadAll(); // wtf is this?
GL.ClearColor(Color.Black);
_nativeWindow.Visible = true;
_nativeWindow.KeyDown += OnKeyDown;
_nativeWindow.KeyUp += OnKeyUp;
_nativeWindow.KeyPress += OnKeyPress;
ImGuiIO* io = ImGuiNative.igGetIO();
ImGuiNative.ImFontAtlas_AddFontDefault(io->FontAtlas);
SetOpenTKKeyMappings(io);
_textInputBufferLength = 1024;
_textInputBuffer = Marshal.AllocHGlobal(_textInputBufferLength);
long* ptr = (long*)_textInputBuffer.ToPointer();
for (int i = 0; i < 1024 / sizeof(long); i++)
{
ptr[i] = 0;
}
CreateDeviceObjects();
}
private void OnKeyPress(object sender, KeyPressEventArgs e)
{
ImGuiNative.ImGuiIO_AddInputCharacter(e.KeyChar);
}
private static unsafe void SetOpenTKKeyMappings(ImGuiIO* io)
{
io->KeyMap[(int)GuiKey.Tab] = (int)Key.Tab;
io->KeyMap[(int)GuiKey.LeftArrow] = (int)Key.Left;
io->KeyMap[(int)GuiKey.RightArrow] = (int)Key.Right;
io->KeyMap[(int)GuiKey.UpArrow] = (int)Key.Up;
io->KeyMap[(int)GuiKey.DownArrow] = (int)Key.Down;
io->KeyMap[(int)GuiKey.PageUp] = (int)Key.PageUp;
io->KeyMap[(int)GuiKey.PageDown] = (int)Key.PageDown;
io->KeyMap[(int)GuiKey.Home] = (int)Key.Home;
io->KeyMap[(int)GuiKey.End] = (int)Key.End;
io->KeyMap[(int)GuiKey.Delete] = (int)Key.Delete;
io->KeyMap[(int)GuiKey.Backspace] = (int)Key.BackSpace;
io->KeyMap[(int)GuiKey.Enter] = (int)Key.Enter;
io->KeyMap[(int)GuiKey.Escape] = (int)Key.Escape;
io->KeyMap[(int)GuiKey.A] = (int)Key.A;
io->KeyMap[(int)GuiKey.C] = (int)Key.C;
io->KeyMap[(int)GuiKey.V] = (int)Key.V;
io->KeyMap[(int)GuiKey.X] = (int)Key.X;
io->KeyMap[(int)GuiKey.Y] = (int)Key.Y;
io->KeyMap[(int)GuiKey.Z] = (int)Key.Z;
}
private unsafe void OnKeyDown(object sender, KeyboardKeyEventArgs e)
{
var ptr = ImGuiNative.igGetIO();
ptr->KeysDown[(int)e.Key] = 1;
UpdateModifiers(e, ptr);
}
private unsafe void OnKeyUp(object sender, KeyboardKeyEventArgs e)
{
var ptr = ImGuiNative.igGetIO();
ptr->KeysDown[(int)e.Key] = 0;
UpdateModifiers(e, ptr);
}
private static unsafe void UpdateModifiers(KeyboardKeyEventArgs e, ImGuiIO* ptr)
{
ptr->KeyAlt = e.Alt ? (byte)1 : (byte)0;
ptr->KeyCtrl = e.Control ? (byte)1 : (byte)0;
ptr->KeyShift = e.Shift ? (byte)1 : (byte)0;
}
private unsafe void CreateDeviceObjects()
{
ImGuiIO* io = ImGuiNative.igGetIO();
// Build texture atlas
byte* pixels;
int width, height;
ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(io->FontAtlas, &pixels, &width, &height, null);
// Create OpenGL texture
s_fontTexture = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, s_fontTexture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, width, height, 0, PixelFormat.Alpha, PixelType.UnsignedByte, new IntPtr(pixels));
// Store the texture identifier in the ImFontAtlas substructure.
io->FontAtlas->TexID = new IntPtr(s_fontTexture).ToPointer();
// Cleanup (don't clear the input data if you want to append new fonts later)
//io.Fonts->ClearInputData();
ImGuiNative.ImFontAtlas_ClearTexData(io->FontAtlas);
GL.BindTexture(TextureTarget.Texture2D, 0);
}
public void RunWindowLoop()
{
while (_nativeWindow.Visible)
{
RenderFrame();
_nativeWindow.ProcessEvents();
}
}
private unsafe void RenderFrame()
{
ImGuiIO* 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);
UpdateImGuiInput(io);
ImGuiNative.igNewFrame();
SubmitImGuiStiff();
ImGuiNative.igRender();
ImDrawData* data = ImGuiNative.igGetDrawData();
RenderImDrawData(data);
}
private unsafe void SubmitImGuiStiff()
{
ImGuiNative.igGetStyle()->WindowRounding = 0;
ImGuiNative.igSetNextWindowSize(new System.Numerics.Vector2(_nativeWindow.Width - 10, _nativeWindow.Height - 20), SetCondition.Always);
ImGuiNative.igSetNextWindowPosCenter(SetCondition.Always);
ImGuiNative.igBegin("ImGUI.NET Sample Program", ref _mainWindowOpened, WindowFlags.NoResize | WindowFlags.NoTitleBar | WindowFlags.NoMove);
ImGuiNative.igBeginMainMenuBar();
if (ImGuiNative.igBeginMenu("Help"))
{
if (ImGuiNative.igMenuItem("About", "Ctrl-Alt-A", false, true))
{
}
ImGuiNative.igEndMenu();
}
ImGuiNative.igEndMainMenuBar();
ImGuiNative.igText("Hello,");
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);
if (ImGuiNative.igButton("Press me!", new System.Numerics.Vector2(120, 30)))
{
_pressCount += 1;
}
ImGuiNative.igTextColored(new System.Numerics.Vector4(0, 1, 1, 1), $"Button pressed {_pressCount} times.");
ImGuiNative.igInputTextMultiline("Input some numbers:",
_textInputBuffer, (uint)_textInputBufferLength,
new System.Numerics.Vector2(360, 240),
InputTextFlags.CharsDecimal,
OnTextEdited, null);
ImGuiNative.igSliderFloat("SlidableValue", ref _sliderVal, -50f, 100f, $"{_sliderVal.ToString("##0.00")}", 1);
if (ImGuiNative.igTreeNode("First Item"))
{
ImGuiNative.igText("Word!");
ImGuiNative.igTreePop();
}
if (ImGuiNative.igTreeNode("Second Item"))
{
ImGuiNative.igColorButton(_buttonColor, false, true);
if (ImGui.Button("Push me to change color", new System.Numerics.Vector2(120, 30)))
{
_buttonColor = new System.Numerics.Vector4(_buttonColor.Y + .25f, _buttonColor.Z, _buttonColor.X, _buttonColor.W);
if (_buttonColor.X > 1.0f)
{
_buttonColor.X -= 1.0f;
}
}
ImGuiNative.igTreePop();
}
ImGuiNative.igEnd();
}
private unsafe int OnTextEdited(TextEditCallbackData* data)
{
char currentEventChar = (char)data->EventChar;
Console.WriteLine("Event char: " + currentEventChar);
return 0;
}
private unsafe void UpdateImGuiInput(ImGuiIO* io)
{
MouseState cursorState = OpenTK.Input.Mouse.GetCursorState();
MouseState mouseState = Mouse.GetState();
if (_nativeWindow.Bounds.Contains(cursorState.X, cursorState.Y))
{
Point windowPoint = _nativeWindow.PointToClient(new Point(cursorState.X, cursorState.Y));
io->MousePos = new System.Numerics.Vector2(windowPoint.X, windowPoint.Y);
}
else
{
io->MousePos = new System.Numerics.Vector2(-1f, -1f);
}
io->MouseDown[0] = (mouseState.LeftButton == ButtonState.Pressed) ? (byte)255 : (byte)0; // Left
io->MouseDown[1] = (mouseState.RightButton == ButtonState.Pressed) ? (byte)255 : (byte)0; // Right
io->MouseDown[2] = (mouseState.MiddleButton == ButtonState.Pressed) ? (byte)255 : (byte)0; // Middle
float newWheelPos = mouseState.WheelPrecise;
float delta = newWheelPos - _wheelPosition;
_wheelPosition = newWheelPos;
io->MouseWheel = delta;
}
private unsafe void RenderImDrawData(ImDrawData* draw_data)
{
// Rendering
int display_w, display_h;
display_w = _nativeWindow.Width;
display_h = _nativeWindow.Height;
Vector4 clear_color = new Vector4(114f / 255f, 144f / 255f, 154f / 255f, 1.0f);
GL.Viewport(0, 0, display_w, display_h);
GL.ClearColor(clear_color.X, clear_color.Y, clear_color.Z, clear_color.W);
GL.Clear(ClearBufferMask.ColorBufferBit);
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
int last_texture;
GL.GetInteger(GetPName.TextureBinding2D, out last_texture);
GL.PushAttrib(AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.TransformBit);
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
GL.Disable(EnableCap.CullFace);
GL.Disable(EnableCap.DepthTest);
GL.Enable(EnableCap.ScissorTest);
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
GL.EnableClientState(ArrayCap.ColorArray);
GL.Enable(EnableCap.Texture2D);
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
GL.UseProgram(0);
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
ImGuiIO* io = ImGuiNative.igGetIO();
float fb_height = io->DisplaySize.Y * io->DisplayFramebufferScale.Y;
// Can implement the below in C#.
//draw_data->ScaleClipRects(io.DisplayFramebufferScale);
// Setup orthographic projection matrix
GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
GL.LoadIdentity();
GL.Ortho(0.0f, io->DisplaySize.X, io->DisplaySize.Y, 0.0f, -1.0f, 1.0f);
GL.MatrixMode(MatrixMode.Modelview);
GL.PushMatrix();
GL.LoadIdentity();
// Render command lists
// #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
ImDrawList* 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);
//glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF("pos")));
GL.VertexPointer(2, VertexPointerType.Float, sizeof(ImDrawVert), new IntPtr(vtx_buffer + ImDrawVert.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));
//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));
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
ImDrawCmd* pcmd = &(((ImDrawCmd*)cmd_list->CmdBuffer.Data)[cmd_i]);
if (pcmd->UserCallback != IntPtr.Zero)
{
throw new NotImplementedException();
//pcmd->UserCallback(cmd_list, pcmd);
}
else
{
//glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
GL.BindTexture(TextureTarget.Texture2D, pcmd->TextureId.ToInt32());
//glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
GL.Scissor(
(int)pcmd->ClipRect.X,
(int)(fb_height - pcmd->ClipRect.W),
(int)(pcmd->ClipRect.Z - pcmd->ClipRect.X),
(int)(pcmd->ClipRect.W - pcmd->ClipRect.Y));
//glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer);
ushort[] indices = new ushort[pcmd->ElemCount];
for (int i = 0; i < indices.Length; i++) { indices[i] = idx_buffer[i]; }
GL.DrawElements(PrimitiveType.Triangles, (int)pcmd->ElemCount, DrawElementsType.UnsignedShort, new IntPtr(idx_buffer));
}
idx_buffer += pcmd->ElemCount;
}
}
// #undef OFFSETOF
// Restore modified state
GL.DisableClientState(ArrayCap.ColorArray);
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.VertexArray);
GL.BindTexture(TextureTarget.Texture2D, last_texture);
GL.MatrixMode(MatrixMode.Modelview);
GL.PopMatrix();
GL.MatrixMode(MatrixMode.Projection);
GL.PopMatrix();
GL.PopAttrib();
_graphicsContext.SwapBuffers();
}
}
}

@ -0,0 +1,13 @@
{
"dependencies": {
"Microsoft.NETCore.Console": "1.0.0-beta-23430",
"System.Console": "4.0.0-beta-23430"
},
"runtimes": {
"win10-x64": { },
"ubuntu.14.04-x64": { },
},
"frameworks": {
"dnxcore50": { }
}
}

@ -0,0 +1,92 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET.SampleProgram", "ImGui.NET.SampleProgram\ImGui.NET.SampleProgram.csproj", "{AE9BC745-284F-42F3-8236-C43F00000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET", "ImGui.NET\ImGui.NET.csproj", "{2665014F-0FEC-4268-8F77-7B029921AB09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
OSX_Debug|Any CPU = OSX_Debug|Any CPU
OSX_Debug|x64 = OSX_Debug|x64
OSX_Release|Any CPU = OSX_Release|Any CPU
OSX_Release|x64 = OSX_Release|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Ubuntu_Debug|Any CPU = Ubuntu_Debug|Any CPU
Ubuntu_Debug|x64 = Ubuntu_Debug|x64
Ubuntu_Release|Any CPU = Ubuntu_Release|Any CPU
Ubuntu_Release|x64 = Ubuntu_Release|x64
Windows_Debug|Any CPU = Windows_Debug|Any CPU
Windows_Debug|x64 = Windows_Debug|x64
Windows_Release|Any CPU = Windows_Release|Any CPU
Windows_Release|x64 = Windows_Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE9BC745-284F-42F3-8236-C43F00000000}.Debug|Any CPU.ActiveCfg = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Debug|Any CPU.Build.0 = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Debug|x64.ActiveCfg = Ubuntu_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Debug|x64.Build.0 = Ubuntu_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Debug|Any CPU.ActiveCfg = OSX_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Debug|x64.ActiveCfg = OSX_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Debug|x64.Build.0 = OSX_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Release|Any CPU.ActiveCfg = OSX_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Release|x64.ActiveCfg = OSX_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.OSX_Release|x64.Build.0 = OSX_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Release|Any CPU.ActiveCfg = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Release|Any CPU.Build.0 = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Release|x64.ActiveCfg = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Release|x64.Build.0 = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Debug|Any CPU.ActiveCfg = Ubuntu_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Debug|x64.ActiveCfg = Ubuntu_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Debug|x64.Build.0 = Ubuntu_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Release|Any CPU.ActiveCfg = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Release|x64.ActiveCfg = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Ubuntu_Release|x64.Build.0 = Ubuntu_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Debug|x64.ActiveCfg = Windows_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Debug|x64.Build.0 = Windows_Debug|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Release|x64.ActiveCfg = Windows_Release|x64
{AE9BC745-284F-42F3-8236-C43F00000000}.Windows_Release|x64.Build.0 = Windows_Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Debug|x64.ActiveCfg = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Debug|x64.Build.0 = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Debug|Any CPU.ActiveCfg = OSX_Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Debug|Any CPU.Build.0 = OSX_Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Debug|x64.ActiveCfg = OSX_Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Debug|x64.Build.0 = OSX_Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Release|Any CPU.ActiveCfg = OSX_Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Release|Any CPU.Build.0 = OSX_Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Release|x64.ActiveCfg = OSX_Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.OSX_Release|x64.Build.0 = OSX_Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Release|Any CPU.Build.0 = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Release|x64.ActiveCfg = Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Release|x64.Build.0 = Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Debug|Any CPU.Build.0 = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Debug|x64.ActiveCfg = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Debug|x64.Build.0 = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Release|Any CPU.ActiveCfg = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Release|Any CPU.Build.0 = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Release|x64.ActiveCfg = Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Ubuntu_Release|x64.Build.0 = Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Debug|Any CPU.Build.0 = Debug|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Debug|x64.ActiveCfg = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Debug|x64.Build.0 = Debug|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Release|Any CPU.ActiveCfg = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Release|Any CPU.Build.0 = Release|Any CPU
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Release|x64.ActiveCfg = Release|x64
{2665014F-0FEC-4268-8F77-7B029921AB09}.Windows_Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{
/// <summary>
/// Enumeration for ColorEditMode()
/// </summary>
public enum ColorEditMode
{
UserSelect = -2,
UserSelectShowButton = -1,
RGB = 0,
HSV = 1,
HEX = 2
}
}

@ -0,0 +1,58 @@
namespace ImGui
{
/// <summary>
/// Enumeration for PushStyleColor() / PopStyleColor()
/// </summary>
public enum ColorTarget
{
Text,
TextDisabled,
WindowBg,
ChildWindowBg,
Border,
BorderShadow,
/// <summary>
/// Background of checkbox, radio button, plot, slider, text input
/// </summary>
FrameBg,
FrameBgHovered,
FrameBgActive,
TitleBg,
TitleBgCollapsed,
TitleBgActive,
MenuBarBg,
ScrollbarBg,
ScrollbarGrab,
ScrollbarGrabHovered,
ScrollbarGrabActive,
ComboBg,
CheckMark,
SliderGrab,
SliderGrabActive,
Button,
ButtonHovered,
ButtonActive,
Header,
HeaderHovered,
HeaderActive,
Column,
ColumnHovered,
ColumnActive,
ResizeGrip,
ResizeGripHovered,
ResizeGripActive,
CloseButton,
CloseButtonHovered,
CloseButtonActive,
PlotLines,
PlotLinesHovered,
PlotHistogram,
PlotHistogramHovered,
TextSelectedBg,
TooltipBg,
/// <summary>
/// darken entire screen when a modal window is active
/// </summary>
ModalWindowDarkening,
};
}

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{
/// <summary>
/// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
/// </summary>
public enum GuiKey : int
{
/// <summary>
/// for tabbing through fields
/// </summary>
Tab,
/// <summary>
/// for text edit
/// </summary>
LeftArrow,
/// <summary>
/// for text edit
/// </summary>
RightArrow,
/// <summary>
/// for text edit
/// </summary>
UpArrow,
/// <summary>
/// for text edit
/// </summary>
DownArrow,
PageUp,
PageDown,
/// <summary>
/// for text edit
/// </summary>
Home,
/// <summary>
/// for text edit
/// </summary>
End,
/// <summary>
/// for text edit
/// </summary>
Delete,
/// <summary>
/// for text edit
/// </summary>
Backspace,
/// <summary>
/// for text edit
/// </summary>
Enter,
/// <summary>
/// for text edit
/// </summary>
Escape,
/// <summary>
/// for text edit CTRL+A: select all
/// </summary>
A,
/// <summary>
/// for text edit CTRL+C: copy
/// </summary>
C,
/// <summary>
/// for text edit CTRL+V: paste
/// </summary>
V,
/// <summary>
/// for text edit CTRL+X: cut
/// </summary>
X,
/// <summary>
/// for text edit CTRL+Y: redo
/// </summary>
Y,
/// <summary>
/// for text edit CTRL+Z: undo
/// </summary>
Z,
Count
}
}

@ -0,0 +1,28 @@
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; }
*/
};
}

@ -0,0 +1,28 @@
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;
namespace ImGui
{
// All draw data to render an ImGui frame
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ImDrawData
{
public byte Valid; // Only valid after Render() is called and before the next NewFrame() is called.
public ImDrawList** 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
// Functions
/*
ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
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.
*/
};
}

@ -0,0 +1,119 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
// Draw command list
// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
// 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
{
// This is what you have to render
// ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
// ImVector<ImDrawIdx> IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
// ImVector<ImDrawVert> VtxBuffer; // Vertex buffer.
/// <summary>
/// ImVector(ImDrawCmd)
/// </summary>
public ImVector CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
/// <summary>
/// ImVector(ImDrawIdx)
/// </summary>
public ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
/// <summary>
/// ImVector(ImDrawVert)
/// </summary>
public ImVector VtxBuffer; // Vertex buffer.
// [Internal, used while building lists]
public IntPtr _OwnerName; // Pointer to owner window's name (if any) for debugging
public uint _VtxCurrentIdx; // [Internal] == VtxBuffer.Size
//ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
//ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
public IntPtr _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
public IntPtr _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
//ImVector<ImVec4> _ClipRectStack; // [Internal]
//ImVector<ImTextureID> _TextureIdStack; // [Internal]
//ImVector<ImVec2> _Path; // [Internal] current path building
public ImVector _ClipRectStack; // [Internal]
public ImVector _TextureIdStack; // [Internal]
public ImVector _Path; // [Internal] current path building
public int _ChannelsCurrent; // [Internal] current channel number (0)
public int _ChannelsCount; // [Internal] number of active channels (1+)
//ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
public ImVector _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
/*
ImDrawList() { _OwnerName = NULL; Clear(); }
~ImDrawList() { ClearFreeMemory(); }
IMGUI_API void Clear();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. The values are x1, y1, x2, y2.
IMGUI_API void PushClipRectFullScreen();
IMGUI_API void PopClipRect();
IMGUI_API void PushTextureID(const ImTextureID& texture_id);
IMGUI_API void PopTextureID();
// Primitives
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 col = 0xFFFFFFFF);
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
// Stateful path API, add points then finish with PathFill() or PathStroke()
inline void PathClear() { _Path.resize(0); }
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || _Path[_Path.Size - 1].x != pos.x || _Path[_Path.Size - 1].y != pos.y) _Path.push_back(pos); }
inline void PathFill(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col, true); PathClear(); }
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness, true); PathClear(); }
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners = 0x0F);
// Channels
// - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
IMGUI_API void ChannelsSplit(int channels_count);
IMGUI_API void ChannelsMerge();
IMGUI_API void ChannelsSetCurrent(int channel_index);
// Advanced
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
// Internal helpers
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col);
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
IMGUI_API void UpdateClipRect();
IMGUI_API void UpdateTextureID();
*/
};
}

@ -0,0 +1,17 @@
using ImVec2 = System.Numerics.Vector2;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ImDrawVert
{
public ImVec2 pos;
public ImVec2 uv;
public uint col;
public const int PosOffset = 0;
public const int UVOffset = 8;
public const int ColOffset = 16;
};
}

@ -0,0 +1,74 @@
using System;
using System.Runtime.InteropServices;
using System.Numerics;
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
{
// Members: Settings
public float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
public float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
public Vector2 DisplayOffset; // = (0.0f,1.0f) // Offset font rendering by xx pixels
public ushort FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
/// <summary>
/// ImFontConfig*
/// </summary>
public IntPtr ConfigData; // // Pointer within ImFontAtlas->ConfigData
public int ConfigDataCount; //
// Members: Runtime data
[StructLayout(LayoutKind.Sequential)]
public struct Glyph
{
ushort Codepoint;
float XAdvance;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1; // Texture coordinates
};
public float Ascent, Descent; // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
/// <summary>
/// ImFontAtlas*
/// </summary>
public IntPtr ContainerAtlas; // What we has been loaded into
/// <summary>
/// ImVector(Glyph)
/// </summary>
public ImVector Glyphs;
public Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
public float FallbackXAdvance; //
//ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
//ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point.
public ImVector IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
public ImVector IndexLookup; // Sparse. Index glyphs by Unicode code-point.
// Methods
/*
IMGUI_API ImFont();
IMGUI_API ~ImFont();
IMGUI_API void Clear();
IMGUI_API void BuildLookupTable();
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
IMGUI_API void SetFallbackChar(ImWchar c);
float GetCharAdvance(unsigned short c) const { return ((int)c<IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
bool IsLoaded() const { return ContainerAtlas != NULL; }
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
*/
};
}

@ -0,0 +1,73 @@
using ImWchar = System.UInt16;
using ImVec2 = System.Numerics.Vector2;
using System.Runtime.InteropServices;
using System;
namespace ImGui
{
// Load and rasterize multiple TTF fonts into a same texture.
// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
// We also add custom graphic data into the texture that serves for ImGui.
// 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
// 3. Upload the pixels data into a texture within your graphics system.
// 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 ImFont* AddFont(ImFontConfig* font_cfg) { }
public ImFont* AddFontDefault(ImFontConfig* font_cfg = null) { }
public ImFont* AddFontFromFileTTF(char* filename, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null) { }
public ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
public ImFont* AddFontFromMemoryCompressedTTF(void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // 'compressed_ttf_data' still owned by caller. Compress with binary_to_compressed_c.cpp
public ImFont* AddFontFromMemoryCompressedBase85TTF(char* compressed_ttf_data_base85, float size_pixels, ImFontConfig* font_cfg = null, ImWchar* glyph_ranges = null); // 'compressed_ttf_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 paramaeter
public void ClearTexData(); // Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory.
public void ClearInputData(); // Clear the input TTF data (inc sizes, glyph ranges)
public void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates)
public void Clear() { } // Clear all
// Retrieve texture data
// User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
// After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
// RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
// Pitch = Width * BytesPerPixels
public void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = null); // 1 byte per-pixel
public void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = null); // 4 bytes-per-pixel
void SetTexID(void* id) { TexID = id; }
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
// (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->)
public ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
public ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
public ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
public ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
public ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
*/
// Members
// (Access texture data via GetTexData*() calls which will setup a default font for you.)
public void* TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
public byte* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
public UIntPtr TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
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)
/// <summary>
/// (ImVector(ImFont*)
/// </summary>
public ImVector Fonts;
// Private
/// <summary>
/// ImVector(ImFontConfig)
/// </summary>
public ImVector ConfigData; // Internal data
/*
public bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
*/
}
}

@ -0,0 +1,77 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ImFontConfig
{
/// <summary>
/// TTF data
/// </summary>
public IntPtr FontData;
/// <summary>
/// TTF data size
/// </summary>
public int FontDataSize;
/// <summary>
/// TTF data ownership taken by the container ImFontAtlas (will delete memory itself).
/// Set to true.
/// </summary>
public bool FontDataOwnedByAtlas;
/// <summary>
/// 0.
/// Index of font within TTF file
/// </summary>
public int FontNo;
/// <summary>
/// Size in pixels for rasterizer.
/// </summary>
public float SizePixels;
/// <summary>
/// Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
/// Set to 3.
/// </summary>
public int OversampleH;
/// <summary>
/// Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
/// Set to 1.
/// </summary>
public int OversampleV;
/// <summary>
/// Align every character to pixel boundary (if enabled, set OversampleH/V to 1).
/// Set to false.
/// </summary>
public bool PixelSnapH;
/// <summary>
/// Extra spacing (in pixels) between glyphs.
/// Set to (0, 0).
/// </summary>
public Vector2 GlyphExtraSpacing;
/// <summary>
/// List of Unicode range (2 value per range, values are inclusive, zero-terminated list).
/// </summary>
public char* GlyphRanges;
/// <summary>
/// Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
/// Set to false.
/// </summary>
public bool MergeMode;
/// <summary>
/// When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline.
/// Set to false.
/// </summary>
public bool MergeGlyphCenterV;
// [Internal]
/// <summary>
/// [Internal Use Only] Name (strictly for debugging)
/// </summary>
public fixed char Name[32];
/// <summary>
/// [Internal Use Only]
/// </summary>
public IntPtr DstFont;
};
}

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<ProjectGuid>{2665014F-0FEC-4268-8F77-7B029921AB09}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ImGui</RootNamespace>
<AssemblyName>ImGui.NET</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="ColorTarget.cs" />
<Compile Include="MouseCursorKind.cs" />
<Compile Include="SelectableFlags.cs" />
<Compile Include="StyleVar.cs" />
<Compile Include="WindowFlags.cs" />
<Compile Include="ColorEditMode.cs" />
<Compile Include="GuiKey.cs" />
<Compile Include="ImDrawCmd.cs" />
<Compile Include="ImDrawData.cs" />
<Compile Include="ImDrawList.cs" />
<Compile Include="ImDrawVert.cs" />
<Compile Include="ImFont.cs" />
<Compile Include="ImFontAtlas.cs" />
<Compile Include="ImFontConfig.cs" />
<Compile Include="ImGui.cs" />
<Compile Include="ImGuiIO.cs" />
<Compile Include="ImGuiStorage.cs" />
<Compile Include="ImGuiStyle.cs" />
<Compile Include="ImGuiTextEditCallbackData.cs" />
<Compile Include="ImVector.cs" />
<Compile Include="InputTextFlags.cs" />
<Compile Include="ImGuiNative.cs" />
<Compile Include="SetCondition.cs" />
<Compile Include="TextEditCallback.cs" />
<Compile Include="TextEditCallbackData.cs" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OSX_Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\OSX_Debug\</OutputPath>
<DefineConstants>;DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OSX_Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\OSX_Debug\</OutputPath>
<DefineConstants>;DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OSX_Release|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\OSX_Release\</OutputPath>
<DefineConstants>;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<NoStdLib>true</NoStdLib>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OSX_Release|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\OSX_Release\</OutputPath>
<DefineConstants>;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<NoStdLib>true</NoStdLib>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

@ -0,0 +1,41 @@
using System;
using System.Numerics;
namespace ImGui
{
public static class ImGui
{
public static void NewFrame()
{
ImGuiNative.igNewFrame();
}
public static void Render()
{
ImGuiNative.igRender();
}
public static unsafe void LoadDefaultFont()
{
ImGuiIO* ioPtr = ImGuiNative.igGetIO();
ImGuiNative.ImFontAtlas_AddFontDefault(ioPtr->FontAtlas);
}
public static void Text(string message)
{
ImGuiNative.igText(message);
}
public static void Text(string message, Vector4 color)
{
ImGuiNative.igTextColored(color, message);
}
public static bool Button(string message, Vector2 size)
{
return ImGuiNative.igButton(message, size);
}
}
}

@ -0,0 +1,202 @@
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;
}
}
}

@ -0,0 +1,714 @@
using System.Runtime.InteropServices;
using System.Numerics;
using System;
namespace ImGui
{
/// <summary>
/// Contains all of the exported functions from the native (c)imGui module.
/// </summary>
public static unsafe class ImGuiNative
{
private const string cimguiLib = "cimgui";
[DllImport(cimguiLib)]
public static extern ImGuiIO* igGetIO();
[DllImport(cimguiLib)]
public static extern ImGuiStyle* igGetStyle();
[DllImport(cimguiLib)]
public static extern ImDrawData* igGetDrawData();
[DllImport(cimguiLib)]
public static extern void igNewFrame();
[DllImport(cimguiLib)]
public static extern void igRender();
[DllImport(cimguiLib)]
public static extern void igShutdown();
[DllImport(cimguiLib)]
public static extern void igShowUserGuide();
[DllImport(cimguiLib)]
public static extern void igShowStyleEditor(ref ImGuiStyle @ref);
[DllImport(cimguiLib)]
public static extern void igShowTestWindow(ref bool opened);
[DllImport(cimguiLib)]
public static extern void igShowMetricsWindow(ref bool opened);
// Window
[DllImport(cimguiLib)]
public static extern bool igBegin(string name, ref bool p_opened, WindowFlags flags);
[DllImport(cimguiLib)]
public static extern bool igBegin2(string name, ref bool p_opened, Vector2 size_on_first_use, float bg_alpha, WindowFlags flags);
[DllImport(cimguiLib)]
public static extern void igEnd();
[DllImport(cimguiLib)]
public static extern bool igBeginChild(string str_id, Vector2 size, bool border, WindowFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igBeginChildEx(uint id, Vector2 size, bool border, WindowFlags extra_flags);
[DllImport(cimguiLib)]
public static extern void igEndChild();
[DllImport(cimguiLib)]
public static extern void igGetContentRegionMax(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern void igGetContentRegionAvail(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern float igGetContentRegionAvailWidth();
[DllImport(cimguiLib)]
public static extern void igGetWindowContentRegionMin(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern void igGetWindowContentRegionMax(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern float igGetWindowContentRegionWidth();
[DllImport(cimguiLib)]
public static extern ImDrawList* igGetWindowDrawList();
[DllImport(cimguiLib)]
public static extern ImFont* igGetWindowFont();
[DllImport(cimguiLib)]
public static extern float igGetWindowFontSize();
[DllImport(cimguiLib)]
public static extern void igSetWindowFontScale(float scale);
[DllImport(cimguiLib)]
public static extern void igGetWindowPos(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern void igGetWindowSize(out Vector2 @out);
[DllImport(cimguiLib)]
public static extern float igGetWindowWidth();
[DllImport(cimguiLib)]
public static extern float igGetWindowHeight();
[DllImport(cimguiLib)]
public static extern bool igIsWindowCollapsed();
[DllImport(cimguiLib)]
public static extern void igSetNextWindowPos(Vector2 pos, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowPosCenter(SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowSize(Vector2 size, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowContentSize(Vector2 size);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowContentWidth(float width);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowCollapsed(bool collapsed, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetNextWindowFocus();
[DllImport(cimguiLib)]
public static extern void igSetWindowPos(Vector2 pos, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowSize(Vector2 size, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowCollapsed(bool collapsed, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowFocus();
[DllImport(cimguiLib)]
public static extern void igSetWindowPosByName(string name, Vector2 pos, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowSize2(string name, Vector2 size, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowCollapsed2(string name, bool collapsed, SetCondition cond);
[DllImport(cimguiLib)]
public static extern void igSetWindowFocus2(string name);
[DllImport(cimguiLib)]
public static extern float igGetScrollX();
[DllImport(cimguiLib)]
public static extern float igGetScrollY();
[DllImport(cimguiLib)]
public static extern float igGetScrollMaxX();
[DllImport(cimguiLib)]
public static extern float igGetScrollMaxY();
[DllImport(cimguiLib)]
public static extern void igSetScrollX(float scroll_x);
[DllImport(cimguiLib)]
public static extern void igSetScrollY(float scroll_y);
[DllImport(cimguiLib)]
public static extern void igSetScrollHere(float center_y_ratio = 0.5f);
[DllImport(cimguiLib)]
public static extern void igSetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f);
[DllImport(cimguiLib)]
public static extern void igSetKeyboardFocusHere(int offset);
[DllImport(cimguiLib)]
public static extern void igSetStateStorage(ref Storage tree);
[DllImport(cimguiLib)]
public static extern Storage* igGetStateStorage();
// Parameters stacks (shared)
[DllImport(cimguiLib)]
public static extern void igPushFont(ImFont* font);
[DllImport(cimguiLib)]
public static extern void igPopFont();
[DllImport(cimguiLib)]
public static extern void igPushStyleColor(ColorTarget idx, Vector4 col);
[DllImport(cimguiLib)]
public static extern void igPopStyleColor(int count);
[DllImport(cimguiLib)]
public static extern void igPushStyleVar(StyleVar idx, float val);
[DllImport(cimguiLib)]
public static extern void igPushStyleVarVec(StyleVar idx, Vector2 val);
[DllImport(cimguiLib)]
public static extern void igPopStyleVar(int count);
// Parameters stacks (current window)
[DllImport(cimguiLib)]
public static extern void igPushItemWidth(float item_width);
[DllImport(cimguiLib)]
public static extern void igPopItemWidth();
[DllImport(cimguiLib)]
public static extern float igCalcItemWidth();
[DllImport(cimguiLib)]
public static extern void igPushTextWrapPos(float wrap_pos_x);
[DllImport(cimguiLib)]
public static extern void igPopTextWrapPos();
[DllImport(cimguiLib)]
public static extern void igPushAllowKeyboardFocus(bool v);
[DllImport(cimguiLib)]
public static extern void igPopAllowKeyboardFocus();
[DllImport(cimguiLib)]
public static extern void igPushButtonRepeat(bool repeat);
[DllImport(cimguiLib)]
public static extern void igPopButtonRepeat();
// Layout
[DllImport(cimguiLib)]
public static extern void igBeginGroup();
[DllImport(cimguiLib)]
public static extern void igEndGroup();
[DllImport(cimguiLib)]
public static extern void igSeparator();
[DllImport(cimguiLib)]
public static extern void igSameLine(float local_pos_x, float spacing_w);
[DllImport(cimguiLib)]
public static extern void igSpacing();
[DllImport(cimguiLib)]
public static extern void igDummy(Vector2* size);
[DllImport(cimguiLib)]
public static extern void igIndent();
[DllImport(cimguiLib)]
public static extern void igUnindent();
[DllImport(cimguiLib)]
public static extern void igColumns(int count, string id, bool border);
[DllImport(cimguiLib)]
public static extern void igNextColumn();
[DllImport(cimguiLib)]
public static extern int igGetColumnIndex();
[DllImport(cimguiLib)]
public static extern float igGetColumnOffset(int column_index);
[DllImport(cimguiLib)]
public static extern void igSetColumnOffset(int column_index, float offset_x);
[DllImport(cimguiLib)]
public static extern float igGetColumnWidth(int column_index);
[DllImport(cimguiLib)]
public static extern int igGetColumnsCount();
[DllImport(cimguiLib)]
public static extern void igGetCursorPos(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern float igGetCursorPosX();
[DllImport(cimguiLib)]
public static extern float igGetCursorPosY();
[DllImport(cimguiLib)]
public static extern void igSetCursorPos(Vector2 local_pos);
[DllImport(cimguiLib)]
public static extern void igSetCursorPosX(float x);
[DllImport(cimguiLib)]
public static extern void igSetCursorPosY(float y);
[DllImport(cimguiLib)]
public static extern void igGetCursorStartPos(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igGetCursorScreenPos(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igSetCursorScreenPos(Vector2 pos);
[DllImport(cimguiLib)]
public static extern void igAlignFirstTextHeightToWidgets();
[DllImport(cimguiLib)]
public static extern float igGetTextLineHeight();
[DllImport(cimguiLib)]
public static extern float igGetTextLineHeightWithSpacing();
[DllImport(cimguiLib)]
public static extern float igGetItemsLineHeightWithSpacing();
// ID scopes
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them
// You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide')
[DllImport(cimguiLib)]
public static extern void igPushIdStr(string str_id);
[DllImport(cimguiLib)]
public static extern void igPushIdStrRange(string str_begin, string str_end);
[DllImport(cimguiLib)]
public static extern void igPushIdPtr(void* ptr_id);
[DllImport(cimguiLib)]
public static extern void igPushIdInt(int int_id);
[DllImport(cimguiLib)]
public static extern void igPopId();
[DllImport(cimguiLib)]
public static extern uint igGetIdStr(string str_id);
[DllImport(cimguiLib)]
public static extern uint igGetIdStrRange(string str_begin, string str_end);
[DllImport(cimguiLib)]
public static extern uint igGetIdPtr(void* ptr_id);
// Widgets
[DllImport(cimguiLib)]
public static extern void igText(string fmt);
[DllImport(cimguiLib)]
public static extern void igTextColored(Vector4 col, string fmt);
[DllImport(cimguiLib)]
public static extern void igTextDisabled(string fmt);
[DllImport(cimguiLib)]
public static extern void igTextWrapped(string fmt);
[DllImport(cimguiLib)]
public static extern void igTextUnformatted(string text, string text_end);
[DllImport(cimguiLib)]
public static extern void igLabelText(string label, string fmt);
[DllImport(cimguiLib)]
public static extern void igBullet();
[DllImport(cimguiLib)]
public static extern void igBulletText(string fmt);
[DllImport(cimguiLib)]
public static extern bool igButton(string label, Vector2 size);
[DllImport(cimguiLib)]
public static extern bool igSmallButton(string label);
[DllImport(cimguiLib)]
public static extern bool igInvisibleButton(string str_id, Vector2 size);
[DllImport(cimguiLib)]
public static extern void igImage(IntPtr user_texture_id, Vector2 size, Vector2 uv0, Vector2 uv1, Vector4 tint_col, Vector4 border_col);
[DllImport(cimguiLib)]
public static extern bool igImageButton(IntPtr user_texture_id, Vector2 size, Vector2 uv0, Vector2 uv1, int frame_padding, Vector4 bg_col, Vector4 tint_col);
[DllImport(cimguiLib)]
public static extern bool igCollapsingHeader(string label, string str_id, bool display_frame, bool default_open);
[DllImport(cimguiLib)]
public static extern bool igCheckbox(string label, bool* v);
[DllImport(cimguiLib)]
public static extern bool igCheckboxFlags(string label, UIntPtr* flags, uint flags_value);
[DllImport(cimguiLib)]
public static extern bool igRadioButtonBool(string label, bool active);
[DllImport(cimguiLib)]
public static extern bool igRadioButton(string label, int* v, int v_button);
[DllImport(cimguiLib)]
public static extern bool igCombo(string label, ref int current_item, char** items, int items_count, int height_in_items);
[DllImport(cimguiLib)]
public static extern bool igCombo2(string label, ref int current_item, string items_separated_by_zeros, int height_in_items);
[DllImport(cimguiLib)]
public static extern bool igCombo3(string label, ref int current_item, ItemSelectedCallback items_getter, IntPtr data, int items_count, int height_in_items);
[DllImport(cimguiLib)]
public static extern bool igColorButton(Vector4 col, bool small_height, bool outline_border);
[DllImport(cimguiLib)]
public static extern bool igColorEdit3(string label, Vector3 col);
[DllImport(cimguiLib)]
public static extern bool igColorEdit4(string label, Vector4 col, bool show_alpha);
[DllImport(cimguiLib)]
public static extern void igColorEditMode(ColorEditMode mode);
[DllImport(cimguiLib)]
public static extern void igPlotLines(string label, float* values, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, Vector2 graph_size, int stride);
/*
[DllImport(LibName)]
public static extern void igPlotLines2(string label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, Vector2 graph_size);
*/
[DllImport(cimguiLib)]
public static extern void igPlotHistogram(string label, float* values, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, Vector2 graph_size, int stride);
/*
[DllImport(LibName)]
public static extern void igPlotHistogram2(string label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, string overlay_text, float scale_min, float scale_max, Vector2 graph_size);
*/
// Widgets: Sliders (tip: ctrl+click on a slider to input text)
[DllImport(cimguiLib)]
public static extern bool igSliderFloat(string label, float* v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igSliderFloat(string label, ref float v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igSliderFloat2(string label, Vector2 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igSliderFloat3(string label, Vector3 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igSliderFloat4(string label, Vector4 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igSliderAngle(string label, float* v_rad, float v_degrees_min, float v_degrees_max);
[DllImport(cimguiLib)]
public static extern bool igSliderInt(string label, int* v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igSliderInt2(string label, Int2 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igSliderInt3(string label, Int3 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igSliderInt4(string label, Int4 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igVSliderFloat(string label, Vector2 size, float* v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igVSliderInt(string label, Vector2 size, int* v, int v_min, int v_max, string display_format);
// Widgets: Drags (tip: ctrl+click on a drag box to input text)
[DllImport(cimguiLib)]
public static extern bool igDragFloat(string label, float* v, float v_speed, float v_min, float v_max, string display_format, float power); // If v_max >= v_max we have no bound
[DllImport(cimguiLib)]
public static extern bool igDragFloat2(string label, Vector2 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igDragFloat3(string label, Vector3 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igDragFloat4(string label, Vector4 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
public static extern bool igDragFloatRange2(string label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, string display_format = "%.3f", string display_format_max = null, float power = 1.0f);
[DllImport(cimguiLib)]
public static extern bool igDragInt(string label, int* v, float v_speed, int v_min, int v_max, string display_format); // If v_max >= v_max we have no bound
[DllImport(cimguiLib)]
public static extern bool igDragInt2(string label, Int2 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igDragInt3(string label, Int3 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igDragInt4(string label, Int4 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
public static extern bool igDragIntRange2(string label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, string display_format = "%.0f", string display_format_max = null);
// Widgets: Input
[DllImport(cimguiLib)]
public static extern bool igInputText(string label, IntPtr buffer, uint buf_size, InputTextFlags flags, TextEditCallback callback, void* user_data);
[DllImport(cimguiLib)]
public static extern bool igInputTextMultiline(string label, IntPtr buffer, uint buf_size, Vector2 size, InputTextFlags flags, TextEditCallback callback, void* user_data);
[DllImport(cimguiLib)]
public static extern bool igInputFloat(string label, float* v, float step, float step_fast, int decimal_precision, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputFloat2(string label, Vector2 v, int decimal_precision, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputFloat3(string label, Vector3 v, int decimal_precision, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputFloat4(string label, Vector4 v, int decimal_precision, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputInt(string label, int* v, int step, int step_fast, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputInt2(string label, Int2 v, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputInt3(string label, Int3 v, InputTextFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igInputInt4(string label, Int4 v, InputTextFlags extra_flags);
// Widgets: Trees
[DllImport(cimguiLib)]
public static extern bool igTreeNode(string str_label_id);
[DllImport(cimguiLib)]
//public static extern bool igTreeNodeStr(string str_id, string fmt, ...);
public static extern bool igTreeNodeStr(string str_id, string fmt);
[DllImport(cimguiLib)]
//public static extern bool igTreeNodePtr(void* ptr_id, string fmt, ...);
public static extern bool igTreeNodePtr(void* ptr_id, string fmt);
/*
[DllImport(LibName)]
public static extern bool igTreeNodeStrV(string str_id, string fmt, va_list args);
[DllImport(LibName)]
public static extern bool igTreeNodePtrV(void* ptr_id, string fmt, va_list args);
*/
[DllImport(cimguiLib)]
public static extern void igTreePushStr(string str_id);
[DllImport(cimguiLib)]
public static extern void igTreePushPtr(void* ptr_id);
[DllImport(cimguiLib)]
public static extern void igTreePop();
[DllImport(cimguiLib)]
public static extern void igSetNextTreeNodeOpened(bool opened, SetCondition cond);
// Widgets: Selectable / Lists
[DllImport(cimguiLib)]
public static extern bool igSelectable(string label, bool selected, SelectableFlags flags, Vector2 size);
[DllImport(cimguiLib)]
public static extern bool igSelectableEx(string label, bool* p_selected, SelectableFlags flags, Vector2 size);
[DllImport(cimguiLib)]
public static extern bool igListBox(string label, int* current_item, char** items, int items_count, int height_in_items);
[DllImport(cimguiLib)]
public static extern bool igListBox2(string label, ref int currentItem, ItemSelectedCallback items_getter, IntPtr data, int items_count, int height_in_items);
[DllImport(cimguiLib)]
public static extern bool igListBoxHeader(string label, Vector2 size);
[DllImport(cimguiLib)]
public static extern bool igListBoxHeader2(string label, int items_count, int height_in_items);
[DllImport(cimguiLib)]
public static extern void igListBoxFooter();
// Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare your own within the ImGui namespace!)
[DllImport(cimguiLib)]
public static extern void igValueBool(string prefix, bool b);
[DllImport(cimguiLib)]
public static extern void igValueInt(string prefix, int v);
[DllImport(cimguiLib)]
public static extern void igValueUInt(string prefix, uint v);
[DllImport(cimguiLib)]
public static extern void igValueFloat(string prefix, float v, string float_format);
[DllImport(cimguiLib)]
public static extern void igColor(string prefix, Vector4 v);
[DllImport(cimguiLib)]
public static extern void igColor2(string prefix, uint v);
// Tooltip
[DllImport(cimguiLib)]
//public static extern void igSetTooltip(string fmt, ...);
public static extern void igSetTooltip(string fmt);
/*
[DllImport(LibName)]
public static extern void igSetTooltipV(string fmt, va_list args);
*/
[DllImport(cimguiLib)]
public static extern void igBeginTooltip();
[DllImport(cimguiLib)]
public static extern void igEndTooltip();
// Widgets: Menus
[DllImport(cimguiLib)]
public static extern bool igBeginMainMenuBar();
[DllImport(cimguiLib)]
public static extern void igEndMainMenuBar();
[DllImport(cimguiLib)]
public static extern bool igBeginMenuBar();
[DllImport(cimguiLib)]
public static extern void igEndMenuBar();
[DllImport(cimguiLib)]
public static extern bool igBeginMenu(string label);
[DllImport(cimguiLib)]
public static extern bool igBeginMenu(string label, bool enabled);
[DllImport(cimguiLib)]
public static extern void igEndMenu();
[DllImport(cimguiLib)]
public static extern bool igMenuItem(string label, string shortcut, bool selected, bool enabled);
[DllImport(cimguiLib)]
public static extern bool igMenuItemPtr(string label, string shortcut, bool* p_selected, bool enabled);
// Popup
[DllImport(cimguiLib)]
public static extern void igOpenPopup(string str_id);
[DllImport(cimguiLib)]
public static extern bool igBeginPopup(string str_id);
[DllImport(cimguiLib)]
public static extern bool igBeginPopupModal(string name, ref bool p_opened, WindowFlags extra_flags);
[DllImport(cimguiLib)]
public static extern bool igBeginPopupContextItem(string str_id, int mouse_button);
[DllImport(cimguiLib)]
public static extern bool igBeginPopupContextWindow(bool also_over_items, string str_id, int mouse_button);
[DllImport(cimguiLib)]
public static extern bool igBeginPopupContextVoid(string str_id, int mouse_button);
[DllImport(cimguiLib)]
public static extern void igEndPopup();
[DllImport(cimguiLib)]
public static extern void igCloseCurrentPopup();
// Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened.
[DllImport(cimguiLib)]
public static extern void igLogToTTY(int max_depth);
[DllImport(cimguiLib)]
public static extern void igLogToFile(int max_depth, string filename);
[DllImport(cimguiLib)]
public static extern void igLogToClipboard(int max_depth);
[DllImport(cimguiLib)]
public static extern void igLogFinish();
[DllImport(cimguiLib)]
public static extern void igLogButtons();
[DllImport(cimguiLib)]
//public static extern void igLogText(string fmt, ...);
public static extern void igLogText(string fmt);
// Utilities
[DllImport(cimguiLib)]
public static extern bool igIsItemHovered();
[DllImport(cimguiLib)]
public static extern bool igIsItemHoveredRect();
[DllImport(cimguiLib)]
public static extern bool igIsItemActive();
[DllImport(cimguiLib)]
public static extern bool igIsItemVisible();
[DllImport(cimguiLib)]
public static extern bool igIsAnyItemHovered();
[DllImport(cimguiLib)]
public static extern bool igIsAnyItemActive();
[DllImport(cimguiLib)]
public static extern void igGetItemRectMin(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igGetItemRectMax(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igGetItemRectSize(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern bool igIsWindowHovered();
[DllImport(cimguiLib)]
public static extern bool igIsWindowFocused();
[DllImport(cimguiLib)]
public static extern bool igIsRootWindowFocused();
[DllImport(cimguiLib)]
public static extern bool igIsRootWindowOrAnyChildFocused();
[DllImport(cimguiLib)]
public static extern bool igIsRectVisible(Vector2 item_size);
[DllImport(cimguiLib)]
public static extern bool igIsPosHoveringAnyWindow(Vector2 pos);
[DllImport(cimguiLib)]
public static extern float igGetTime();
[DllImport(cimguiLib)]
public static extern int igGetFrameCount();
[DllImport(cimguiLib)]
public static extern string igGetStyleColName(ColorTarget idx);
[DllImport(cimguiLib)]
public static extern void igCalcItemRectClosestPoint(Vector2* pOut, Vector2 pos, bool on_edge, float outward);
[DllImport(cimguiLib)]
public static extern void igCalcTextSize(Vector2* pOut, string text, string text_end, bool hide_text_after_double_hash, float wrap_width);
[DllImport(cimguiLib)]
public static extern void igCalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);
[DllImport(cimguiLib)]
public static extern bool igBeginChildFrame(uint id, Vector2 size, WindowFlags extra_flags);
[DllImport(cimguiLib)]
public static extern void igEndChildFrame();
[DllImport(cimguiLib)]
public static extern void igColorConvertU32ToFloat4(Vector4* pOut, uint @in);
[DllImport(cimguiLib)]
public static extern uint igColorConvertFloat4ToU32(Vector4 @in);
[DllImport(cimguiLib)]
public static extern void igColorConvertRGBtoHSV(float r, float g, float b, float* out_h, float* out_s, float* out_v);
[DllImport(cimguiLib)]
public static extern void igColorConvertHSVtoRGB(float h, float s, float v, float* out_r, float* out_g, float* out_b);
[DllImport(cimguiLib)]
public static extern bool igIsKeyDown(int key_index);
[DllImport(cimguiLib)]
public static extern bool igIsKeyPressed(int key_index, bool repeat);
[DllImport(cimguiLib)]
public static extern bool igIsKeyReleased(int key_index);
[DllImport(cimguiLib)]
public static extern bool igIsMouseDown(int button);
[DllImport(cimguiLib)]
public static extern bool igIsMouseClicked(int button, bool repeat);
[DllImport(cimguiLib)]
public static extern bool igIsMouseDoubleClicked(int button);
[DllImport(cimguiLib)]
public static extern bool igIsMouseReleased(int button);
[DllImport(cimguiLib)]
public static extern bool igIsMouseHoveringWindow();
[DllImport(cimguiLib)]
public static extern bool igIsMouseHoveringAnyWindow();
[DllImport(cimguiLib)]
public static extern bool igIsMouseHoveringRect(Vector2 pos_min, Vector2 pos_max, bool clip);
[DllImport(cimguiLib)]
public static extern bool igIsMouseDragging(int button, float lock_threshold);
[DllImport(cimguiLib)]
public static extern void igGetMousePos(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igGetMousePosOnOpeningCurrentPopup(Vector2* pOut);
[DllImport(cimguiLib)]
public static extern void igGetMouseDragDelta(Vector2* pOut, int button, float lock_threshold);
[DllImport(cimguiLib)]
public static extern void igResetMouseDragDelta(int button);
[DllImport(cimguiLib)]
public static extern MouseCursorKind igGetMouseCursor();
[DllImport(cimguiLib)]
public static extern void igSetMouseCursor(MouseCursorKind type);
[DllImport(cimguiLib)]
public static extern void igCaptureKeyboardFromApp();
[DllImport(cimguiLib)]
public static extern void igCaptureMouseFromApp();
// Helpers functions to access functions pointers @in ImGui::GetIO()
[DllImport(cimguiLib)]
public static extern void* igMemAlloc(uint sz);
[DllImport(cimguiLib)]
public static extern void igMemFree(void* ptr);
[DllImport(cimguiLib)]
public static extern string igGetClipboardText();
[DllImport(cimguiLib)]
public static extern void igSetClipboardText(string text);
// public state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
[DllImport(cimguiLib)]
public static extern string igGetVersion();
[DllImport(cimguiLib)]
public static extern void* igGetpublicState();
[DllImport(cimguiLib)]
public static extern uint igGetpublicStateSize();
[DllImport(cimguiLib)]
public static extern void igSetpublicState(void* state, bool construct);
[DllImport(cimguiLib)]
public static extern void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* 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);
[DllImport(cimguiLib)]
public static extern void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex);
[DllImport(cimguiLib)]
public static extern ImFont* ImFontAtlas_AddFont(ImFontAtlas* atlas, ref ImFontConfig 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); }
[DllImport(cimguiLib)]
public static extern ImFont* ImFontAtlas_AddFontFromFileTTF(ImFontAtlas* 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);
[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);
[DllImport(cimguiLib)]
public static extern ImFont* ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas* atlas, string compressed_ttf_data_base85, float size_pixels, ImFontConfig* font_cfg, char* glyph_ranges);
[DllImport(cimguiLib)]
public static extern void ImFontAtlas_ClearTexData(ImFontAtlas* atlas);
[DllImport(cimguiLib)]
public static extern void ImFontAtlas_Clear(ImFontAtlas* atlas);
[DllImport(cimguiLib)]
public static extern void ImGuiIO_AddInputCharacter(ushort c);
[DllImport(cimguiLib)]
public static extern void ImGuiIO_AddInputCharactersUTF8(string utf8_chars);
[DllImport(cimguiLib)]
public static extern int ImDrawList_GetVertexBufferSize(ImDrawList* list);
[DllImport(cimguiLib)]
public static extern ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n);
[DllImport(cimguiLib)]
public static extern int ImDrawList_GetIndexBufferSize(ImDrawList* list);
[DllImport(cimguiLib)]
public static extern ushort* ImDrawList_GetIndexPtr(ImDrawList* list, int n);
[DllImport(cimguiLib)]
public static extern int ImDrawList_GetCmdSize(ImDrawList* list);
[DllImport(cimguiLib)]
public static extern ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n);
[DllImport(cimguiLib)]
public static extern void ImDrawData_DeIndexAllBuffers(ImDrawData* drawData);
}
[StructLayout(LayoutKind.Sequential)]
public struct Int2
{
public readonly int X, Y;
}
[StructLayout(LayoutKind.Sequential)]
public struct Int3
{
public readonly int X, Y, Z;
}
[StructLayout(LayoutKind.Sequential)]
public struct Int4
{
public readonly int X, Y, Z, W;
}
public delegate bool ItemSelectedCallback(IntPtr data, int index, string out_text);
}

@ -0,0 +1,50 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Storage
{
/// <summary>
/// A vector of Storage.Pair values.
/// </summary>
public ImVector Data;
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Pair
{
public uint Key;
private OverlappedDataItem _overlappedData;
public float FloatData
{
get { return _overlappedData.FloatData; }
set { _overlappedData.FloatData = value; }
}
public int IntData
{
get { return _overlappedData.IntData; }
set { _overlappedData.IntData = value; }
}
public IntPtr PtrData
{
get { return _overlappedData.PtrData; }
set { _overlappedData.PtrData = value; }
}
}
[StructLayout(LayoutKind.Explicit)]
private unsafe struct OverlappedDataItem
{
[FieldOffset(0)]
public float FloatData;
[FieldOffset(0)]
public int IntData;
[FieldOffset(0)]
public IntPtr PtrData;
}
}
}

@ -0,0 +1,40 @@
using ImGuiAlign = System.Int32;
using System.Runtime.InteropServices;
using System.Numerics;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ImGuiStyle
{
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 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).
public Vector2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
public Vector2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
public Vector2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
public float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
public float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
public float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
public float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
public float ScrollbarRounding; // Radius of grab corners for scrollbar
public float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar
public float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
public Vector2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
public Vector2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
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();
*/
};
}

@ -0,0 +1,36 @@
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; }
*/
}
}

@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct ImVector
{
//[MarshalAs(UnmanagedType.SysInt)]
public int Size;
//[MarshalAs(UnmanagedType.SysInt)]
public int Capacity;
///<summary>T* Data</summary>
public void* Data;
}
}

@ -0,0 +1,74 @@
namespace ImGui
{
/// <summary>
/// Flags for ImGui.InputText()
/// </summary>
public enum InputTextFlags : int
{
Default = 0,
/// <summary>
/// Allow 0123456789.+-*/
/// </summary>
CharsDecimal = 1 << 0,
/// <summary>
/// Allow 0123456789ABCDEFabcdef
/// </summary>
CharsHexadecimal = 1 << 1,
/// <summary>
/// Turn a..z into A..Z
/// </summary>
CharsUppercase = 1 << 2,
/// <summary>
/// Filter out spaces, tabs
/// </summary>
CharsNoBlank = 1 << 3,
/// <summary>
/// Select entire text when first taking mouse focus
/// </summary>
AutoSelectAll = 1 << 4,
/// <summary>
/// Return 'true' when Enter is pressed (as opposed to when the value was modified)
/// </summary>
EnterReturnsTrue = 1 << 5,
/// <summary>
/// Call user function on pressing TAB (for completion handling)
/// </summary>
CallbackCompletion = 1 << 6,
/// <summary>
/// Call user function on pressing Up/Down arrows (for history handling)
/// </summary>
CallbackHistory = 1 << 7,
/// <summary>
/// Call user function every time
/// </summary>
CallbackAlways = 1 << 8,
/// <summary>
/// Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
/// </summary>
CallbackCharFilter = 1 << 9,
/// <summary>
/// Pressing TAB input a '\t' character into the text field
/// </summary>
AllowTabInput = 1 << 10,
/// <summary>
/// In multi-line mode, allow exiting edition by pressing Enter. Ctrl+Enter to add new line (by default adds new lines with Enter).
/// </summary>
CtrlEnterForNewLine = 1 << 11,
/// <summary>
/// Disable following the cursor horizontally
/// </summary>
NoHorizontalScroll = 1 << 12,
/// <summary>
/// Insert mode
/// </summary>
AlwaysInsertMode = 1 << 13,
/// <summary>
/// Read-only mode
/// </summary>
ReadOnly = 1 << 14,
/// <summary>
/// For internal use by InputTextMultiline()
/// </summary>
Multiline = 1 << 20
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{
/// <summary>
/// Enumeration for GetMouseCursor()
/// </summary>
public enum MouseCursorKind
{
Arrow = 0,
/// <summary>
/// When hovering over InputText, etc.
/// </summary>
TextInput,
/// <summary>
/// Unused
/// </summary>
Move,
/// <summary>
/// Unused
/// </summary>
ResizeNS,
/// <summary>
/// When hovering over a column
/// </summary>
ResizeEW,
/// <summary>
/// Unused
/// </summary>
ResizeNESW,
/// <summary>
/// When hovering over the bottom-right corner of a window
/// </summary>
ResizeNWSE,
}
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{
/// <summary>
/// Flags for ImGui::Selectable()
/// </summary>
public enum SelectableFlags
{
// Default: 0
Default = 0,
/// <summary>
/// Clicking this doesn't close parent popup window
/// </summary>
DontClosePopups = 1 << 0,
/// <summary>
/// Selectable frame can span all columns (text will still fit in current column)
/// </summary>
SpanAllColumns = 1 << 1
}
}

@ -0,0 +1,26 @@
namespace ImGui
{
/// <summary>
/// Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions.
/// All those functions treat 0 as a shortcut to Always.
/// </summary>
public enum SetCondition
{
/// <summary>
/// Set the variable.
/// </summary>
Always = 1 << 0,
/// <summary>
/// Only set the variable on the first call per runtime session
/// </summary>
Once = 1 << 1,
/// <summary>
/// Only set the variable if the window doesn't exist in the .ini file
/// </summary>
FirstUseEver = 1 << 2,
/// <summary>
/// Only set the variable if the window is appearing after being inactive (or the first time)
/// </summary>
Appearing = 1 << 3
}
}

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImGui
{
/// <summary>
/// Enumeration for PushStyleVar() / PopStyleVar()
/// NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
/// </summary>
public enum StyleVar
{
/// <summary>
/// float
/// </summary>
Alpha,
/// <summary>
/// System.Numerics.Vector2
/// </summary>
WindowPadding,
/// <summary>
/// float
/// </summary>
WindowRounding,
/// <summary>
/// System.Numerics.Vector2
/// </summary>
WindowMinSize,
/// <summary>
/// float
/// </summary>
ChildWindowRounding,
/// <summary>
/// System.Numerics.Vector2
/// </summary>
FramePadding,
/// <summary>
/// float
/// </summary>
FrameRounding,
/// <summary>
/// System.Numerics.Vector2
/// </summary>
ItemSpacing,
/// <summary>
/// System.Numerics.Vector2
/// </summary>
ItemInnerSpacing,
/// <summary>
/// float
/// </summary>
IndentSpacing,
/// <summary>
/// float
/// </summary>
GrabMinSize
};
}

@ -0,0 +1,4 @@
namespace ImGui
{
public unsafe delegate int TextEditCallback(TextEditCallbackData* data);
}

@ -0,0 +1,63 @@
using System;
using System.Runtime.InteropServices;
namespace ImGui
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct TextEditCallbackData
{
/// <summary>
/// One of InputTextFlags.*. Read-only.
/// </summary>
public InputTextFlags EventFlag;
/// <summary>
/// What user passed to InputText(). Read-only.
/// </summary>
public InputTextFlags Flags;
/// <summary>
/// What user passed to InputText(). Read-only.
/// </summary>
public IntPtr UserData;
private byte _ReadOnly;
/// <summary>
/// Read-only mode. Read-only.
/// </summary>
public bool ReadOnly { get { return _ReadOnly == 1; } }
// CharFilter event:
/// <summary>
/// Character input. Read-write (replace character or set to zero).
/// </summary>
public ushort EventChar;
// Completion,History,Always events:
/// <summary>
/// Key pressed (Up/Down/Tab). Read-only.
/// </summary>
public GuiKey EventKey;
/// <summary>
/// Current text. Read-write (pointed data only). char* in native code.
/// </summary>
public IntPtr Buf;
/// <summary>
/// Read-only.
/// </summary>
public int BufSize;
/// <summary>
/// Must set if you modify Buf directly. Write-only.
/// </summary>
public byte BufDirty;
/// <summary>
/// Read-write.
/// </summary>
public int CursorPos;
/// <summary>
/// Read-write. (Equal to SelectionEnd when no selection)
/// </summary>
public int SelectionStart;
/// <summary>
/// Read-write.
/// </summary>
public int SelectionEnd;
}
}

@ -0,0 +1,67 @@
namespace ImGui
{
/// <summary>
/// Flags for ImGui::Begin()
/// </summary>
public enum WindowFlags : int
{
Default = 0,
/// <summary>
/// Disable title-bar
/// </summary>
NoTitleBar = 1 << 0,
/// <summary>
/// Disable user resizing with the lower-right grip
/// </summary>
NoResize = 1 << 1,
/// <summary>
/// Disable user moving the window
/// </summary>
NoMove = 1 << 2,
/// <summary>
/// Disable scrollbar (window can still scroll with mouse or programatically)
/// </summary>
NoScrollbar = 1 << 3,
/// <summary>
/// Disable user scrolling with mouse wheel
/// </summary>
NoScrollWithMouse = 1 << 4,
/// <summary>
/// Disable user collapsing window by double-clicking on it
/// </summary>
NoCollapse = 1 << 5,
/// <summary>
/// Resize every window to its content every frame
/// </summary>
AlwaysAutoResize = 1 << 6,
/// <summary>
/// Show borders around windows and items
/// </summary>
ShowBorders = 1 << 7,
/// <summary>
/// Never load/save settings in .ini file
/// </summary>
NoSavedSettings = 1 << 8,
/// <summary>
/// Disable catching mouse or keyboard inputs
/// </summary>
NoInputs = 1 << 9,
/// <summary>
/// Has a menu-bar
/// </summary>
MenuBar = 1 << 10,
/// <summary>
/// Enable horizontal scrollbar (off by default).
/// You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width.
/// </summary>
HorizontalScrollbar = 1 << 11,
/// <summary>
/// Disable taking focus when transitioning from hidden to visible state
/// </summary>
NoFocusOnAppearing = 1 << 12,
/// <summary>
/// Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
/// </summary>
NoBringToFrontOnFocus = 1 << 13,
}
}

@ -0,0 +1,13 @@
{
"dependencies": {
"Microsoft.NETCore.Console": "1.0.0-beta-23413",
"System.Console": "4.0.0-beta-23427"
},
"runtimes": {
"win10-x64": { },
"ubuntu.14.04-x64": { },
},
"frameworks": {
"dnxcore50": { }
}
}
Loading…
Cancel
Save