More wrappers, adding more XML comments, some file movement

internals
Eric Mellino 9 years ago
parent 77fabedf66
commit f9b870dda0
  1. 2
      src/ImGui.NET.SampleProgram/SampleWindow.cs
  2. 64
      src/ImGui.NET/IO.cs
  3. 4
      src/ImGui.NET/ImGui.NET.Net46.csproj
  4. 4
      src/ImGui.NET/ImGui.NET.csproj
  5. 239
      src/ImGui.NET/ImGui.cs
  6. 60
      src/ImGui.NET/ImGuiNative.cs
  7. 22
      src/ImGui.NET/IntStructs.cs
  8. 103
      src/ImGui.NET/NativeStyle.cs
  9. 190
      src/ImGui.NET/Style.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,

@ -19,61 +19,101 @@ namespace ImGuiNET
public NativeIO* GetNativePointer() => _nativePtr;
/// <summary>
/// Display size, in pixels. For clamping windows positions.
/// Default value: [unset]
/// </summary>
public Vector2 DisplaySize
{
get { return _nativePtr->DisplaySize; }
set { _nativePtr->DisplaySize = value; }
}
/// <summary>
/// Time elapsed since last frame, in seconds.
/// Default value: 1.0f / 10.0f.
/// </summary>
public float DeltaTime
{
get { return _nativePtr->DeltaTime; }
set { _nativePtr->DeltaTime = value; }
}
/// <summary>
/// For retina display or other situations where window coordinates are different from framebuffer coordinates.
/// User storage only, presently not used by ImGui.
/// Default value: (1.0f, 1.0f).
/// </summary>
public Vector2 DisplayFramebufferScale
{
get { return _nativePtr->DisplayFramebufferScale; }
set { _nativePtr->DisplayFramebufferScale = value; }
}
public Vector2 DisplaySize
{
get { return _nativePtr->DisplaySize; }
set { _nativePtr->DisplaySize = value; }
}
/// <summary>
/// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.).
/// </summary>
public Vector2 MousePosition
{
get { return _nativePtr->MousePos; }
set { _nativePtr->MousePos = value; }
}
/// <summary>
/// Mouse wheel: 1 unit scrolls about 5 lines text.
/// </summary>
public float MouseWheel
{
get { return _nativePtr->MouseWheel; }
set { _nativePtr->MouseWheel = value; }
}
/// <summary>
/// Mouse buttons: left, right, middle + extras.
/// ImGui itself mostly only uses left button (BeginPopupContext** are using right button).
/// Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
/// </summary>
public MouseDownStates MouseDown { get; }
/// <summary>
/// Map of indices into the KeysDown[512] entries array.
/// Default values: [unset]
/// </summary>
public KeyMap KeyMap { get; }
/// <summary>
/// Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
/// </summary>
public KeyDownStates KeysDown { get; }
public FontAtlasWrapped FontAtlas { get; }
public bool AltPressed
{
get { return _nativePtr->KeyAlt == 1; }
set { _nativePtr->KeyAlt = value ? (byte)1 : (byte)0; }
}
/// <summary>
/// Keyboard modifier pressed: Control.
/// </summary>
public bool CtrlPressed
{
get { return _nativePtr->KeyCtrl == 1; }
set { _nativePtr->KeyCtrl = value ? (byte)1 : (byte)0; }
}
/// <summary>
/// Keyboard modifier pressed: Shift
/// </summary>
public bool ShiftPressed
{
get { return _nativePtr->KeyShift == 1; }
set { _nativePtr->KeyShift = value ? (byte)1 : (byte)0; }
}
/// <summary>
/// Keyboard modifier pressed: Alt
/// </summary>
public bool AltPressed
{
get { return _nativePtr->KeyAlt == 1; }
set { _nativePtr->KeyAlt = value ? (byte)1 : (byte)0; }
}
}
public unsafe class KeyMap

@ -15,10 +15,12 @@
<ItemGroup>
<Compile Include="Align.cs" />
<Compile Include="ColorTarget.cs" />
<Compile Include="IntStructs.cs" />
<Compile Include="MouseCursorKind.cs" />
<Compile Include="NativeIO.cs" />
<Compile Include="SelectableFlags.cs" />
<Compile Include="StyleVar.cs" />
<Compile Include="Style.cs" />
<Compile Include="WindowFlags.cs" />
<Compile Include="ColorEditMode.cs" />
<Compile Include="GuiKey.cs" />
@ -32,7 +34,7 @@
<Compile Include="ImGui.cs" />
<Compile Include="IO.cs" />
<Compile Include="Storage.cs" />
<Compile Include="Style.cs" />
<Compile Include="NativeStyle.cs" />
<Compile Include="ImVector.cs" />
<Compile Include="InputTextFlags.cs" />
<Compile Include="ImGuiNative.cs" />

