From e009f01d381021f5c2285da0a610c49ec397ec76 Mon Sep 17 00:00:00 2001 From: paoda Date: Fri, 22 Mar 2024 09:49:07 -0500 Subject: [PATCH] chore: update to 1a80092c18ddfeb31ec1252f47f71d344a7fd0ab --- README.md | 63 +- build.zig | 228 +++--- build.zig.zon | 2 +- libs/imgui/backends/imgui_impl_wgpu.cpp | 17 + src/backend_glfw_dx12.zig | 74 ++ src/gui.zig | 918 ++++++++++++++---------- src/zgui.cpp | 115 ++- 7 files changed, 826 insertions(+), 591 deletions(-) create mode 100644 src/backend_glfw_dx12.zig diff --git a/README.md b/README.md index 7abb47a..7c75bcb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# zgui v1.89.6 - dear imgui bindings +# zgui v0.1.0 - dear imgui bindings Easy to use, hand-crafted API with default arguments, named parameters and Zig style text formatting. [Here](https://github.com/michal-z/zig-gamedev/tree/main/samples/minimal_zgpu_zgui) is a simple sample application, and [here](https://github.com/michal-z/zig-gamedev/tree/main/samples/gui_test_wgpu) is a full one. @@ -11,64 +11,41 @@ Easy to use, hand-crafted API with default arguments, named parameters and Zig s ## Getting started -Copy `zgui` folder to a `libs` subdirectory of the root of your project and add the following to your `build.zig.zon` .dependencies: +Copy `zgui` to a subdirectory in your project and add the following to your `build.zig.zon` .dependencies: ```zig .zgui = .{ .path = "libs/zgui" }, ``` -To get glfw/wgpu rendering backend working also copy `zgpu`, `zglfw`, `zpool` and `system-sdk` folders and add the depenency paths (see [zgpu](https://github.com/zig-gamedev/zig-gamedev/tree/main/libs/zgpu) for the details). Alternatively, you can provide your own rendering backend by specifying `.no_backend` in the package options. +To get glfw/wgpu rendering backend working also copy `zglfw`, `system-sdk`, `zgpu` and `zpool` folders and add the depenency paths (see [zgpu](https://github.com/zig-gamedev/zig-gamedev/tree/main/libs/zgpu) for the details). Then in your `build.zig` add: ```zig -const zgui = @import("zgui"); - -// Needed for glfw/wgpu rendering backend -const zglfw = @import("zglfw"); -const zgpu = @import("zgpu"); -const zpool = @import("zpool"); pub fn build(b: *std.Build) void { - ... - const optimize = b.standardOptimizeOption(.{}); - const target = b.standardTargetOptions(.{}); + const exe = b.addExecutable(.{ ... }); - const zgui_pkg = zgui.package(b, target, optimize, .{ - .options = .{ .backend = .glfw_wgpu }, + const zgui = b.dependency("zgui", .{ + .shared = false, + .with_implot = true, }); - - zgui_pkg.link(exe); + exe.root_module.addImport("zgui", zgui.module("root")); + exe.linkLibrary(zgui.artifact("imgui")); - // Needed for glfw/wgpu rendering backend - const zglfw_pkg = zglfw.package(b, target, optimize, .{}); - const zpool_pkg = zpool.package(b, target, optimize, .{}); - const zgpu_pkg = zgpu.package(b, target, optimize, .{ - .deps = .{ .zpool = zpool_pkg.zpool, .zglfw = zglfw_pkg.zglfw }, - }); + { // Needed for glfw/wgpu rendering backend + const zglfw = b.dependency("zglfw", .{}); + exe.root_module.addImport("zglfw", zglfw.module("root")); + exe.linkLibrary(zglfw.artifact("glfw")); - zglfw_pkg.link(exe); - zgpu_pkg.link(exe); + const zpool = b.dependency("zpool", .{}); + exe.root_module.addImport("zpool", zglfw.module("root")); + + const zgpu = b.dependency("zgpu", .{}); + exe.root_module.addImport("zgpu", zglfw.module("root")); + exe.linkLibrary(zglfw.artifact("wgpu")); + } } ``` -You may also include zgui without bundled imgui or implot: - -```zig -// In build.zig - - const pkg = zgui.package(b, exe.target, .ReleaseSafe, .{ - .options = .{ - .backend = .no_backend, - .with_imgui = false, - .with_implot = false, - }, - }); - const lib = pkg.zgui_c_cpp; - lib.defineCMacro("IMGUI_USER_CONFIG", - \\"../imconfig_custom.h" - ); - lib.addIncludePath("lib/imgui"); -``` - Now in your code you may import and use `zgui`: ```zig diff --git a/build.zig b/build.zig index 08fd840..8cdc49f 100644 --- a/build.zig +++ b/build.zig @@ -4,61 +4,47 @@ pub const Backend = enum { no_backend, glfw_wgpu, glfw_opengl3, + glfw_dx12, win32_dx12, }; -const default_options = struct { - const shared = false; - const with_imgui = true; - const with_implot = true; -}; +pub fn build(b: *std.Build) void { + const optimize = b.standardOptimizeOption(.{}); + const target = b.standardTargetOptions(.{}); -pub const Options = struct { - backend: Backend, - shared: bool = default_options.shared, - /// use bundled imgui source - with_imgui: bool = default_options.with_imgui, - /// use bundled implot source - with_implot: bool = default_options.with_implot, -}; + const options = .{ + .backend = b.option(Backend, "backend", "Backend to build (default: no_backend)") orelse .no_backend, + .shared = b.option( + bool, + "shared", + "Bulid as a shared library", + ) orelse false, + .with_implot = b.option( + bool, + "with_implot", + "Build with bundled implot source", + ) orelse true, + }; -pub const Package = struct { - options: Options, - zgui: *std.Build.Module, - zgui_options: *std.Build.Module, - zgui_c_cpp: *std.Build.Step.Compile, - - pub fn link(pkg: Package, exe: *std.Build.Step.Compile) void { - exe.linkLibrary(pkg.zgui_c_cpp); - exe.root_module.addImport("zgui", pkg.zgui); - exe.root_module.addImport("zgui_options", pkg.zgui_options); + const options_step = b.addOptions(); + inline for (std.meta.fields(@TypeOf(options))) |field| { + options_step.addOption(field.type, field.name, @field(options, field.name)); } -}; -pub fn package( - b: *std.Build, - target: std.Build.ResolvedTarget, - optimize: std.builtin.Mode, - args: struct { - options: Options, - }, -) Package { - const step = b.addOptions(); - step.addOption(Backend, "backend", args.options.backend); - step.addOption(bool, "shared", args.options.shared); + const options_module = options_step.createModule(); - const zgui_options = step.createModule(); - - const zgui = b.addModule("zgui", .{ - .root_source_file = .{ .path = thisDir() ++ "/src/gui.zig" }, + _ = b.addModule("root", .{ + .root_source_file = .{ .path = "src/gui.zig" }, .imports = &.{ - .{ .name = "zgui_options", .module = zgui_options }, + .{ .name = "zgui_options", .module = options_module }, }, }); - const zgui_c_cpp = if (args.options.shared) blk: { + const cflags = &.{"-fno-sanitize=undefined"}; + + const imgui = if (options.shared) blk: { const lib = b.addSharedLibrary(.{ - .name = "zgui", + .name = "imgui", .target = target, .optimize = optimize, }); @@ -76,147 +62,113 @@ pub fn package( break :blk lib; } else b.addStaticLibrary(.{ - .name = "zgui", + .name = "imgui", .target = target, .optimize = optimize, }); - zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs" }); - zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs/imgui" }); + b.installArtifact(imgui); - const abi = target.result.abi; - zgui_c_cpp.linkLibC(); - if (abi != .msvc) - zgui_c_cpp.linkLibCpp(); + imgui.addIncludePath(.{ .path = "libs" }); + imgui.addIncludePath(.{ .path = "libs/imgui" }); - const cflags = &.{"-fno-sanitize=undefined"}; + imgui.linkLibC(); + if (target.result.abi != .msvc) + imgui.linkLibCpp(); - zgui_c_cpp.addCSourceFile(.{ - .file = .{ .path = thisDir() ++ "/src/zgui.cpp" }, + imgui.addCSourceFile(.{ + .file = .{ .path = "src/zgui.cpp" }, .flags = cflags, }); - if (args.options.with_imgui) { - zgui_c_cpp.addCSourceFiles(.{ - .files = &.{ - thisDir() ++ "/libs/imgui/imgui.cpp", - thisDir() ++ "/libs/imgui/imgui_widgets.cpp", - thisDir() ++ "/libs/imgui/imgui_tables.cpp", - thisDir() ++ "/libs/imgui/imgui_draw.cpp", - thisDir() ++ "/libs/imgui/imgui_demo.cpp", - }, - .flags = cflags, - }); - } + imgui.addCSourceFiles(.{ + .files = &.{ + "libs/imgui/imgui.cpp", + "libs/imgui/imgui_widgets.cpp", + "libs/imgui/imgui_tables.cpp", + "libs/imgui/imgui_draw.cpp", + "libs/imgui/imgui_demo.cpp", + }, + .flags = cflags, + }); - if (args.options.with_implot) { - zgui_c_cpp.defineCMacro("ZGUI_IMPLOT", "1"); - zgui_c_cpp.addCSourceFiles(.{ + if (options.with_implot) { + imgui.defineCMacro("ZGUI_IMPLOT", "1"); + imgui.addCSourceFiles(.{ .files = &.{ - thisDir() ++ "/libs/imgui/implot_demo.cpp", - thisDir() ++ "/libs/imgui/implot.cpp", - thisDir() ++ "/libs/imgui/implot_items.cpp", + "libs/imgui/implot_demo.cpp", + "libs/imgui/implot.cpp", + "libs/imgui/implot_items.cpp", }, .flags = cflags, }); } else { - zgui_c_cpp.defineCMacro("ZGUI_IMPLOT", "0"); + imgui.defineCMacro("ZGUI_IMPLOT", "0"); } - switch (args.options.backend) { + switch (options.backend) { .glfw_wgpu => { const zglfw = b.dependency("zglfw", .{}); const zgpu = b.dependency("zgpu", .{}); - zgui_c_cpp.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); - zgui_c_cpp.addIncludePath(.{ .path = zgpu.path("libs/dawn/include").getPath(b) }); - zgui_c_cpp.addCSourceFiles(.{ + imgui.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); + imgui.addIncludePath(.{ .path = zgpu.path("libs/dawn/include").getPath(b) }); + imgui.addCSourceFiles(.{ .files = &.{ - thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", - thisDir() ++ "/libs/imgui/backends/imgui_impl_wgpu.cpp", + "libs/imgui/backends/imgui_impl_glfw.cpp", + "libs/imgui/backends/imgui_impl_wgpu.cpp", }, .flags = cflags, }); }, .glfw_opengl3 => { const zglfw = b.dependency("zglfw", .{}); - zgui_c_cpp.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); - zgui_c_cpp.addCSourceFiles(.{ + imgui.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); + imgui.addCSourceFiles(.{ .files = &.{ - thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", - thisDir() ++ "/libs/imgui/backends/imgui_impl_opengl3.cpp", + "libs/imgui/backends/imgui_impl_glfw.cpp", + "libs/imgui/backends/imgui_impl_opengl3.cpp", }, .flags = &(cflags.* ++ .{"-DIMGUI_IMPL_OPENGL_LOADER_CUSTOM"}), }); }, - .win32_dx12 => { - zgui_c_cpp.addCSourceFiles(.{ + .glfw_dx12 => { + const zglfw = b.dependency("zglfw", .{}); + imgui.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); + imgui.addCSourceFiles(.{ .files = &.{ - thisDir() ++ "/libs/imgui/backends/imgui_impl_win32.cpp", - thisDir() ++ "/libs/imgui/backends/imgui_impl_dx12.cpp", + "libs/imgui/backends/imgui_impl_glfw.cpp", + "libs/imgui/backends/imgui_impl_dx12.cpp", }, .flags = cflags, }); - zgui_c_cpp.linkSystemLibrary("d3dcompiler_47"); - zgui_c_cpp.linkSystemLibrary("dwmapi"); + imgui.linkSystemLibrary("d3dcompiler_47"); + }, + .win32_dx12 => { + imgui.addCSourceFiles(.{ + .files = &.{ + "libs/imgui/backends/imgui_impl_win32.cpp", + "libs/imgui/backends/imgui_impl_dx12.cpp", + }, + .flags = cflags, + }); + imgui.linkSystemLibrary("d3dcompiler_47"); + imgui.linkSystemLibrary("dwmapi"); }, .no_backend => {}, } - return .{ - .options = args.options, - .zgui = zgui, - .zgui_options = zgui_options, - .zgui_c_cpp = zgui_c_cpp, - }; -} - -pub fn build(b: *std.Build) void { - const optimize = b.standardOptimizeOption(.{}); - const target = b.standardTargetOptions(.{}); - - _ = package(b, target, optimize, .{ - .options = .{ - .backend = b.option(Backend, "backend", "Select backend") orelse .no_backend, - .shared = b.option( - bool, - "shared", - "Bulid as a shared library", - ) orelse default_options.shared, - .with_imgui = b.option( - bool, - "with_imgui", - "Build with bundled imgui source", - ) orelse default_options.with_imgui, - .with_implot = b.option( - bool, - "with_implot", - "Build with bundled implot source", - ) orelse default_options.with_implot, - }, - }); - const test_step = b.step("test", "Run zgui tests"); - test_step.dependOn(runTests(b, optimize, target)); -} -pub fn runTests( - b: *std.Build, - optimize: std.builtin.OptimizeMode, - target: std.Build.ResolvedTarget, -) *std.Build.Step { - const gui_tests = b.addTest(.{ - .name = "gui-tests", - .root_source_file = .{ .path = thisDir() ++ "/src/gui.zig" }, + const tests = b.addTest(.{ + .name = "zgui-tests", + .root_source_file = .{ .path = "src/gui.zig" }, .target = target, .optimize = optimize, }); - const pkg = package(b, target, optimize, .{ - .options = .{ .backend = .no_backend }, - }); - pkg.link(gui_tests); - return &b.addRunArtifact(gui_tests).step; -} + b.installArtifact(tests); -inline fn thisDir() []const u8 { - return comptime std.fs.path.dirname(@src().file) orelse "."; + tests.root_module.addImport("zgui_options", options_module); + tests.linkLibrary(imgui); + + test_step.dependOn(&b.addRunArtifact(tests).step); } diff --git a/build.zig.zon b/build.zig.zon index bad19f4..00a295a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = "zgui", - .version = "1.89.6", + .version = "0.1.0", .paths = .{ "build.zig", "build.zig.zon", diff --git a/libs/imgui/backends/imgui_impl_wgpu.cpp b/libs/imgui/backends/imgui_impl_wgpu.cpp index f17657b..6c2b448 100644 --- a/libs/imgui/backends/imgui_impl_wgpu.cpp +++ b/libs/imgui/backends/imgui_impl_wgpu.cpp @@ -189,6 +189,13 @@ static void SafeRelease(WGPUBuffer& res) wgpuBufferRelease(res); res = nullptr; } +// FIX(zig-gamedev): https://github.com/ocornut/imgui/commit/9266c0d2d1390e50d2d8070896932c2564594407 +static void SafeRelease(WGPUPipelineLayout& res) + { + if (res) + wgpuPipelineLayoutRelease(res); + res = nullptr; + } static void SafeRelease(WGPURenderPipeline& res) { if (res) @@ -664,7 +671,15 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() depth_stencil_state.depthWriteEnabled = false; depth_stencil_state.depthCompare = WGPUCompareFunction_Always; depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always; + // FIX(zig-gamedev): https://github.com/ocornut/imgui/commit/03417cc77d15100b18c486b55db409ee5e9c363e + depth_stencil_state.stencilFront.failOp = WGPUStencilOperation_Keep; + depth_stencil_state.stencilFront.depthFailOp = WGPUStencilOperation_Keep; + depth_stencil_state.stencilFront.passOp = WGPUStencilOperation_Keep; depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always; + // FIX(zig-gamedev): https://github.com/ocornut/imgui/commit/03417cc77d15100b18c486b55db409ee5e9c363e + depth_stencil_state.stencilBack.failOp = WGPUStencilOperation_Keep; + depth_stencil_state.stencilBack.depthFailOp = WGPUStencilOperation_Keep; + depth_stencil_state.stencilBack.passOp = WGPUStencilOperation_Keep; // Configure disabled depth-stencil state graphics_pipeline_desc.depthStencil = (bd->depthStencilFormat == WGPUTextureFormat_Undefined) ? nullptr : &depth_stencil_state; @@ -694,6 +709,8 @@ bool ImGui_ImplWGPU_CreateDeviceObjects() SafeRelease(vertex_shader_desc.module); SafeRelease(pixel_shader_desc.module); + // FIX(zig-gamedev): https://github.com/ocornut/imgui/commit/9266c0d2d1390e50d2d8070896932c2564594407 + SafeRelease(graphics_pipeline_desc.layout); SafeRelease(bg_layouts[0]); return true; diff --git a/src/backend_glfw_dx12.zig b/src/backend_glfw_dx12.zig new file mode 100644 index 0000000..ea48e94 --- /dev/null +++ b/src/backend_glfw_dx12.zig @@ -0,0 +1,74 @@ +const gui = @import("gui.zig"); + +pub fn init( + window: *const anyopaque, // zglfw.Window + device: *const anyopaque, // ID3D12Device + num_frames_in_flight: u32, + rtv_format: c_uint, // DXGI_FORMAT + cbv_srv_heap: *const anyopaque, // ID3D12DescriptorHeap + font_srv_cpu_desc_handle: D3D12_CPU_DESCRIPTOR_HANDLE, + font_srv_gpu_desc_handle: D3D12_GPU_DESCRIPTOR_HANDLE, +) void { + if (!ImGui_ImplGlfw_InitForOther(window, true)) { + @panic("failed to init glfw for imgui"); + } + + if (!ImGui_ImplDX12_Init( + device, + num_frames_in_flight, + rtv_format, + cbv_srv_heap, + font_srv_cpu_desc_handle, + font_srv_gpu_desc_handle, + )) { + @panic("failed to init d3d12 for imgui"); + } +} + +pub fn deinit() void { + ImGui_ImplGlfw_Shutdown(); + ImGui_ImplDX12_Shutdown(); +} + +pub fn newFrame(fb_width: u32, fb_height: u32) void { + ImGui_ImplGlfw_NewFrame(); + ImGui_ImplDX12_NewFrame(); + + gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height))); + gui.io.setDisplayFramebufferScale(1.0, 1.0); + + gui.newFrame(); +} + +pub fn draw( + graphics_command_list: *const anyopaque, // *ID3D12GraphicsCommandList +) void { + gui.render(); + ImGui_ImplDX12_RenderDrawData(gui.getDrawData(), graphics_command_list); +} + +pub const D3D12_CPU_DESCRIPTOR_HANDLE = extern struct { + ptr: c_ulonglong, +}; + +pub const D3D12_GPU_DESCRIPTOR_HANDLE = extern struct { + ptr: c_ulonglong, +}; + +extern fn ImGui_ImplGlfw_InitForOther(window: *const anyopaque, install_callbacks: bool) bool; +extern fn ImGui_ImplGlfw_NewFrame() void; +extern fn ImGui_ImplGlfw_Shutdown() void; +extern fn ImGui_ImplDX12_Init( + device: *const anyopaque, // ID3D12Device + num_frames_in_flight: u32, + rtv_format: u32, // DXGI_FORMAT + cbv_srv_heap: *const anyopaque, // ID3D12DescriptorHeap + font_srv_cpu_desc_handle: D3D12_CPU_DESCRIPTOR_HANDLE, + font_srv_gpu_desc_handle: D3D12_GPU_DESCRIPTOR_HANDLE, +) bool; +extern fn ImGui_ImplDX12_Shutdown() void; +extern fn ImGui_ImplDX12_NewFrame() void; +extern fn ImGui_ImplDX12_RenderDrawData( + draw_data: *const anyopaque, // *ImDrawData + graphics_command_list: *const anyopaque, // *ID3D12GraphicsCommandList +) void; diff --git a/src/gui.zig b/src/gui.zig index bb50585..c50b57f 100644 --- a/src/gui.zig +++ b/src/gui.zig @@ -8,6 +8,7 @@ pub const plot = @import("plot.zig"); pub const backend = switch (@import("zgui_options").backend) { .glfw_wgpu => @import("backend_glfw_wgpu.zig"), .glfw_opengl3 => @import("backend_glfw_opengl.zig"), + .glfw_dx12 => @import("backend_glfw_dx12.zig"), .win32_dx12 => .{}, // TODO: .no_backend => .{}, }; @@ -116,7 +117,7 @@ extern fn zguiSetAllocatorFunctions( free_func: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void, ) void; //-------------------------------------------------------------------------------------------------- -pub const ConfigFlags = packed struct(u32) { +pub const ConfigFlags = packed struct(c_int) { nav_enable_keyboard: bool = false, nav_enable_gamepad: bool = false, nav_enable_set_mouse_pos: bool = false, @@ -131,12 +132,12 @@ pub const ConfigFlags = packed struct(u32) { pub const FontConfig = extern struct { font_data: ?*anyopaque, - font_data_size: i32, + font_data_size: c_int, font_data_owned_by_atlas: bool, - font_no: i32, + font_no: c_int, size_pixels: f32, - oversample_h: i32, - oversample_v: i32, + oversample_h: c_int, + oversample_v: c_int, pixel_snap_h: bool, glyph_extra_spacing: [2]f32, glyph_offset: [2]f32, @@ -144,7 +145,7 @@ pub const FontConfig = extern struct { glyph_min_advance_x: f32, glyph_max_advance_x: f32, merge_mode: bool, - font_builder_flags: u32, + font_builder_flags: c_uint, rasterizer_multiply: f32, ellipsis_char: Wchar, name: [40]u8, @@ -178,9 +179,9 @@ pub const io = struct { ) Font; pub fn addFontFromMemory(fontdata: []const u8, size_pixels: f32) Font { - return zguiIoAddFontFromMemory(fontdata.ptr, @as(i32, @intCast(fontdata.len)), size_pixels); + return zguiIoAddFontFromMemory(fontdata.ptr, @intCast(fontdata.len), size_pixels); } - extern fn zguiIoAddFontFromMemory(font_data: *const anyopaque, font_size: i32, size_pixels: f32) Font; + extern fn zguiIoAddFontFromMemory(font_data: *const anyopaque, font_size: c_int, size_pixels: f32) Font; pub fn addFontFromMemoryWithConfig( fontdata: []const u8, @@ -190,7 +191,7 @@ pub const io = struct { ) Font { return zguiIoAddFontFromMemoryWithConfig( fontdata.ptr, - @as(i32, @intCast(fontdata.len)), + @intCast(fontdata.len), size_pixels, if (config) |c| &c else null, ranges, @@ -198,23 +199,36 @@ pub const io = struct { } extern fn zguiIoAddFontFromMemoryWithConfig( font_data: *const anyopaque, - font_size: i32, + font_size: c_int, size_pixels: f32, config: ?*const FontConfig, ranges: ?[*]const Wchar, ) Font; - /// `pub fn getFont(index: u32) Font` - pub const getFont = zguiIoGetFont; - extern fn zguiIoGetFont(index: u32) Font; + pub fn getFont(index: u32) Font { + return zguiIoGetFont(index); + } + extern fn zguiIoGetFont(index: c_uint) Font; /// `pub fn setDefaultFont(font: Font) void` pub const setDefaultFont = zguiIoSetDefaultFont; extern fn zguiIoSetDefaultFont(font: Font) void; - /// `pub fn getFontsTextDataAsRgba32() return fonts pixel data and size - pub const getFontsTextDataAsRgba32 = zguiIoGetFontsTexDataAsRgba32; - extern fn zguiIoGetFontsTexDataAsRgba32(width: *i32, height: *i32) [*c]const u32; + pub fn getFontsTextDataAsRgba32() struct { + width: i32, + height: i32, + pixels: ?[*]const u32, + } { + var width: i32 = undefined; + var height: i32 = undefined; + const ptr = zguiIoGetFontsTexDataAsRgba32(&width, &height); + return .{ + .width = width, + .height = height, + .pixels = ptr, + }; + } + extern fn zguiIoGetFontsTexDataAsRgba32(width: *c_int, height: *c_int) [*c]const u32; /// `pub fn setFontsTexId(id:TextureIdent) set the backend Id for the fonts atlas pub const setFontsTexId = zguiIoSetFontsTexId; @@ -235,6 +249,10 @@ pub const io = struct { pub const getWantCaptureKeyboard = zguiIoGetWantCaptureKeyboard; extern fn zguiIoGetWantCaptureKeyboard() bool; + /// `pub fn zguiIoGetWantTextInput() bool` + pub const getWantTextInput = zguiIoGetWantTextInput; + extern fn zguiIoGetWantTextInput() bool; + pub fn setIniFilename(filename: ?[*:0]const u8) void { zguiIoSetIniFilename(filename); } @@ -281,11 +299,15 @@ pub const io = struct { pub const addInputCharactersUTF8 = zguiIoAddInputCharactersUTF8; extern fn zguiIoAddInputCharactersUTF8(utf8_chars: ?[*:0]const u8) void; - pub const setKeyEventNativeData = zguiIoSetKeyEventNativeData; - extern fn zguiIoSetKeyEventNativeData(key: Key, keycode: i32, scancode: i32) void; + pub fn setKeyEventNativeData(key: Key, keycode: i32, scancode: i32) void { + zguiIoSetKeyEventNativeData(key, keycode, scancode); + } + extern fn zguiIoSetKeyEventNativeData(key: Key, keycode: c_int, scancode: c_int) void; - pub const addCharacterEvent = zguiIoAddCharacterEvent; - extern fn zguiIoAddCharacterEvent(char: i32) void; + pub fn addCharacterEvent(char: i32) void { + zguiIoAddCharacterEvent(char); + } + extern fn zguiIoAddCharacterEvent(char: c_int) void; }; pub fn setClipboardText(value: [:0]const u8) void { @@ -301,9 +323,9 @@ extern fn zguiGetClipboardText() [*:0]const u8; const Context = *opaque {}; pub const DrawData = *extern struct { valid: bool, - cmd_lists_count: i32, - total_idx_count: i32, - total_vtx_count: i32, + cmd_lists_count: c_int, + total_idx_count: c_int, + total_vtx_count: c_int, cmd_lists: [*]DrawList, display_pos: [2]f32, display_size: [2]f32, @@ -313,7 +335,7 @@ pub const Font = *opaque {}; pub const Ident = u32; pub const TextureIdent = *anyopaque; pub const Wchar = u16; -pub const Key = enum(u32) { +pub const Key = enum(c_int) { none = 0, tab = 512, left_arrow, @@ -462,7 +484,7 @@ pub const Key = enum(u32) { mod_mask_ = 0xf000, }; //-------------------------------------------------------------------------------------------------- -pub const WindowFlags = packed struct(u32) { +pub const WindowFlags = packed struct(c_int) { no_title_bar: bool = false, no_resize: bool = false, no_move: bool = false, @@ -480,10 +502,11 @@ pub const WindowFlags = packed struct(u32) { always_vertical_scrollbar: bool = false, always_horizontal_scrollbar: bool = false, always_use_window_padding: bool = false, + _removed: u1 = 0, no_nav_inputs: bool = false, no_nav_focus: bool = false, unsaved_document: bool = false, - _padding: u12 = 0, + _padding: u11 = 0, pub const no_nav = WindowFlags{ .no_nav_inputs = true, .no_nav_focus = true }; pub const no_decoration = WindowFlags{ @@ -499,7 +522,7 @@ pub const WindowFlags = packed struct(u32) { }; }; //-------------------------------------------------------------------------------------------------- -pub const SliderFlags = packed struct(u32) { +pub const SliderFlags = packed struct(c_int) { _reserved0: bool = false, _reserved1: bool = false, _reserved2: bool = false, @@ -511,14 +534,14 @@ pub const SliderFlags = packed struct(u32) { _padding: u24 = 0, }; //-------------------------------------------------------------------------------------------------- -pub const ButtonFlags = packed struct(u32) { +pub const ButtonFlags = packed struct(c_int) { mouse_button_left: bool = false, mouse_button_right: bool = false, mouse_button_middle: bool = false, _padding: u29 = 0, }; //-------------------------------------------------------------------------------------------------- -pub const Direction = enum(i32) { +pub const Direction = enum(c_int) { none = -1, left = 0, right = 1, @@ -526,9 +549,9 @@ pub const Direction = enum(i32) { down = 3, }; //-------------------------------------------------------------------------------------------------- -pub const DataType = enum(u32) { I8, U8, I16, U16, I32, U32, I64, U64, F32, F64 }; +pub const DataType = enum(c_int) { I8, U8, I16, U16, I32, U32, I64, U64, F32, F64 }; //-------------------------------------------------------------------------------------------------- -pub const Condition = enum(u32) { +pub const Condition = enum(c_int) { none = 0, always = 1, once = 2, @@ -607,9 +630,11 @@ pub fn setNextWindowBgAlpha(args: SetNextWindowBgAlpha) void { } extern fn zguiSetNextWindowBgAlpha(alpha: f32) void; -/// `pub fn setKeyboardFocusHere(offset: i32) void` -pub const setKeyboardFocusHere = zguiSetKeyboardFocusHere; -extern fn zguiSetKeyboardFocusHere(offset: i32) void; +pub fn setKeyboardFocusHere(offset: i32) void { + zguiSetKeyboardFocusHere(offset); +} +extern fn zguiSetKeyboardFocusHere(offset: c_int) void; + //-------------------------------------------------------------------------------------------------- const Begin = struct { popen: ?*bool = null, @@ -690,7 +715,7 @@ extern fn zguiSetScrollHereY(center_y_ratio: f32) void; extern fn zguiSetScrollFromPosX(local_x: f32, center_x_ratio: f32) void; extern fn zguiSetScrollFromPosY(local_y: f32, center_y_ratio: f32) void; //-------------------------------------------------------------------------------------------------- -pub const FocusedFlags = packed struct(u32) { +pub const FocusedFlags = packed struct(c_int) { child_windows: bool = false, root_window: bool = false, any_window: bool = false, @@ -700,7 +725,7 @@ pub const FocusedFlags = packed struct(u32) { pub const root_and_child_windows = FocusedFlags{ .root_window = true, .child_windows = true }; }; //-------------------------------------------------------------------------------------------------- -pub const HoveredFlags = packed struct(u32) { +pub const HoveredFlags = packed struct(c_int) { child_windows: bool = false, root_window: bool = false, any_window: bool = false, @@ -712,7 +737,10 @@ pub const HoveredFlags = packed struct(u32) { allow_when_overlapped: bool = false, allow_when_disabled: bool = false, no_nav_override: bool = false, - _padding: u21 = 0, + delay_normal: bool = false, + delay_short: bool = false, + no_shared_delay: bool = false, + _padding: u18 = 0, pub const rect_only = HoveredFlags{ .allow_when_blocked_by_popup = true, @@ -845,17 +873,17 @@ pub const Style = extern struct { extern fn zguiStyle_ScaleAllSizes(style: *Style, scale_factor: f32) void; pub fn getColor(style: Style, idx: StyleCol) [4]f32 { - return style.colors[@intFromEnum(idx)]; + return style.colors[@intCast(@intFromEnum(idx))]; } pub fn setColor(style: *Style, idx: StyleCol, color: [4]f32) void { - style.colors[@intFromEnum(idx)] = color; + style.colors[@intCast(@intFromEnum(idx))] = color; } }; /// `pub fn getStyle() *Style` pub const getStyle = zguiGetStyle; extern fn zguiGetStyle() *Style; //-------------------------------------------------------------------------------------------------- -pub const StyleCol = enum(u32) { +pub const StyleCol = enum(c_int) { text, text_disabled, window_bg, @@ -910,38 +938,41 @@ pub const StyleCol = enum(u32) { nav_windowing_dim_bg, modal_window_dim_bg, }; -const PushStyleColor4f = struct { + +pub fn pushStyleColor4f(args: struct { idx: StyleCol, c: [4]f32, -}; -pub fn pushStyleColor4f(args: PushStyleColor4f) void { +}) void { zguiPushStyleColor4f(args.idx, &args.c); } -const PushStyleColor1u = struct { +extern fn zguiPushStyleColor4f(idx: StyleCol, col: *const [4]f32) void; + +pub fn pushStyleColor1u(args: struct { idx: StyleCol, c: u32, -}; -pub fn pushStyleColor1u(args: PushStyleColor1u) void { +}) void { zguiPushStyleColor1u(args.idx, args.c); } -const PopStyleColor = struct { +extern fn zguiPushStyleColor1u(idx: StyleCol, col: c_uint) void; + +pub fn popStyleColor(args: struct { count: i32 = 1, -}; -pub fn popStyleColor(args: PopStyleColor) void { +}) void { zguiPopStyleColor(args.count); } +extern fn zguiPopStyleColor(count: c_int) void; + /// `fn pushTextWrapPos(wrap_pos_x: f32) void` pub const pushTextWrapPos = zguiPushTextWrapPos; +extern fn zguiPushTextWrapPos(wrap_pos_x: f32) void; + /// `fn popTextWrapPos() void` pub const popTextWrapPos = zguiPopTextWrapPos; -extern fn zguiPushStyleColor4f(idx: StyleCol, col: *const [4]f32) void; -extern fn zguiPushStyleColor1u(idx: StyleCol, col: u32) void; -extern fn zguiPopStyleColor(count: i32) void; -extern fn zguiPushTextWrapPos(wrap_pos_x: f32) void; extern fn zguiPopTextWrapPos() void; + //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- -pub const StyleVar = enum(u32) { +pub const StyleVar = enum(c_int) { alpha, // 1f disabled_alpha, // 1f window_padding, // 2f @@ -971,29 +1002,30 @@ pub const StyleVar = enum(u32) { separator_text_align, // 2f separator_text_padding, // 2f }; -const PushStyleVar1f = struct { + +pub fn pushStyleVar1f(args: struct { idx: StyleVar, v: f32, -}; -pub fn pushStyleVar1f(args: PushStyleVar1f) void { +}) void { zguiPushStyleVar1f(args.idx, args.v); } -const PushStyleVar2f = struct { +extern fn zguiPushStyleVar1f(idx: StyleVar, v: f32) void; + +pub fn pushStyleVar2f(args: struct { idx: StyleVar, v: [2]f32, -}; -pub fn pushStyleVar2f(args: PushStyleVar2f) void { +}) void { zguiPushStyleVar2f(args.idx, &args.v); } -const PopStyleVar = struct { +extern fn zguiPushStyleVar2f(idx: StyleVar, v: *const [2]f32) void; + +pub fn popStyleVar(args: struct { count: i32 = 1, -}; -pub fn popStyleVar(args: PopStyleVar) void { +}) void { zguiPopStyleVar(args.count); } -extern fn zguiPushStyleVar1f(idx: StyleVar, v: f32) void; -extern fn zguiPushStyleVar2f(idx: StyleVar, v: *const [2]f32) void; -extern fn zguiPopStyleVar(count: i32) void; +extern fn zguiPopStyleVar(count: c_int) void; + //-------------------------------------------------------------------------------------------------- /// `void pushItemWidth(item_width: f32) void` pub const pushItemWidth = zguiPushItemWidth; @@ -1142,7 +1174,7 @@ extern fn zguiGetCursorStartPos(pos: *[2]f32) void; extern fn zguiGetCursorScreenPos(pos: *[2]f32) void; extern fn zguiSetCursorScreenPos(screen_x: f32, screen_y: f32) void; //-------------------------------------------------------------------------------------------------- -pub const Cursor = enum(i32) { +pub const Cursor = enum(c_int) { none = -1, arrow = 0, text_input, @@ -1205,36 +1237,42 @@ extern fn zguiGetItemRectMin(rect: *[2]f32) void; pub fn pushStrId(str_id: []const u8) void { zguiPushStrId(str_id.ptr, str_id.ptr + str_id.len); } +extern fn zguiPushStrId(str_id_begin: [*]const u8, str_id_end: [*]const u8) void; + pub fn pushStrIdZ(str_id: [:0]const u8) void { zguiPushStrIdZ(str_id); } +extern fn zguiPushStrIdZ(str_id: [*:0]const u8) void; + pub fn pushPtrId(ptr_id: *const anyopaque) void { zguiPushPtrId(ptr_id); } +extern fn zguiPushPtrId(ptr_id: *const anyopaque) void; + pub fn pushIntId(int_id: i32) void { zguiPushIntId(int_id); } -extern fn zguiPushStrId(str_id_begin: [*]const u8, str_id_end: [*]const u8) void; -extern fn zguiPushStrIdZ(str_id: [*:0]const u8) void; -extern fn zguiPushPtrId(ptr_id: *const anyopaque) void; -extern fn zguiPushIntId(int_id: i32) void; -//-------------------------------------------------------------------------------------------------- +extern fn zguiPushIntId(int_id: c_int) void; + /// `pub fn popId() void` pub const popId = zguiPopId; extern fn zguiPopId() void; -//-------------------------------------------------------------------------------------------------- + pub fn getStrId(str_id: []const u8) Ident { return zguiGetStrId(str_id.ptr, str_id.ptr + str_id.len); } +extern fn zguiGetStrId(str_id_begin: [*]const u8, str_id_end: [*]const u8) Ident; + pub fn getStrIdZ(str_id: [:0]const u8) Ident { return zguiGetStrIdZ(str_id); } +extern fn zguiGetStrIdZ(str_id: [*:0]const u8) Ident; + pub fn getPtrId(ptr_id: *const anyopaque) Ident { return zguiGetPtrId(ptr_id); } -extern fn zguiGetStrId(str_id_begin: [*]const u8, str_id_end: [*]const u8) Ident; -extern fn zguiGetStrIdZ(str_id: [*:0]const u8) Ident; extern fn zguiGetPtrId(ptr_id: *const anyopaque) Ident; + //-------------------------------------------------------------------------------------------------- // // Widgets: Text @@ -1398,39 +1436,35 @@ extern fn zguiImageButton( pub const bullet = zguiBullet; extern fn zguiBullet() void; //-------------------------------------------------------------------------------------------------- -const RadioButton = struct { +pub fn radioButton(label: [:0]const u8, args: struct { active: bool, -}; -pub fn radioButton(label: [:0]const u8, args: RadioButton) bool { +}) bool { return zguiRadioButton(label, args.active); } extern fn zguiRadioButton(label: [*:0]const u8, active: bool) bool; //-------------------------------------------------------------------------------------------------- -const RadioButtonStatePtr = struct { +pub fn radioButtonStatePtr(label: [:0]const u8, args: struct { v: *i32, v_button: i32, -}; -pub fn radioButtonStatePtr(label: [:0]const u8, args: RadioButtonStatePtr) bool { +}) bool { return zguiRadioButtonStatePtr(label, args.v, args.v_button); } -extern fn zguiRadioButtonStatePtr(label: [*:0]const u8, v: *i32, v_button: i32) bool; +extern fn zguiRadioButtonStatePtr(label: [*:0]const u8, v: *c_int, v_button: c_int) bool; //-------------------------------------------------------------------------------------------------- -const Checkbox = struct { +pub fn checkbox(label: [:0]const u8, args: struct { v: *bool, -}; -pub fn checkbox(label: [:0]const u8, args: Checkbox) bool { +}) bool { return zguiCheckbox(label, args.v); } extern fn zguiCheckbox(label: [*:0]const u8, v: *bool) bool; //-------------------------------------------------------------------------------------------------- -const CheckboxBits = struct { +pub fn checkboxBits(label: [:0]const u8, args: struct { bits: *u32, bits_value: u32, -}; -pub fn checkboxBits(label: [:0]const u8, args: CheckboxBits) bool { +}) bool { return zguiCheckboxBits(label, args.bits, args.bits_value); } -extern fn zguiCheckboxBits(label: [*:0]const u8, bits: *u32, bits_value: u32) bool; +extern fn zguiCheckboxBits(label: [*:0]const u8, bits: *c_uint, bits_value: c_uint) bool; //-------------------------------------------------------------------------------------------------- const ProgressBar = struct { fraction: f32, @@ -1447,12 +1481,11 @@ extern fn zguiProgressBar(fraction: f32, w: f32, h: f32, overlay: ?[*:0]const u8 // Widgets: Combo Box // //-------------------------------------------------------------------------------------------------- -const Combo = struct { +pub fn combo(label: [:0]const u8, args: struct { current_item: *i32, items_separated_by_zeros: [:0]const u8, popup_max_height_in_items: i32 = -1, -}; -pub fn combo(label: [:0]const u8, args: Combo) bool { +}) bool { return zguiCombo( label, args.current_item, @@ -1473,7 +1506,7 @@ pub fn comboFromEnum( const item_type = @typeInfo(@TypeOf(current_item.*)); switch (item_type) { .Enum => |e| { - comptime var str: [:0]const u8 = ""; + var str: [:0]const u8 = ""; for (e.fields) |f| { str = str ++ f.name ++ "\x00"; @@ -1499,12 +1532,12 @@ pub fn comboFromEnum( } extern fn zguiCombo( label: [*:0]const u8, - current_item: *i32, + current_item: *c_int, items_separated_by_zeros: [*:0]const u8, - popup_max_height_in_items: i32, + popup_max_height_in_items: c_int, ) bool; //-------------------------------------------------------------------------------------------------- -pub const ComboFlags = packed struct(u32) { +pub const ComboFlags = packed struct(c_int) { popup_align_left: bool = false, height_small: bool = false, height_regular: bool = false, @@ -1828,9 +1861,8 @@ fn SliderFloatGen(comptime T: type) type { flags: SliderFlags = .{}, }; } -//-------------------------------------------------------------------------------------------------- -const SliderFloat = SliderFloatGen(f32); -pub fn sliderFloat(label: [:0]const u8, args: SliderFloat) bool { + +pub fn sliderFloat(label: [:0]const u8, args: SliderFloatGen(f32)) bool { return zguiSliderFloat(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderFloat( @@ -1841,9 +1873,8 @@ extern fn zguiSliderFloat( cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderFloat2 = SliderFloatGen([2]f32); -pub fn sliderFloat2(label: [:0]const u8, args: SliderFloat2) bool { + +pub fn sliderFloat2(label: [:0]const u8, args: SliderFloatGen([2]f32)) bool { return zguiSliderFloat2(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderFloat2( @@ -1854,9 +1885,8 @@ extern fn zguiSliderFloat2( cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderFloat3 = SliderFloatGen([3]f32); -pub fn sliderFloat3(label: [:0]const u8, args: SliderFloat3) bool { + +pub fn sliderFloat3(label: [:0]const u8, args: SliderFloatGen([3]f32)) bool { return zguiSliderFloat3(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderFloat3( @@ -1867,9 +1897,8 @@ extern fn zguiSliderFloat3( cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderFloat4 = SliderFloatGen([4]f32); -pub fn sliderFloat4(label: [:0]const u8, args: SliderFloat4) bool { + +pub fn sliderFloat4(label: [:0]const u8, args: SliderFloatGen([4]f32)) bool { return zguiSliderFloat4(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderFloat4( @@ -1880,6 +1909,7 @@ extern fn zguiSliderFloat4( cfmt: [*:0]const u8, flags: SliderFlags, ) bool; + //-------------------------------------------------------------------------------------------------- fn SliderIntGen(comptime T: type) type { return struct { @@ -1890,58 +1920,55 @@ fn SliderIntGen(comptime T: type) type { flags: SliderFlags = .{}, }; } -//-------------------------------------------------------------------------------------------------- -const SliderInt = SliderIntGen(i32); -pub fn sliderInt(label: [:0]const u8, args: SliderInt) bool { + +pub fn sliderInt(label: [:0]const u8, args: SliderIntGen(i32)) bool { return zguiSliderInt(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderInt( label: [*:0]const u8, - v: *i32, - min: i32, - max: i32, + v: *c_int, + min: c_int, + max: c_int, cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderInt2 = SliderIntGen([2]i32); -pub fn sliderInt2(label: [:0]const u8, args: SliderInt2) bool { + +pub fn sliderInt2(label: [:0]const u8, args: SliderIntGen([2]i32)) bool { return zguiSliderInt2(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderInt2( label: [*:0]const u8, - v: *[2]i32, - min: i32, - max: i32, + v: *[2]c_int, + min: c_int, + max: c_int, cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderInt3 = SliderIntGen([3]i32); -pub fn sliderInt3(label: [:0]const u8, args: SliderInt3) bool { + +pub fn sliderInt3(label: [:0]const u8, args: SliderIntGen([3]i32)) bool { return zguiSliderInt3(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderInt3( label: [*:0]const u8, - v: *[3]i32, - min: i32, - max: i32, + v: *[3]c_int, + min: c_int, + max: c_int, cfmt: [*:0]const u8, flags: SliderFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const SliderInt4 = SliderIntGen([4]i32); -pub fn sliderInt4(label: [:0]const u8, args: SliderInt4) bool { + +pub fn sliderInt4(label: [:0]const u8, args: SliderIntGen([4]i32)) bool { return zguiSliderInt4(label, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiSliderInt4( label: [*:0]const u8, - v: *[4]i32, - min: i32, - max: i32, + v: *[4]c_int, + min: c_int, + max: c_int, cfmt: [*:0]const u8, flags: SliderFlags, ) bool; + //-------------------------------------------------------------------------------------------------- fn SliderScalarGen(comptime T: type) type { return struct { @@ -1972,6 +1999,7 @@ extern fn zguiSliderScalar( cfmt: ?[*:0]const u8, flags: SliderFlags, ) bool; + //-------------------------------------------------------------------------------------------------- fn SliderScalarNGen(comptime T: type) type { const ScalarType = @typeInfo(T).Array.child; @@ -2008,7 +2036,7 @@ extern fn zguiSliderScalarN( flags: SliderFlags, ) bool; //-------------------------------------------------------------------------------------------------- -const VSliderFloat = struct { +pub fn vsliderFloat(label: [:0]const u8, args: struct { w: f32, h: f32, v: *f32, @@ -2016,9 +2044,17 @@ const VSliderFloat = struct { max: f32, cfmt: [:0]const u8 = "%.3f", flags: SliderFlags = .{}, -}; -pub fn vsliderFloat(label: [:0]const u8, args: VSliderFloat) bool { - return zguiVSliderFloat(label, args.w, args.h, args.v, args.min, args.max, args.cfmt, args.flags); +}) bool { + return zguiVSliderFloat( + label, + args.w, + args.h, + args.v, + args.min, + args.max, + args.cfmt, + args.flags, + ); } extern fn zguiVSliderFloat( label: [*:0]const u8, @@ -2031,7 +2067,7 @@ extern fn zguiVSliderFloat( flags: SliderFlags, ) bool; //-------------------------------------------------------------------------------------------------- -const VSliderInt = struct { +pub fn vsliderInt(label: [:0]const u8, args: struct { w: f32, h: f32, v: *i32, @@ -2039,8 +2075,7 @@ const VSliderInt = struct { max: i32, cfmt: [:0]const u8 = "%d", flags: SliderFlags = .{}, -}; -pub fn vsliderInt(label: [:0]const u8, args: VSliderInt) bool { +}) bool { return zguiVSliderInt(label, args.w, args.h, args.v, args.min, args.max, args.cfmt, args.flags); } extern fn zguiVSliderInt( @@ -2048,8 +2083,8 @@ extern fn zguiVSliderInt( w: f32, h: f32, v: *i32, - min: i32, - max: i32, + min: c_int, + max: c_int, cfmt: [*:0]const u8, flags: SliderFlags, ) bool; @@ -2120,7 +2155,7 @@ extern fn zguiSliderAngle( // Widgets: Input with Keyboard // //-------------------------------------------------------------------------------------------------- -pub const InputTextFlags = packed struct(u32) { +pub const InputTextFlags = packed struct(c_int) { chars_decimal: bool = false, chars_hexadecimal: bool = false, chars_uppercase: bool = false, @@ -2141,7 +2176,8 @@ pub const InputTextFlags = packed struct(u32) { chars_scientific: bool = false, callback_resize: bool = false, callback_edit: bool = false, - _padding: u12 = 0, + escape_clears_all: bool = false, + _padding: u11 = 0, }; //-------------------------------------------------------------------------------------------------- pub const InputTextCallbackData = extern struct { @@ -2161,13 +2197,25 @@ pub const InputTextCallbackData = extern struct { /// `pub fn init() InputTextCallbackData` pub const init = zguiInputTextCallbackData_Init; + extern fn zguiInputTextCallbackData_Init() InputTextCallbackData; /// `pub fn deleteChars(data: *InputTextCallbackData, pos: i32, bytes_count: i32) void` pub const deleteChars = zguiInputTextCallbackData_DeleteChars; + extern fn zguiInputTextCallbackData_DeleteChars( + data: *InputTextCallbackData, + pos: c_int, + bytes_count: c_int, + ) void; pub fn insertChars(data: *InputTextCallbackData, pos: i32, txt: []const u8) void { zguiInputTextCallbackData_InsertChars(data, pos, txt.ptr, txt.ptr + txt.len); } + extern fn zguiInputTextCallbackData_InsertChars( + data: *InputTextCallbackData, + pos: c_int, + text: [*]const u8, + text_end: [*]const u8, + ) void; pub fn selectAll(data: *InputTextCallbackData) void { data.selection_start = 0; @@ -2182,30 +2230,16 @@ pub const InputTextCallbackData = extern struct { pub fn hasSelection(data: InputTextCallbackData) bool { return data.selection_start != data.selection_end; } - - extern fn zguiInputTextCallbackData_Init() InputTextCallbackData; - extern fn zguiInputTextCallbackData_DeleteChars( - data: *InputTextCallbackData, - pos: i32, - bytes_count: i32, - ) void; - extern fn zguiInputTextCallbackData_InsertChars( - data: *InputTextCallbackData, - pos: i32, - text: [*]const u8, - text_end: [*]const u8, - ) void; }; pub const InputTextCallback = *const fn (data: *InputTextCallbackData) i32; //-------------------------------------------------------------------------------------------------- -const InputText = struct { +pub fn inputText(label: [:0]const u8, args: struct { buf: []u8, flags: InputTextFlags = .{}, callback: ?InputTextCallback = null, user_data: ?*anyopaque = null, -}; -pub fn inputText(label: [:0]const u8, args: InputText) bool { +}) bool { return zguiInputText( label, args.buf.ptr, @@ -2224,15 +2258,14 @@ extern fn zguiInputText( user_data: ?*anyopaque, ) bool; //-------------------------------------------------------------------------------------------------- -const InputTextMultiline = struct { +pub fn inputTextMultiline(label: [:0]const u8, args: struct { buf: []u8, w: f32 = 0.0, h: f32 = 0.0, flags: InputTextFlags = .{}, callback: ?InputTextCallback = null, user_data: ?*anyopaque = null, -}; -pub fn inputTextMultiline(label: [:0]const u8, args: InputTextMultiline) bool { +}) bool { return zguiInputTextMultiline( label, args.buf.ptr, @@ -2255,14 +2288,13 @@ extern fn zguiInputTextMultiline( user_data: ?*anyopaque, ) bool; //-------------------------------------------------------------------------------------------------- -const InputTextWithHint = struct { +pub fn inputTextWithHint(label: [:0]const u8, args: struct { hint: [:0]const u8, buf: []u8, flags: InputTextFlags = .{}, callback: ?InputTextCallback = null, user_data: ?*anyopaque = null, -}; -pub fn inputTextWithHint(label: [:0]const u8, args: InputTextWithHint) bool { +}) bool { return zguiInputTextWithHint( label, args.hint, @@ -2283,14 +2315,13 @@ extern fn zguiInputTextWithHint( user_data: ?*anyopaque, ) bool; //-------------------------------------------------------------------------------------------------- -const InputFloat = struct { +pub fn inputFloat(label: [:0]const u8, args: struct { v: *f32, step: f32 = 0.0, step_fast: f32 = 0.0, cfmt: [:0]const u8 = "%.3f", flags: InputTextFlags = .{}, -}; -pub fn inputFloat(label: [:0]const u8, args: InputFloat) bool { +}) bool { return zguiInputFloat( label, args.v, @@ -2308,6 +2339,7 @@ extern fn zguiInputFloat( cfmt: [*:0]const u8, flags: InputTextFlags, ) bool; + //-------------------------------------------------------------------------------------------------- fn InputFloatGen(comptime T: type) type { return struct { @@ -2316,9 +2348,7 @@ fn InputFloatGen(comptime T: type) type { flags: InputTextFlags = .{}, }; } -//-------------------------------------------------------------------------------------------------- -const InputFloat2 = InputFloatGen([2]f32); -pub fn inputFloat2(label: [:0]const u8, args: InputFloat2) bool { +pub fn inputFloat2(label: [:0]const u8, args: InputFloatGen([2]f32)) bool { return zguiInputFloat2(label, args.v, args.cfmt, args.flags); } extern fn zguiInputFloat2( @@ -2327,9 +2357,8 @@ extern fn zguiInputFloat2( cfmt: [*:0]const u8, flags: InputTextFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const InputFloat3 = InputFloatGen([3]f32); -pub fn inputFloat3(label: [:0]const u8, args: InputFloat3) bool { + +pub fn inputFloat3(label: [:0]const u8, args: InputFloatGen([3]f32)) bool { return zguiInputFloat3(label, args.v, args.cfmt, args.flags); } extern fn zguiInputFloat3( @@ -2338,9 +2367,8 @@ extern fn zguiInputFloat3( cfmt: [*:0]const u8, flags: InputTextFlags, ) bool; -//-------------------------------------------------------------------------------------------------- -const InputFloat4 = InputFloatGen([4]f32); -pub fn inputFloat4(label: [:0]const u8, args: InputFloat4) bool { + +pub fn inputFloat4(label: [:0]const u8, args: InputFloatGen([4]f32)) bool { return zguiInputFloat4(label, args.v, args.cfmt, args.flags); } extern fn zguiInputFloat4( @@ -2349,23 +2377,24 @@ extern fn zguiInputFloat4( cfmt: [*:0]const u8, flags: InputTextFlags, ) bool; + //-------------------------------------------------------------------------------------------------- -const InputInt = struct { +pub fn inputInt(label: [:0]const u8, args: struct { v: *i32, step: i32 = 1, step_fast: i32 = 100, flags: InputTextFlags = .{}, -}; -pub fn inputInt(label: [:0]const u8, args: InputInt) bool { +}) bool { return zguiInputInt(label, args.v, args.step, args.step_fast, args.flags); } extern fn zguiInputInt( label: [*:0]const u8, - v: *i32, - step: i32, - step_fast: i32, + v: *c_int, + step: c_int, + step_fast: c_int, flags: InputTextFlags, ) bool; + //-------------------------------------------------------------------------------------------------- fn InputIntGen(comptime T: type) type { return struct { @@ -2373,24 +2402,21 @@ fn InputIntGen(comptime T: type) type { flags: InputTextFlags = .{}, }; } -//-------------------------------------------------------------------------------------------------- -const InputInt2 = InputIntGen([2]i32); -pub fn inputInt2(label: [:0]const u8, args: InputInt2) bool { +pub fn inputInt2(label: [:0]const u8, args: InputIntGen([2]i32)) bool { return zguiInputInt2(label, args.v, args.flags); } -extern fn zguiInputInt2(label: [*:0]const u8, v: *[2]i32, flags: InputTextFlags) bool; -//-------------------------------------------------------------------------------------------------- -const InputInt3 = InputIntGen([3]i32); -pub fn inputInt3(label: [:0]const u8, args: InputInt3) bool { +extern fn zguiInputInt2(label: [*:0]const u8, v: *[2]c_int, flags: InputTextFlags) bool; + +pub fn inputInt3(label: [:0]const u8, args: InputIntGen([3]i32)) bool { return zguiInputInt3(label, args.v, args.flags); } -extern fn zguiInputInt3(label: [*:0]const u8, v: *[3]i32, flags: InputTextFlags) bool; -//-------------------------------------------------------------------------------------------------- -const InputInt4 = InputIntGen([4]i32); -pub fn inputInt4(label: [:0]const u8, args: InputInt4) bool { +extern fn zguiInputInt3(label: [*:0]const u8, v: *[3]c_int, flags: InputTextFlags) bool; + +pub fn inputInt4(label: [:0]const u8, args: InputIntGen([4]i32)) bool { return zguiInputInt4(label, args.v, args.flags); } -extern fn zguiInputInt4(label: [*:0]const u8, v: *[4]i32, flags: InputTextFlags) bool; +extern fn zguiInputInt4(label: [*:0]const u8, v: *[4]c_int, flags: InputTextFlags) bool; + //-------------------------------------------------------------------------------------------------- const InputDouble = struct { v: *f64, @@ -2480,7 +2506,8 @@ extern fn zguiInputScalarN( // Widgets: Color Editor/Picker // //-------------------------------------------------------------------------------------------------- -pub const ColorEditFlags = packed struct(u32) { +pub const ColorEditFlags = packed struct(c_int) { + _reserved0: bool = false, no_alpha: bool = false, no_picker: bool = false, no_options: bool = false, @@ -2492,11 +2519,11 @@ pub const ColorEditFlags = packed struct(u32) { no_drag_drop: bool = false, no_border: bool = false, - _reserved0: bool = false, _reserved1: bool = false, _reserved2: bool = false, _reserved3: bool = false, _reserved4: bool = false, + _reserved5: bool = false, alpha_bar: bool = false, alpha_preview: bool = false, @@ -2512,7 +2539,7 @@ pub const ColorEditFlags = packed struct(u32) { input_rgb: bool = false, input_hsv: bool = false, - _padding: u4 = 0, + _padding: u3 = 0, pub const default_options = ColorEditFlags{ .uint8 = true, @@ -2590,7 +2617,7 @@ extern fn zguiColorButton( // Widgets: Trees // //-------------------------------------------------------------------------------------------------- -pub const TreeNodeFlags = packed struct(u32) { +pub const TreeNodeFlags = packed struct(c_int) { selected: bool = false, framed: bool = false, allow_item_overlap: bool = false, @@ -2700,7 +2727,7 @@ extern fn zguiSetNextItemOpen(is_open: bool, cond: Condition) void; // Selectables // //-------------------------------------------------------------------------------------------------- -pub const SelectableFlags = packed struct(u32) { +pub const SelectableFlags = packed struct(c_int) { dont_close_popups: bool = false, span_all_columns: bool = false, allow_double_click: bool = false, @@ -2792,7 +2819,7 @@ pub const TableBorderFlags = packed struct(u4) { .outer_h = true, }; // Draw all borders. }; -pub const TableFlags = packed struct(u32) { +pub const TableFlags = packed struct(c_int) { resizable: bool = false, reorderable: bool = false, hideable: bool = false, @@ -2838,13 +2865,13 @@ pub const TableFlags = packed struct(u32) { _padding: u4 = 0, }; -pub const TableRowFlags = packed struct(u32) { +pub const TableRowFlags = packed struct(c_int) { headers: bool = false, _padding: u31 = 0, }; -pub const TableColumnFlags = packed struct(u32) { +pub const TableColumnFlags = packed struct(c_int) { // Input configuration flags disabled: bool = false, default_hide: bool = false, @@ -2889,29 +2916,28 @@ pub const TableColumnSortSpecs = extern struct { pub const TableSortSpecs = *extern struct { specs: [*]TableColumnSortSpecs, - count: i32, + count: c_int, dirty: bool, }; -pub const TableBgTarget = enum(u32) { +pub const TableBgTarget = enum(c_int) { none = 0, row_bg0 = 1, row_bg1 = 2, cell_bg = 3, }; -pub const BeginTable = struct { +pub fn beginTable(name: [:0]const u8, args: struct { column: i32, flags: TableFlags = .{}, outer_size: [2]f32 = .{ 0, 0 }, inner_width: f32 = 0, -}; -pub fn beginTable(name: [:0]const u8, args: BeginTable) bool { +}) bool { return zguiBeginTable(name, args.column, args.flags, &args.outer_size, args.inner_width); } extern fn zguiBeginTable( str_id: [*:0]const u8, - column: i32, + column: c_int, flags: TableFlags, outer_size: *const [2]f32, inner_width: f32, @@ -2989,15 +3015,15 @@ extern fn zguiTableGetColumnFlags(column_n: i32) TableColumnFlags; pub const tableSetColumnEnabled = zguiTableSetColumnEnabled; extern fn zguiTableSetColumnEnabled(column_n: i32, v: bool) void; -pub const TableSetBgColor = struct { +pub fn tableSetBgColor(args: struct { target: TableBgTarget, color: u32, column_n: i32 = -1, -}; -pub fn tableSetBgColor(args: TableSetBgColor) void { +}) void { zguiTableSetBgColor(args.target, args.color, args.column_n); } -extern fn zguiTableSetBgColor(target: TableBgTarget, color: u32, column_n: i32) void; +extern fn zguiTableSetBgColor(target: TableBgTarget, color: c_uint, column_n: c_int) void; + //-------------------------------------------------------------------------------------------------- // // Item/Widgets Utilities and Query Functions @@ -3211,18 +3237,21 @@ extern fn zguiEndTooltip() void; pub const beginPopupContextWindow = zguiBeginPopupContextWindow; /// `pub fn beginPopupContextItem() bool` pub const beginPopupContextItem = zguiBeginPopupContextItem; -pub const PopupFlags = packed struct(u32) { +pub const PopupFlags = packed struct(c_int) { mouse_button_left: bool = false, mouse_button_right: bool = false, mouse_button_middle: bool = false, - mouse_button_mask_: bool = false, - mouse_button_default_: bool = false, + + _reserved0: bool = false, + _reserved1: bool = false, + no_open_over_existing_popup: bool = false, no_open_over_items: bool = false, any_popup_id: bool = false, any_popup_level: bool = false, - any_popup: bool = false, - _padding: u22 = 0, + _padding: u23 = 0, + + pub const any_popup = PopupFlags{ .any_popup_id = true, .any_popup_level = true }; }; pub fn beginPopupModal(name: [:0]const u8, args: Begin) bool { return zguiBeginPopupModal(name, args.popen, args.flags); @@ -3248,7 +3277,7 @@ extern fn zguiCloseCurrentPopup() void; // Tabs // //-------------------------------------------------------------------------------------------------- -pub const TabBarFlags = packed struct(u32) { +pub const TabBarFlags = packed struct(c_int) { reorderable: bool = false, auto_select_new_tabs: bool = false, tab_list_popup_button: bool = false, @@ -3258,14 +3287,8 @@ pub const TabBarFlags = packed struct(u32) { fitting_policy_resize_down: bool = false, fitting_policy_scroll: bool = false, _padding: u24 = 0, - - pub const fitting_policy_mask = TabBarFlags{ - .fitting_policy_resize_down = true, - .fitting_policy_scroll = true, - }; - pub const fitting_policy_default = TabBarFlags{ .fitting_policy_resize_down = true }; }; -pub const TabItemFlags = packed struct(u32) { +pub const TabItemFlags = packed struct(c_int) { unsaved_document: bool = false, set_selected: bool = false, no_close_with_middle_mouse_button: bool = false, @@ -3371,10 +3394,99 @@ extern fn zguiGetMouseDragDelta(button: MouseButton, lock_threshold: f32, delta: extern fn zguiResetMouseDragDelta(button: MouseButton) void; //-------------------------------------------------------------------------------------------------- // +// Drag and Drop +// +//-------------------------------------------------------------------------------------------------- +pub const DragDropFlags = packed struct(c_int) { + source_no_preview_tooltip: bool = false, + source_no_disable_hover: bool = false, + source_no_hold_open_to_others: bool = false, + source_allow_null_id: bool = false, + source_extern: bool = false, + source_auto_expire_payload: bool = false, + + _padding0: u4 = 0, + + accept_before_delivery: bool = false, + accept_no_draw_default_rect: bool = false, + accept_no_preview_tooltip: bool = false, + + _padding1: u19 = 0, + + pub const accept_peek_only = @This(){ .accept_before_delivery = true, .accept_no_draw_default_rect = true }; +}; + +const Payload = extern struct { + data: *anyopaque = null, + data_size: c_int = 0, + source_id: c_uint = 0, + source_parent_id: c_uint = 0, + data_frame_count: c_int = -1, + data_type: [32:0]c_char, + preview: bool = false, + delivery: bool = false, + + pub fn init() Payload { + var payload = Payload{}; + payload.clear(); + return payload; + } + + /// `pub fn clear(payload: *Payload) void` + pub const clear = zguiImGuiPayload_Clear; + extern fn zguiImGuiPayload_Clear(payload: *Payload) void; + + /// `pub fn isDataType(payload: *const Payload, type: [*:0]const u8) bool` + pub const isDataType = zguiImGuiPayload_IsDataType; + extern fn zguiImGuiPayload_IsDataType(payload: *const Payload, type: [*:0]const u8) bool; + + /// `pub fn isPreview(payload: *const Payload) bool` + pub const isPreview = zguiImGuiPayload_IsPreview; + extern fn zguiImGuiPayload_IsPreview(payload: *const Payload) bool; + + /// `pub fn isDelivery(payload: *const Payload) bool; + pub const isDelivery = zguiImGuiPayload_IsDelivery; + extern fn zguiImGuiPayload_IsDelivery(payload: *const Payload) bool; +}; + +pub fn beginDragDropSource(flags: DragDropFlags) bool { + return zguiBeginDragDropSource(flags); +} + +/// Note: `payload_type` can be at most 32 characters long +pub fn setDragDropPayload(payload_type: [*:0]const u8, data: []const u8, cond: Condition) bool { + return zguiSetDragDropPayload(payload_type, @alignCast(@ptrCast(data.ptr)), data.len, cond); +} +pub fn endDragDropSource() void { + zguiEndDragDropSource(); +} +pub fn beginDragDropTarget() bool { + return zguiBeginDragDropTarget(); +} + +/// Note: `payload_type` can be at most 32 characters long +pub fn acceptDragDropPayload(payload_type: [*:0]const u8, flags: DragDropFlags) ?*Payload { + return zguiAcceptDragDropPayload(payload_type, flags); +} +pub fn endDragDropTarget() void { + zguiEndDragDropTarget(); +} +pub fn getDragDropPayload() ?*Payload { + return zguiGetDragDropPayload(); +} +extern fn zguiBeginDragDropSource(flags: DragDropFlags) bool; +extern fn zguiSetDragDropPayload(type: [*:0]const u8, data: *const anyopaque, sz: usize, cond: Condition) bool; +extern fn zguiEndDragDropSource() void; +extern fn zguiBeginDragDropTarget() bool; +extern fn zguiAcceptDragDropPayload(type: [*:0]const u8, flags: DragDropFlags) [*c]Payload; +extern fn zguiEndDragDropTarget() void; +extern fn zguiGetDragDropPayload() [*c]Payload; +//-------------------------------------------------------------------------------------------------- +// // DrawFlags // //-------------------------------------------------------------------------------------------------- -pub const DrawFlags = packed struct(u32) { +pub const DrawFlags = packed struct(c_int) { closed: bool = false, _padding0: u3 = 0, round_corners_top_left: bool = false, @@ -3415,9 +3527,9 @@ pub const DrawFlags = packed struct(u32) { pub const DrawCmd = extern struct { clip_rect: [4]f32, texture_id: TextureIdent, - vtx_offset: u32, - idx_offset: u32, - elem_count: u32, + vtx_offset: c_uint, + idx_offset: c_uint, + elem_count: c_uint, user_callback: ?DrawCallback, user_callback_data: ?*anyopaque, }; @@ -3463,8 +3575,11 @@ pub const DrawList = *opaque { extern fn zguiDrawList_ClearFreeMemory(draw_list: DrawList) void; //---------------------------------------------------------------------------------------------- - pub const getVertexBufferLength = zguiDrawList_GetVertexBufferLength; - extern fn zguiDrawList_GetVertexBufferLength(draw_list: DrawList) i32; + pub fn getVertexBufferLength(draw_list: DrawList) i32 { + return zguiDrawList_GetVertexBufferLength(draw_list); + } + extern fn zguiDrawList_GetVertexBufferLength(draw_list: DrawList) c_int; + pub const getVertexBufferData = zguiDrawList_GetVertexBufferData; extern fn zguiDrawList_GetVertexBufferData(draw_list: DrawList) [*]DrawVert; pub fn getVertexBuffer(draw_list: DrawList) []DrawVert { @@ -3472,8 +3587,11 @@ pub const DrawList = *opaque { return draw_list.getVertexBufferData()[0..len]; } - pub const getIndexBufferLength = zguiDrawList_GetIndexBufferLength; - extern fn zguiDrawList_GetIndexBufferLength(draw_list: DrawList) i32; + pub fn getIndexBufferLength(draw_list: DrawList) i32 { + return zguiDrawList_GetIndexBufferLength(draw_list); + } + extern fn zguiDrawList_GetIndexBufferLength(draw_list: DrawList) c_int; + pub const getIndexBufferData = zguiDrawList_GetIndexBufferData; extern fn zguiDrawList_GetIndexBufferData(draw_list: DrawList) [*]DrawIdx; pub fn getIndexBuffer(draw_list: DrawList) []DrawIdx { @@ -3481,11 +3599,16 @@ pub const DrawList = *opaque { return draw_list.getIndexBufferData()[0..len]; } - pub const getCurrentIndex = zguiDrawList_GetCurrentIndex; - extern fn zguiDrawList_GetCurrentIndex(draw_list: DrawList) u32; + pub fn getCurrentIndex(draw_list: DrawList) u32 { + return zguiDrawList_GetCurrentIndex(draw_list); + } + extern fn zguiDrawList_GetCurrentIndex(draw_list: DrawList) c_uint; + + pub fn getCmdBufferLength(draw_list: DrawList) i32 { + return zguiDrawList_GetCmdBufferLength(draw_list); + } + extern fn zguiDrawList_GetCmdBufferLength(draw_list: DrawList) c_int; - pub const getCmdBufferLength = zguiDrawList_GetCmdBufferLength; - extern fn zguiDrawList_GetCmdBufferLength(draw_list: DrawList) i32; pub const getCmdBufferData = zguiDrawList_GetCmdBufferData; extern fn zguiDrawList_GetCmdBufferData(draw_list: DrawList) [*]DrawCmd; pub fn getCmdBuffer(draw_list: DrawList) []DrawCmd { @@ -3493,7 +3616,7 @@ pub const DrawList = *opaque { return draw_list.getCmdBufferData()[0..len]; } - pub const DrawListFlags = packed struct(u32) { + pub const DrawListFlags = packed struct(c_int) { anti_aliased_lines: bool = false, anti_aliased_lines_use_tex: bool = false, anti_aliased_fill: bool = false, @@ -3554,13 +3677,12 @@ pub const DrawList = *opaque { } extern fn zguiDrawList_GetClipRectMax(draw_list: DrawList, clip_min: *[2]f32) void; //---------------------------------------------------------------------------------------------- - const AddLine = struct { + pub fn addLine(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, col: u32, thickness: f32, - }; - pub fn addLine(draw_list: DrawList, args: AddLine) void { + }) void { zguiDrawList_AddLine(draw_list, &args.p1, &args.p2, args.col, args.thickness); } extern fn zguiDrawList_AddLine( @@ -3571,15 +3693,14 @@ pub const DrawList = *opaque { thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddRect = struct { + pub fn addRect(draw_list: DrawList, args: struct { pmin: [2]f32, pmax: [2]f32, col: u32, rounding: f32 = 0.0, flags: DrawFlags = .{}, thickness: f32 = 1.0, - }; - pub fn addRect(draw_list: DrawList, args: AddRect) void { + }) void { zguiDrawList_AddRect( draw_list, &args.pmin, @@ -3600,15 +3721,21 @@ pub const DrawList = *opaque { thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddRectFilled = struct { + pub fn addRectFilled(draw_list: DrawList, args: struct { pmin: [2]f32, pmax: [2]f32, col: u32, rounding: f32 = 0.0, flags: DrawFlags = .{}, - }; - pub fn addRectFilled(draw_list: DrawList, args: AddRectFilled) void { - zguiDrawList_AddRectFilled(draw_list, &args.pmin, &args.pmax, args.col, args.rounding, args.flags); + }) void { + zguiDrawList_AddRectFilled( + draw_list, + &args.pmin, + &args.pmax, + args.col, + args.rounding, + args.flags, + ); } extern fn zguiDrawList_AddRectFilled( draw_list: DrawList, @@ -3619,15 +3746,14 @@ pub const DrawList = *opaque { flags: DrawFlags, ) void; //---------------------------------------------------------------------------------------------- - const AddRectFilledMultiColor = struct { + pub fn addRectFilledMultiColor(draw_list: DrawList, args: struct { pmin: [2]f32, pmax: [2]f32, col_upr_left: u32, col_upr_right: u32, col_bot_right: u32, col_bot_left: u32, - }; - pub fn addRectFilledMultiColor(draw_list: DrawList, args: AddRectFilledMultiColor) void { + }) void { zguiDrawList_AddRectFilledMultiColor( draw_list, &args.pmin, @@ -3642,22 +3768,29 @@ pub const DrawList = *opaque { draw_list: DrawList, pmin: *const [2]f32, pmax: *const [2]f32, - col_upr_left: u32, - col_upr_right: u32, - col_bot_right: u32, - col_bot_left: u32, + col_upr_left: c_uint, + col_upr_right: c_uint, + col_bot_right: c_uint, + col_bot_left: c_uint, ) void; //---------------------------------------------------------------------------------------------- - const AddQuad = struct { + pub fn addQuad(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, p4: [2]f32, col: u32, thickness: f32 = 1.0, - }; - pub fn addQuad(draw_list: DrawList, args: AddQuad) void { - zguiDrawList_AddQuad(draw_list, &args.p1, &args.p2, &args.p3, &args.p4, args.col, args.thickness); + }) void { + zguiDrawList_AddQuad( + draw_list, + &args.p1, + &args.p2, + &args.p3, + &args.p4, + args.col, + args.thickness, + ); } extern fn zguiDrawList_AddQuad( draw_list: DrawList, @@ -3669,14 +3802,13 @@ pub const DrawList = *opaque { thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddQuadFilled = struct { + pub fn addQuadFilled(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, p4: [2]f32, col: u32, - }; - pub fn addQuadFilled(draw_list: DrawList, args: AddQuadFilled) void { + }) void { zguiDrawList_AddQuadFilled(draw_list, &args.p1, &args.p2, &args.p3, &args.p4, args.col); } extern fn zguiDrawList_AddQuadFilled( @@ -3688,14 +3820,13 @@ pub const DrawList = *opaque { col: u32, ) void; //---------------------------------------------------------------------------------------------- - const AddTriangle = struct { + pub fn addTriangle(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, col: u32, thickness: f32 = 1.0, - }; - pub fn addTriangle(draw_list: DrawList, args: AddTriangle) void { + }) void { zguiDrawList_AddTriangle(draw_list, &args.p1, &args.p2, &args.p3, args.col, args.thickness); } extern fn zguiDrawList_AddTriangle( @@ -3707,13 +3838,12 @@ pub const DrawList = *opaque { thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddTriangleFilled = struct { + pub fn addTriangleFilled(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, col: u32, - }; - pub fn addTriangleFilled(draw_list: DrawList, args: AddTriangleFilled) void { + }) void { zguiDrawList_AddTriangleFilled(draw_list, &args.p1, &args.p2, &args.p3, args.col); } extern fn zguiDrawList_AddTriangleFilled( @@ -3724,32 +3854,37 @@ pub const DrawList = *opaque { col: u32, ) void; //---------------------------------------------------------------------------------------------- - const AddCircle = struct { + pub fn addCircle(draw_list: DrawList, args: struct { p: [2]f32, r: f32, col: u32, - num_segments: u32 = 0, + num_segments: i32 = 0, thickness: f32 = 1.0, - }; - pub fn addCircle(draw_list: DrawList, args: AddCircle) void { - zguiDrawList_AddCircle(draw_list, &args.p, args.r, args.col, args.num_segments, args.thickness); + }) void { + zguiDrawList_AddCircle( + draw_list, + &args.p, + args.r, + args.col, + args.num_segments, + args.thickness, + ); } extern fn zguiDrawList_AddCircle( draw_list: DrawList, center: *const [2]f32, radius: f32, col: u32, - num_segments: u32, + num_segments: c_int, thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddCircleFilled = struct { + pub fn addCircleFilled(draw_list: DrawList, args: struct { p: [2]f32, r: f32, col: u32, - num_segments: u32 = 0, - }; - pub fn addCircleFilled(draw_list: DrawList, args: AddCircleFilled) void { + num_segments: u16 = 0, + }) void { zguiDrawList_AddCircleFilled(draw_list, &args.p, args.r, args.col, args.num_segments); } extern fn zguiDrawList_AddCircleFilled( @@ -3757,35 +3892,40 @@ pub const DrawList = *opaque { center: *const [2]f32, radius: f32, col: u32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- - const AddNgon = struct { + pub fn addNgon(draw_list: DrawList, args: struct { p: [2]f32, r: f32, col: u32, num_segments: u32, thickness: f32 = 1.0, - }; - pub fn addNgon(draw_list: DrawList, args: AddNgon) void { - zguiDrawList_AddNgon(draw_list, &args.p, args.r, args.col, args.num_segments, args.thickness); + }) void { + zguiDrawList_AddNgon( + draw_list, + &args.p, + args.r, + args.col, + args.num_segments, + args.thickness, + ); } extern fn zguiDrawList_AddNgon( draw_list: DrawList, center: *const [2]f32, radius: f32, col: u32, - num_segments: u32, + num_segments: c_int, thickness: f32, ) void; //---------------------------------------------------------------------------------------------- - const AddNgonFilled = struct { + pub fn addNgonFilled(draw_list: DrawList, args: struct { p: [2]f32, r: f32, col: u32, num_segments: u32, - }; - pub fn addNgonFilled(draw_list: DrawList, args: AddNgonFilled) void { + }) void { zguiDrawList_AddNgonFilled(draw_list, &args.p, args.r, args.col, args.num_segments); } extern fn zguiDrawList_AddNgonFilled( @@ -3793,7 +3933,7 @@ pub const DrawList = *opaque { center: *const [2]f32, radius: f32, col: u32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- pub fn addText(draw_list: DrawList, pos: [2]f32, col: u32, comptime fmt: []const u8, args: anytype) void { @@ -3811,16 +3951,15 @@ pub const DrawList = *opaque { text_end: [*]const u8, ) void; //---------------------------------------------------------------------------------------------- - const AddPolyline = struct { + pub fn addPolyline(draw_list: DrawList, points: []const [2]f32, args: struct { col: u32, flags: DrawFlags = .{}, thickness: f32 = 1.0, - }; - pub fn addPolyline(draw_list: DrawList, points: []const [2]f32, args: AddPolyline) void { + }) void { zguiDrawList_AddPolyline( draw_list, points.ptr, - @as(u32, @intCast(points.len)), + @intCast(points.len), args.col, args.flags, args.thickness, @@ -3829,7 +3968,7 @@ pub const DrawList = *opaque { extern fn zguiDrawList_AddPolyline( draw_list: DrawList, points: [*]const [2]f32, - num_points: u32, + num_points: c_int, col: u32, flags: DrawFlags, thickness: f32, @@ -3843,18 +3982,18 @@ pub const DrawList = *opaque { zguiDrawList_AddConvexPolyFilled( draw_list, points.ptr, - @as(u32, @intCast(points.len)), + @intCast(points.len), col, ); } extern fn zguiDrawList_AddConvexPolyFilled( draw_list: DrawList, points: [*]const [2]f32, - num_points: u32, + num_points: c_int, col: u32, ) void; //---------------------------------------------------------------------------------------------- - const AddBezierCubic = struct { + pub fn addBezierCubic(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, @@ -3862,8 +4001,7 @@ pub const DrawList = *opaque { col: u32, thickness: f32 = 1.0, num_segments: u32 = 0, - }; - pub fn addBezierCubic(draw_list: DrawList, args: AddBezierCubic) void { + }) void { zguiDrawList_AddBezierCubic( draw_list, &args.p1, @@ -3883,18 +4021,17 @@ pub const DrawList = *opaque { p4: *const [2]f32, col: u32, thickness: f32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- - const AddBezierQuadratic = struct { + pub fn addBezierQuadratic(draw_list: DrawList, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, col: u32, thickness: f32 = 1.0, num_segments: u32 = 0, - }; - pub fn addBezierQuadratic(draw_list: DrawList, args: AddBezierQuadratic) void { + }) void { zguiDrawList_AddBezierQuadratic( draw_list, &args.p1, @@ -3912,17 +4049,16 @@ pub const DrawList = *opaque { p3: *const [2]f32, col: u32, thickness: f32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- - const AddImage = struct { + pub fn addImage(draw_list: DrawList, user_texture_id: TextureIdent, args: struct { pmin: [2]f32, pmax: [2]f32, uvmin: [2]f32 = .{ 0, 0 }, uvmax: [2]f32 = .{ 1, 1 }, col: u32 = 0xff_ff_ff_ff, - }; - pub fn addImage(draw_list: DrawList, user_texture_id: TextureIdent, args: AddImage) void { + }) void { zguiDrawList_AddImage( draw_list, user_texture_id, @@ -3943,7 +4079,7 @@ pub const DrawList = *opaque { col: u32, ) void; //---------------------------------------------------------------------------------------------- - const AddImageQuad = struct { + pub fn addImageQuad(draw_list: DrawList, user_texture_id: TextureIdent, args: struct { p1: [2]f32, p2: [2]f32, p3: [2]f32, @@ -3953,8 +4089,7 @@ pub const DrawList = *opaque { uv3: [2]f32 = .{ 1, 1 }, uv4: [2]f32 = .{ 0, 1 }, col: u32 = 0xff_ff_ff_ff, - }; - pub fn addImageQuad(draw_list: DrawList, user_texture_id: TextureIdent, args: AddImageQuad) void { + }) void { zguiDrawList_AddImageQuad( draw_list, user_texture_id, @@ -3983,7 +4118,7 @@ pub const DrawList = *opaque { col: u32, ) void; //---------------------------------------------------------------------------------------------- - const AddImageRounded = struct { + pub fn addImageRounded(draw_list: DrawList, user_texture_id: TextureIdent, args: struct { pmin: [2]f32, pmax: [2]f32, uvmin: [2]f32 = .{ 0, 0 }, @@ -3991,8 +4126,7 @@ pub const DrawList = *opaque { col: u32 = 0xff_ff_ff_ff, rounding: f32 = 4.0, flags: DrawFlags = .{}, - }; - pub fn addImageRounded(draw_list: DrawList, user_texture_id: TextureIdent, args: AddImageRounded) void { + }) void { zguiDrawList_AddImageRounded( draw_list, user_texture_id, @@ -4030,27 +4164,27 @@ pub const DrawList = *opaque { } extern fn zguiDrawList_PathLineToMergeDuplicate(draw_list: DrawList, pos: *const [2]f32) void; //---------------------------------------------------------------------------------------------- - pub const pathFillConvex = zguiDrawList_PathFillConvex; - extern fn zguiDrawList_PathFillConvex(draw_list: DrawList, col: u32) void; + pub fn pathFillConvex(draw_list: DrawList, col: u32) void { + return zguiDrawList_PathFillConvex(draw_list, col); + } + extern fn zguiDrawList_PathFillConvex(draw_list: DrawList, col: c_uint) void; //---------------------------------------------------------------------------------------------- - const PathStroke = struct { + pub fn pathStroke(draw_list: DrawList, args: struct { col: u32, flags: DrawFlags = .{}, thickness: f32 = 1.0, - }; - pub fn pathStroke(draw_list: DrawList, args: PathStroke) void { + }) void { zguiDrawList_PathStroke(draw_list, args.col, args.flags, args.thickness); } extern fn zguiDrawList_PathStroke(draw_list: DrawList, col: u32, flags: DrawFlags, thickness: f32) void; //---------------------------------------------------------------------------------------------- - const PathArcTo = struct { + pub fn pathArcTo(draw_list: DrawList, args: struct { p: [2]f32, r: f32, amin: f32, amax: f32, - num_segments: u32 = 0, - }; - pub fn pathArcTo(draw_list: DrawList, args: PathArcTo) void { + num_segments: u16 = 0, + }) void { zguiDrawList_PathArcTo( draw_list, &args.p, @@ -4066,56 +4200,59 @@ pub const DrawList = *opaque { radius: f32, amin: f32, amax: f32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- - const PathArcToFast = struct { + pub fn pathArcToFast(draw_list: DrawList, args: struct { p: [2]f32, r: f32, - amin_of_12: f32, - amax_of_12: f32, - }; - pub fn pathArcToFast(draw_list: DrawList, args: PathArcToFast) void { + amin_of_12: u16, + amax_of_12: u16, + }) void { zguiDrawList_PathArcToFast(draw_list, &args.p, args.r, args.amin_of_12, args.amax_of_12); } extern fn zguiDrawList_PathArcToFast( draw_list: DrawList, center: *const [2]f32, radius: f32, - a_min_of_12: f32, - a_max_of_12: f32, + a_min_of_12: c_int, + a_max_of_12: c_int, ) void; //---------------------------------------------------------------------------------------------- - const PathBezierCubicCurveTo = struct { + pub fn pathBezierCubicCurveTo(draw_list: DrawList, args: struct { p2: [2]f32, p3: [2]f32, p4: [2]f32, - num_segments: u32 = 0, - }; - pub fn pathBezierCubicCurveTo(draw_list: DrawList, args: PathBezierCubicCurveTo) void { - zguiDrawList_PathBezierCubicCurveTo(draw_list, &args.p2, &args.p3, &args.p4, args.num_segments); + num_segments: u16 = 0, + }) void { + zguiDrawList_PathBezierCubicCurveTo( + draw_list, + &args.p2, + &args.p3, + &args.p4, + args.num_segments, + ); } extern fn zguiDrawList_PathBezierCubicCurveTo( draw_list: DrawList, p2: *const [2]f32, p3: *const [2]f32, p4: *const [2]f32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- - const PathBezierQuadraticCurveTo = struct { + pub fn pathBezierQuadraticCurveTo(draw_list: DrawList, args: struct { p2: [2]f32, p3: [2]f32, - num_segments: u32 = 0, - }; - pub fn pathBezierQuadraticCurveTo(draw_list: DrawList, args: PathBezierQuadraticCurveTo) void { + num_segments: u16 = 0, + }) void { zguiDrawList_PathBezierQuadraticCurveTo(draw_list, &args.p2, &args.p3, args.num_segments); } extern fn zguiDrawList_PathBezierQuadraticCurveTo( draw_list: DrawList, p2: *const [2]f32, p3: *const [2]f32, - num_segments: u32, + num_segments: c_int, ) void; //---------------------------------------------------------------------------------------------- const PathRect = struct { @@ -4136,7 +4273,19 @@ pub const DrawList = *opaque { ) void; //---------------------------------------------------------------------------------------------- pub const primReserve = zguiDrawList_PrimReserve; + extern fn zguiDrawList_PrimReserve( + draw_list: DrawList, + idx_count: i32, + vtx_count: i32, + ) void; + pub const primUnreserve = zguiDrawList_PrimUnreserve; + extern fn zguiDrawList_PrimUnreserve( + draw_list: DrawList, + idx_count: i32, + vtx_count: i32, + ) void; + pub fn primRect( draw_list: DrawList, a: [2]f32, @@ -4145,6 +4294,13 @@ pub const DrawList = *opaque { ) void { return zguiDrawList_PrimRect(draw_list, &a, &b, col); } + extern fn zguiDrawList_PrimRect( + draw_list: DrawList, + a: *const [2]f32, + b: *const [2]f32, + col: u32, + ) void; + pub fn primRectUV( draw_list: DrawList, a: [2]f32, @@ -4155,6 +4311,15 @@ pub const DrawList = *opaque { ) void { return zguiDrawList_PrimRectUV(draw_list, &a, &b, &uv_a, &uv_b, col); } + extern fn zguiDrawList_PrimRectUV( + draw_list: DrawList, + a: *const [2]f32, + b: *const [2]f32, + uv_a: *const [2]f32, + uv_b: *const [2]f32, + col: u32, + ) void; + pub fn primQuadUV( draw_list: DrawList, a: [2]f32, @@ -4169,40 +4334,6 @@ pub const DrawList = *opaque { ) void { return zguiDrawList_PrimQuadUV(draw_list, &a, &b, &c, &d, &uv_a, &uv_b, &uv_c, &uv_d, col); } - pub fn primWriteVtx( - draw_list: DrawList, - pos: [2]f32, - uv: [2]f32, - col: u32, - ) void { - return zguiDrawList_PrimWriteVtx(draw_list, &pos, &uv, col); - } - pub const primWriteIdx = zguiDrawList_PrimWriteIdx; - - extern fn zguiDrawList_PrimReserve( - draw_list: DrawList, - idx_count: i32, - vtx_count: i32, - ) void; - extern fn zguiDrawList_PrimUnreserve( - draw_list: DrawList, - idx_count: i32, - vtx_count: i32, - ) void; - extern fn zguiDrawList_PrimRect( - draw_list: DrawList, - a: *const [2]f32, - b: *const [2]f32, - col: u32, - ) void; - extern fn zguiDrawList_PrimRectUV( - draw_list: DrawList, - a: *const [2]f32, - b: *const [2]f32, - uv_a: *const [2]f32, - uv_b: *const [2]f32, - col: u32, - ) void; extern fn zguiDrawList_PrimQuadUV( draw_list: DrawList, a: *const [2]f32, @@ -4215,12 +4346,23 @@ pub const DrawList = *opaque { uv_d: *const [2]f32, col: u32, ) void; + + pub fn primWriteVtx( + draw_list: DrawList, + pos: [2]f32, + uv: [2]f32, + col: u32, + ) void { + return zguiDrawList_PrimWriteVtx(draw_list, &pos, &uv, col); + } extern fn zguiDrawList_PrimWriteVtx( draw_list: DrawList, pos: *const [2]f32, uv: *const [2]f32, col: u32, ) void; + + pub const primWriteIdx = zguiDrawList_PrimWriteIdx; extern fn zguiDrawList_PrimWriteIdx( draw_list: DrawList, idx: DrawIdx, @@ -4239,5 +4381,29 @@ pub const DrawList = *opaque { }; test { - std.testing.refAllDeclsRecursive(@This()); + const testing = std.testing; + + testing.refAllDeclsRecursive(@This()); + + init(testing.allocator); + defer deinit(); + + io.setIniFilename(null); + + _ = io.getFontsTextDataAsRgba32(); + + io.setDisplaySize(1, 1); + + newFrame(); + + try testing.expect(begin("testing", .{})); + defer end(); + + const Testing = enum { + one, + two, + three, + }; + var value = Testing.one; + _ = comboFromEnum("comboFromEnum", &value); } diff --git a/src/zgui.cpp b/src/zgui.cpp index afc0ac1..8c5881f 100644 --- a/src/zgui.cpp +++ b/src/zgui.cpp @@ -460,6 +460,51 @@ ZGUI_API bool zguiDragScalarN( return ImGui::DragScalarN(label, data_type, p_data, components, v_speed, p_min, p_max, format, flags); } +ZGUI_API bool zguiBeginDragDropSource(ImGuiDragDropFlags flags = 0) { + return ImGui::BeginDragDropSource(flags); +} +ZGUI_API bool zguiSetDragDropPayload( + const char* type, + const void* data, + size_t sz, + ImGuiCond cond = 0 +) { + return ImGui::SetDragDropPayload(type, data, sz, cond); +} +ZGUI_API void zguiEndDragDropSource() { + return ImGui::EndDragDropSource(); +} +ZGUI_API bool zguiBeginDragDropTarget() { + return ImGui::BeginDragDropTarget(); +} +ZGUI_API const ImGuiPayload* zguiAcceptDragDropPayload( + const char* type, + ImGuiDragDropFlags flags = 0 +) { + return ImGui::AcceptDragDropPayload(type); +} +ZGUI_API void zguiEndDragDropTarget() { + return ImGui::EndDragDropTarget(); +} +ZGUI_API const ImGuiPayload* zguiGetDragDropPayload() { + return ImGui::GetDragDropPayload(); +} + +ZGUI_API void zguiImGuiPayload_Clear(ImGuiPayload* payload) { payload->Clear(); } + +ZGUI_API bool zguiImGuiPayload_IsDataType(const ImGuiPayload* payload, const char* type) { + return payload->IsDataType(type); +} + +ZGUI_API bool zguiImGuiPayload_IsPreview(const ImGuiPayload* payload) { + return payload->IsPreview(); +} + +ZGUI_API bool zguiImGuiPayload_IsDelivery(const ImGuiPayload* payload) { + return payload->IsDelivery(); +} + + ZGUI_API bool zguiCombo( const char* label, int* current_item, @@ -1025,7 +1070,7 @@ ZGUI_API void zguiPushStyleColor4f(ImGuiCol idx, const float col[4]) { ImGui::PushStyleColor(idx, { col[0], col[1], col[2], col[3] }); } -ZGUI_API void zguiPushStyleColor1u(ImGuiCol idx, unsigned int col) { +ZGUI_API void zguiPushStyleColor1u(ImGuiCol idx, ImU32 col) { ImGui::PushStyleColor(idx, col); } @@ -1257,6 +1302,10 @@ ZGUI_API bool zguiIoGetWantCaptureKeyboard(void) { return ImGui::GetIO().WantCaptureKeyboard; } +ZGUI_API bool zguiIoGetWantTextInput(void) { + return ImGui::GetIO().WantTextInput; +} + ZGUI_API void zguiIoSetIniFilename(const char* filename) { ImGui::GetIO().IniFilename = filename; } @@ -1311,7 +1360,7 @@ ZGUI_API void zguiIoSetKeyEventNativeData(ImGuiKey key, int keycode, int scancod ImGui::GetIO().SetKeyEventNativeData(key, keycode, scancode); } -ZGUI_API void zguiIoAddCharacterEvent(int c) { +ZGUI_API void zguiIoAddCharacterEvent(unsigned int c) { ImGui::GetIO().AddInputCharacter(c); } @@ -1579,7 +1628,7 @@ ZGUI_API void zguiTableSetColumnEnabled(int column_n, bool v) { ImGui::TableSetColumnEnabled(column_n, v); } -ZGUI_API void zguiTableSetBgColor(ImGuiTableBgTarget target, unsigned int color, int column_n) { +ZGUI_API void zguiTableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n) { ImGui::TableSetBgColor(target, color, column_n); } //-------------------------------------------------------------------------------------------------- @@ -1727,7 +1776,7 @@ ZGUI_API void zguiDrawList_AddLine( ImDrawList* draw_list, const float p1[2], const float p2[2], - unsigned int col, + ImU32 col, float thickness ) { draw_list->AddLine({ p1[0], p1[1] }, { p2[0], p2[1] }, col, thickness); @@ -1737,7 +1786,7 @@ ZGUI_API void zguiDrawList_AddRect( ImDrawList* draw_list, const float pmin[2], const float pmax[2], - unsigned int col, + ImU32 col, float rounding, ImDrawFlags flags, float thickness @@ -1749,7 +1798,7 @@ ZGUI_API void zguiDrawList_AddRectFilled( ImDrawList* draw_list, const float pmin[2], const float pmax[2], - unsigned int col, + ImU32 col, float rounding, ImDrawFlags flags ) { @@ -1760,10 +1809,10 @@ ZGUI_API void zguiDrawList_AddRectFilledMultiColor( ImDrawList* draw_list, const float pmin[2], const float pmax[2], - unsigned int col_upr_left, - unsigned int col_upr_right, - unsigned int col_bot_right, - unsigned int col_bot_left + ImU32 col_upr_left, + ImU32 col_upr_right, + ImU32 col_bot_right, + ImU32 col_bot_left ) { draw_list->AddRectFilledMultiColor( { pmin[0], pmin[1] }, @@ -1781,7 +1830,7 @@ ZGUI_API void zguiDrawList_AddQuad( const float p2[2], const float p3[2], const float p4[2], - unsigned int col, + ImU32 col, float thickness ) { draw_list->AddQuad({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, { p4[0], p4[1] }, col, thickness); @@ -1793,7 +1842,7 @@ ZGUI_API void zguiDrawList_AddQuadFilled( const float p2[2], const float p3[2], const float p4[2], - unsigned int col + ImU32 col ) { draw_list->AddQuadFilled({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, { p4[0], p4[1] }, col); } @@ -1803,7 +1852,7 @@ ZGUI_API void zguiDrawList_AddTriangle( const float p1[2], const float p2[2], const float p3[2], - unsigned int col, + ImU32 col, float thickness ) { draw_list->AddTriangle({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, col, thickness); @@ -1814,7 +1863,7 @@ ZGUI_API void zguiDrawList_AddTriangleFilled( const float p1[2], const float p2[2], const float p3[2], - unsigned int col + ImU32 col ) { draw_list->AddTriangleFilled({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, col); } @@ -1823,7 +1872,7 @@ ZGUI_API void zguiDrawList_AddCircle( ImDrawList* draw_list, const float center[2], float radius, - unsigned int col, + ImU32 col, int num_segments, float thickness ) { @@ -1834,7 +1883,7 @@ ZGUI_API void zguiDrawList_AddCircleFilled( ImDrawList* draw_list, const float center[2], float radius, - unsigned int col, + ImU32 col, int num_segments ) { draw_list->AddCircleFilled({ center[0], center[1] }, radius, col, num_segments); @@ -1844,7 +1893,7 @@ ZGUI_API void zguiDrawList_AddNgon( ImDrawList* draw_list, const float center[2], float radius, - unsigned int col, + ImU32 col, int num_segments, float thickness ) { @@ -1855,7 +1904,7 @@ ZGUI_API void zguiDrawList_AddNgonFilled( ImDrawList* draw_list, const float center[2], float radius, - unsigned int col, + ImU32 col, int num_segments ) { draw_list->AddNgonFilled({ center[0], center[1] }, radius, col, num_segments); @@ -1864,7 +1913,7 @@ ZGUI_API void zguiDrawList_AddNgonFilled( ZGUI_API void zguiDrawList_AddText( ImDrawList* draw_list, const float pos[2], - unsigned int col, + ImU32 col, const char* text_begin, const char* text_end ) { @@ -1875,7 +1924,7 @@ ZGUI_API void zguiDrawList_AddPolyline( ImDrawList* draw_list, const float points[][2], int num_points, - unsigned int col, + ImU32 col, ImDrawFlags flags, float thickness ) { @@ -1886,7 +1935,7 @@ ZGUI_API void zguiDrawList_AddConvexPolyFilled( ImDrawList* draw_list, const float points[][2], int num_points, - unsigned int col + ImU32 col ) { draw_list->AddConvexPolyFilled((const ImVec2*)&points[0][0], num_points, col); } @@ -1897,7 +1946,7 @@ ZGUI_API void zguiDrawList_AddBezierCubic( const float p2[2], const float p3[2], const float p4[2], - unsigned int col, + ImU32 col, float thickness, int num_segments ) { @@ -1911,7 +1960,7 @@ ZGUI_API void zguiDrawList_AddBezierQuadratic( const float p1[2], const float p2[2], const float p3[2], - unsigned int col, + ImU32 col, float thickness, int num_segments ) { @@ -1927,7 +1976,7 @@ ZGUI_API void zguiDrawList_AddImage( const float pmax[2], const float uvmin[2], const float uvmax[2], - unsigned int col + ImU32 col ) { draw_list->AddImage( user_texture_id, @@ -1950,7 +1999,7 @@ ZGUI_API void zguiDrawList_AddImageQuad( const float uv2[2], const float uv3[2], const float uv4[2], - unsigned int col + ImU32 col ) { draw_list->AddImageQuad( user_texture_id, @@ -1973,7 +2022,7 @@ ZGUI_API void zguiDrawList_AddImageRounded( const float pmax[2], const float uvmin[2], const float uvmax[2], - unsigned int col, + ImU32 col, float rounding, ImDrawFlags flags ) { @@ -2001,11 +2050,11 @@ ZGUI_API void zguiDrawList_PathLineToMergeDuplicate(ImDrawList* draw_list, const draw_list->PathLineToMergeDuplicate({ pos[0], pos[1] }); } -ZGUI_API void zguiDrawList_PathFillConvex(ImDrawList* draw_list, unsigned int col) { +ZGUI_API void zguiDrawList_PathFillConvex(ImDrawList* draw_list, ImU32 col) { draw_list->PathFillConvex(col); } -ZGUI_API void zguiDrawList_PathStroke(ImDrawList* draw_list, unsigned int col, ImDrawFlags flags, float thickness) { +ZGUI_API void zguiDrawList_PathStroke(ImDrawList* draw_list, ImU32 col, ImDrawFlags flags, float thickness) { draw_list->PathStroke(col, flags, thickness); } @@ -2071,7 +2120,7 @@ ZGUI_API void zguiDrawList_PrimRect( ImDrawList* draw_list, const float a[2], const float b[2], - unsigned int col + ImU32 col ) { draw_list->PrimRect({ a[0], a[1] }, { b[0], b[1] }, col); } @@ -2082,7 +2131,7 @@ ZGUI_API void zguiDrawList_PrimRectUV( const float b[2], const float uv_a[2], const float uv_b[2], - unsigned int col + ImU32 col ) { draw_list->PrimRectUV({ a[0], a[1] }, { b[0], b[1] }, { uv_a[0], uv_a[1] }, { uv_b[0], uv_b[1] }, col); } @@ -2097,7 +2146,7 @@ ZGUI_API void zguiDrawList_PrimQuadUV( const float uv_b[2], const float uv_c[2], const float uv_d[2], - unsigned int col + ImU32 col ) { draw_list->PrimQuadUV( { a[0], a[1] }, { b[0], b[1] }, { c[0], c[1] }, { d[0], d[1] }, @@ -2110,7 +2159,7 @@ ZGUI_API void zguiDrawList_PrimWriteVtx( ImDrawList* draw_list, const float pos[2], const float uv[2], - unsigned int col + ImU32 col ) { draw_list->PrimWriteVtx({ pos[0], pos[1] }, { uv[0], uv[1] }, col); } @@ -2189,7 +2238,7 @@ ZGUI_API void zguiPlot_PushStyleColor4f(ImPlotCol idx, const float col[4]) { ImPlot::PushStyleColor(idx, { col[0], col[1], col[2], col[3] }); } -ZGUI_API void zguiPlot_PushStyleColor1u(ImPlotCol idx, unsigned int col) { +ZGUI_API void zguiPlot_PushStyleColor1u(ImPlotCol idx, ImU32 col) { ImPlot::PushStyleColor(idx, col); }