Skip to content

Commit a5a66dd

Browse files
committed
Merge remote-tracking branch 'origin/master' into ImPlot_ImNodes_ImGuizmo_Integration
# Conflicts: # src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj
2 parents d6f961f + 66f1afa commit a5a66dd

File tree

6 files changed

+115
-13
lines changed

6 files changed

+115
-13
lines changed

src/CodeGenerator/CodeGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
27+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2828
</ItemGroup>
2929
</Project>

src/ImGui.NET.SampleProgram.XNA/ImGui.NET.SampleProgram.XNA.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.7.0.1708" />
23+
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
2424
</ItemGroup>
2525

2626
</Project>

src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ protected virtual void SetupInput()
158158
_keys.Add(io.KeyMap[(int)ImGuiKey.Backspace] = (int)Keys.Back);
159159
_keys.Add(io.KeyMap[(int)ImGuiKey.Enter] = (int)Keys.Enter);
160160
_keys.Add(io.KeyMap[(int)ImGuiKey.Escape] = (int)Keys.Escape);
161+
_keys.Add(io.KeyMap[(int)ImGuiKey.Space] = (int)Keys.Space);
161162
_keys.Add(io.KeyMap[(int)ImGuiKey.A] = (int)Keys.A);
162163
_keys.Add(io.KeyMap[(int)ImGuiKey.C] = (int)Keys.C);
163164
_keys.Add(io.KeyMap[(int)ImGuiKey.V] = (int)Keys.V);
@@ -195,17 +196,9 @@ protected virtual Effect UpdateEffect(Texture2D texture)
195196

196197
var io = ImGui.GetIO();
197198

198-
// MonoGame-specific //////////////////////
199-
var offset = .5f;
200-
///////////////////////////////////////////
201-
202-
// FNA-specific ///////////////////////////
203-
//var offset = 0f;
204-
///////////////////////////////////////////
205-
206199
_effect.World = Matrix.Identity;
207200
_effect.View = Matrix.Identity;
208-
_effect.Projection = Matrix.CreateOrthographicOffCenter(offset, io.DisplaySize.X + offset, io.DisplaySize.Y + offset, offset, -1f, 1f);
201+
_effect.Projection = Matrix.CreateOrthographicOffCenter(0f, io.DisplaySize.X, io.DisplaySize.Y, 0f, -1f, 1f);
209202
_effect.TextureEnabled = true;
210203
_effect.Texture = texture;
211204
_effect.VertexColorEnabled = true;

src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="..\ImGui.NET\ImGui.NET.csproj" />
11-
<PackageReference Include="Veldrid" Version="4.3.3" />
12-
<PackageReference Include="Veldrid.StartupUtilities" Version="4.3.3" />
11+
<PackageReference Include="Veldrid" Version="4.8.0" />
12+
<PackageReference Include="Veldrid.StartupUtilities" Version="4.8.0" />
1313
<ProjectReference Include="..\ImPlot.NET\ImPlot.NET.csproj" />
1414
</ItemGroup>
1515

src/ImGui.NET.SampleProgram/ImGuiController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ private static void SetKeyMappings()
416416
io.KeyMap[(int)ImGuiKey.Backspace] = (int)Key.BackSpace;
417417
io.KeyMap[(int)ImGuiKey.Enter] = (int)Key.Enter;
418418
io.KeyMap[(int)ImGuiKey.Escape] = (int)Key.Escape;
419+
io.KeyMap[(int)ImGuiKey.Space] = (int)Key.Space;
419420
io.KeyMap[(int)ImGuiKey.A] = (int)Key.A;
420421
io.KeyMap[(int)ImGuiKey.C] = (int)Key.C;
421422
io.KeyMap[(int)ImGuiKey.V] = (int)Key.V;

src/ImGui.NET/ImGui.Manual.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,114 @@ public static bool InputTextMultiline(
247247
return result != 0;
248248
}
249249

