DearImGui is back again
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user