diff --git a/src/ImGui.NET.SampleProgram/SampleWindow.cs b/src/ImGui.NET.SampleProgram/SampleWindow.cs
index 76b8154..a47c1e4 100644
--- a/src/ImGui.NET.SampleProgram/SampleWindow.cs
+++ b/src/ImGui.NET.SampleProgram/SampleWindow.cs
@@ -217,7 +217,7 @@ namespace ImGuiNET
_pressCount += 1;
}
- ImGui.TextColored(new System.Numerics.Vector4(0, 1, 1, 1), $"Button pressed {_pressCount} times.");
+ ImGui.Text($"Button pressed {_pressCount} times.", new System.Numerics.Vector4(0, 1, 1, 1));
ImGui.InputTextMultiline("Input some text:",
_textInputBuffer, (uint)_textInputBufferLength,
diff --git a/src/ImGui.NET/IO.cs b/src/ImGui.NET/IO.cs
index 6d235aa..cfed8d0 100644
--- a/src/ImGui.NET/IO.cs
+++ b/src/ImGui.NET/IO.cs
@@ -19,61 +19,101 @@ namespace ImGuiNET
public NativeIO* GetNativePointer() => _nativePtr;
+ ///
+ /// Display size, in pixels. For clamping windows positions.
+ /// Default value: [unset]
+ ///
+ public Vector2 DisplaySize
+ {
+ get { return _nativePtr->DisplaySize; }
+ set { _nativePtr->DisplaySize = value; }
+ }
+
+ ///
+ /// Time elapsed since last frame, in seconds.
+ /// Default value: 1.0f / 10.0f.
+ ///
public float DeltaTime
{
get { return _nativePtr->DeltaTime; }
set { _nativePtr->DeltaTime = value; }
}
+ ///
+ /// For retina display or other situations where window coordinates are different from framebuffer coordinates.
+ /// User storage only, presently not used by ImGui.
+ /// Default value: (1.0f, 1.0f).
+ ///
public Vector2 DisplayFramebufferScale
{
get { return _nativePtr->DisplayFramebufferScale; }
set { _nativePtr->DisplayFramebufferScale = value; }
}
- public Vector2 DisplaySize
- {
- get { return _nativePtr->DisplaySize; }
- set { _nativePtr->DisplaySize = value; }
- }
-
+ ///
+ /// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.).
+ ///
public Vector2 MousePosition
{
get { return _nativePtr->MousePos; }
set { _nativePtr->MousePos = value; }
}
+ ///
+ /// Mouse wheel: 1 unit scrolls about 5 lines text.
+ ///
public float MouseWheel
{
get { return _nativePtr->MouseWheel; }
set { _nativePtr->MouseWheel = value; }
}
+ ///
+ /// 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 MouseDownStates MouseDown { get; }
+ ///
+ /// Map of indices into the KeysDown[512] entries array.
+ /// Default values: [unset]
+ ///
public KeyMap KeyMap { get; }
+ ///
+ /// Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
+ ///
public KeyDownStates KeysDown { get; }
public FontAtlasWrapped FontAtlas { get; }
- public bool AltPressed
- {
- get { return _nativePtr->KeyAlt == 1; }
- set { _nativePtr->KeyAlt = value ? (byte)1 : (byte)0; }
- }
-
+ ///
+ /// Keyboard modifier pressed: Control.
+ ///
public bool CtrlPressed
{
get { return _nativePtr->KeyCtrl == 1; }
set { _nativePtr->KeyCtrl = value ? (byte)1 : (byte)0; }
}
+ ///
+ /// Keyboard modifier pressed: Shift
+ ///
public bool ShiftPressed
{
get { return _nativePtr->KeyShift == 1; }
set { _nativePtr->KeyShift = value ? (byte)1 : (byte)0; }
}
+
+ ///
+ /// Keyboard modifier pressed: Alt
+ ///
+ public bool AltPressed
+ {
+ get { return _nativePtr->KeyAlt == 1; }
+ set { _nativePtr->KeyAlt = value ? (byte)1 : (byte)0; }
+ }
}
public unsafe class KeyMap
diff --git a/src/ImGui.NET/ImGui.NET.Net46.csproj b/src/ImGui.NET/ImGui.NET.Net46.csproj
index 89ab06f..9fcb15d 100644
--- a/src/ImGui.NET/ImGui.NET.Net46.csproj
+++ b/src/ImGui.NET/ImGui.NET.Net46.csproj
@@ -15,10 +15,12 @@
+
+
@@ -32,7 +34,7 @@
-
+
diff --git a/src/ImGui.NET/ImGui.NET.csproj b/src/ImGui.NET/ImGui.NET.csproj
index 2f407e3..c7312b8 100644
--- a/src/ImGui.NET/ImGui.NET.csproj
+++ b/src/ImGui.NET/ImGui.NET.csproj
@@ -12,10 +12,12 @@
+
+
@@ -30,7 +32,7 @@
-
+
diff --git a/src/ImGui.NET/ImGui.cs b/src/ImGui.NET/ImGui.cs
index f6d2f92..96ec2e9 100644
--- a/src/ImGui.NET/ImGui.cs
+++ b/src/ImGui.NET/ImGui.cs
@@ -16,13 +16,18 @@ namespace ImGuiNET
ImGuiNative.igRender();
}
+ public static void Shutdown()
+ {
+ ImGuiNative.igShutdown();
+ }
+
private static unsafe readonly IO s_io = new IO(ImGuiNative.igGetIO());
public static unsafe IO GetIO() => s_io;
- private static unsafe readonly StyleWrapped s_style = new StyleWrapped(ImGuiNative.igGetStyle());
+ private static unsafe readonly Style s_style = new Style(ImGuiNative.igGetStyle());
- public static unsafe StyleWrapped GetStyle()
+ public static unsafe Style GetStyle()
{
return s_style;
}
@@ -33,14 +38,44 @@ namespace ImGuiNET
ImGuiNative.ImFontAtlas_AddFontDefault(ioPtr->FontAtlas);
}
+ public static void PushID(string id)
+ {
+ ImGuiNative.igPushIdStr(id);
+ }
+
+ public static void PushID(int id)
+ {
+ ImGuiNative.igPushIdInt(id);
+ }
+
+ public static void PushIDRange(string idBegin, string idEnd)
+ {
+ ImGuiNative.igPushIdStrRange(idBegin, idEnd);
+ }
+
+ public static void PopID()
+ {
+ ImGuiNative.igPopId();
+ }
+
+ public static uint GetID(string id)
+ {
+ return ImGuiNative.igGetIdStr(id);
+ }
+
+ public static uint GetID(string idBegin, string idEnd)
+ {
+ return ImGuiNative.igGetIdStrRange(idBegin, idEnd);
+ }
+
public static void Text(string message)
{
ImGuiNative.igText(message);
}
- public static void TextColored(Vector4 colorRGBA, string text)
+ public static void Text(string message, Vector4 color)
{
- ImGuiNative.igTextColored(colorRGBA, text);
+ ImGuiNative.igTextColored(color, message);
}
public static void TextDisabled(string text)
@@ -178,19 +213,124 @@ namespace ImGuiNET
}
}
- public static void PushId(string id)
+ public static bool SliderFloat(string sliderLabel, ref float value, float min, float max, string displayText, float power)
{
- ImGuiNative.igPushIdStr(id);
+ return ImGuiNative.igSliderFloat(sliderLabel, ref value, min, max, displayText, power);
}
- public static void PopId()
+ public static bool SliderVector2(string label, ref Vector2 value, float min, float max, string displayText, float power)
{
- ImGuiNative.igPopId();
+ return ImGuiNative.igSliderFloat2(label, ref value, min, max, displayText, power);
}
- public static void Text(string message, Vector4 color)
+ public static bool SliderVector3(string label, ref Vector3 value, float min, float max, string displayText, float power)
{
- ImGuiNative.igTextColored(color, message);
+ return ImGuiNative.igSliderFloat3(label, ref value, min, max, displayText, power);
+ }
+
+ public static bool SliderVector4(string label, ref Vector4 value, float min, float max, string displayText, float power)
+ {
+ return ImGuiNative.igSliderFloat4(label, ref value, min, max, displayText, power);
+ }
+
+ public static bool SliderAngle(string label, ref float radians, float minDegrees, float maxDegrees)
+ {
+ return ImGuiNative.igSliderAngle(label, ref radians, minDegrees, maxDegrees);
+ }
+
+ public static bool SliderInt(string sliderLabel, ref int value, int min, int max, string displayText)
+ {
+ return ImGuiNative.igSliderInt(sliderLabel, ref value, min, max, displayText);
+ }
+
+ public static bool SliderInt2(string label, ref Int2 value, int min, int max, string displayText)
+ {
+ return ImGuiNative.igSliderInt2(label, ref value, min, max, displayText);
+ }
+
+ public static bool SliderInt3(string label, ref Int3 value, int min, int max, string displayText)
+ {
+ return ImGuiNative.igSliderInt3(label, ref value, min, max, displayText);
+ }
+
+ public static bool SliderInt4(string label, ref Int4 value, int min, int max, string displayText)
+ {
+ return ImGuiNative.igSliderInt4(label, ref value, min, max, displayText);
+ }
+
+ public static void DragFloat(string label, ref float value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
+ {
+ ImGuiNative.igDragFloat(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
+ }
+
+ public static void DragVector2(string label, ref Vector2 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
+ {
+ ImGuiNative.igDragFloat2(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
+ }
+
+ public static void DragVector3(string label, ref Vector3 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
+ {
+ ImGuiNative.igDragFloat3(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
+ }
+
+ public static void DragVector4(string label, ref Vector4 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
+ {
+ ImGuiNative.igDragFloat4(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
+ }
+
+ public static bool DragFloatRange2(
+ string label,
+ ref float currentMinValue,
+ ref float currentMaxValue,
+ float speed = 1.0f,
+ float minValueLimit = 0.0f,
+ float maxValueLimit = 0.0f,
+ string displayFormat = "%.3f",
+ string displayFormatMax = null,
+ float power = 1.0f)
+ {
+ return ImGuiNative.igDragFloatRange2(label, ref currentMinValue, ref currentMaxValue, speed, minValueLimit, maxValueLimit, displayFormat, displayFormatMax, power);
+ }
+
+ public static bool DragInt(string label, ref int value, float speed, int minValue, int maxValue, string displayText)
+ {
+ return ImGuiNative.igDragInt(label, ref value, speed, minValue, maxValue, displayText);
+ }
+
+ public static bool DragInt2(string label, ref Int2 value, float speed, int minValue, int maxValue, string displayText)
+ {
+ return ImGuiNative.igDragInt2(label, ref value, speed, minValue, maxValue, displayText);
+ }
+
+ public static bool DragInt3(string label, ref Int3 value, float speed, int minValue, int maxValue, string displayText)
+ {
+ return ImGuiNative.igDragInt3(label, ref value, speed, minValue, maxValue, displayText);
+ }
+
+ public static bool DragInt4(string label, ref Int4 value, float speed, int minValue, int maxValue, string displayText)
+ {
+ return ImGuiNative.igDragInt4(label, ref value, speed, minValue, maxValue, displayText);
+ }
+
+ public static bool DragIntRange2(
+ string label,
+ ref int currentMinValue,
+ ref int currentMaxValue,
+ float speed = 1.0f,
+ int minLimit = 0,
+ int maxLimit = 0,
+ string displayFormat = "%.0f",
+ string displayFormatMax = null)
+ {
+ return ImGuiNative.igDragIntRange2(
+ label,
+ ref currentMinValue,
+ ref currentMaxValue,
+ speed,
+ minLimit,
+ maxLimit,
+ displayFormat,
+ displayFormatMax);
}
public static bool Button(string message)
@@ -393,6 +533,44 @@ namespace ImGuiNET
ImGuiNative.igEndChild();
}
+ public static Vector2 GetContentRegionMax()
+ {
+ Vector2 value;
+ ImGuiNative.igGetContentRegionMax(out value);
+ return value;
+ }
+
+ public static Vector2 GetContentRegionAvailable()
+ {
+ Vector2 value;
+ ImGuiNative.igGetContentRegionAvail(out value);
+ return value;
+ }
+
+ public static float GetContentRegionAvailableWidth()
+ {
+ return ImGuiNative.igGetContentRegionAvailWidth();
+ }
+
+ public static Vector2 GetWindowContentRegionMin()
+ {
+ Vector2 value;
+ ImGuiNative.igGetWindowContentRegionMin(out value);
+ return value;
+ }
+
+ public static Vector2 GetWindowContentRegionMax()
+ {
+ Vector2 value;
+ ImGuiNative.igGetWindowContentRegionMax(out value);
+ return value;
+ }
+
+ public static float GetWindowContentRegionWidth()
+ {
+ return ImGuiNative.igGetWindowContentRegionWidth();
+ }
+
public static bool Selectable(string label)
{
return Selectable(label, false);
@@ -483,31 +661,6 @@ namespace ImGuiNET
ImGuiNative.igOpenPopup(id);
}
- public static void SliderFloat(string sliderLabel, ref float value, float min, float max, string displayText, float power)
- {
- ImGuiNative.igSliderFloat(sliderLabel, ref value, min, max, displayText, power);
- }
-
- public static void DragFloat(string label, ref float value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
- {
- ImGuiNative.igDragFloat(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
- }
-
- public static void DragVector2(string label, ref Vector2 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
- {
- ImGuiNative.igDragFloat2(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
- }
-
- public static void DragVector3(string label, ref Vector3 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
- {
- ImGuiNative.igDragFloat3(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
- }
-
- public static void DragVector4(string label, ref Vector4 value, float min, float max, float dragSpeed = 1f, string displayFormat = "%f", float dragPower = 1f)
- {
- ImGuiNative.igDragFloat4(label, ref value, dragSpeed, min, max, displayFormat, dragPower);
- }
-
public static void SameLine()
{
ImGuiNative.igSameLine(0, 0);
@@ -550,20 +703,4 @@ namespace ImGuiNET
return result;
}
}
-
- public unsafe class StyleWrapped
- {
- private readonly Style* _stylePtr;
-
- public StyleWrapped(Style* style)
- {
- _stylePtr = style;
- }
-
- public float WindowRounding
- {
- get { return _stylePtr->WindowRounding; }
- set { _stylePtr->WindowRounding = value; }
- }
- }
}
diff --git a/src/ImGui.NET/ImGuiNative.cs b/src/ImGui.NET/ImGuiNative.cs
index 962d16e..c1d9c2b 100644
--- a/src/ImGui.NET/ImGuiNative.cs
+++ b/src/ImGui.NET/ImGuiNative.cs
@@ -12,10 +12,10 @@ namespace ImGuiNET
private const string cimguiLib = "cimgui";
[DllImport(cimguiLib)]
- public static extern NativeIO* igGetIO(); /* { return (IO*)igGetIO_Raw().ToPointer(); } */
+ public static extern NativeIO* igGetIO();
[DllImport(cimguiLib)]
- public static extern Style* igGetStyle();
+ public static extern NativeStyle* igGetStyle();
[DllImport(cimguiLib)]
public static extern DrawData* igGetDrawData();
@@ -29,7 +29,7 @@ namespace ImGuiNET
[DllImport(cimguiLib)]
public static extern void igShowUserGuide();
[DllImport(cimguiLib)]
- public static extern void igShowStyleEditor(ref Style @ref);
+ public static extern void igShowStyleEditor(ref NativeStyle @ref);
[DllImport(cimguiLib)]
public static extern void igShowTestWindow(ref bool opened);
@@ -53,19 +53,21 @@ namespace ImGuiNET
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 DrawList* igGetWindowDrawList();
[DllImport(cimguiLib)]
@@ -354,28 +356,28 @@ namespace ImGuiNET
public static extern bool igSliderFloat(string label, ref float v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderFloat2(string label, Vector2 v, float v_min, float v_max, string display_format, float power);
+ public static extern bool igSliderFloat2(string label, ref Vector2 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderFloat3(string label, Vector3 v, float v_min, float v_max, string display_format, float power);
+ public static extern bool igSliderFloat3(string label, ref Vector3 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderFloat4(string label, Vector4 v, float v_min, float v_max, string display_format, float power);
+ public static extern bool igSliderFloat4(string label, ref Vector4 v, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderAngle(string label, float* v_rad, float v_degrees_min, float v_degrees_max);
+ public static extern bool igSliderAngle(string label, ref float v_rad, float v_degrees_min, float v_degrees_max);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderInt(string label, int* v, int v_min, int v_max, string display_format);
+ public static extern bool igSliderInt(string label, ref int v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderInt2(string label, Int2 v, int v_min, int v_max, string display_format);
+ public static extern bool igSliderInt2(string label, ref Int2 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderInt3(string label, Int3 v, int v_min, int v_max, string display_format);
+ public static extern bool igSliderInt3(string label, ref Int3 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igSliderInt4(string label, Int4 v, int v_min, int v_max, string display_format);
+ public static extern bool igSliderInt4(string label, ref Int4 v, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool igVSliderFloat(string label, Vector2 size, float* v, float v_min, float v_max, string display_format, float power);
@@ -398,22 +400,22 @@ namespace ImGuiNET
public static extern bool igDragFloat4(string label, ref Vector4 v, float v_speed, float v_min, float v_max, string display_format, float power);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- 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);
+ public static extern bool igDragFloatRange2(string label, ref float v_current_min, ref 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)]
[return: MarshalAs(UnmanagedType.I1)]
- 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
+ public static extern bool igDragInt(string label, ref 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)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igDragInt2(string label, Int2 v, float v_speed, int v_min, int v_max, string display_format);
+ public static extern bool igDragInt2(string label, ref Int2 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igDragInt3(string label, Int3 v, float v_speed, int v_min, int v_max, string display_format);
+ public static extern bool igDragInt3(string label, ref Int3 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern bool igDragInt4(string label, Int4 v, float v_speed, int v_min, int v_max, string display_format);
+ public static extern bool igDragInt4(string label, ref Int4 v, float v_speed, int v_min, int v_max, string display_format);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
- 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);
+ public static extern bool igDragIntRange2(string label, ref int v_current_min, ref 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
@@ -549,7 +551,7 @@ namespace ImGuiNET
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool igBeginPopup(string str_id);
[DllImport(cimguiLib)]
- [return:MarshalAs(UnmanagedType.I1)]
+ [return: MarshalAs(UnmanagedType.I1)]
public static extern bool igBeginPopupModal(string name, byte* p_opened, WindowFlags extra_flags);
public static bool igBeginPopupModal(string name, WindowFlags extra_flags)
@@ -567,7 +569,7 @@ namespace ImGuiNET
}
[DllImport(cimguiLib)]
- [return:MarshalAs(UnmanagedType.I1)]
+ [return: MarshalAs(UnmanagedType.I1)]
public static extern bool igBeginPopupContextItem(string str_id, int mouse_button);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
@@ -790,23 +792,5 @@ namespace ImGuiNET
public static extern void ImDrawData_DeIndexAllBuffers(DrawData* 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);
}
diff --git a/src/ImGui.NET/IntStructs.cs b/src/ImGui.NET/IntStructs.cs
new file mode 100644
index 0000000..263cf58
--- /dev/null
+++ b/src/ImGui.NET/IntStructs.cs
@@ -0,0 +1,22 @@
+using System.Runtime.InteropServices;
+
+namespace ImGuiNET
+{
+ [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;
+ }
+}
diff --git a/src/ImGui.NET/NativeStyle.cs b/src/ImGui.NET/NativeStyle.cs
new file mode 100644
index 0000000..112b122
--- /dev/null
+++ b/src/ImGui.NET/NativeStyle.cs
@@ -0,0 +1,103 @@
+using System.Runtime.InteropServices;
+using System.Numerics;
+
+namespace ImGuiNET
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct NativeStyle
+ {
+ ///
+ /// Global alpha applies to everything in ImGui.
+ ///
+ public float Alpha;
+ ///
+ /// Padding within a window.
+ ///
+ public Vector2 WindowPadding;
+ ///
+ /// Minimum window size.
+ ///
+ public Vector2 WindowMinSize;
+ ///
+ /// Radius of window corners rounding. Set to 0.0f to have rectangular windows.
+ ///
+ public float WindowRounding;
+ ///
+ /// Alignment for title bar text.
+ ///
+ public Align WindowTitleAlign;
+ ///
+ /// Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
+ ///
+ public float ChildWindowRounding;
+ ///
+ /// Padding within a framed rectangle (used by most widgets).
+ ///
+ public Vector2 FramePadding;
+ ///
+ /// Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
+ ///
+ public float FrameRounding;
+ ///
+ /// Horizontal and vertical spacing between widgets/lines.
+ ///
+ public Vector2 ItemSpacing;
+ ///
+ /// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
+ ///
+ public Vector2 ItemInnerSpacing;
+ ///
+ /// 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 Vector2 TouchExtraPadding;
+ ///
+ /// Default alpha of window background, if not specified in ImGui::Begin().
+ ///
+ public float WindowFillAlphaDefault;
+ ///
+ /// Horizontal indentation when e.g. entering a tree node
+ ///
+ public float IndentSpacing;
+ ///
+ /// Minimum horizontal spacing between two columns
+ ///
+ public float ColumnsMinSpacing;
+ ///
+ /// Width of the vertical scrollbar, Height of the horizontal scrollbar
+ ///
+ public float ScrollbarSize;
+ ///
+ /// Radius of grab corners for scrollbar
+ ///
+ public float ScrollbarRounding;
+ ///
+ /// Minimum width/height of a grab box for slider/scrollbar
+ ///
+ public float GrabMinSize;
+ ///
+ /// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
+ ///
+ public float GrabRounding;
+ ///
+ /// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
+ ///
+ public Vector2 DisplayWindowPadding;
+ ///
+ /// 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 Vector2 DisplaySafeAreaPadding;
+ ///
+ /// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
+ ///
+ public byte AntiAliasedLines;
+ ///
+ /// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
+ ///
+ public byte AntiAliasedShapes;
+ ///
+ /// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
+ ///
+ public float CurveTessellationTol;
+ public fixed float Colors[(int)ColorTarget.Count * 4];
+ };
+}
diff --git a/src/ImGui.NET/Style.cs b/src/ImGui.NET/Style.cs
index 9ffabcd..9d922b3 100644
--- a/src/ImGui.NET/Style.cs
+++ b/src/ImGui.NET/Style.cs
@@ -1,103 +1,235 @@
-using System.Runtime.InteropServices;
-using System.Numerics;
+using System.Numerics;
namespace ImGuiNET
{
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct Style
+ public unsafe class Style
{
+ private readonly NativeStyle* _stylePtr;
+
+ public Style(NativeStyle* style)
+ {
+ _stylePtr = style;
+ }
+
///
/// Global alpha applies to everything in ImGui.
///
- public float Alpha;
+ public float Alpha
+ {
+ get { return _stylePtr->Alpha; }
+ set { _stylePtr->Alpha = value; }
+ }
+
///
/// Padding within a window.
///
- public Vector2 WindowPadding;
+ public Vector2 WindowPadding
+ {
+ get { return _stylePtr->WindowPadding; }
+ set { _stylePtr->WindowPadding = value; }
+ }
+
///
/// Minimum window size.
///
- public Vector2 WindowMinSize;
+ public Vector2 WindowMinSize
+ {
+ get { return _stylePtr->WindowMinSize; }
+ set { _stylePtr->WindowMinSize = value; }
+ }
+
///
/// Radius of window corners rounding. Set to 0.0f to have rectangular windows.
///
- public float WindowRounding;
+ public float WindowRounding
+ {
+ get { return _stylePtr->WindowRounding; }
+ set { _stylePtr->WindowRounding = value; }
+ }
+
///
/// Alignment for title bar text.
///
- public Align WindowTitleAlign;
+ public Align WindowTitleAlign
+ {
+ get { return _stylePtr->WindowTitleAlign; }
+ set { _stylePtr->WindowTitleAlign = value; }
+ }
+
///
/// Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
///
- public float ChildWindowRounding;
+ public float ChildWindowRounding
+ {
+ get { return _stylePtr->ChildWindowRounding; }
+ set { _stylePtr->ChildWindowRounding = value; }
+ }
+
///
/// Padding within a framed rectangle (used by most widgets).
///
- public Vector2 FramePadding;
+ public Vector2 FramePadding
+ {
+ get { return _stylePtr->FramePadding; }
+ set { _stylePtr->FramePadding = value; }
+ }
+
///
/// Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
///
- public float FrameRounding;
+ public float FrameRounding
+ {
+ get { return _stylePtr->FrameRounding; }
+ set { _stylePtr->FrameRounding = value; }
+ }
+
///
/// Horizontal and vertical spacing between widgets/lines.
///
- public Vector2 ItemSpacing;
+ public Vector2 ItemSpacing
+ {
+ get { return _stylePtr->ItemSpacing; }
+ set { _stylePtr->ItemSpacing = value; }
+ }
+
///
/// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
///
- public Vector2 ItemInnerSpacing;
+ public Vector2 ItemInnerSpacing
+ {
+ get { return _stylePtr->ItemInnerSpacing; }
+ set { _stylePtr->ItemInnerSpacing = value; }
+ }
+
///
/// 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 Vector2 TouchExtraPadding;
+ public Vector2 TouchExtraPadding
+ {
+ get { return _stylePtr->TouchExtraPadding; }
+ set { _stylePtr->TouchExtraPadding = value; }
+ }
+
///
/// Default alpha of window background, if not specified in ImGui::Begin().
///
- public float WindowFillAlphaDefault;
+ public float WindowFillAlphaDefault
+ {
+ get { return _stylePtr->WindowFillAlphaDefault; }
+ set { _stylePtr->WindowFillAlphaDefault = value; }
+ }
+
///
/// Horizontal indentation when e.g. entering a tree node
///
- public float IndentSpacing;
+ public float IndentSpacing
+ {
+ get { return _stylePtr->IndentSpacing; }
+ set { _stylePtr->IndentSpacing = value; }
+ }
+
///
/// Minimum horizontal spacing between two columns
///
- public float ColumnsMinSpacing;
+ public float ColumnsMinSpacing
+ {
+ get { return _stylePtr->ColumnsMinSpacing; }
+ set { _stylePtr->ColumnsMinSpacing = value; }
+ }
+
///
/// Width of the vertical scrollbar, Height of the horizontal scrollbar
///
- public float ScrollbarSize;
+ public float ScrollbarSize
+ {
+ get { return _stylePtr->ScrollbarSize; }
+ set { _stylePtr->ScrollbarSize = value; }
+ }
+
///
/// Radius of grab corners for scrollbar
///
- public float ScrollbarRounding;
+ public float ScrollbarRounding
+ {
+ get { return _stylePtr->ScrollbarRounding; }
+ set { _stylePtr->ScrollbarRounding = value; }
+ }
+
///
/// Minimum width/height of a grab box for slider/scrollbar
///
- public float GrabMinSize;
+ public float GrabMinSize
+ {
+ get { return _stylePtr->GrabMinSize; }
+ set { _stylePtr->GrabMinSize = value; }
+ }
+
///
/// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
///
- public float GrabRounding;
+ public float GrabRounding
+ {
+ get { return _stylePtr->GrabRounding; }
+ set { _stylePtr->GrabRounding = value; }
+ }
+
///
/// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
///
- public Vector2 DisplayWindowPadding;
+ public Vector2 DisplayWindowPadding
+ {
+ get { return _stylePtr->DisplayWindowPadding; }
+ set { _stylePtr->DisplayWindowPadding = value; }
+ }
+
///
/// 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 Vector2 DisplaySafeAreaPadding;
+ public Vector2 DisplaySafeAreaPadding
+ {
+ get { return _stylePtr->DisplaySafeAreaPadding; }
+ set { _stylePtr->DisplaySafeAreaPadding = value; }
+ }
+
///
/// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
///
- public byte AntiAliasedLines;
+ public bool AntiAliasedLines
+ {
+ get { return _stylePtr->AntiAliasedLines == 1; }
+ set { _stylePtr->AntiAliasedLines = value ? (byte)1 : (byte)0; }
+ }
+
///
/// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
///
- public byte AntiAliasedShapes;
+ public bool AntiAliasedShapes
+ {
+ get { return _stylePtr->AntiAliasedShapes == 1; }
+ set { _stylePtr->AntiAliasedShapes = value ? (byte)1 : (byte)0; }
+ }
+
///
/// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
///
- public float CurveTessellationTol;
- public fixed float Colors[(int)ColorTarget.Count * 4];
- };
+ public float CurveTessellationTolerance
+ {
+ get { return _stylePtr->CurveTessellationTol; }
+ set { _stylePtr->CurveTessellationTol = value; }
+ }
+
+ ///
+ /// Gets the current style color for the given UI element type.
+ ///
+ /// The type of UI element.
+ /// The element's color as currently configured.
+ public float GetColor(ColorTarget target) => _stylePtr->Colors[(int)target];
+
+ ///
+ /// Sets the style color for a particular UI element type.
+ ///
+ /// The type of UI element.
+ /// The new color.
+ public void SetColor(ColorTarget target, float value) => _stylePtr->Colors[(int)target] = value;
+ }
}