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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
zig-out

# Ignore some special OS files
*.DS_Store
*.DS_Store
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 PlotArgs = struct {
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: PlotArgs) 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: PlotArgs) 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