Add similar manual overloads for InputTextMultiline.

internals
Eric Mellino 6 years ago
parent a2ecece82d
commit 1ed6432be0
  1. 3
      src/CodeGenerator/Program.cs
  2. 106
      src/ImGui.NET/Generated/ImGui.gen.cs
  3. 62
      src/ImGui.NET/ImGui.Manual.cs

@ -103,7 +103,8 @@ namespace CodeGenerator
private static readonly HashSet<string> s_skippedFunctions = new HashSet<string>()
{
"igInputText"
"igInputText",
"igInputTextMultiline"
};
static void Main(string[] args)

@ -3465,112 +3465,6 @@ namespace ImGuiNET
{
ImGuiNative.igEndPopup();
}
public static bool InputTextMultiline(string label, string buf, uint buf_size)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);
byte* native_label = stackalloc byte[label_byteCount + 1];
fixed (char* label_ptr = label)
{
int native_label_offset = Encoding.UTF8.GetBytes(label_ptr, label.Length, native_label, label_byteCount);
native_label[native_label_offset] = 0;
}
int buf_byteCount = Encoding.UTF8.GetByteCount(buf);
byte* native_buf = stackalloc byte[buf_byteCount + 1];
fixed (char* buf_ptr = buf)
{
int native_buf_offset = Encoding.UTF8.GetBytes(buf_ptr, buf.Length, native_buf, buf_byteCount);
native_buf[native_buf_offset] = 0;
}
Vector2 size = new Vector2();
ImGuiInputTextFlags flags = 0;
ImGuiInputTextCallback callback = null;
void* user_data = null;
byte ret = ImGuiNative.igInputTextMultiline(native_label, native_buf, buf_size, size, flags, callback, user_data);
return ret != 0;
}
public static bool InputTextMultiline(string label, string buf, uint buf_size, Vector2 size)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);
byte* native_label = stackalloc byte[label_byteCount + 1];
fixed (char* label_ptr = label)
{
int native_label_offset = Encoding.UTF8.GetBytes(label_ptr, label.Length, native_label, label_byteCount);
native_label[native_label_offset] = 0;
}
int buf_byteCount = Encoding.UTF8.GetByteCount(buf);
byte* native_buf = stackalloc byte[buf_byteCount + 1];
fixed (char* buf_ptr = buf)
{
int native_buf_offset = Encoding.UTF8.GetBytes(buf_ptr, buf.Length, native_buf, buf_byteCount);
native_buf[native_buf_offset] = 0;
}
ImGuiInputTextFlags flags = 0;
ImGuiInputTextCallback callback = null;
void* user_data = null;
byte ret = ImGuiNative.igInputTextMultiline(native_label, native_buf, buf_size, size, flags, callback, user_data);
return ret != 0;
}
public static bool InputTextMultiline(string label, string buf, uint buf_size, Vector2 size, ImGuiInputTextFlags flags)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);
byte* native_label = stackalloc byte[label_byteCount + 1];
fixed (char* label_ptr = label)
{
int native_label_offset = Encoding.UTF8.GetBytes(label_ptr, label.Length, native_label, label_byteCount);
native_label[native_label_offset] = 0;
}
int buf_byteCount = Encoding.UTF8.GetByteCount(buf);
byte* native_buf = stackalloc byte[buf_byteCount + 1];
fixed (char* buf_ptr = buf)
{
int native_buf_offset = Encoding.UTF8.GetBytes(buf_ptr, buf.Length, native_buf, buf_byteCount);
native_buf[native_buf_offset] = 0;
}
ImGuiInputTextCallback callback = null;
void* user_data = null;
byte ret = ImGuiNative.igInputTextMultiline(native_label, native_buf, buf_size, size, flags, callback, user_data);
return ret != 0;
}
public static bool InputTextMultiline(string label, string buf, uint buf_size, Vector2 size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);
byte* native_label = stackalloc byte[label_byteCount + 1];
fixed (char* label_ptr = label)
{
int native_label_offset = Encoding.UTF8.GetBytes(label_ptr, label.Length, native_label, label_byteCount);
native_label[native_label_offset] = 0;
}
int buf_byteCount = Encoding.UTF8.GetByteCount(buf);
byte* native_buf = stackalloc byte[buf_byteCount + 1];
fixed (char* buf_ptr = buf)
{
int native_buf_offset = Encoding.UTF8.GetBytes(buf_ptr, buf.Length, native_buf, buf_byteCount);
native_buf[native_buf_offset] = 0;
}
void* user_data = null;
byte ret = ImGuiNative.igInputTextMultiline(native_label, native_buf, buf_size, size, flags, callback, user_data);
return ret != 0;
}
public static bool InputTextMultiline(string label, string buf, uint buf_size, Vector2 size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, IntPtr user_data)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);
byte* native_label = stackalloc byte[label_byteCount + 1];
fixed (char* label_ptr = label)
{
int native_label_offset = Encoding.UTF8.GetBytes(label_ptr, label.Length, native_label, label_byteCount);
native_label[native_label_offset] = 0;
}
int buf_byteCount = Encoding.UTF8.GetByteCount(buf);
byte* native_buf = stackalloc byte[buf_byteCount + 1];
fixed (char* buf_ptr = buf)
{
int native_buf_offset = Encoding.UTF8.GetBytes(buf_ptr, buf.Length, native_buf, buf_byteCount);
native_buf[native_buf_offset] = 0;
}
void* native_user_data = (void*)user_data.ToPointer();
byte ret = ImGuiNative.igInputTextMultiline(native_label, native_buf, buf_size, size, flags, callback, native_user_data);
return ret != 0;
}
public static bool Selectable(string label)
{
int label_byteCount = Encoding.UTF8.GetByteCount(label);

@ -1,4 +1,5 @@
using System;
using System.Numerics;
using System.Text;
namespace ImGuiNET
@ -110,6 +111,67 @@ namespace ImGuiNET
return result != 0;
}
public static bool InputTextMultiline(
string label,
ref string input,
uint maxLength,
Vector2 size) => InputTextMultiline(label, ref input, maxLength, size, 0, null, IntPtr.Zero);
public static bool InputTextMultiline(
string label,
ref string input,
uint maxLength,
Vector2 size,
ImGuiInputTextFlags flags) => InputTextMultiline(label, ref input, maxLength, size, flags, null, IntPtr.Zero);
public static bool InputTextMultiline(
string label,
ref string input,
uint maxLength,
Vector2 size,
ImGuiInputTextFlags flags,
ImGuiInputTextCallback callback) => InputTextMultiline(label, ref input, maxLength, size, flags, callback, IntPtr.Zero);
public static bool InputTextMultiline(
string label,
ref string input,
uint maxLength,
Vector2 size,
ImGuiInputTextFlags flags,
ImGuiInputTextCallback callback,
IntPtr user_data)
{
int labelByteCount = Encoding.UTF8.GetByteCount(label);
byte* labelBytes = stackalloc byte[labelByteCount];
fixed (char* labelPtr = label)
{
Encoding.UTF8.GetBytes(labelPtr, label.Length, labelBytes, labelByteCount);
}
int bytesNeeded = Encoding.UTF8.GetByteCount(input);
int stackBufSize = Math.Max((int)maxLength, bytesNeeded);
byte* bufBytes = stackalloc byte[stackBufSize];
fixed (char* u16Ptr = input)
{
Encoding.UTF8.GetBytes(u16Ptr, input.Length, bufBytes, stackBufSize);
}
byte result = ImGuiNative.igInputTextMultiline(
labelBytes,
bufBytes,
(uint)stackBufSize,
size,
flags,
callback,
user_data.ToPointer());
if (!Util.AreStringsEqual(input, bufBytes))
{
input = Util.StringFromPtr(bufBytes);
}
return result != 0;
}
public static bool InputText(
string label,
IntPtr buf,

Loading…
Cancel
Save