Skip to content
47 changes: 47 additions & 0 deletions src/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4551,6 +4551,53 @@ pub const DrawList = *opaque {
text: [*]const u8,
text_end: [*]const u8,
) void;
const AddTextArgs = struct {
font: ?Font,
font_size: f32,
wrap_width: f32 = 0,
cpu_fine_clip_rect: ?[*]const [4]f32 = null,
};
pub fn addTextExtended(
draw_list: DrawList,
pos: [2]f32,
col: u32,
comptime fmt: []const u8,
args: anytype,
add_text_args: AddTextArgs,
) void {
const txt = format(fmt, args);
addTextExtendedUnformatted(draw_list, pos, col, txt, add_text_args);
}
pub fn addTextExtendedUnformatted(
draw_list: DrawList,
pos: [2]f32,
col: u32,
txt: []const u8,
add_text_args: AddTextArgs,
) void {
zguiDrawList_AddTextExtended(
draw_list,
add_text_args.font,
add_text_args.font_size,
&pos,
col,
txt.ptr,
txt.ptr + txt.len,
add_text_args.wrap_width,
add_text_args.cpu_fine_clip_rect,
);
}
extern fn zguiDrawList_AddTextExtended(
draw_list: DrawList,
font: ?Font,
font_size: f32,
pos: *const [2]f32,
col: u32,
text: [*]const u8,
text_end: [*]const u8,
wrap_width: f32,
cpu_fine_clip_rect: ?[*]const [4]f32,
) void;
//----------------------------------------------------------------------------------------------
pub fn addPolyline(draw_list: DrawList, points: []const [2]f32, args: struct {
col: u32,
Expand Down
15 changes: 15 additions & 0 deletions src/zgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,6 +2519,21 @@ extern "C"
draw_list->AddText({pos[0], pos[1]}, col, text_begin, text_end);
}

ZGUI_API void zguiDrawList_AddTextExtended(
ImDrawList *draw_list,
ImFont* font,
float font_size,
const float pos[2],
ImU32 col,
const char* text_begin,
const char* text_end,
float wrap_width,
const float cpu_fine_clip_rect[][4])
{
const ImVec4* clip_rect = (cpu_fine_clip_rect != nullptr) ? (const ImVec4 *)&cpu_fine_clip_rect[0][0] : nullptr;
draw_list->AddText(font, font_size, {pos[0], pos[1]}, col, text_begin, text_end, wrap_width, clip_rect);
}

ZGUI_API void zguiDrawList_AddPolyline(
ImDrawList *draw_list,
const float points[][2],
Expand Down
Loading