chore: update to zgui v1.89.6
This commit is contained in:
41
src/gui.zig
41
src/gui.zig
@@ -1,4 +1,18 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Zig bindings for 'dear imgui' library. Easy to use, hand-crafted API with default arguments,
|
||||
// named parameters and Zig style text formatting.
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub const version = @import("std").SemanticVersion{ .major = 1, .minor = 89, .patch = 6 };
|
||||
|
||||
pub const plot = @import("plot.zig");
|
||||
pub const backend = switch (@import("zgui_options").backend) {
|
||||
.glfw_wgpu => @import("backend_glfw_wgpu.zig"),
|
||||
.win32_dx12 => .{}, // TODO:
|
||||
.no_backend => .{},
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -175,7 +189,13 @@ pub const io = struct {
|
||||
config: ?FontConfig,
|
||||
ranges: ?[*]const Wchar,
|
||||
) Font {
|
||||
return zguiIoAddFontFromMemoryWithConfig(fontdata.ptr, @intCast(i32, fontdata.len), size_pixels, if (config) |c| &c else null, ranges);
|
||||
return zguiIoAddFontFromMemoryWithConfig(
|
||||
fontdata.ptr,
|
||||
@intCast(i32, fontdata.len),
|
||||
size_pixels,
|
||||
if (config) |c| &c else null,
|
||||
ranges,
|
||||
);
|
||||
}
|
||||
extern fn zguiIoAddFontFromMemoryWithConfig(
|
||||
font_data: *const anyopaque,
|
||||
@@ -3025,6 +3045,16 @@ extern fn zguiColorConvertRGBtoHSV(r: f32, g: f32, b: f32, out_h: *f32, out_s: *
|
||||
extern fn zguiColorConvertHSVtoRGB(h: f32, s: f32, v: f32, out_r: *f32, out_g: *f32, out_b: *f32) void;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Inputs Utilities: Keyboard
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn isKeyDown(key: Key) bool {
|
||||
return zguiIsKeyDown(key);
|
||||
}
|
||||
|
||||
extern fn zguiIsKeyDown(key: Key) bool;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Helpers
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -3053,7 +3083,14 @@ pub fn typeToDataTypeEnum(comptime T: type) DataType {
|
||||
u64 => .U64,
|
||||
f32 => .F32,
|
||||
f64 => .F64,
|
||||
else => @compileError("Only fundamental scalar types allowed"),
|
||||
usize => switch (@sizeOf(usize)) {
|
||||
1 => .U8,
|
||||
2 => .U16,
|
||||
4 => .U32,
|
||||
8 => .U64,
|
||||
else => @compileError("Unsupported usize length"),
|
||||
},
|
||||
else => @compileError("Only fundamental scalar types allowed: " ++ @typeName(T)),
|
||||
};
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
44
src/plot.zig
44
src/plot.zig
@@ -497,6 +497,50 @@ extern fn zguiPlot_PlotScatter(
|
||||
offset: i32,
|
||||
stride: i32,
|
||||
) void;
|
||||
|
||||
pub const ShadedFlags = packed struct(u32) {
|
||||
_padding: u32 = 0,
|
||||
};
|
||||
fn PlotShadedGen(comptime T: type) type {
|
||||
return struct {
|
||||
xv: []const T,
|
||||
yv: []const T,
|
||||
yref: f64 = 0.0,
|
||||
flags: ShadedFlags = .{},
|
||||
offset: i32 = 0,
|
||||
stride: i32 = @sizeOf(T),
|
||||
};
|
||||
}
|
||||
pub fn plotShaded(label_id: [:0]const u8, comptime T: type, args: PlotShadedGen(T)) void {
|
||||
assert(args.xv.len == args.yv.len);
|
||||
zguiPlot_PlotShaded(
|
||||
label_id,
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.xv.ptr,
|
||||
args.yv.ptr,
|
||||
@intCast(i32, args.xv.len),
|
||||
args.yref,
|
||||
args.flags,
|
||||
args.offset,
|
||||
args.stride,
|
||||
);
|
||||
}
|
||||
extern fn zguiPlot_PlotShaded(
|
||||
label_id: [*:0]const u8,
|
||||
data_type: gui.DataType,
|
||||
xv: *const anyopaque,
|
||||
yv: *const anyopaque,
|
||||
count: i32,
|
||||
yref: f64,
|
||||
flags: ShadedFlags,
|
||||
offset: i32,
|
||||
stride: i32,
|
||||
) void;
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
/// `pub fn showDemoWindow(popen: ?*bool) void`
|
||||
pub const showDemoWindow = zguiPlot_ShowDemoWindow;
|
||||
extern fn zguiPlot_ShowDemoWindow(popen: ?*bool) void;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
/// `pub fn endPlot() void`
|
||||
pub const endPlot = zguiPlot_EndPlot;
|
||||
|
||||
43
src/zgui.cpp
43
src/zgui.cpp
@@ -1579,6 +1579,14 @@ ZGUI_API void zguiColorConvertHSVtoRGB(float h, float s, float v, float* out_r,
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Inputs Utilities: Keyboard
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ZGUI_API bool zguiIsKeyDown(ImGuiKey key) {
|
||||
return ImGui::IsKeyDown(key);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// DrawList
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2308,6 +2316,41 @@ ZGUI_API void zguiPlot_PlotScatterValues(
|
||||
assert(false);
|
||||
}
|
||||
|
||||
ZGUI_API void zguiPlot_PlotShaded(
|
||||
const char* label_id,
|
||||
ImGuiDataType data_type,
|
||||
const void* xv,
|
||||
const void* yv,
|
||||
int count,
|
||||
double yref,
|
||||
ImPlotShadedFlags flags,
|
||||
int offset,
|
||||
int stride
|
||||
) {
|
||||
if (data_type == ImGuiDataType_S8)
|
||||
ImPlot::PlotShaded(label_id, (const ImS8*)xv, (const ImS8*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_U8)
|
||||
ImPlot::PlotShaded(label_id, (const ImU8*)xv, (const ImU8*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_S16)
|
||||
ImPlot::PlotShaded(label_id, (const ImS16*)xv, (const ImS16*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_U16)
|
||||
ImPlot::PlotShaded(label_id, (const ImU16*)xv, (const ImU16*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_S32)
|
||||
ImPlot::PlotShaded(label_id, (const ImS32*)xv, (const ImS32*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_U32)
|
||||
ImPlot::PlotShaded(label_id, (const ImU32*)xv, (const ImU32*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
ImPlot::PlotShaded(label_id, (const float*)xv, (const float*)yv, count, yref, flags, offset, stride);
|
||||
else if (data_type == ImGuiDataType_Double)
|
||||
ImPlot::PlotShaded(label_id, (const double*)xv, (const double*)yv, count, yref, flags, offset, stride);
|
||||
else
|
||||
assert(false);
|
||||
}
|
||||
|
||||
ZGUI_API void zguiPlot_ShowDemoWindow(bool* p_open) {
|
||||
ImPlot::ShowDemoWindow(p_open);
|
||||
}
|
||||
|
||||
ZGUI_API void zguiPlot_EndPlot(void) {
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user