@ -12,10 +12,12 @@
<ItemGroup>
<Compile Include="Align.cs" />
<Compile Include="ColorTarget.cs" />
<Compile Include="IntStructs.cs" />
<Compile Include="MouseCursorKind.cs" />
<Compile Include="NativeIO.cs" />
<Compile Include="SelectableFlags.cs" />
<Compile Include="StyleVar.cs" />
<Compile Include="Style.cs" />
<Compile Include="TextInputBuffer.cs" />
<Compile Include="WindowFlags.cs" />
<Compile Include="ColorEditMode.cs" />
@ -30,7 +32,7 @@
<Compile Include="ImGui.cs" />
<Compile Include="IO.cs" />
<Compile Include="Storage.cs" />
<Compile Include="Style.cs" />
<Compile Include="NativeStyle.cs" />
<Compile Include="ImVector.cs" />
<Compile Include="InputTextFlags.cs" />
<Compile Include="ImGuiNative.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; }
}
}
}

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

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

@ -0,0 +1,103 @@
using System.Runtime.InteropServices;
using System.Numerics;
namespace ImGuiNET
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct NativeStyle
{
/// <summary>
/// Global alpha applies to everything in ImGui.
/// </summary>
public float Alpha;
/// <summary>
/// Padding within a window.
/// </summary>
public Vector2 WindowPadding;
/// <summary>
/// Minimum window size.
/// </summary>
public Vector2 WindowMinSize;
/// <summary>
/// Radius of window corners rounding. Set to 0.0f to have rectangular windows.
/// </summary>
public float WindowRounding;
/// <summary>
/// Alignment for title bar text.
/// </summary>
public Align WindowTitleAlign;
/// <summary>
/// Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
/// </summary>
public float ChildWindowRounding;
/// <summary>
/// Padding within a framed rectangle (used by most widgets).
/// </summary>
public Vector2 FramePadding;
/// <summary>
/// Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
/// </summary>
public float FrameRounding;
/// <summary>
/// Horizontal and vertical spacing between widgets/lines.
/// </summary>
public Vector2 ItemSpacing;
/// <summary>
/// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
/// </summary>
public Vector2 ItemInnerSpacing;
/// <summary>
/// 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!
/// </summary>
public Vector2 TouchExtraPadding;
/// <summary>
/// Default alpha of window background, if not specified in ImGui::Begin().
/// </summary>
public float WindowFillAlphaDefault;
/// <summary>
/// Horizontal indentation when e.g. entering a tree node
/// </summary>
public float IndentSpacing;
/// <summary>
/// Minimum horizontal spacing between two columns
/// </summary>
public float ColumnsMinSpacing;
/// <summary>
/// Width of the vertical scrollbar, Height of the horizontal scrollbar
/// </summary>
public float ScrollbarSize;
/// <summary>
/// Radius of grab corners for scrollbar
/// </summary>
public float ScrollbarRounding;
/// <summary>
/// Minimum width/height of a grab box for slider/scrollbar
/// </summary>
public float GrabMinSize;
/// <summary>
/// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
/// </summary>
public float GrabRounding;
/// <summary>
/// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
/// </summary>
public Vector2 DisplayWindowPadding;
/// <summary>
/// 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.
/// </summary>
public Vector2 DisplaySafeAreaPadding;
/// <summary>
/// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
/// </summary>
public byte AntiAliasedLines;
/// <summary>
/// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
/// </summary>
public byte AntiAliasedShapes;
/// <summary>
/// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
/// </summary>
public float CurveTessellationTol;
public fixed float Colors[(int)ColorTarget.Count * 4];
};
}

