public static unsafe void InputTextMultiline(string label, IntPtr textBuffer, uint bufferSize, Vector2 size, InputTextFlags flags, TextEditCallback callback, IntPtr userData) { ImGuiNative.igInputTextMultiline(utf8String(label), textBuffer, bufferSize, size, flags, callback, userData.ToPointer()); }
private static char[] ApplyFilter(Queue <char> imeBuffer, InputTextFlags flags, Func <char, bool> checker) { if (checker != null) { List <char> list = new List <char>(); foreach (var c in imeBuffer) { if (checker(c)) { list.Add(c); } } return(list.ToArray()); } else if (flags == 0 || !CheckFlags(flags)) { return(imeBuffer.ToArray()); } else { List <char> list = new List <char>(); foreach (var c in imeBuffer) { bool pass = false; char charToAdd = c; if (flags.HaveFlag(InputTextFlags.CharsDecimal)) { if (c >= '0' && c <= '9' || c == '.') { pass = true; } } else if (flags.HaveFlag(InputTextFlags.CharsHexadecimal)) { if (flags.HaveFlag(InputTextFlags.CharsUppercase)) { if (c >= '0' && c <= '9' || c >= 'A' && c <= 'F') { pass = true; } } else { if (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f') { pass = true; } } } else if (flags.HaveFlag(InputTextFlags.CharsUppercase)) { if (c >= 'A' && c <= 'Z') { pass = true; } else if (c >= 'a' && c <= 'z') { charToAdd = char.ToUpper(c); pass = true; } } else if (flags.HaveFlag(InputTextFlags.CharsNoBlank)) { if (!char.IsWhiteSpace(c)) { pass = true; } } if (pass) { list.Add(charToAdd); } } return(list.ToArray()); } }
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback, IntPtr userData) { return ImGuiNative.igInputText(label, textBuffer, bufferSize, flags, textEditCallback, userData.ToPointer()); }
public static string TextBoxBehavior(int id, Rect rect, string text, out bool hovered, out bool active, out InputTextContext context, InputTextFlags flags = 0, Func <char, bool> checker = null) { GUIContext g = Form.current.uiContext; active = false; hovered = g.IsHovered(rect, id); if (hovered) { g.SetHoverID(id); if (Mouse.Instance.LeftButtonPressed) { g.SetActiveID(id); } } else { if (Mouse.Instance.LeftButtonPressed) { if (g.ActiveId == id) { g.SetActiveID(0); } } } if (g.ActiveId == id && g.InputTextState.inputTextContext.Id != id) //editing text box changed to TextBox<id> { g.InputTextState.stateMachine.CurrentState = "Active"; //reset state g.InputTextState.inputTextContext = new InputTextContext() //reset input text context data { Id = id, CaretIndex = 0, SelectIndex = 0, Selecting = false, CaretPosition = Point.Zero, Flags = flags, Checker = checker, Rect = rect, Text = text }; } context = null; if (g.ActiveId == id) { active = true; var stateMachine = g.InputTextState.stateMachine; context = g.InputTextState.inputTextContext; context.Rect = rect; // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. // Down the line we should have a cleaner library-wide concept of Selected vs Active. g.ActiveIdAllowOverlap = !Mouse.Instance.LeftButtonPressed; #if INSPECT_STATE var A = stateMachine.CurrentState; #endif if (Mouse.Instance.LeftButtonPressed) { stateMachine.MoveNext(TextBoxCommand.MoveCaret, context); } if (hovered && Mouse.Instance.LeftButtonState == KeyState.Down && stateMachine.CurrentState != TextBoxState.ActiveSelecting) { stateMachine.MoveNext(TextBoxCommand.MoveCaret, context); stateMachine.MoveNext(TextBoxCommand.BeginSelect, context); } if (hovered && Mouse.Instance.LeftButtonState == KeyState.Up) { stateMachine.MoveNext(TextBoxCommand.EndSelect, context); } if (stateMachine.CurrentState == TextBoxState.Active) { stateMachine.MoveNext(TextBoxCommand.DoEdit, context); } if (stateMachine.CurrentState == TextBoxState.ActiveSelecting) { stateMachine.MoveNext(TextBoxCommand.DoSelect, context); } stateMachine.MoveNext(TextBoxCommand.MoveCaretKeyboard, context); #if INSPECT_STATE var B = stateMachine.CurrentState; Debug.WriteLineIf(A != B, string.Format("TextBox<{0}> {1}=>{2} CaretIndex: {3}, SelectIndex: {4}", id, A, B, context.CaretIndex, context.SelectIndex)); #endif return(context.Text); } return(text); }
public static extern bool igInputFloat4(string label, Vector4 v, int decimal_precision, InputTextFlags extra_flags);
public static extern bool igInputInt4(string label, Int4 v, InputTextFlags extra_flags);
public static bool InputText(string label, ref string text, uint maxLength = 1024, InputTextFlags flags = InputTextFlags.Default, TextEditCallback callback = null) { bool state; byte[] textArray = new byte[maxLength]; Encoding.Default.GetBytes(text, 0, text.Length, textArray, 0); byte[] labelArray = Encoding.UTF8.GetBytes(label); unsafe { fixed(byte *txtPtr = textArray) { state = ImGuiNative.igInputText(labelArray, new IntPtr(txtPtr), maxLength, flags, callback, IntPtr.Zero.ToPointer()); } } text = System.Text.Encoding.Default.GetString(textArray).TrimEnd('\0'); return(state); }
public static extern bool igInputTextMultiline(string label, IntPtr buffer, uint buf_size, Vector2 size, InputTextFlags flags, TextEditCallback callback, void* user_data);
public static extern bool igInputInt(string label, int *v, int step, int step_fast, InputTextFlags extra_flags);
public static extern bool igInputFloat(string label, float *v, float step, float step_fast, int decimal_precision, InputTextFlags extra_flags);
public static extern bool igInputTextMultiline(string label, IntPtr buffer, uint buf_size, Vector2 size, InputTextFlags flags, TextEditCallback callback, void *user_data);
// Unput Text public static unsafe string InputText(string label, string currentValue, uint maxLength, InputTextFlags flags) { var currentStringBytes = Encoding.Default.GetBytes(currentValue); var buffer = new byte[maxLength]; Array.Copy(currentStringBytes, buffer, Math.Min(currentStringBytes.Length, maxLength)); int Callback(TextEditCallbackData *data) { var pCursorPos = (int *)data->UserData; if (!data->HasSelection()) { *pCursorPos = data->CursorPos; } return(0); } ImGui.InputText(label, buffer, maxLength, flags, Callback); return(Encoding.Default.GetString(buffer).TrimEnd('\0')); }
public static bool HaveFlag(this InputTextFlags value, InputTextFlags flag) { return((value & flag) != 0); }
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback) { return(InputText(label, textBuffer, bufferSize, flags, textEditCallback, IntPtr.Zero)); }
protected BaseEditableText(int index, object editObject, MemberInfo info, Type type, ObjectAccessor objectAccessor, InputTextFlags flags) { _label = $"{index}: {info.Name}"; _info = info; _flags = flags; }
public static extern bool igInputFloat(string label, float* v, float step, float step_fast, int decimal_precision, InputTextFlags extra_flags);
public static unsafe void InputTextMultiline(string label, IntPtr textBuffer, uint bufferSize, Vector2 size, InputTextFlags flags, TextEditCallback callback) { ImGuiNative.igInputTextMultiline(label, textBuffer, bufferSize, size, flags, callback, null); }
public static extern bool igInputInt(string label, int* v, int step, int step_fast, InputTextFlags extra_flags);
public static unsafe bool InputText(string label, byte[] textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback, IntPtr userData) { Debug.Assert(bufferSize <= textBuffer.Length); fixed(byte *ptrBuf = textBuffer) { return(InputText(label, new IntPtr(ptrBuf), bufferSize, flags, textEditCallback, userData)); } }
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback) { return InputText(label, textBuffer, bufferSize, flags, textEditCallback, IntPtr.Zero); }
public static unsafe bool InputText(string label, IntPtr textBuffer, uint bufferSize, InputTextFlags flags, TextEditCallback textEditCallback, IntPtr userData) { return(ImGuiNative.igInputText(utf8String(label), textBuffer, bufferSize, flags, textEditCallback, userData.ToPointer())); }
public static unsafe void InputTextMultiline(string label, IntPtr textBuffer, uint bufferSize, Vector2 size, InputTextFlags flags, TextEditCallback callback, IntPtr userData) { ImGuiNative.igInputTextMultiline(label, textBuffer, bufferSize, size, flags, callback, userData.ToPointer()); }
public static string TextBox(string label, double width, string text, InputTextFlags flags, Func <char, bool> checker) { return(TextBox(label, width, text, flags, checker, null)); }