Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ zig-out

# Ignore some special OS files
*.DS_Store

# Ignore local example builds
example/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, seems I have missed that out when I was testing the library.

60 changes: 60 additions & 0 deletions src/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,66 @@ pub const textLink = zguiTextLink;

extern fn zguiTextLinkOpenURL(label: [*:0]const u8, url: ?[*:0]const u8) void;
pub const textLinkOpenURL = zguiTextLinkOpenURL;
//--------------------------------------------------------------------------------------------------
const PlotNative = struct {
Copy link
Preview

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The struct name 'PlotNative' is ambiguous and doesn't clearly indicate its purpose. Consider renaming it to 'PlotArgs' or 'PlotOptions' to better reflect that it contains plotting parameters.

Suggested change
const PlotNative = struct {
const PlotArgs = struct {

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bot is right. Let's use PlotArgs here for consistency.

v: [*]f32,
v_count: c_int,
v_offset: c_int = 0,
overlay: ?[:0]const u8 = null,
scale_min: f32 = f32_max,
scale_max: f32 = f32_max,
graph_size: [2]f32 = .{ 0, 0 },
stride: c_int = @sizeOf(f32),
};
pub fn plotLines(label: [*:0]const u8, args: PlotNative) void {
zguiPlotLines(
label,
args.v,
args.v_count,
args.v_offset,
if (args.overlay) |o| o else null,
args.scale_min,
args.scale_max,
&args.graph_size,
args.stride,
);
}
extern fn zguiPlotLines(
label: [*:0]const u8,
v: [*]f32,
v_count: c_int,
v_offset: c_int,
overlay: ?[*:0]const u8,
scale_min: f32,
scale_max: f32,
graph_size: *const [2]f32,
stride: c_int,
) void;

pub fn plotHistogram(label: [*:0]const u8, args: PlotNative) void {
zguiPlotHistogram(
label,
args.v,
args.v_count,
args.v_offset,
if (args.overlay) |o| o else null,
args.scale_min,
args.scale_max,
&args.graph_size,
args.stride,
);
}
extern fn zguiPlotHistogram(
label: [*:0]const u8,
v: [*]f32,
v_count: c_int,
v_offset: c_int,
overlay: ?[*:0]const u8,
scale_min: f32,
scale_max: f32,
graph_size: *const [2]f32,
stride: c_int,
) void;

//--------------------------------------------------------------------------------------------------
//
Expand Down
30 changes: 30 additions & 0 deletions src/zgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,36 @@ extern "C"
{
ImGui::CloseCurrentPopup();
}

ZGUI_API void zguiPlotLines(
const char* label,
const float* values,
int values_count,
int values_offset,
const char* overlay_text,
float scale_min,
float scale_max,
float graph_size[2],
int stride)
{
ImGui::PlotLines(label, values, values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_size[0], graph_size[1]), stride);
}


ZGUI_API void zguiPlotHistogram(
const char* label,
const float* values,
int values_count,
int values_offset,
const char* overlay_text,
float scale_min,
float scale_max,
float graph_size[2],
int stride)
{
ImGui::PlotHistogram(label, values, values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_size[0], graph_size[1]), stride);
}

//--------------------------------------------------------------------------------------------------
//
// Tables
Expand Down
Loading