@ -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;
}
/// <summary>
/// Global alpha applies to everything in ImGui.
/// </summary>
public float Alpha;
public float Alpha
{
get { return _stylePtr->Alpha; }
set { _stylePtr->Alpha = value; }
}
/// <summary>
/// Padding within a window.
/// </summary>
public Vector2 WindowPadding;
public Vector2 WindowPadding
{
get { return _stylePtr->WindowPadding; }
set { _stylePtr->WindowPadding = value; }
}
/// <summary>
/// Minimum window size.
/// </summary>
public Vector2 WindowMinSize;
public Vector2 WindowMinSize
{
get { return _stylePtr->WindowMinSize; }
set { _stylePtr->WindowMinSize = value; }
}
/// <summary>
/// Radius of window corners rounding. Set to 0.0f to have rectangular windows.
/// </summary>
public float WindowRounding;
public float WindowRounding
{
get { return _stylePtr->WindowRounding; }
set { _stylePtr->WindowRounding = value; }
}
/// <summary>
/// Alignment for title bar text.
/// </summary>
public Align WindowTitleAlign;
public Align WindowTitleAlign
{
get { return _stylePtr->WindowTitleAlign; }
set { _stylePtr->WindowTitleAlign = value; }
}
/// <summary>
/// Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
/// </summary>
public float ChildWindowRounding;
public float ChildWindowRounding
{
get { return _stylePtr->ChildWindowRounding; }
set { _stylePtr->ChildWindowRounding = value; }
}
/// <summary>
/// Padding within a framed rectangle (used by most widgets).
/// </summary>
public Vector2 FramePadding;
public Vector2 FramePadding
{
get { return _stylePtr->FramePadding; }
set { _stylePtr->FramePadding = value; }
}
/// <summary>
/// Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
/// </summary>
public float FrameRounding;
public float FrameRounding
{
get { return _stylePtr->FrameRounding; }
set { _stylePtr->FrameRounding = value; }
}
/// <summary>
/// Horizontal and vertical spacing between widgets/lines.
/// </summary>
public Vector2 ItemSpacing;
public Vector2 ItemSpacing
{
get { return _stylePtr->ItemSpacing; }
set { _stylePtr->ItemSpacing = value; }
}
/// <summary>
/// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
/// </summary>
public Vector2 ItemInnerSpacing;
public Vector2 ItemInnerSpacing
{
get { return _stylePtr->ItemInnerSpacing; }
set { _stylePtr->ItemInnerSpacing = value; }
}
/// <summary>
/// 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!
/// </summary>
public Vector2 TouchExtraPadding;
public Vector2 TouchExtraPadding
{
get { return _stylePtr->TouchExtraPadding; }
set { _stylePtr->TouchExtraPadding = value; }
}
/// <summary>
/// Default alpha of window background, if not specified in ImGui::Begin().
/// </summary>
public float WindowFillAlphaDefault;
public float WindowFillAlphaDefault
{
get { return _stylePtr->WindowFillAlphaDefault; }
set { _stylePtr->WindowFillAlphaDefault = value; }
}
/// <summary>
/// Horizontal indentation when e.g. entering a tree node
/// </summary>
public float IndentSpacing;
public float IndentSpacing
{
get { return _stylePtr->IndentSpacing; }
set { _stylePtr->IndentSpacing = value; }
}
/// <summary>
/// Minimum horizontal spacing between two columns
/// </summary>
public float ColumnsMinSpacing;
public float ColumnsMinSpacing
{
get { return _stylePtr->ColumnsMinSpacing; }
set { _stylePtr->ColumnsMinSpacing = value; }
}
/// <summary>
/// Width of the vertical scrollbar, Height of the horizontal scrollbar
/// </summary>
public float ScrollbarSize;
public float ScrollbarSize
{
get { return _stylePtr->ScrollbarSize; }
set { _stylePtr->ScrollbarSize = value; }
}
/// <summary>
/// Radius of grab corners for scrollbar
/// </summary>
public float ScrollbarRounding;
public float ScrollbarRounding
{
get { return _stylePtr->ScrollbarRounding; }
set { _stylePtr->ScrollbarRounding = value; }
}
/// <summary>
/// Minimum width/height of a grab box for slider/scrollbar
/// </summary>
public float GrabMinSize;
public float GrabMinSize
{
get { return _stylePtr->GrabMinSize; }
set { _stylePtr->GrabMinSize = value; }
}
/// <summary>
/// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
/// </summary>
public float GrabRounding;
public float GrabRounding
{
get { return _stylePtr->GrabRounding; }
set { _stylePtr->GrabRounding = value; }
}
/// <summary>
/// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
/// </summary>
public Vector2 DisplayWindowPadding;
public Vector2 DisplayWindowPadding
{
get { return _stylePtr->DisplayWindowPadding; }
set { _stylePtr->DisplayWindowPadding = value; }
}
/// <summary>
/// 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.
/// </summary>
public Vector2 DisplaySafeAreaPadding;
public Vector2 DisplaySafeAreaPadding
{
get { return _stylePtr->DisplaySafeAreaPadding; }
set { _stylePtr->DisplaySafeAreaPadding = value; }
}
/// <summary>
/// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
/// </summary>
public byte AntiAliasedLines;
public bool AntiAliasedLines
{
get { return _stylePtr->AntiAliasedLines == 1; }
set { _stylePtr->AntiAliasedLines = value ? (byte)1 : (byte)0; }
}
/// <summary>
/// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
/// </summary>
public byte AntiAliasedShapes;
public bool AntiAliasedShapes
{
get { return _stylePtr->AntiAliasedShapes == 1; }
set { _stylePtr->AntiAliasedShapes = value ? (byte)1 : (byte)0; }
}
/// <summary>
/// Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
/// </summary>
public float CurveTessellationTol;
public fixed float Colors[(int)ColorTarget.Count * 4];
};
public float CurveTessellationTolerance
{
get { return _stylePtr->CurveTessellationTol; }
set { _stylePtr->CurveTessellationTol = value; }
}
/// <summary>
/// Gets the current style color for the given UI element type.
/// </summary>
/// <param name="target">The type of UI element.</param>
/// <returns>The element's color as currently configured.</returns>
public float GetColor(ColorTarget target) => _stylePtr->Colors[(int)target];
/// <summary>
/// Sets the style color for a particular UI element type.
/// </summary>
/// <param name="target">The type of UI element.</param>
/// <param name="value">The new color.</param>
public void SetColor(ColorTarget target, float value) => _stylePtr->Colors[(int)target] = value;
}
}

Loading…
Cancel
Save