misc wrappers for native funcs

internals
dpethes 8 years ago
parent f2d9754ffc
commit d8d2805a1a
  1. 49
      src/ImGui.NET/ImGui.cs
  2. 6
      src/ImGui.NET/ImGuiNative.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ImGuiNET namespace ImGuiNET
{ {
@ -92,6 +93,11 @@ namespace ImGuiNET
ImGuiNative.igTextWrapped(text); ImGuiNative.igTextWrapped(text);
} }
public static void TextUnformatted(string message)
{
ImGuiNative.igTextUnformatted(message, null);
}
public static void LabelText(string label, string text) public static void LabelText(string label, string text)
{ {
ImGuiNative.igLabelText(label, text); ImGuiNative.igLabelText(label, text);
@ -451,6 +457,18 @@ namespace ImGuiNET
return ImGuiNative.igGetWindowWidth(); return ImGuiNative.igGetWindowWidth();
} }
public static Vector2 GetWindowSize()
{
Vector2 size;
ImGuiNative.igGetWindowSize(out size);
return size;
}
public static void SetWindowSize(Vector2 size, SetCondition cond)
{
ImGuiNative.igSetWindowSize(size, cond);
}
public static bool BeginWindow(string windowTitle) => BeginWindow(windowTitle, WindowFlags.Default); public static bool BeginWindow(string windowTitle) => BeginWindow(windowTitle, WindowFlags.Default);
public static bool BeginWindow(string windowTitle, WindowFlags flags) public static bool BeginWindow(string windowTitle, WindowFlags flags)
@ -534,6 +552,20 @@ namespace ImGuiNET
return ImGuiNative.igMenuItem(label, shortcut, selected, enabled); return ImGuiNative.igMenuItem(label, shortcut, selected, enabled);
} }
public static unsafe bool InputText(string label, byte[] textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback)
{
return InputText(label, textBuffer, bufferSize, flags, textEditCallback, IntPtr.Zero);
}
public static unsafe bool InputText(string label, byte[] textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback, IntPtr userData)
{
Debug.Assert(bufferSize <= textBuffer.Length);
fixed (byte* ptrBuf = textBuffer)
{
return InputText(label, new IntPtr(ptrBuf), bufferSize, flags, textEditCallback, userData);
}
}
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback) public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback)
{ {
return InputText(label, textBuffer, bufferSize, flags, textEditCallback, IntPtr.Zero); return InputText(label, textBuffer, bufferSize, flags, textEditCallback, IntPtr.Zero);
@ -688,6 +720,18 @@ namespace ImGuiNET
} }
} }
public static Vector2 GetCursorStartPos()
{
Vector2 retVal;
ImGuiNative.igGetCursorStartPos(out retVal);
return retVal;
}
public static bool BeginChild(string id, bool border = false, WindowFlags flags = 0)
{
return BeginChild(id, new Vector2(0, 0), border, flags);
}
public static bool BeginChild(string id, Vector2 size, bool border, WindowFlags flags) public static bool BeginChild(string id, Vector2 size, bool border, WindowFlags flags)
{ {
return ImGuiNative.igBeginChild(id, size, border, flags); return ImGuiNative.igBeginChild(id, size, border, flags);
@ -1011,5 +1055,10 @@ namespace ImGuiNET
{ {
ImGuiNative.igSetKeyboardFocusHere(offset); ImGuiNative.igSetKeyboardFocusHere(offset);
} }
public static void CalcListClipping(int itemsCount, float itemsHeight, ref int outItemsDisplayStart, ref int outItemsDisplayEnd)
{
ImGuiNative.igCalcListClipping(itemsCount, itemsHeight, ref outItemsDisplayStart, ref outItemsDisplayEnd);
}
} }
} }

@ -225,7 +225,7 @@ namespace ImGuiNET
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igSetCursorPosY(float y); public static extern void igSetCursorPosY(float y);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igGetCursorStartPos(Vector2* pOut); public static extern void igGetCursorStartPos(out Vector2 pOut);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igGetCursorScreenPos(Vector2* pOut); public static extern void igGetCursorScreenPos(Vector2* pOut);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
@ -272,7 +272,7 @@ namespace ImGuiNET
public static extern void igTextWrapped(string fmt); public static extern void igTextWrapped(string fmt);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igTextUnformatted(byte* text, byte* text_end); public static extern void igTextUnformatted(string text, string text_end);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igLabelText(string label, string fmt); public static extern void igLabelText(string label, string fmt);
@ -658,7 +658,7 @@ namespace ImGuiNET
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igCalcTextSize(out Vector2 pOut, char* text, char* text_end, bool hide_text_after_double_hash, float wrap_width); public static extern void igCalcTextSize(out Vector2 pOut, char* text, char* text_end, bool hide_text_after_double_hash, float wrap_width);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void igCalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); public static extern void igCalcListClipping(int items_count, float items_height, ref int out_items_display_start, ref int out_items_display_end);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)] [return: MarshalAs(UnmanagedType.I1)]

Loading…
Cancel
Save