From 49aa2d9fafd6f256f6b1bc35d8eb5796a0217db1 Mon Sep 17 00:00:00 2001 From: Zaafar Date: Tue, 15 Sep 2020 21:12:50 -0400 Subject: [PATCH 1/6] updating deps --- src/CodeGenerator/CodeGenerator.csproj | 2 +- .../ImGui.NET.SampleProgram.XNA.csproj | 2 +- src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj | 4 ++-- src/ImGui.NET/ImGui.NET.csproj | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CodeGenerator/CodeGenerator.csproj b/src/CodeGenerator/CodeGenerator.csproj index 78613cf..1694ecd 100644 --- a/src/CodeGenerator/CodeGenerator.csproj +++ b/src/CodeGenerator/CodeGenerator.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/ImGui.NET.SampleProgram.XNA/ImGui.NET.SampleProgram.XNA.csproj b/src/ImGui.NET.SampleProgram.XNA/ImGui.NET.SampleProgram.XNA.csproj index d2202c0..83e6402 100644 --- a/src/ImGui.NET.SampleProgram.XNA/ImGui.NET.SampleProgram.XNA.csproj +++ b/src/ImGui.NET.SampleProgram.XNA/ImGui.NET.SampleProgram.XNA.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj b/src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj index bb07cc0..398ee22 100644 --- a/src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj +++ b/src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/src/ImGui.NET/ImGui.NET.csproj b/src/ImGui.NET/ImGui.NET.csproj index 26b507d..bdf53f1 100644 --- a/src/ImGui.NET/ImGui.NET.csproj +++ b/src/ImGui.NET/ImGui.NET.csproj @@ -16,9 +16,9 @@ ImGuiNET - - - + + + From c56b19b6ae722aafa94fa9e0b7beb8b465d98190 Mon Sep 17 00:00:00 2001 From: Zaafar Date: Tue, 15 Sep 2020 21:28:42 -0400 Subject: [PATCH 2/6] Updating MonoGame-specific offset as it's not required anymore. --- src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs b/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs index 5d745c2..04c121e 100644 --- a/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs +++ b/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs @@ -195,17 +195,9 @@ namespace ImGuiNET.SampleProgram.XNA var io = ImGui.GetIO(); - // MonoGame-specific ////////////////////// - var offset = .5f; - /////////////////////////////////////////// - - // FNA-specific /////////////////////////// - //var offset = 0f; - /////////////////////////////////////////// - _effect.World = Matrix.Identity; _effect.View = Matrix.Identity; - _effect.Projection = Matrix.CreateOrthographicOffCenter(offset, io.DisplaySize.X + offset, io.DisplaySize.Y + offset, offset, -1f, 1f); + _effect.Projection = Matrix.CreateOrthographicOffCenter(0f, io.DisplaySize.X, io.DisplaySize.Y, 0f, -1f, 1f); _effect.TextureEnabled = true; _effect.Texture = texture; _effect.VertexColorEnabled = true; From 8a9c83f7754db354ac920f7571ce2cc9dcc52b2b Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Sat, 28 Nov 2020 21:31:30 -0800 Subject: [PATCH 3/6] Revert ImGui.NET dependency changes. --- src/ImGui.NET/ImGui.NET.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImGui.NET/ImGui.NET.csproj b/src/ImGui.NET/ImGui.NET.csproj index bdf53f1..26b507d 100644 --- a/src/ImGui.NET/ImGui.NET.csproj +++ b/src/ImGui.NET/ImGui.NET.csproj @@ -16,9 +16,9 @@ ImGuiNET - - - + + + From 475146aa8f3d76b736d7e2ba89edb2ac2aca2a0f Mon Sep 17 00:00:00 2001 From: mrmav Date: Sat, 20 Jun 2020 13:37:56 +0100 Subject: [PATCH 4/6] added space input to XNA sample --- src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs b/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs index 04c121e..829b83b 100644 --- a/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs +++ b/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs @@ -158,6 +158,7 @@ namespace ImGuiNET.SampleProgram.XNA _keys.Add(io.KeyMap[(int)ImGuiKey.Backspace] = (int)Keys.Back); _keys.Add(io.KeyMap[(int)ImGuiKey.Enter] = (int)Keys.Enter); _keys.Add(io.KeyMap[(int)ImGuiKey.Escape] = (int)Keys.Escape); + _keys.Add(io.KeyMap[(int)ImGuiKey.Space] = (int)Keys.Space); _keys.Add(io.KeyMap[(int)ImGuiKey.A] = (int)Keys.A); _keys.Add(io.KeyMap[(int)ImGuiKey.C] = (int)Keys.C); _keys.Add(io.KeyMap[(int)ImGuiKey.V] = (int)Keys.V); From 820e5c37944c11d4fd59f214bc53a35bb7747838 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Sat, 28 Nov 2020 21:40:49 -0800 Subject: [PATCH 5/6] Add mapping for the space key. --- src/ImGui.NET.SampleProgram/ImGuiController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImGui.NET.SampleProgram/ImGuiController.cs b/src/ImGui.NET.SampleProgram/ImGuiController.cs index 396517e..3c600ad 100644 --- a/src/ImGui.NET.SampleProgram/ImGuiController.cs +++ b/src/ImGui.NET.SampleProgram/ImGuiController.cs @@ -413,6 +413,7 @@ namespace ImGuiNET io.KeyMap[(int)ImGuiKey.Backspace] = (int)Key.BackSpace; io.KeyMap[(int)ImGuiKey.Enter] = (int)Key.Enter; io.KeyMap[(int)ImGuiKey.Escape] = (int)Key.Escape; + io.KeyMap[(int)ImGuiKey.Space] = (int)Key.Space; io.KeyMap[(int)ImGuiKey.A] = (int)Key.A; io.KeyMap[(int)ImGuiKey.C] = (int)Key.C; io.KeyMap[(int)ImGuiKey.V] = (int)Key.V; From 66f1afa9a268c2b70ff9403c570e45c8847e37a4 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Thu, 2 Apr 2020 22:56:21 +0200 Subject: [PATCH 6/6] Add InputTextWithHint overloads --- src/ImGui.NET/ImGui.Manual.cs | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/src/ImGui.NET/ImGui.Manual.cs b/src/ImGui.NET/ImGui.Manual.cs index 522c6f7..8fac3de 100644 --- a/src/ImGui.NET/ImGui.Manual.cs +++ b/src/ImGui.NET/ImGui.Manual.cs @@ -247,6 +247,114 @@ namespace ImGuiNET return result != 0; } + public static bool InputTextWithHint( + string label, + string hint, + ref string input, + uint maxLength) => InputTextWithHint(label, hint, ref input, maxLength, 0, null, IntPtr.Zero); + + public static bool InputTextWithHint( + string label, + string hint, + ref string input, + uint maxLength, + ImGuiInputTextFlags flags) => InputTextWithHint(label, hint, ref input, maxLength, flags, null, IntPtr.Zero); + + public static bool InputTextWithHint( + string label, + string hint, + ref string input, + uint maxLength, + ImGuiInputTextFlags flags, + ImGuiInputTextCallback callback) => InputTextWithHint(label, hint, ref input, maxLength, flags, callback, IntPtr.Zero); + + public static bool InputTextWithHint( + string label, + string hint, + ref string input, + uint maxLength, + ImGuiInputTextFlags flags, + ImGuiInputTextCallback callback, + IntPtr user_data) + { + int utf8LabelByteCount = Encoding.UTF8.GetByteCount(label); + byte* utf8LabelBytes; + if (utf8LabelByteCount > Util.StackAllocationSizeLimit) + { + utf8LabelBytes = Util.Allocate(utf8LabelByteCount + 1); + } + else + { + byte* stackPtr = stackalloc byte[utf8LabelByteCount + 1]; + utf8LabelBytes = stackPtr; + } + Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + + int utf8HintByteCount = Encoding.UTF8.GetByteCount(hint); + byte* utf8HintBytes; + if (utf8HintByteCount > Util.StackAllocationSizeLimit) + { + utf8HintBytes = Util.Allocate(utf8HintByteCount + 1); + } + else + { + byte* stackPtr = stackalloc byte[utf8HintByteCount + 1]; + utf8HintBytes = stackPtr; + } + Util.GetUtf8(hint, utf8HintBytes, utf8HintByteCount); + + int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); + int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); + + byte* utf8InputBytes; + byte* originalUtf8InputBytes; + if (inputBufSize > Util.StackAllocationSizeLimit) + { + utf8InputBytes = Util.Allocate(inputBufSize); + originalUtf8InputBytes = Util.Allocate(inputBufSize); + } + else + { + byte* inputStackBytes = stackalloc byte[inputBufSize]; + utf8InputBytes = inputStackBytes; + byte* originalInputStackBytes = stackalloc byte[inputBufSize]; + originalUtf8InputBytes = originalInputStackBytes; + } + Util.GetUtf8(input, utf8InputBytes, inputBufSize); + uint clearBytesCount = (uint)(inputBufSize - utf8InputByteCount); + Unsafe.InitBlockUnaligned(utf8InputBytes + utf8InputByteCount, 0, clearBytesCount); + Unsafe.CopyBlock(originalUtf8InputBytes, utf8InputBytes, (uint)inputBufSize); + + byte result = ImGuiNative.igInputTextWithHint( + utf8LabelBytes, + utf8HintBytes, + utf8InputBytes, + (uint)inputBufSize, + flags, + callback, + user_data.ToPointer()); + if (!Util.AreStringsEqual(originalUtf8InputBytes, inputBufSize, utf8InputBytes)) + { + input = Util.StringFromPtr(utf8InputBytes); + } + + if (utf8LabelByteCount > Util.StackAllocationSizeLimit) + { + Util.Free(utf8LabelBytes); + } + if (utf8HintByteCount > Util.StackAllocationSizeLimit) + { + Util.Free(utf8HintBytes); + } + if (inputBufSize > Util.StackAllocationSizeLimit) + { + Util.Free(utf8InputBytes); + Util.Free(originalUtf8InputBytes); + } + + return result != 0; + } + public static bool InputText( string label, IntPtr buf,