More DrawList additions

internals
Eric Mellino 8 years ago
parent 191632ad56
commit 8ab65d3575
  1. 33
      src/ImGui.NET/DrawList.cs
  2. 11
      src/ImGui.NET/ImGui.NET.csproj
  3. 15
      src/ImGui.NET/ImGui.cs
  4. 10
      src/ImGui.NET/ImGuiNative.cs

@ -1,6 +1,8 @@
using System; using System;
using System.Buffers;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
namespace ImGuiNET namespace ImGuiNET
{ {
@ -54,6 +56,37 @@ namespace ImGuiNET
{ {
ImGuiNative.ImDrawList_AddCircle(_nativeDrawList, center, radius, color, numSegments, thickness); ImGuiNative.ImDrawList_AddCircle(_nativeDrawList, center, radius, color, numSegments, thickness);
} }
public unsafe void AddText(Vector2 position, string text, uint color)
{
int bytes = Encoding.UTF8.GetByteCount(text);
byte[] tempBytes = ArrayPool<byte>.Shared.Rent(bytes);
Encoding.UTF8.GetBytes(text, 0, text.Length, tempBytes, 0);
fixed (byte* bytePtr = &tempBytes[0])
{
ImGuiNative.ImDrawList_AddText(_nativeDrawList, position, color, bytePtr, bytePtr + bytes);
}
}
public void PushClipRect(Vector2 min, Vector2 max, bool intersectWithCurrentClipRect)
{
ImGuiNative.ImDrawList_PushClipRect(_nativeDrawList, min, max, intersectWithCurrentClipRect ? (byte)1 : (byte)0);
}
public void PushClipRectFullScreen()
{
ImGuiNative.ImDrawList_PushClipRectFullScreen(_nativeDrawList);
}
public void PopClipRect()
{
ImGuiNative.ImDrawList_PopClipRect(_nativeDrawList);
}
public void AddDrawCmd()
{
ImGuiNative.ImDrawList_AddDrawCmd(_nativeDrawList);
}
} }
/// <summary> /// <summary>

@ -16,11 +16,12 @@
<DocumentationFile Condition="'$(Configuration)' == 'Release'">bin\Release\ImGui.NET.xml</DocumentationFile> <DocumentationFile Condition="'$(Configuration)' == 'Release'">bin\Release\ImGui.NET.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" /> <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.1.1" /> <PackageReference Include="System.Numerics.Vectors" Version="4.3.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.0.0" /> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.1.0" /> <PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" /> <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Buffers" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\..\deps\cimgui\win7-x64\cimgui.dll"> <Content Include="..\..\deps\cimgui\win7-x64\cimgui.dll">

@ -421,6 +421,11 @@ namespace ImGuiNET
ImGuiNative.igSetNextWindowSize(size, condition); ImGuiNative.igSetNextWindowSize(size, condition);
} }
public static void SetNextWindowFocus()
{
ImGuiNative.igSetNextWindowFocus();
}
public static void SetNextWindowPos(Vector2 position, SetCondition condition) public static void SetNextWindowPos(Vector2 position, SetCondition condition)
{ {
ImGuiNative.igSetNextWindowPos(position, condition); ImGuiNative.igSetNextWindowPos(position, condition);
@ -1002,6 +1007,16 @@ namespace ImGuiNET
ImGuiNative.igSameLine(localPositionX, spacingW); ImGuiNative.igSameLine(localPositionX, spacingW);
} }
public static void PushClipRect(Vector2 min, Vector2 max, bool intersectWithCurrentCliRect)
{
ImGuiNative.igPushClipRect(min, max, intersectWithCurrentCliRect ? (byte)1 : (byte)0);
}
public static void PopClipRect()
{
ImGuiNative.igPopClipRect();
}
public static bool IsLastItemHovered() public static bool IsLastItemHovered()
{ {
return ImGuiNative.igIsItemHovered(); return ImGuiNative.igIsItemHovered();

@ -604,6 +604,12 @@ namespace ImGuiNET
//public static extern void igLogText(string fmt, ...); //public static extern void igLogText(string fmt, ...);
public static extern void igLogText(string fmt); public static extern void igLogText(string fmt);
// Clipping
[DllImport(cimguiLib)]
public static extern void igPushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max, byte intersect_with_current_clip_rect);
[DllImport(cimguiLib)]
public static extern void igPopClipRect();
// Utilities // Utilities
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)] [return: MarshalAs(UnmanagedType.I1)]
@ -831,9 +837,9 @@ namespace ImGuiNET
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImDrawList_AddCircleFilled(NativeDrawList* list, Vector2 centre, float radius, uint col, int num_segments); public static extern void ImDrawList_AddCircleFilled(NativeDrawList* list, Vector2 centre, float radius, uint col, int num_segments);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImDrawList_AddText(NativeDrawList* list, Vector2 pos, uint col, char* text_begin, char* text_end); public static extern void ImDrawList_AddText(NativeDrawList* list, Vector2 pos, uint col, byte* text_begin, byte* text_end);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImDrawList_AddTextExt(NativeDrawList* list, NativeFont* font, float font_size, Vector2 pos, uint col, char* text_begin, char* text_end, float wrap_width, Vector4* cpu_fine_clip_rect); public static extern void ImDrawList_AddTextExt(NativeDrawList* list, NativeFont* font, float font_size, Vector2 pos, uint col, byte* text_begin, byte* text_end, float wrap_width, Vector4* cpu_fine_clip_rect);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]
public static extern void ImDrawList_AddImage(NativeDrawList* list, void* user_texture_id, Vector2 a, Vector2 b, Vector2 uv0, Vector2 uv1, uint col); public static extern void ImDrawList_AddImage(NativeDrawList* list, void* user_texture_id, Vector2 a, Vector2 b, Vector2 uv0, Vector2 uv1, uint col);
[DllImport(cimguiLib)] [DllImport(cimguiLib)]

Loading…
Cancel
Save