250+
public static bool InputTextWithHint(
251+
string label,
252+
string hint,
253+
ref string input,
254+
uint maxLength) => InputTextWithHint(label, hint, ref input, maxLength, 0, null, IntPtr.Zero);
255+
256+
public static bool InputTextWithHint(
257+
string label,
258+
string hint,
259+
ref string input,
260+
uint maxLength,
261+
ImGuiInputTextFlags flags) => InputTextWithHint(label, hint, ref input, maxLength, flags, null, IntPtr.Zero);
262+
263+
public static bool InputTextWithHint(
264+
string label,
265+
string hint,
266+
ref string input,
267+
uint maxLength,
268+
ImGuiInputTextFlags flags,
269+
ImGuiInputTextCallback callback) => InputTextWithHint(label, hint, ref input, maxLength, flags, callback, IntPtr.Zero);
270+
271+
public static bool InputTextWithHint(
272+
string label,
273+
string hint,
274+
ref string input,
275+
uint maxLength,
276+
ImGuiInputTextFlags flags,
277+
ImGuiInputTextCallback callback,
278+
IntPtr user_data)
279+
{
280+
int utf8LabelByteCount = Encoding.UTF8.GetByteCount(label);
281+
byte* utf8LabelBytes;
282+
if (utf8LabelByteCount > Util.StackAllocationSizeLimit)
283+
{
284+
utf8LabelBytes = Util.Allocate(utf8LabelByteCount + 1);
285+
}
286+
else
287+
{
288+
byte* stackPtr = stackalloc byte[utf8LabelByteCount + 1];
289+
utf8LabelBytes = stackPtr;
290+
}
291+
Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount);
292+
293+
int utf8HintByteCount = Encoding.UTF8.GetByteCount(hint);
294+
byte* utf8HintBytes;
295+
if (utf8HintByteCount > Util.StackAllocationSizeLimit)
296+
{
297+
utf8HintBytes = Util.Allocate(utf8HintByteCount + 1);
298+
}
299+
else
300+
{
301+
byte* stackPtr = stackalloc byte[utf8HintByteCount + 1];
302+
utf8HintBytes = stackPtr;
303+
}
304+
Util.GetUtf8(hint, utf8HintBytes, utf8HintByteCount);
305+
306+
int utf8InputByteCount = Encoding.UTF8.GetByteCount(input);
307+
int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1);
308+
309+
byte* utf8InputBytes;
310+
byte* originalUtf8InputBytes;
311+
if (inputBufSize > Util.StackAllocationSizeLimit)
312+
{
313+
utf8InputBytes = Util.Allocate(inputBufSize);
314+
originalUtf8InputBytes = Util.Allocate(inputBufSize);
315+
}
316+
else
317+
{
318+
byte* inputStackBytes = stackalloc byte[inputBufSize];
319+
utf8InputBytes = inputStackBytes;
320+
byte* originalInputStackBytes = stackalloc byte[inputBufSize];
321+
originalUtf8InputBytes = originalInputStackBytes;
322+
}
323+
Util.GetUtf8(input, utf8InputBytes, inputBufSize);
324+
uint clearBytesCount = (uint)(inputBufSize - utf8InputByteCount);
325+
Unsafe.InitBlockUnaligned(utf8InputBytes + utf8InputByteCount, 0, clearBytesCount);
326+
Unsafe.CopyBlock(originalUtf8InputBytes, utf8InputBytes, (uint)inputBufSize);
327+
328+
byte result = ImGuiNative.igInputTextWithHint(
329+
utf8LabelBytes,
330+
utf8HintBytes,
331+
utf8InputBytes,
332+
(uint)inputBufSize,
333+
flags,
334+
callback,
335+
user_data.ToPointer());
336+
if (!Util.AreStringsEqual(originalUtf8InputBytes, inputBufSize, utf8InputBytes))
337+
{
338+
input = Util.StringFromPtr(utf8InputBytes);
339+
}
340+
341+
if (utf8LabelByteCount > Util.StackAllocationSizeLimit)
342+
{
343+
Util.Free(utf8LabelBytes);
344+
}
345+
if (utf8HintByteCount > Util.StackAllocationSizeLimit)
346+
{
347+
Util.Free(utf8HintBytes);
348+
}
349+
if (inputBufSize > Util.StackAllocationSizeLimit)
350+
{
351+
Util.Free(utf8InputBytes);
352+
Util.Free(originalUtf8InputBytes);
353+
}
354+
355+
return result != 0;
356+
}
357+
250358
public static bool InputText(
251359
string label,
252360
IntPtr buf,

0 commit comments

Comments
 (0)