diff --git a/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs b/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs index ca2b3333..da87114d 100644 --- a/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs +++ b/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs @@ -479,6 +479,36 @@ public static bool Begin(ReadOnlySpan name, ImGuiWindowFlags flags) public static bool MenuItem(ReadOnlySpan label, bool enabled) { return MenuItem(label, string.Empty, false, enabled); + } + + public static bool BeginPopupModal(ReadOnlySpan name, ImGuiWindowFlags flags) + { + byte* native_name; + int name_byteCount = 0; + if (name != null) + { + name_byteCount = Encoding.UTF8.GetByteCount(name); + if (name_byteCount > Util.StackAllocationSizeLimit) + { + native_name = Util.Allocate(name_byteCount + 1); + } + else + { + byte* native_name_stackBytes = stackalloc byte[name_byteCount + 1]; + native_name = native_name_stackBytes; + } + int native_name_offset = Util.GetUtf8(name, native_name, name_byteCount); + native_name[native_name_offset] = 0; + } + else { native_name = null; } + byte* native_p_open = null; + byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); + if (name_byteCount > Util.StackAllocationSizeLimit) + { + Util.Free(native_name); + } + + return ret != 0; } } } diff --git a/src/ImGui.NET/ImGui.Manual.cs b/src/ImGui.NET/ImGui.Manual.cs index d47d1c75..b53709e6 100644 --- a/src/ImGui.NET/ImGui.Manual.cs +++ b/src/ImGui.NET/ImGui.Manual.cs @@ -471,11 +471,41 @@ public static bool Begin(string name, ImGuiWindowFlags flags) } return ret != 0; - } + } public static bool MenuItem(string label, bool enabled) { return MenuItem(label, string.Empty, false, enabled); + } + + public static bool BeginPopupModal(string name, ImGuiWindowFlags flags) + { + byte* native_name; + int name_byteCount = 0; + if (name != null) + { + name_byteCount = Encoding.UTF8.GetByteCount(name); + if (name_byteCount > Util.StackAllocationSizeLimit) + { + native_name = Util.Allocate(name_byteCount + 1); + } + else + { + byte* native_name_stackBytes = stackalloc byte[name_byteCount + 1]; + native_name = native_name_stackBytes; + } + int native_name_offset = Util.GetUtf8(name, native_name, name_byteCount); + native_name[native_name_offset] = 0; + } + else { native_name = null; } + byte* native_p_open = null; + byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); + if (name_byteCount > Util.StackAllocationSizeLimit) + { + Util.Free(native_name); + } + + return ret != 0; } } }