Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 110 additions & 3 deletions src/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ fn zguiMemFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.C) void {
defer mem_mutex.unlock();

if (mem_allocations != null) {
const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
mem_allocator.?.free(mem);
if (mem_allocations.?.fetchRemove(@intFromPtr(ptr))) |kv| {
const size = kv.value;
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
mem_allocator.?.free(mem);
}
}
}
}
Expand Down Expand Up @@ -4226,6 +4228,59 @@ pub const DrawList = *opaque {
num_segments: c_int,
) void;
//----------------------------------------------------------------------------------------------
pub fn addEllipse(draw_list: DrawList, args: struct {
p: [2]f32,
r: [2]f32,
col: u32,
rot: f32 = 0,
num_segments: i32 = 0,
thickness: f32 = 1.0,
}) void {
zguiDrawList_AddEllipse(
draw_list,
&args.p,
&args.r,
args.col,
args.rot,
args.num_segments,
args.thickness,
);
}
extern fn zguiDrawList_AddEllipse(
draw_list: DrawList,
center: *const [2]f32,
radius: *const [2]f32,
col: u32,
rot: f32,
num_segments: c_int,
thickness: f32,
) void;
//----------------------------------------------------------------------------------------------
pub fn addEllipseFilled(draw_list: DrawList, args: struct {
p: [2]f32,
r: [2]f32,
col: u32,
rot: f32 = 0,
num_segments: u16 = 0,
}) void {
zguiDrawList_AddEllipseFilled(
draw_list,
&args.p,
&args.r,
args.col,
args.rot,
args.num_segments,
);
}
extern fn zguiDrawList_AddEllipseFilled(
draw_list: DrawList,
center: *const [2]f32,
radius: *const [2]f32,
col: u32,
rot: f32,
num_segments: c_int,
) void;
//----------------------------------------------------------------------------------------------
pub fn addNgon(draw_list: DrawList, args: struct {
p: [2]f32,
r: f32,
Expand Down Expand Up @@ -4324,6 +4379,25 @@ pub const DrawList = *opaque {
col: u32,
) void;
//----------------------------------------------------------------------------------------------
pub fn addConcavePolyFilled(
draw_list: DrawList,
points: []const [2]f32,
col: u32,
) void {
zguiDrawList_AddConcavePolyFilled(
draw_list,
points.ptr,
@intCast(points.len),
col,
);
}
extern fn zguiDrawList_AddConcavePolyFilled(
draw_list: DrawList,
points: [*]const [2]f32,
num_points: c_int,
col: u32,
) void;
//----------------------------------------------------------------------------------------------
pub fn addBezierCubic(draw_list: DrawList, args: struct {
p1: [2]f32,
p2: [2]f32,
Expand Down Expand Up @@ -4500,6 +4574,11 @@ pub const DrawList = *opaque {
}
extern fn zguiDrawList_PathFillConvex(draw_list: DrawList, col: c_uint) void;
//----------------------------------------------------------------------------------------------
pub fn pathFillConcave(draw_list: DrawList, col: u32) void {
return zguiDrawList_PathFillConcave(draw_list, col);
}
extern fn zguiDrawList_PathFillConcave(draw_list: DrawList, col: c_uint) void;
//----------------------------------------------------------------------------------------------
pub fn pathStroke(draw_list: DrawList, args: struct {
col: u32,
flags: DrawFlags = .{},
Expand Down Expand Up @@ -4550,6 +4629,34 @@ pub const DrawList = *opaque {
a_max_of_12: c_int,
) void;
//----------------------------------------------------------------------------------------------
pub fn pathEllipticalArcTo(draw_list: DrawList, args: struct {
p: [2]f32,
r: [2]f32,
rot: f32,
amin: f32,
amax: f32,
num_segments: u16 = 0,
}) void {
zguiDrawList_PathEllipticalArcTo(
draw_list,
&args.p,
&args.r,
args.rot,
args.amin,
args.amax,
args.num_segments,
);
}
extern fn zguiDrawList_PathEllipticalArcTo(
draw_list: DrawList,
center: *const [2]f32,
radius: *const [2]f32,
rot: f32,
amin: f32,
amax: f32,
num_segments: c_int,
) void;
//----------------------------------------------------------------------------------------------
pub fn pathBezierCubicCurveTo(draw_list: DrawList, args: struct {
p2: [2]f32,
p3: [2]f32,
Expand Down
49 changes: 49 additions & 0 deletions src/zgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,29 @@ extern "C"
draw_list->AddCircleFilled({center[0], center[1]}, radius, col, num_segments);
}

ZGUI_API void zguiDrawList_AddEllipse(
ImDrawList *draw_list,
const float center[2],
const float radius[2],
ImU32 col,
float rot,
int num_segments,
float thickness)
{
draw_list->AddEllipse({center[0], center[1]}, {radius[0], radius[1]}, col, rot, num_segments, thickness);
}

ZGUI_API void zguiDrawList_AddEllipseFilled(
ImDrawList *draw_list,
const float center[2],
const float radius[2],
ImU32 col,
float rot,
int num_segments)
{
draw_list->AddEllipseFilled({center[0], center[1]}, {radius[0], radius[1]}, col, rot, num_segments);
}

ZGUI_API void zguiDrawList_AddNgon(
ImDrawList *draw_list,
const float center[2],
Expand Down Expand Up @@ -2291,6 +2314,15 @@ extern "C"
draw_list->AddConvexPolyFilled((const ImVec2 *)&points[0][0], num_points, col);
}

ZGUI_API void zguiDrawList_AddConcavePolyFilled(
ImDrawList *draw_list,
const float points[][2],
int num_points,
ImU32 col)
{
draw_list->AddConcavePolyFilled((const ImVec2 *)&points[0][0], num_points, col);
}

ZGUI_API void zguiDrawList_AddBezierCubic(
ImDrawList *draw_list,
const float p1[2],
Expand Down Expand Up @@ -2404,6 +2436,11 @@ extern "C"
draw_list->PathFillConvex(col);
}

ZGUI_API void zguiDrawList_PathFillConcave(ImDrawList *draw_list, ImU32 col)
{
draw_list->PathFillConcave(col);
}

ZGUI_API void zguiDrawList_PathStroke(ImDrawList *draw_list, ImU32 col, ImDrawFlags flags, float thickness)
{
draw_list->PathStroke(col, flags, thickness);
Expand All @@ -2430,6 +2467,18 @@ extern "C"
draw_list->PathArcToFast({center[0], center[1]}, radius, a_min_of_12, a_max_of_12);
}

ZGUI_API void zguiDrawList_PathEllipticalArcTo(
ImDrawList *draw_list,
const float center[2],
const float radius[2],
float rot,
int a_min,
int a_max,
int num_segments)
{
draw_list->PathEllipticalArcTo({center[0], center[1]}, {radius[0], radius[1]}, rot, a_min, a_max, num_segments);
}

ZGUI_API void zguiDrawList_PathBezierCubicCurveTo(
ImDrawList *draw_list,
const float p2[2],
Expand Down
Loading