DearImGui is back again

This commit is contained in:
2025-03-22 17:33:10 +01:00
parent 9a8ab7853a
commit 2208a7200f
6 changed files with 172 additions and 49 deletions

View File

@@ -144,3 +144,34 @@ ImGui_ImplSdl_SetClipboardText :: (data: *void, text: *u8) #c_call {
SDL_SetClipboardText(text);
}
text_resize_callback :: (data: *ImGui.InputTextCallbackData) -> s32 #c_call {
push_context {
str := cast(*string)data.UserData;
result : *u8 = alloc(data.BufTextLen + 1);
memcpy(result, str.data, str.count);
result[str.count] = 0;
if str.data != null {
free(str.data);
}
str.count = data.BufTextLen;
str.data = result;
data.Buf = str.data;
}
return 0;
}
imgui_input_text :: (label: string, text: *string) {
if text.data == null {
text.data = alloc(1);
memset(text.data, 0, 1);
}
changed := ImGui.InputText(to_temp_c_string(label), to_temp_c_string(text.*), cast(u64) text.count + 1, .CallbackResize, text_resize_callback, user_data=text);
}
imgui_input_int :: (label: string, val: *int) {
new_val := cast(s32)val.*;
ImGui.InputInt(to_temp_c_string(label), *new_val);
val.* = cast(int)new_val;
}