diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-10-13 01:19:27 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-10-13 01:19:27 -0500 |
| commit | 1f9b827badb2de4c4eaae11c0d02242ec90af7f6 (patch) | |
| tree | 27acb295833e6eee730dd71f98db280d54c6a4ad /vendor/zgui/src | |
| parent | b5d0c1dcd751f4735d9f6b45c805300000c9d171 (diff) | |
| download | particle-sim-1f9b827badb2de4c4eaae11c0d02242ec90af7f6.tar.gz | |
Updating to zig 0.15.1
Diffstat (limited to 'vendor/zgui/src')
| -rw-r--r-- | vendor/zgui/src/backend_dx12.zig | 59 | ||||
| -rw-r--r-- | vendor/zgui/src/backend_glfw.zig | 35 | ||||
| -rw-r--r-- | vendor/zgui/src/backend_glfw_dx12.zig | 45 | ||||
| -rw-r--r-- | vendor/zgui/src/backend_glfw_opengl.zig | 44 | ||||
| -rw-r--r-- | vendor/zgui/src/backend_glfw_wgpu.zig | 67 | ||||
| -rw-r--r-- | vendor/zgui/src/backend_win32_dx12.zig | 48 | ||||
| -rw-r--r-- | vendor/zgui/src/gui.zig | 4580 | ||||
| -rw-r--r-- | vendor/zgui/src/plot.zig | 596 | ||||
| -rw-r--r-- | vendor/zgui/src/te.zig | 255 | ||||
| -rw-r--r-- | vendor/zgui/src/zgui.cpp | 2708 |
10 files changed, 0 insertions, 8437 deletions
diff --git a/vendor/zgui/src/backend_dx12.zig b/vendor/zgui/src/backend_dx12.zig deleted file mode 100644 index 22672e7..0000000 --- a/vendor/zgui/src/backend_dx12.zig +++ /dev/null @@ -1,59 +0,0 @@ -pub const D3D12_CPU_DESCRIPTOR_HANDLE = extern struct { - ptr: c_ulonglong, -}; - -pub const D3D12_GPU_DESCRIPTOR_HANDLE = extern struct { - ptr: c_ulonglong, -}; - -pub fn init( - 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_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_ImplDX12_Shutdown(); -} - -pub fn newFrame() void { - ImGui_ImplDX12_NewFrame(); -} - -pub fn render( - draw_data: *const anyopaque, // *gui.DrawData - gfx_command_list: *const anyopaque, // *ID3D12GraphicsCommandList -) void { - ImGui_ImplDX12_RenderDrawData(draw_data, gfx_command_list); -} - -// Those functions are defined in 'imgui_impl_dx12.cpp` -// (they include few custom changes). -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/vendor/zgui/src/backend_glfw.zig b/vendor/zgui/src/backend_glfw.zig deleted file mode 100644 index 83603fe..0000000 --- a/vendor/zgui/src/backend_glfw.zig +++ /dev/null @@ -1,35 +0,0 @@ -const gui = @import("gui.zig"); - -// This call will install GLFW callbacks to handle GUI interactions. -// Those callbacks will chain-call user's previously installed callbacks, if any. -// This means that custom user's callbacks need to be installed *before* calling zgpu.gui.init(). -pub fn init( - window: *const anyopaque, // zglfw.Window -) void { - if (!ImGui_ImplGlfw_InitForOther(window, true)) { - unreachable; - } -} - -pub fn initOpenGL( - window: *const anyopaque, // zglfw.Window -) void { - if (!ImGui_ImplGlfw_InitForOpenGL(window, true)) { - unreachable; - } -} - -pub fn deinit() void { - ImGui_ImplGlfw_Shutdown(); -} - -pub fn newFrame() void { - ImGui_ImplGlfw_NewFrame(); -} - -// Those functions are defined in `imgui_impl_glfw.cpp` -// (they include few custom changes). -extern fn ImGui_ImplGlfw_InitForOther(window: *const anyopaque, install_callbacks: bool) bool; -extern fn ImGui_ImplGlfw_InitForOpenGL(window: *const anyopaque, install_callbacks: bool) bool; -extern fn ImGui_ImplGlfw_NewFrame() void; -extern fn ImGui_ImplGlfw_Shutdown() void; diff --git a/vendor/zgui/src/backend_glfw_dx12.zig b/vendor/zgui/src/backend_glfw_dx12.zig deleted file mode 100644 index 48c63cb..0000000 --- a/vendor/zgui/src/backend_glfw_dx12.zig +++ /dev/null @@ -1,45 +0,0 @@ -const gui = @import("gui.zig"); -const backend_glfw = @import("backend_glfw.zig"); -const backend_dx12 = @import("backend_dx12.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: backend_dx12.D3D12_CPU_DESCRIPTOR_HANDLE, - font_srv_gpu_desc_handle: backend_dx12.D3D12_GPU_DESCRIPTOR_HANDLE, -) void { - backend_glfw.init(window); - backend_dx12.init( - device, - num_frames_in_flight, - rtv_format, - cbv_srv_heap, - font_srv_cpu_desc_handle, - font_srv_gpu_desc_handle, - ); -} - -pub fn deinit() void { - backend_dx12.deinit(); - backend_glfw.deinit(); -} - -pub fn newFrame(fb_width: u32, fb_height: u32) void { - backend_glfw.newFrame(); - backend_dx12.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(); - backend_dx12.render(gui.getDrawData(), graphics_command_list); -} diff --git a/vendor/zgui/src/backend_glfw_opengl.zig b/vendor/zgui/src/backend_glfw_opengl.zig deleted file mode 100644 index cb94dc3..0000000 --- a/vendor/zgui/src/backend_glfw_opengl.zig +++ /dev/null @@ -1,44 +0,0 @@ -const gui = @import("gui.zig"); -const backend_glfw = @import("backend_glfw.zig"); - -pub fn initWithGlSlVersion( - window: *const anyopaque, // zglfw.Window - glsl_version: ?[:0]const u8, // e.g. "#version 130" -) void { - backend_glfw.initOpenGL(window); - - ImGui_ImplOpenGL3_Init(@ptrCast(glsl_version)); -} - -pub fn init( - window: *const anyopaque, // zglfw.Window -) void { - initWithGlSlVersion(window, null); -} - -pub fn deinit() void { - ImGui_ImplOpenGL3_Shutdown(); - backend_glfw.deinit(); -} - -pub fn newFrame(fb_width: u32, fb_height: u32) void { - backend_glfw.newFrame(); - ImGui_ImplOpenGL3_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() void { - gui.render(); - ImGui_ImplOpenGL3_RenderDrawData(gui.getDrawData()); -} - -// Those functions are defined in 'imgui_impl_opengl3.cpp` -// (they include few custom changes). -extern fn ImGui_ImplOpenGL3_Init(glsl_version: [*c]const u8) void; -extern fn ImGui_ImplOpenGL3_Shutdown() void; -extern fn ImGui_ImplOpenGL3_NewFrame() void; -extern fn ImGui_ImplOpenGL3_RenderDrawData(data: *const anyopaque) void; diff --git a/vendor/zgui/src/backend_glfw_wgpu.zig b/vendor/zgui/src/backend_glfw_wgpu.zig deleted file mode 100644 index e6fa517..0000000 --- a/vendor/zgui/src/backend_glfw_wgpu.zig +++ /dev/null @@ -1,67 +0,0 @@ -const gui = @import("gui.zig"); -const backend_glfw = @import("backend_glfw.zig"); - -// This call will install GLFW callbacks to handle GUI interactions. -// Those callbacks will chain-call user's previously installed callbacks, if any. -// This means that custom user's callbacks need to be installed *before* calling zgpu.gui.init(). -pub fn init( - window: *const anyopaque, // zglfw.Window - wgpu_device: *const anyopaque, // wgpu.Device - wgpu_swap_chain_format: u32, // wgpu.TextureFormat - wgpu_depth_format: u32, // wgpu.TextureFormat -) void { - backend_glfw.init(window); - - var info = ImGui_ImplWGPU_InitInfo{ - .device = wgpu_device, - .num_frames_in_flight = 1, - .rt_format = wgpu_swap_chain_format, - .depth_format = wgpu_depth_format, - .pipeline_multisample_state = .{}, - }; - - if (!ImGui_ImplWGPU_Init(&info)) { - unreachable; - } -} - -pub fn deinit() void { - ImGui_ImplWGPU_Shutdown(); - backend_glfw.deinit(); -} - -pub fn newFrame(fb_width: u32, fb_height: u32) void { - ImGui_ImplWGPU_NewFrame(); - backend_glfw.newFrame(); - - gui.io.setDisplaySize(@floatFromInt(fb_width), @floatFromInt(fb_height)); - gui.io.setDisplayFramebufferScale(1.0, 1.0); - - gui.newFrame(); -} - -pub fn draw(wgpu_render_pass: *const anyopaque) void { - gui.render(); - ImGui_ImplWGPU_RenderDrawData(gui.getDrawData(), wgpu_render_pass); -} - -pub const ImGui_ImplWGPU_InitInfo = extern struct { - device: *const anyopaque, - num_frames_in_flight: u32 = 1, - rt_format: u32, - depth_format: u32, - - pipeline_multisample_state: extern struct { - next_in_chain: ?*const anyopaque = null, - count: u32 = 1, - mask: u32 = @bitCast(@as(i32, -1)), - alpha_to_coverage_enabled: bool = false, - }, -}; - -// Those functions are defined in 'imgui_impl_wgpu.cpp` -// (they include few custom changes). -extern fn ImGui_ImplWGPU_Init(init_info: *ImGui_ImplWGPU_InitInfo) bool; -extern fn ImGui_ImplWGPU_NewFrame() void; -extern fn ImGui_ImplWGPU_RenderDrawData(draw_data: *const anyopaque, pass_encoder: *const anyopaque) void; -extern fn ImGui_ImplWGPU_Shutdown() void; diff --git a/vendor/zgui/src/backend_win32_dx12.zig b/vendor/zgui/src/backend_win32_dx12.zig deleted file mode 100644 index 2cc5bf9..0000000 --- a/vendor/zgui/src/backend_win32_dx12.zig +++ /dev/null @@ -1,48 +0,0 @@ -const std = @import("std"); - -const gui = @import("gui.zig"); -const backend_dx12 = @import("backend_dx12.zig"); - -pub fn init( - hwnd: *const anyopaque, // HWND - d3d12_device: *const anyopaque, // ID3D12Device* - num_frames_in_flight: u16, - rtv_format: u32, // DXGI_FORMAT - cbv_srv_heap: *const anyopaque, // ID3D12DescriptorHeap* - font_srv_cpu_desc_handle: backend_dx12.D3D12_CPU_DESCRIPTOR_HANDLE, - font_srv_gpu_desc_handle: backend_dx12.D3D12_GPU_DESCRIPTOR_HANDLE, -) void { - std.debug.assert(ImGui_ImplWin32_Init(hwnd)); - backend_dx12.init( - d3d12_device, - num_frames_in_flight, - rtv_format, - cbv_srv_heap, - font_srv_cpu_desc_handle, - font_srv_gpu_desc_handle, - ); -} - -pub fn deinit() void { - backend_dx12.deinit(); - ImGui_ImplWin32_Shutdown(); -} - -pub fn newFrame(fb_width: u32, fb_height: u32) void { - ImGui_ImplWin32_NewFrame(); - backend_dx12.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) void { - gui.render(); - backend_dx12.render(gui.getDrawData(), graphics_command_list); -} - -extern fn ImGui_ImplWin32_Init(hwnd: *const anyopaque) bool; -extern fn ImGui_ImplWin32_Shutdown() void; -extern fn ImGui_ImplWin32_NewFrame() void; diff --git a/vendor/zgui/src/gui.zig b/vendor/zgui/src/gui.zig deleted file mode 100644 index 4bb4eac..0000000 --- a/vendor/zgui/src/gui.zig +++ /dev/null @@ -1,4580 +0,0 @@ -//-------------------------------------------------------------------------------------------------- -// -// Zig bindings for 'dear imgui' library. Easy to use, hand-crafted API with default arguments, -// named parameters and Zig style text formatting. -// -//-------------------------------------------------------------------------------------------------- -pub const plot = @import("plot.zig"); -pub const te = @import("te.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"), - .glfw => @import("backend_glfw.zig"), - .win32_dx12 => @import("backend_win32_dx12.zig"), - .no_backend => .{}, -}; -const te_enabled = @import("zgui_options").with_te; -//-------------------------------------------------------------------------------------------------- -const std = @import("std"); -const assert = std.debug.assert; -//-------------------------------------------------------------------------------------------------- -pub const f32_min: f32 = 1.17549435082228750796873653722225e-38; -pub const f32_max: f32 = 3.40282346638528859811704183484517e+38; -//-------------------------------------------------------------------------------------------------- -pub const DrawIdx = u16; -pub const DrawVert = extern struct { - pos: [2]f32, - uv: [2]f32, - color: u32, -}; -//-------------------------------------------------------------------------------------------------- - -pub fn init(allocator: std.mem.Allocator) void { - if (zguiGetCurrentContext() == null) { - mem_allocator = allocator; - mem_allocations = std.AutoHashMap(usize, usize).init(allocator); - mem_allocations.?.ensureTotalCapacity(32) catch @panic("zgui: out of memory"); - zguiSetAllocatorFunctions(zguiMemAlloc, zguiMemFree); - - _ = zguiCreateContext(null); - - temp_buffer = std.ArrayList(u8).init(allocator); - temp_buffer.?.resize(3 * 1024 + 1) catch unreachable; - - if (te_enabled) { - te.init(); - } - } -} -pub fn deinit() void { - if (zguiGetCurrentContext() != null) { - temp_buffer.?.deinit(); - zguiDestroyContext(null); - - // Must be after destroy imgui context. - // And before allocation check - if (te_enabled) { - te.deinit(); - } - - if (mem_allocations.?.count() > 0) { - var it = mem_allocations.?.iterator(); - while (it.next()) |kv| { - const address = kv.key_ptr.*; - const size = kv.value_ptr.*; - mem_allocator.?.free(@as([*]align(mem_alignment) u8, @ptrFromInt(address))[0..size]); - std.log.info( - "[zgui] Possible memory leak or static memory usage detected: (address: 0x{x}, size: {d})", - .{ address, size }, - ); - } - mem_allocations.?.clearAndFree(); - } - - assert(mem_allocations.?.count() == 0); - mem_allocations.?.deinit(); - mem_allocations = null; - mem_allocator = null; - } -} -pub fn initNoContext(allocator: std.mem.Allocator) void { - if (temp_buffer == null) { - temp_buffer = std.ArrayList(u8).init(allocator); - temp_buffer.?.resize(3 * 1024 + 1) catch unreachable; - } -} -pub fn deinitNoContext() void { - if (temp_buffer) |buf| { - buf.deinit(); - } -} -extern fn zguiCreateContext(shared_font_atlas: ?*const anyopaque) Context; -extern fn zguiDestroyContext(ctx: ?Context) void; -extern fn zguiGetCurrentContext() ?Context; -//-------------------------------------------------------------------------------------------------- -var mem_allocator: ?std.mem.Allocator = null; -var mem_allocations: ?std.AutoHashMap(usize, usize) = null; -var mem_mutex: std.Thread.Mutex = .{}; -const mem_alignment = 16; - -fn zguiMemAlloc(size: usize, _: ?*anyopaque) callconv(.C) ?*anyopaque { - mem_mutex.lock(); - defer mem_mutex.unlock(); - - const mem = mem_allocator.?.alignedAlloc( - u8, - mem_alignment, - size, - ) catch @panic("zgui: out of memory"); - - mem_allocations.?.put(@intFromPtr(mem.ptr), size) catch @panic("zgui: out of memory"); - - return mem.ptr; -} - -fn zguiMemFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.C) void { - if (maybe_ptr) |ptr| { - mem_mutex.lock(); - defer mem_mutex.unlock(); - - if (mem_allocations != null) { - const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value; - const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size]; - mem_allocator.?.free(mem); - } - } -} - -extern fn zguiSetAllocatorFunctions( - alloc_func: ?*const fn (usize, ?*anyopaque) callconv(.C) ?*anyopaque, - free_func: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void, -) void; -//-------------------------------------------------------------------------------------------------- -pub const ConfigFlags = packed struct(c_int) { - nav_enable_keyboard: bool = false, - nav_enable_gamepad: bool = false, - nav_enable_set_mouse_pos: bool = false, - nav_no_capture_keyboard: bool = false, - no_mouse: bool = false, - no_mouse_cursor_change: bool = false, - dock_enable: bool = false, - _pading0: u3 = 0, - viewport_enable: bool = false, - _pading1: u3 = 0, - dpi_enable_scale_viewport: bool = false, - dpi_enable_scale_fonts: bool = false, - user_storage: u4 = 0, - is_srgb: bool = false, - is_touch_screen: bool = false, - _padding: u10 = 0, -}; - -pub const FontConfig = extern struct { - font_data: ?*anyopaque, - font_data_size: c_int, - font_data_owned_by_atlas: bool, - font_no: c_int, - size_pixels: f32, - oversample_h: c_int, - oversample_v: c_int, - pixel_snap_h: bool, - glyph_extra_spacing: [2]f32, - glyph_offset: [2]f32, - glyph_ranges: [*c]u16, - glyph_min_advance_x: f32, - glyph_max_advance_x: f32, - merge_mode: bool, - font_builder_flags: c_uint, - rasterizer_multiply: f32, - rasterizer_density: f32, - ellipsis_char: Wchar, - name: [40]u8, - dst_font: *Font, - - pub fn init() FontConfig { - return zguiFontConfig_Init(); - } - extern fn zguiFontConfig_Init() FontConfig; -}; - -pub const io = struct { - pub fn addFontFromFile(filename: [:0]const u8, size_pixels: f32) Font { - return zguiIoAddFontFromFile(filename, size_pixels); - } - extern fn zguiIoAddFontFromFile(filename: [*:0]const u8, size_pixels: f32) Font; - - pub fn addFontFromFileWithConfig( - filename: [:0]const u8, - size_pixels: f32, - config: ?FontConfig, - ranges: ?[*]const Wchar, - ) Font { - return zguiIoAddFontFromFileWithConfig(filename, size_pixels, if (config) |c| &c else null, ranges); - } - extern fn zguiIoAddFontFromFileWithConfig( - filename: [*:0]const u8, - size_pixels: f32, - config: ?*const FontConfig, - ranges: ?[*]const Wchar, - ) Font; - - pub fn addFontFromMemory(fontdata: []const u8, size_pixels: f32) Font { - return zguiIoAddFontFromMemory(fontdata.ptr, @intCast(fontdata.len), size_pixels); - } - extern fn zguiIoAddFontFromMemory(font_data: *const anyopaque, font_size: c_int, size_pixels: f32) Font; - - pub fn addFontFromMemoryWithConfig( - fontdata: []const u8, - size_pixels: f32, - config: ?FontConfig, - ranges: ?[*]const Wchar, - ) Font { - return zguiIoAddFontFromMemoryWithConfig( - fontdata.ptr, - @intCast(fontdata.len), - size_pixels, - if (config) |c| &c else null, - ranges, - ); - } - extern fn zguiIoAddFontFromMemoryWithConfig( - font_data: *const anyopaque, - font_size: c_int, - size_pixels: f32, - config: ?*const FontConfig, - ranges: ?[*]const Wchar, - ) 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() 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; - extern fn zguiIoSetFontsTexId(id: TextureIdent) void; - - pub const getFontsTexId = zguiIoGetFontsTexId; - extern fn zguiIoGetFontsTexId() TextureIdent; - - /// `pub fn zguiIoSetConfigWindowsMoveFromTitleBarOnly(bool) void` - pub const setConfigWindowsMoveFromTitleBarOnly = zguiIoSetConfigWindowsMoveFromTitleBarOnly; - extern fn zguiIoSetConfigWindowsMoveFromTitleBarOnly(enabled: bool) void; - - /// `pub fn zguiIoGetWantCaptureMouse() bool` - pub const getWantCaptureMouse = zguiIoGetWantCaptureMouse; - extern fn zguiIoGetWantCaptureMouse() bool; - - /// `pub fn zguiIoGetWantCaptureKeyboard() bool` - 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); - } - extern fn zguiIoSetIniFilename(filename: ?[*:0]const u8) void; - - /// `pub fn setDisplaySize(width: f32, height: f32) void` - pub const setDisplaySize = zguiIoSetDisplaySize; - extern fn zguiIoSetDisplaySize(width: f32, height: f32) void; - - pub fn getDisplaySize() [2]f32 { - var size: [2]f32 = undefined; - zguiIoGetDisplaySize(&size); - return size; - } - extern fn zguiIoGetDisplaySize(size: *[2]f32) void; - - /// `pub fn setDisplayFramebufferScale(sx: f32, sy: f32) void` - pub const setDisplayFramebufferScale = zguiIoSetDisplayFramebufferScale; - extern fn zguiIoSetDisplayFramebufferScale(sx: f32, sy: f32) void; - - /// `pub fn setConfigFlags(flags: ConfigFlags) void` - pub const setConfigFlags = zguiIoSetConfigFlags; - extern fn zguiIoSetConfigFlags(flags: ConfigFlags) void; - - /// `pub fn setDeltaTime(delta_time: f32) void` - pub const setDeltaTime = zguiIoSetDeltaTime; - extern fn zguiIoSetDeltaTime(delta_time: f32) void; - - pub const addFocusEvent = zguiIoAddFocusEvent; - extern fn zguiIoAddFocusEvent(focused: bool) void; - - pub const addMousePositionEvent = zguiIoAddMousePositionEvent; - extern fn zguiIoAddMousePositionEvent(x: f32, y: f32) void; - - pub const addMouseButtonEvent = zguiIoAddMouseButtonEvent; - extern fn zguiIoAddMouseButtonEvent(button: MouseButton, down: bool) void; - - pub const addMouseWheelEvent = zguiIoAddMouseWheelEvent; - extern fn zguiIoAddMouseWheelEvent(x: f32, y: f32) void; - - pub const addKeyEvent = zguiIoAddKeyEvent; - extern fn zguiIoAddKeyEvent(key: Key, down: bool) void; - - pub const addInputCharactersUTF8 = zguiIoAddInputCharactersUTF8; - extern fn zguiIoAddInputCharactersUTF8(utf8_chars: ?[*:0]const u8) 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 fn addCharacterEvent(char: i32) void { - zguiIoAddCharacterEvent(char); - } - extern fn zguiIoAddCharacterEvent(char: c_int) void; -}; - -pub fn setClipboardText(value: [:0]const u8) void { - zguiSetClipboardText(value.ptr); -} -pub fn getClipboardText() [:0]const u8 { - const value = zguiGetClipboardText(); - return std.mem.span(value); -} -extern fn zguiSetClipboardText(text: [*:0]const u8) void; -extern fn zguiGetClipboardText() [*:0]const u8; -//-------------------------------------------------------------------------------------------------- -const Context = *opaque {}; -pub const DrawData = *extern struct { - valid: bool, - cmd_lists_count: c_int, - total_idx_count: c_int, - total_vtx_count: c_int, - cmd_lists: Vector(DrawList), - display_pos: [2]f32, - display_size: [2]f32, - framebuffer_scale: [2]f32, -}; -pub const Font = *opaque {}; -pub const Ident = u32; -pub const TextureIdent = *anyopaque; -pub const Wchar = if (@import("zgui_options").use_wchar32) u32 else u16; -pub const Key = enum(c_int) { - none = 0, - tab = 512, - left_arrow, - right_arrow, - up_arrow, - down_arrow, - page_up, - page_down, - home, - end, - insert, - delete, - back_space, - space, - enter, - escape, - left_ctrl, - left_shift, - left_alt, - left_super, - right_ctrl, - right_shift, - right_alt, - right_super, - menu, - zero, - one, - two, - three, - four, - five, - six, - seven, - eight, - nine, - a, - b, - c, - d, - e, - f, - g, - h, - i, - j, - k, - l, - m, - n, - o, - p, - q, - r, - s, - t, - u, - v, - w, - x, - y, - z, - f1, - f2, - f3, - f4, - f5, - f6, - f7, - f8, - f9, - f10, - f11, - f12, - f13, - f14, - f15, - f16, - f17, - f18, - f19, - f20, - f21, - f22, - f23, - f24, - apostrophe, - comma, - minus, - period, - slash, - semicolon, - equal, - left_bracket, - back_slash, - right_bracket, - grave_accent, - caps_lock, - scroll_lock, - num_lock, - print_screen, - pause, - keypad_0, - keypad_1, - keypad_2, - keypad_3, - keypad_4, - keypad_5, - keypad_6, - keypad_7, - keypad_8, - keypad_9, - keypad_decimal, - keypad_divide, - keypad_multiply, - keypad_subtract, - keypad_add, - keypad_enter, - keypad_equal, - - app_back, - app_forward, - - gamepad_start, - gamepad_back, - gamepad_faceleft, - gamepad_faceright, - gamepad_faceup, - gamepad_facedown, - gamepad_dpadleft, - gamepad_dpadright, - gamepad_dpadup, - gamepad_dpaddown, - gamepad_l1, - gamepad_r1, - gamepad_l2, - gamepad_r2, - gamepad_l3, - gamepad_r3, - gamepad_lstickleft, - gamepad_lstickright, - gamepad_lstickup, - gamepad_lstickdown, - gamepad_rstickleft, - gamepad_rstickright, - gamepad_rstickup, - gamepad_rstickdown, - - mouse_left, - mouse_right, - mouse_middle, - mouse_x1, - mouse_x2, - - mouse_wheel_x, - mouse_wheel_y, - - mod_ctrl = 1 << 12, - mod_shift = 1 << 13, - mod_alt = 1 << 14, - mod_super = 1 << 15, - mod_mask_ = 0xf000, -}; - -//-------------------------------------------------------------------------------------------------- -pub const WindowFlags = packed struct(c_int) { - no_title_bar: bool = false, - no_resize: bool = false, - no_move: bool = false, - no_scrollbar: bool = false, - no_scroll_with_mouse: bool = false, - no_collapse: bool = false, - always_auto_resize: bool = false, - no_background: bool = false, - no_saved_settings: bool = false, - no_mouse_inputs: bool = false, - menu_bar: bool = false, - horizontal_scrollbar: bool = false, - no_focus_on_appearing: bool = false, - no_bring_to_front_on_focus: bool = false, - always_vertical_scrollbar: bool = false, - always_horizontal_scrollbar: bool = false, - no_nav_inputs: bool = false, - no_nav_focus: bool = false, - unsaved_document: bool = false, - no_docking: bool = false, - _padding: u12 = 0, - - pub const no_nav = WindowFlags{ .no_nav_inputs = true, .no_nav_focus = true }; - pub const no_decoration = WindowFlags{ - .no_title_bar = true, - .no_resize = true, - .no_scrollbar = true, - .no_collapse = true, - }; - pub const no_inputs = WindowFlags{ - .no_mouse_inputs = true, - .no_nav_inputs = true, - .no_nav_focus = true, - }; -}; - -pub const ChildFlags = packed struct(c_int) { - border: bool = false, - no_move: bool = false, - always_use_window_padding: bool = false, - resize_x: bool = false, - resize_y: bool = false, - auto_resize_x: bool = false, - auto_resize_y: bool = false, - always_auto_resize: bool = false, - frame_style: bool = false, - _padding: u23 = 0, -}; - -//-------------------------------------------------------------------------------------------------- -pub const SliderFlags = packed struct(c_int) { - _reserved0: bool = false, - _reserved1: bool = false, - _reserved2: bool = false, - _reserved3: bool = false, - always_clamp: bool = false, - logarithmic: bool = false, - no_round_to_format: bool = false, - no_input: bool = false, - _padding: u24 = 0, -}; -//-------------------------------------------------------------------------------------------------- -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(c_int) { - none = -1, - left = 0, - right = 1, - up = 2, - down = 3, -}; -//-------------------------------------------------------------------------------------------------- -pub const DataType = enum(c_int) { I8, U8, I16, U16, I32, U32, I64, U64, F32, F64 }; -//-------------------------------------------------------------------------------------------------- -pub const Condition = enum(c_int) { - none = 0, - always = 1, - once = 2, - first_use_ever = 4, - appearing = 8, -}; -//-------------------------------------------------------------------------------------------------- -// -// Main -// -//-------------------------------------------------------------------------------------------------- -/// `pub fn newFrame() void` -pub const newFrame = zguiNewFrame; -extern fn zguiNewFrame() void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn render() void` -pub const render = zguiRender; -extern fn zguiRender() void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn getDrawData() DrawData` -pub const getDrawData = zguiGetDrawData; -extern fn zguiGetDrawData() DrawData; -//-------------------------------------------------------------------------------------------------- -// -// Demo, Debug, Information -// -//-------------------------------------------------------------------------------------------------- -/// `pub fn showDemoWindow(popen: ?*bool) void` -pub const showDemoWindow = zguiShowDemoWindow; -extern fn zguiShowDemoWindow(popen: ?*bool) void; -//-------------------------------------------------------------------------------------------------- -// -// Windows -// -//-------------------------------------------------------------------------------------------------- -const SetNextWindowPos = struct { - x: f32, - y: f32, - cond: Condition = .none, - pivot_x: f32 = 0.0, - pivot_y: f32 = 0.0, -}; -pub fn setNextWindowPos(args: SetNextWindowPos) void { - zguiSetNextWindowPos(args.x, args.y, args.cond, args.pivot_x, args.pivot_y); -} -extern fn zguiSetNextWindowPos(x: f32, y: f32, cond: Condition, pivot_x: f32, pivot_y: f32) void; -//-------------------------------------------------------------------------------------------------- -const SetNextWindowSize = struct { - w: f32, - h: f32, - cond: Condition = .none, -}; -pub fn setNextWindowSize(args: SetNextWindowSize) void { - zguiSetNextWindowSize(args.w, args.h, args.cond); -} -extern fn zguiSetNextWindowSize(w: f32, h: f32, cond: Condition) void; -//-------------------------------------------------------------------------------------------------- -const SetNextWindowCollapsed = struct { - collapsed: bool, - cond: Condition = .none, -}; -pub fn setNextWindowCollapsed(args: SetNextWindowCollapsed) void { - zguiSetNextWindowCollapsed(args.collapsed, args.cond); -} -extern fn zguiSetNextWindowCollapsed(collapsed: bool, cond: Condition) void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn setNextWindowFocus() void` -pub const setNextWindowFocus = zguiSetNextWindowFocus; -extern fn zguiSetNextWindowFocus() void; -//-------------------------------------------------------------------------------------------------- -const SetNextWindowBgAlpha = struct { - alpha: f32, -}; -pub fn setNextWindowBgAlpha(args: SetNextWindowBgAlpha) void { - zguiSetNextWindowBgAlpha(args.alpha); -} -extern fn zguiSetNextWindowBgAlpha(alpha: f32) void; -//-------------------------------------------------------------------------------------------------- -pub fn setWindowFocus(name: ?[:0]const u8) void { - zguiSetWindowFocus(name orelse null); -} -extern fn zguiSetWindowFocus(name: ?[*:0]const u8) void; -//------------------------------------------------------------------------------------------------- -pub fn setKeyboardFocusHere(offset: i32) void { - zguiSetKeyboardFocusHere(offset); -} -extern fn zguiSetKeyboardFocusHere(offset: c_int) void; - -//-------------------------------------------------------------------------------------------------- -const Begin = struct { - popen: ?*bool = null, - flags: WindowFlags = .{}, -}; -pub fn begin(name: [:0]const u8, args: Begin) bool { - return zguiBegin(name, args.popen, args.flags); -} -/// `pub fn end() void` -pub const end = zguiEnd; -extern fn zguiBegin(name: [*:0]const u8, popen: ?*bool, flags: WindowFlags) bool; -extern fn zguiEnd() void; -//-------------------------------------------------------------------------------------------------- -const BeginChild = struct { - w: f32 = 0.0, - h: f32 = 0.0, - child_flags: ChildFlags = .{}, - window_flags: WindowFlags = .{}, -}; -pub fn beginChild(str_id: [:0]const u8, args: BeginChild) bool { - return zguiBeginChild(str_id, args.w, args.h, args.child_flags, args.window_flags); -} -pub fn beginChildId(id: Ident, args: BeginChild) bool { - return zguiBeginChildId(id, args.w, args.h, args.child_flags, args.window_flags); -} -/// `pub fn endChild() void` -pub const endChild = zguiEndChild; -extern fn zguiBeginChild(str_id: [*:0]const u8, w: f32, h: f32, flags: ChildFlags, window_flags: WindowFlags) bool; -extern fn zguiBeginChildId(id: Ident, w: f32, h: f32, flags: ChildFlags, window_flags: WindowFlags) bool; -extern fn zguiEndChild() void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn zguiGetScrollX() f32` -pub const getScrollX = zguiGetScrollX; -/// `pub fn zguiGetScrollY() f32` -pub const getScrollY = zguiGetScrollY; -/// `pub fn zguiSetScrollX(scroll_x: f32) void` -pub const setScrollX = zguiSetScrollX; -/// `pub fn zguiSetScrollY(scroll_y: f32) void` -pub const setScrollY = zguiSetScrollY; -/// `pub fn zguiGetScrollMaxX() f32` -pub const getScrollMaxX = zguiGetScrollMaxX; -/// `pub fn zguiGetScrollMaxY() f32` -pub const getScrollMaxY = zguiGetScrollMaxY; -extern fn zguiGetScrollX() f32; -extern fn zguiGetScrollY() f32; -extern fn zguiSetScrollX(scroll_x: f32) void; -extern fn zguiSetScrollY(scroll_y: f32) void; -extern fn zguiGetScrollMaxX() f32; -extern fn zguiGetScrollMaxY() f32; -const SetScrollHereX = struct { - center_x_ratio: f32 = 0.5, -}; -const SetScrollHereY = struct { - center_y_ratio: f32 = 0.5, -}; -pub fn setScrollHereX(args: SetScrollHereX) void { - zguiSetScrollHereX(args.center_x_ratio); -} -pub fn setScrollHereY(args: SetScrollHereY) void { - zguiSetScrollHereY(args.center_y_ratio); -} -const SetScrollFromPosX = struct { - local_x: f32, - center_x_ratio: f32 = 0.5, -}; -const SetScrollFromPosY = struct { - local_y: f32, - center_y_ratio: f32 = 0.5, -}; -pub fn setScrollFromPosX(args: SetScrollFromPosX) void { - zguiSetScrollFromPosX(args.local_x, args.center_x_ratio); -} -pub fn setScrollFromPosY(args: SetScrollFromPosY) void { - zguiSetScrollFromPosY(args.local_y, args.center_y_ratio); -} -extern fn zguiSetScrollHereX(center_x_ratio: f32) void; -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(c_int) { - child_windows: bool = false, - root_window: bool = false, - any_window: bool = false, - no_popup_hierarchy: bool = false, - dock_hierarchy: bool = false, - _padding: u27 = 0, - - pub const root_and_child_windows = FocusedFlags{ .root_window = true, .child_windows = true }; -}; -//-------------------------------------------------------------------------------------------------- -pub const HoveredFlags = packed struct(c_int) { - child_windows: bool = false, - root_window: bool = false, - any_window: bool = false, - no_popup_hierarchy: bool = false, - dock_hierarchy: bool = false, - allow_when_blocked_by_popup: bool = false, - _reserved1: bool = false, - allow_when_blocked_by_active_item: bool = false, - allow_when_overlapped_by_item: bool = false, - allow_when_overlapped_by_window: bool = false, - allow_when_disabled: bool = false, - no_nav_override: bool = false, - for_tooltip: bool = false, - stationary: bool = false, - delay_none: bool = false, - delay_normal: bool = false, - delay_short: bool = false, - no_shared_delay: bool = false, - _padding: u14 = 0, - - pub const rect_only = HoveredFlags{ - .allow_when_blocked_by_popup = true, - .allow_when_blocked_by_active_item = true, - .allow_when_overlapped_by_item = true, - .allow_when_overlapped_by_window = true, - }; - pub const root_and_child_windows = HoveredFlags{ .root_window = true, .child_windows = true }; -}; -//-------------------------------------------------------------------------------------------------- -/// `pub fn isWindowAppearing() bool` -pub const isWindowAppearing = zguiIsWindowAppearing; -/// `pub fn isWindowCollapsed() bool` -pub const isWindowCollapsed = zguiIsWindowCollapsed; -pub fn isWindowFocused(flags: FocusedFlags) bool { - return zguiIsWindowFocused(flags); -} -pub fn isWindowHovered(flags: HoveredFlags) bool { - return zguiIsWindowHovered(flags); -} -extern fn zguiIsWindowAppearing() bool; -extern fn zguiIsWindowCollapsed() bool; -extern fn zguiIsWindowFocused(flags: FocusedFlags) bool; -extern fn zguiIsWindowHovered(flags: HoveredFlags) bool; -//-------------------------------------------------------------------------------------------------- -pub fn getWindowPos() [2]f32 { - var pos: [2]f32 = undefined; - zguiGetWindowPos(&pos); - return pos; -} -pub fn getWindowSize() [2]f32 { - var size: [2]f32 = undefined; - zguiGetWindowSize(&size); - return size; -} - -pub fn getContentRegionAvail() [2]f32 { - var size: [2]f32 = undefined; - zguiGetContentRegionAvail(&size); - return size; -} - -pub fn getContentRegionMax() [2]f32 { - var size: [2]f32 = undefined; - zguiGetContentRegionMax(&size); - return size; -} - -pub fn getWindowContentRegionMin() [2]f32 { - var size: [2]f32 = undefined; - zguiGetWindowContentRegionMin(&size); - return size; -} - -pub fn getWindowContentRegionMax() [2]f32 { - var size: [2]f32 = undefined; - zguiGetWindowContentRegionMax(&size); - return size; -} - -/// `pub fn getWindowWidth() f32` -pub const getWindowWidth = zguiGetWindowWidth; -/// `pub fn getWindowHeight() f32` -pub const getWindowHeight = zguiGetWindowHeight; -extern fn zguiGetWindowPos(pos: *[2]f32) void; -extern fn zguiGetWindowSize(size: *[2]f32) void; -extern fn zguiGetWindowWidth() f32; -extern fn zguiGetWindowHeight() f32; -extern fn zguiGetContentRegionAvail(size: *[2]f32) void; -extern fn zguiGetContentRegionMax(size: *[2]f32) void; -extern fn zguiGetWindowContentRegionMin(size: *[2]f32) void; -extern fn zguiGetWindowContentRegionMax(size: *[2]f32) void; -//-------------------------------------------------------------------------------------------------- -// -// Docking -// -//-------------------------------------------------------------------------------------------------- -pub const DockNodeFlags = packed struct(c_int) { - keep_alive_only: bool = false, - _reserved: u1 = 0, - no_docking_over_central_node: bool = false, - passthru_central_node: bool = false, - no_docking_split: bool = false, - no_resize: bool = false, - auto_hide_tab_bar: bool = false, - no_undocking: bool = false, - _padding_0: u2 = 0, - - // Extended enum entries from imgui_internal (unstable, subject to change, use at own risk) - dock_space: bool = false, - central_node: bool = false, - no_tab_bar: bool = false, - hidden_tab_bar: bool = false, - no_window_menu_button: bool = false, - no_close_button: bool = false, - no_resize_x: bool = false, - no_resize_y: bool = false, - docked_windows_in_focus_route: bool = false, - no_docking_split_other: bool = false, - no_docking_over_me: bool = false, - no_docking_over_other: bool = false, - no_docking_over_empty: bool = false, - _padding_1: u9 = 0, -}; -extern fn zguiDockSpace(str_id: [*:0]const u8, size: *const [2]f32, flags: DockNodeFlags) Ident; - -pub fn DockSpace(str_id: [:0]const u8, size: [2]f32, flags: DockNodeFlags) Ident { - return zguiDockSpace(str_id.ptr, &size, flags); -} -extern fn zguiDockSpaceOverViewport(viewport: Viewport, flags: DockNodeFlags) Ident; -pub const DockSpaceOverViewport = zguiDockSpaceOverViewport; - -//-------------------------------------------------------------------------------------------------- -// -// DockBuilder (Unstable internal imgui API, subject to change, use at own risk) -// -//-------------------------------------------------------------------------------------------------- -pub fn dockBuilderDockWindow(window_name: [:0]const u8, node_id: Ident) void { - zguiDockBuilderDockWindow(window_name.ptr, node_id); -} -pub const dockBuilderAddNode = zguiDockBuilderAddNode; -pub const dockBuilderRemoveNode = zguiDockBuilderRemoveNode; -pub fn dockBuilderSetNodePos(node_id: Ident, pos: [2]f32) void { - zguiDockBuilderSetNodePos(node_id, &pos); -} -pub fn dockBuilderSetNodeSize(node_id: Ident, size: [2]f32) void { - zguiDockBuilderSetNodeSize(node_id, &size); -} -pub const dockBuilderSplitNode = zguiDockBuilderSplitNode; -pub const dockBuilderFinish = zguiDockBuilderFinish; - -extern fn zguiDockBuilderDockWindow(window_name: [*:0]const u8, node_id: Ident) void; -extern fn zguiDockBuilderAddNode(node_id: Ident, flags: DockNodeFlags) Ident; -extern fn zguiDockBuilderRemoveNode(node_id: Ident) void; -extern fn zguiDockBuilderSetNodePos(node_id: Ident, pos: *const [2]f32) void; -extern fn zguiDockBuilderSetNodeSize(node_id: Ident, size: *const [2]f32) void; -extern fn zguiDockBuilderSplitNode( - node_id: Ident, - split_dir: Direction, - size_ratio_for_node_at_dir: f32, - out_id_at_dir: ?*Ident, - out_id_at_opposite_dir: ?*Ident, -) Ident; -extern fn zguiDockBuilderFinish(node_id: Ident) void; - -//-------------------------------------------------------------------------------------------------- -// -// Style -// -//-------------------------------------------------------------------------------------------------- -pub const Style = extern struct { - alpha: f32, - disabled_alpha: f32, - window_padding: [2]f32, - window_rounding: f32, - window_border_size: f32, - window_min_size: [2]f32, - window_title_align: [2]f32, - window_menu_button_position: Direction, - child_rounding: f32, - child_border_size: f32, - popup_rounding: f32, - popup_border_size: f32, - frame_padding: [2]f32, - frame_rounding: f32, - frame_border_size: f32, - item_spacing: [2]f32, - item_inner_spacing: [2]f32, - cell_padding: [2]f32, - touch_extra_padding: [2]f32, - indent_spacing: f32, - columns_min_spacing: f32, - scrollbar_size: f32, - scrollbar_rounding: f32, - grab_min_size: f32, - grab_rounding: f32, - log_slider_deadzone: f32, - tab_rounding: f32, - tab_border_size: f32, - tab_min_width_for_close_button: f32, - tab_bar_border_size: f32, - table_angled_header_angle: f32, - color_button_position: Direction, - button_text_align: [2]f32, - selectable_text_align: [2]f32, - separator_text_border_size: f32, - separator_text_align: [2]f32, - separator_text_padding: [2]f32, - display_window_padding: [2]f32, - display_safe_area_padding: [2]f32, - docking_separator_size: f32, - mouse_cursor_scale: f32, - anti_aliased_lines: bool, - anti_aliased_lines_use_tex: bool, - anti_aliased_fill: bool, - curve_tessellation_tol: f32, - circle_tessellation_max_error: f32, - - colors: [@typeInfo(StyleCol).Enum.fields.len][4]f32, - - hover_stationary_delay: f32, - hover_delay_short: f32, - hover_delay_normal: f32, - - hover_flags_for_tooltip_mouse: HoveredFlags, - hover_flags_for_tooltip_nav: HoveredFlags, - - /// `pub fn init() Style` - pub const init = zguiStyle_Init; - extern fn zguiStyle_Init() Style; - - /// `pub fn scaleAllSizes(style: *Style, scale_factor: f32) void` - pub const scaleAllSizes = zguiStyle_ScaleAllSizes; - extern fn zguiStyle_ScaleAllSizes(style: *Style, scale_factor: f32) void; - - pub fn getColor(style: Style, idx: StyleCol) [4]f32 { - return style.colors[@intCast(@intFromEnum(idx))]; - } - pub fn setColor(style: *Style, idx: StyleCol, color: [4]f32) void { - style.colors[@intCast(@intFromEnum(idx))] = color; - } -}; -/// `pub fn getStyle() *Style` -pub const getStyle = zguiGetStyle; -extern fn zguiGetStyle() *Style; -//-------------------------------------------------------------------------------------------------- -pub const StyleCol = enum(c_int) { - text, - text_disabled, - window_bg, - child_bg, - popup_bg, - border, - border_shadow, - frame_bg, - frame_bg_hovered, - frame_bg_active, - title_bg, - title_bg_active, - title_bg_collapsed, - menu_bar_bg, - scrollbar_bg, - scrollbar_grab, - scrollbar_grab_hovered, - scrollbar_grab_active, - check_mark, - slider_grab, - slider_grab_active, - button, - button_hovered, - button_active, - header, - header_hovered, - header_active, - separator, - separator_hovered, - separator_active, - resize_grip, - resize_grip_hovered, - resize_grip_active, - tab, - tab_hovered, - tab_active, - tab_unfocused, - tab_unfocused_active, - docking_preview, - docking_empty_bg, - plot_lines, - plot_lines_hovered, - plot_histogram, - plot_histogram_hovered, - table_header_bg, - table_border_strong, - table_border_light, - table_row_bg, - table_row_bg_alt, - text_selected_bg, - drag_drop_target, - nav_highlight, - nav_windowing_highlight, - nav_windowing_dim_bg, - modal_window_dim_bg, -}; - -pub fn pushStyleColor4f(args: struct { - idx: StyleCol, - c: [4]f32, -}) void { - zguiPushStyleColor4f(args.idx, &args.c); -} -extern fn zguiPushStyleColor4f(idx: StyleCol, col: *const [4]f32) void; - -pub fn pushStyleColor1u(args: struct { - idx: StyleCol, - c: u32, -}) void { - zguiPushStyleColor1u(args.idx, args.c); -} -extern fn zguiPushStyleColor1u(idx: StyleCol, col: c_uint) void; - -pub fn popStyleColor(args: struct { - count: i32 = 1, -}) 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 zguiPopTextWrapPos() void; - -//-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- -pub const StyleVar = enum(c_int) { - alpha, // 1f - disabled_alpha, // 1f - window_padding, // 2f - window_rounding, // 1f - window_border_size, // 1f - window_min_size, // 2f - window_title_align, // 2f - child_rounding, // 1f - child_border_size, // 1f - popup_rounding, // 1f - popup_border_size, // 1f - frame_padding, // 2f - frame_rounding, // 1f - frame_border_size, // 1f - item_spacing, // 2f - item_inner_spacing, // 2f - indent_spacing, // 1f - cell_padding, // 2f - scrollbar_size, // 1f - scrollbar_rounding, // 1f - grab_min_size, // 1f - grab_rounding, // 1f - tab_rounding, // 1f - tab_bar_border_size, // 1f - button_text_align, // 2f - selectable_text_align, // 2f - separator_text_border_size, // 1f - separator_text_align, // 2f - separator_text_padding, // 2f - docking_separator_size, // 1f -}; - -pub fn pushStyleVar1f(args: struct { - idx: StyleVar, - v: f32, -}) void { - zguiPushStyleVar1f(args.idx, args.v); -} -extern fn zguiPushStyleVar1f(idx: StyleVar, v: f32) void; - -pub fn pushStyleVar2f(args: struct { - idx: StyleVar, - v: [2]f32, -}) void { - zguiPushStyleVar2f(args.idx, &args.v); -} -extern fn zguiPushStyleVar2f(idx: StyleVar, v: *const [2]f32) void; - -pub fn popStyleVar(args: struct { - count: i32 = 1, -}) void { - zguiPopStyleVar(args.count); -} -extern fn zguiPopStyleVar(count: c_int) void; - -//-------------------------------------------------------------------------------------------------- -/// `void pushItemWidth(item_width: f32) void` -pub const pushItemWidth = zguiPushItemWidth; -/// `void popItemWidth() void` -pub const popItemWidth = zguiPopItemWidth; -/// `void setNextItemWidth(item_width: f32) void` -pub const setNextItemWidth = zguiSetNextItemWidth; -/// `void setItemDefaultFocus() void` -pub const setItemDefaultFocus = zguiSetItemDefaultFocus; -extern fn zguiPushItemWidth(item_width: f32) void; -extern fn zguiPopItemWidth() void; -extern fn zguiSetNextItemWidth(item_width: f32) void; -extern fn zguiSetItemDefaultFocus() void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn getFont() Font` -pub const getFont = zguiGetFont; -extern fn zguiGetFont() Font; -/// `pub fn getFontSize() f32` -pub const getFontSize = zguiGetFontSize; -extern fn zguiGetFontSize() f32; -/// `void pushFont(font: Font) void` -pub const pushFont = zguiPushFont; -extern fn zguiPushFont(font: Font) void; -/// `void popFont() void` -pub const popFont = zguiPopFont; -extern fn zguiPopFont() void; - -pub fn getFontTexUvWhitePixel() [2]f32 { - var uv: [2]f32 = undefined; - zguiGetFontTexUvWhitePixel(&uv); - return uv; -} -extern fn zguiGetFontTexUvWhitePixel(uv: *[2]f32) void; -//-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- -const BeginDisabled = struct { - disabled: bool = true, -}; -pub fn beginDisabled(args: BeginDisabled) void { - zguiBeginDisabled(args.disabled); -} -/// `pub fn endDisabled() void` -pub const endDisabled = zguiEndDisabled; -extern fn zguiBeginDisabled(disabled: bool) void; -extern fn zguiEndDisabled() void; -//-------------------------------------------------------------------------------------------------- -// -// Cursor / Layout -// -//-------------------------------------------------------------------------------------------------- -/// `pub fn separator() void` -pub const separator = zguiSeparator; -extern fn zguiSeparator() void; - -pub fn separatorText(label: [:0]const u8) void { - zguiSeparatorText(label); -} -extern fn zguiSeparatorText(label: [*:0]const u8) void; -//-------------------------------------------------------------------------------------------------- -const SameLine = struct { - offset_from_start_x: f32 = 0.0, - spacing: f32 = -1.0, -}; -pub fn sameLine(args: SameLine) void { - zguiSameLine(args.offset_from_start_x, args.spacing); -} -extern fn zguiSameLine(offset_from_start_x: f32, spacing: f32) void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn newLine() void` -pub const newLine = zguiNewLine; -extern fn zguiNewLine() void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn spacing() void` -pub const spacing = zguiSpacing; -extern fn zguiSpacing() void; -//-------------------------------------------------------------------------------------------------- -const Dummy = struct { - w: f32, - h: f32, -}; -pub fn dummy(args: Dummy) void { - zguiDummy(args.w, args.h); -} -extern fn zguiDummy(w: f32, h: f32) void; -//-------------------------------------------------------------------------------------------------- -const Indent = struct { - indent_w: f32 = 0.0, -}; -pub fn indent(args: Indent) void { - zguiIndent(args.indent_w); -} -const Unindent = struct { - indent_w: f32 = 0.0, -}; -pub fn unindent(args: Unindent) void { - zguiUnindent(args.indent_w); -} -extern fn zguiIndent(indent_w: f32) void; -extern fn zguiUnindent(indent_w: f32) void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn beginGroup() void` -pub const beginGroup = zguiBeginGroup; -extern fn zguiBeginGroup() void; -/// `pub fn endGroup() void` -pub const endGroup = zguiEndGroup; -extern fn zguiEndGroup() void; -//-------------------------------------------------------------------------------------------------- -pub fn getCursorPos() [2]f32 { - var pos: [2]f32 = undefined; - zguiGetCursorPos(&pos); - return pos; -} -/// `pub fn getCursorPosX() f32` -pub const getCursorPosX = zguiGetCursorPosX; -/// `pub fn getCursorPosY() f32` -pub const getCursorPosY = zguiGetCursorPosY; -extern fn zguiGetCursorPos(pos: *[2]f32) void; -extern fn zguiGetCursorPosX() f32; -extern fn zguiGetCursorPosY() f32; -//-------------------------------------------------------------------------------------------------- -pub fn setCursorPos(local_pos: [2]f32) void { - zguiSetCursorPos(local_pos[0], local_pos[1]); -} -/// `pub fn setCursorPosX(local_x: f32) void` -pub const setCursorPosX = zguiSetCursorPosX; -/// `pub fn setCursorPosY(local_y: f32) void` -pub const setCursorPosY = zguiSetCursorPosY; -extern fn zguiSetCursorPos(local_x: f32, local_y: f32) void; -extern fn zguiSetCursorPosX(local_x: f32) void; -extern fn zguiSetCursorPosY(local_y: f32) void; -//-------------------------------------------------------------------------------------------------- -pub fn getCursorStartPos() [2]f32 { - var pos: [2]f32 = undefined; - zguiGetCursorStartPos(&pos); - return pos; -} -pub fn getCursorScreenPos() [2]f32 { - var pos: [2]f32 = undefined; - zguiGetCursorScreenPos(&pos); - return pos; -} -pub fn setCursorScreenPos(screen_pos: [2]f32) void { - zguiSetCursorPos(screen_pos[0], screen_pos[1]); -} -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(c_int) { - none = -1, - arrow = 0, - text_input, - resize_all, - resize_ns, - resize_ew, - resize_nesw, - resize_nwse, - hand, - not_allowed, - count, -}; -/// `pub fn getMouseCursor() MouseCursor` -pub const getMouseCursor = zguiGetMouseCursor; -/// `pub fn setMouseCursor(cursor: MouseCursor) void` -pub const setMouseCursor = zguiSetMouseCursor; -extern fn zguiGetMouseCursor() Cursor; -extern fn zguiSetMouseCursor(cursor: Cursor) void; -//-------------------------------------------------------------------------------------------------- -pub fn getMousePos() [2]f32 { - var pos: [2]f32 = undefined; - zguiGetMousePos(&pos); - return pos; -} -extern fn zguiGetMousePos(pos: *[2]f32) void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn alignTextToFramePadding() void` -pub const alignTextToFramePadding = zguiAlignTextToFramePadding; -/// `pub fn getTextLineHeight() f32` -pub const getTextLineHeight = zguiGetTextLineHeight; -/// `pub fn getTextLineHeightWithSpacing() f32` -pub const getTextLineHeightWithSpacing = zguiGetTextLineHeightWithSpacing; -/// `pub fn getFrameHeight() f32` -pub const getFrameHeight = zguiGetFrameHeight; -/// `pub fn getFrameHeightWithSpacing() f32` -pub const getFrameHeightWithSpacing = zguiGetFrameHeightWithSpacing; -extern fn zguiAlignTextToFramePadding() void; -extern fn zguiGetTextLineHeight() f32; -extern fn zguiGetTextLineHeightWithSpacing() f32; -extern fn zguiGetFrameHeight() f32; -extern fn zguiGetFrameHeightWithSpacing() f32; -//-------------------------------------------------------------------------------------------------- -pub fn getItemRectMax() [2]f32 { - var rect: [2]f32 = undefined; - zguiGetItemRectMax(&rect); - return rect; -} -pub fn getItemRectMin() [2]f32 { - var rect: [2]f32 = undefined; - zguiGetItemRectMin(&rect); - return rect; -} -pub fn getItemRectSize() [2]f32 { - var rect: [2]f32 = undefined; - zguiGetItemRectSize(&rect); - return rect; -} -extern fn zguiGetItemRectMax(rect: *[2]f32) void; -extern fn zguiGetItemRectMin(rect: *[2]f32) void; -extern fn zguiGetItemRectSize(rect: *[2]f32) void; -//-------------------------------------------------------------------------------------------------- -// -// ID stack/scopes -// -//-------------------------------------------------------------------------------------------------- -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 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 zguiGetPtrId(ptr_id: *const anyopaque) Ident; - -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Text -// -//-------------------------------------------------------------------------------------------------- -pub fn textUnformatted(txt: []const u8) void { - zguiTextUnformatted(txt.ptr, txt.ptr + txt.len); -} -pub fn textUnformattedColored(color: [4]f32, txt: []const u8) void { - pushStyleColor4f(.{ .idx = .text, .c = color }); - textUnformatted(txt); - popStyleColor(.{}); -} -//-------------------------------------------------------------------------------------------------- -pub fn text(comptime fmt: []const u8, args: anytype) void { - const result = format(fmt, args); - zguiTextUnformatted(result.ptr, result.ptr + result.len); -} -pub fn textColored(color: [4]f32, comptime fmt: []const u8, args: anytype) void { - pushStyleColor4f(.{ .idx = .text, .c = color }); - text(fmt, args); - popStyleColor(.{}); -} -extern fn zguiTextUnformatted(txt: [*]const u8, txt_end: [*]const u8) void; -//-------------------------------------------------------------------------------------------------- -pub fn textDisabled(comptime fmt: []const u8, args: anytype) void { - zguiTextDisabled("%s", formatZ(fmt, args).ptr); -} -extern fn zguiTextDisabled(fmt: [*:0]const u8, ...) void; -//-------------------------------------------------------------------------------------------------- -pub fn textWrapped(comptime fmt: []const u8, args: anytype) void { - zguiTextWrapped("%s", formatZ(fmt, args).ptr); -} -extern fn zguiTextWrapped(fmt: [*:0]const u8, ...) void; -//-------------------------------------------------------------------------------------------------- -pub fn bulletText(comptime fmt: []const u8, args: anytype) void { - bullet(); - text(fmt, args); -} -//-------------------------------------------------------------------------------------------------- -pub fn labelText(label: [:0]const u8, comptime fmt: []const u8, args: anytype) void { - zguiLabelText(label, "%s", formatZ(fmt, args).ptr); -} -extern fn zguiLabelText(label: [*:0]const u8, fmt: [*:0]const u8, ...) void; -//-------------------------------------------------------------------------------------------------- -const CalcTextSize = struct { - hide_text_after_double_hash: bool = false, - wrap_width: f32 = -1.0, -}; -pub fn calcTextSize(txt: []const u8, args: CalcTextSize) [2]f32 { - var w: f32 = undefined; - var h: f32 = undefined; - zguiCalcTextSize( - txt.ptr, - txt.ptr + txt.len, - args.hide_text_after_double_hash, - args.wrap_width, - &w, - &h, - ); - return .{ w, h }; -} -extern fn zguiCalcTextSize( - txt: [*]const u8, - txt_end: [*]const u8, - hide_text_after_double_hash: bool, - wrap_width: f32, - out_w: *f32, - out_h: *f32, -) void; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Main -// -//-------------------------------------------------------------------------------------------------- -const Button = struct { - w: f32 = 0.0, - h: f32 = 0.0, -}; -pub fn button(label: [:0]const u8, args: Button) bool { - return zguiButton(label, args.w, args.h); -} -extern fn zguiButton(label: [*:0]const u8, w: f32, h: f32) bool; -//-------------------------------------------------------------------------------------------------- -pub fn smallButton(label: [:0]const u8) bool { - return zguiSmallButton(label); -} -extern fn zguiSmallButton(label: [*:0]const u8) bool; -//-------------------------------------------------------------------------------------------------- -const InvisibleButton = struct { - w: f32, - h: f32, - flags: ButtonFlags = .{}, -}; -pub fn invisibleButton(str_id: [:0]const u8, args: InvisibleButton) bool { - return zguiInvisibleButton(str_id, args.w, args.h, args.flags); -} -extern fn zguiInvisibleButton(str_id: [*:0]const u8, w: f32, h: f32, flags: ButtonFlags) bool; -//-------------------------------------------------------------------------------------------------- -const ArrowButton = struct { - dir: Direction, -}; -pub fn arrowButton(label: [:0]const u8, args: ArrowButton) bool { - return zguiArrowButton(label, args.dir); -} -extern fn zguiArrowButton(label: [*:0]const u8, dir: Direction) bool; -//-------------------------------------------------------------------------------------------------- -const Image = struct { - w: f32, - h: f32, - uv0: [2]f32 = .{ 0.0, 0.0 }, - uv1: [2]f32 = .{ 1.0, 1.0 }, - tint_col: [4]f32 = .{ 1.0, 1.0, 1.0, 1.0 }, - border_col: [4]f32 = .{ 0.0, 0.0, 0.0, 0.0 }, -}; -pub fn image(user_texture_id: TextureIdent, args: Image) void { - zguiImage(user_texture_id, args.w, args.h, &args.uv0, &args.uv1, &args.tint_col, &args.border_col); -} -extern fn zguiImage( - user_texture_id: TextureIdent, - w: f32, - h: f32, - uv0: *const [2]f32, - uv1: *const [2]f32, - tint_col: *const [4]f32, - border_col: *const [4]f32, -) void; -//-------------------------------------------------------------------------------------------------- -const ImageButton = struct { - w: f32, - h: f32, - uv0: [2]f32 = .{ 0.0, 0.0 }, - uv1: [2]f32 = .{ 1.0, 1.0 }, - bg_col: [4]f32 = .{ 0.0, 0.0, 0.0, 0.0 }, - tint_col: [4]f32 = .{ 1.0, 1.0, 1.0, 1.0 }, -}; -pub fn imageButton(str_id: [:0]const u8, user_texture_id: TextureIdent, args: ImageButton) bool { - return zguiImageButton( - str_id, - user_texture_id, - args.w, - args.h, - &args.uv0, - &args.uv1, - &args.bg_col, - &args.tint_col, - ); -} -extern fn zguiImageButton( - str_id: [*:0]const u8, - user_texture_id: TextureIdent, - w: f32, - h: f32, - uv0: *const [2]f32, - uv1: *const [2]f32, - bg_col: *const [4]f32, - tint_col: *const [4]f32, -) bool; -//-------------------------------------------------------------------------------------------------- -/// `pub fn bullet() void` -pub const bullet = zguiBullet; -extern fn zguiBullet() void; -//-------------------------------------------------------------------------------------------------- -pub fn radioButton(label: [:0]const u8, args: struct { - active: bool, -}) bool { - return zguiRadioButton(label, args.active); -} -extern fn zguiRadioButton(label: [*:0]const u8, active: bool) bool; -//-------------------------------------------------------------------------------------------------- -pub fn radioButtonStatePtr(label: [:0]const u8, args: struct { - v: *i32, - v_button: i32, -}) bool { - return zguiRadioButtonStatePtr(label, args.v, args.v_button); -} -extern fn zguiRadioButtonStatePtr(label: [*:0]const u8, v: *c_int, v_button: c_int) bool; -//-------------------------------------------------------------------------------------------------- -pub fn checkbox(label: [:0]const u8, args: struct { - v: *bool, -}) bool { - return zguiCheckbox(label, args.v); -} -extern fn zguiCheckbox(label: [*:0]const u8, v: *bool) bool; -//-------------------------------------------------------------------------------------------------- -pub fn checkboxBits(label: [:0]const u8, args: struct { - bits: *u32, - bits_value: u32, -}) bool { - return zguiCheckboxBits(label, args.bits, args.bits_value); -} -extern fn zguiCheckboxBits(label: [*:0]const u8, bits: *c_uint, bits_value: c_uint) bool; -//-------------------------------------------------------------------------------------------------- -const ProgressBar = struct { - fraction: f32, - w: f32 = -f32_min, - h: f32 = 0.0, - overlay: ?[:0]const u8 = null, -}; -pub fn progressBar(args: ProgressBar) void { - zguiProgressBar(args.fraction, args.w, args.h, if (args.overlay) |o| o else null); -} -extern fn zguiProgressBar(fraction: f32, w: f32, h: f32, overlay: ?[*:0]const u8) void; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Combo Box -// -//-------------------------------------------------------------------------------------------------- -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, -}) bool { - return zguiCombo( - label, - args.current_item, - args.items_separated_by_zeros, - args.popup_max_height_in_items, - ); -} -/// creates a combo box directly from a pointer to an enum value using zig's -/// comptime mechanics to infer the items for the list at compile time -pub fn comboFromEnum( - label: [:0]const u8, - /// must be a pointer to an enum value (var my_enum: *FoodKinds = .Banana) - /// that is backed by some kind of integer that can safely cast into an - /// i32 (the underlying imgui restriction) - current_item: anytype, -) bool { - const EnumType = @TypeOf(current_item.*); - const enum_type_info = switch (@typeInfo(EnumType)) { - .Enum => |enum_type_info| enum_type_info, - else => @compileError("Error: current_item must be a pointer-to-an-enum, not a " ++ @TypeOf(current_item)), - }; - - const FieldNameIndex = std.meta.Tuple(&.{ []const u8, i32 }); - comptime var item_names: [:0]const u8 = ""; - comptime var field_name_to_index_list: [enum_type_info.fields.len]FieldNameIndex = undefined; - comptime var index_to_enum: [enum_type_info.fields.len]EnumType = undefined; - - comptime { - for (enum_type_info.fields, 0..) |f, i| { - item_names = item_names ++ f.name ++ "\x00"; - const e: EnumType = @enumFromInt(f.value); - field_name_to_index_list[i] = .{ f.name, @intCast(i) }; - index_to_enum[i] = e; - } - } - - const field_name_to_index = std.StaticStringMap(i32).initComptime(&field_name_to_index_list); - var item: i32 = field_name_to_index.get(@tagName(current_item.*)).?; - - const result = combo(label, .{ - .items_separated_by_zeros = item_names, - .current_item = &item, - }); - - current_item.* = index_to_enum[@intCast(item)]; - - return result; -} -extern fn zguiCombo( - label: [*:0]const u8, - current_item: *c_int, - items_separated_by_zeros: [*:0]const u8, - popup_max_height_in_items: c_int, -) bool; -//-------------------------------------------------------------------------------------------------- -pub const ComboFlags = packed struct(c_int) { - popup_align_left: bool = false, - height_small: bool = false, - height_regular: bool = false, - height_large: bool = false, - height_largest: bool = false, - no_arrow_button: bool = false, - no_preview: bool = false, - width_fit_preview: bool = false, - _padding: u24 = 0, -}; -//-------------------------------------------------------------------------------------------------- -const BeginCombo = struct { - preview_value: [*:0]const u8, - flags: ComboFlags = .{}, -}; -pub fn beginCombo(label: [:0]const u8, args: BeginCombo) bool { - return zguiBeginCombo(label, args.preview_value, args.flags); -} -extern fn zguiBeginCombo(label: [*:0]const u8, preview_value: ?[*:0]const u8, flags: ComboFlags) bool; -//-------------------------------------------------------------------------------------------------- -/// `pub fn endCombo() void` -pub const endCombo = zguiEndCombo; -extern fn zguiEndCombo() void; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Drag Sliders -// -//-------------------------------------------------------------------------------------------------- -fn DragFloatGen(comptime T: type) type { - return struct { - v: *T, - speed: f32 = 1.0, - min: f32 = 0.0, - max: f32 = 0.0, - cfmt: [:0]const u8 = "%.3f", - flags: SliderFlags = .{}, - }; -} -//-------------------------------------------------------------------------------------------------- -const DragFloat = DragFloatGen(f32); -pub fn dragFloat(label: [:0]const u8, args: DragFloat) bool { - return zguiDragFloat( - label, - args.v, - args.speed, - args.min, - args.max, - args.cfmt, - args.flags, - ); -} -extern fn zguiDragFloat( - label: [*:0]const u8, - v: *f32, - speed: f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragFloat2 = DragFloatGen([2]f32); -pub fn dragFloat2(label: [:0]const u8, args: DragFloat2) bool { - return zguiDragFloat2(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragFloat2( - label: [*:0]const u8, - v: *[2]f32, - speed: f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragFloat3 = DragFloatGen([3]f32); -pub fn dragFloat3(label: [:0]const u8, args: DragFloat3) bool { - return zguiDragFloat3(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragFloat3( - label: [*:0]const u8, - v: *[3]f32, - speed: f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragFloat4 = DragFloatGen([4]f32); -pub fn dragFloat4(label: [:0]const u8, args: DragFloat4) bool { - return zguiDragFloat4(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragFloat4( - label: [*:0]const u8, - v: *[4]f32, - speed: f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragFloatRange2 = struct { - current_min: *f32, - current_max: *f32, - speed: f32 = 1.0, - min: f32 = 0.0, - max: f32 = 0.0, - cfmt: [:0]const u8 = "%.3f", - cfmt_max: ?[:0]const u8 = null, - flags: SliderFlags = .{}, -}; -pub fn dragFloatRange2(label: [:0]const u8, args: DragFloatRange2) bool { - return zguiDragFloatRange2( - label, - args.current_min, - args.current_max, - args.speed, - args.min, - args.max, - args.cfmt, - if (args.cfmt_max) |fm| fm else null, - args.flags, - ); -} -extern fn zguiDragFloatRange2( - label: [*:0]const u8, - current_min: *f32, - current_max: *f32, - speed: f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - cfmt_max: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn DragIntGen(comptime T: type) type { - return struct { - v: *T, - speed: f32 = 1.0, - min: i32 = 0.0, - max: i32 = 0.0, - cfmt: [:0]const u8 = "%d", - flags: SliderFlags = .{}, - }; -} -//-------------------------------------------------------------------------------------------------- -const DragInt = DragIntGen(i32); -pub fn dragInt(label: [:0]const u8, args: DragInt) bool { - return zguiDragInt(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragInt( - label: [*:0]const u8, - v: *i32, - speed: f32, - min: i32, - max: i32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragInt2 = DragIntGen([2]i32); -pub fn dragInt2(label: [:0]const u8, args: DragInt2) bool { - return zguiDragInt2(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragInt2( - label: [*:0]const u8, - v: *[2]i32, - speed: f32, - min: i32, - max: i32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragInt3 = DragIntGen([3]i32); -pub fn dragInt3(label: [:0]const u8, args: DragInt3) bool { - return zguiDragInt3(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragInt3( - label: [*:0]const u8, - v: *[3]i32, - speed: f32, - min: i32, - max: i32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragInt4 = DragIntGen([4]i32); -pub fn dragInt4(label: [:0]const u8, args: DragInt4) bool { - return zguiDragInt4(label, args.v, args.speed, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiDragInt4( - label: [*:0]const u8, - v: *[4]i32, - speed: f32, - min: i32, - max: i32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const DragIntRange2 = struct { - current_min: *i32, - current_max: *i32, - speed: f32 = 1.0, - min: i32 = 0.0, - max: i32 = 0.0, - cfmt: [:0]const u8 = "%d", - cfmt_max: ?[:0]const u8 = null, - flags: SliderFlags = .{}, -}; -pub fn dragIntRange2(label: [:0]const u8, args: DragIntRange2) bool { - return zguiDragIntRange2( - label, - args.current_min, - args.current_max, - args.speed, - args.min, - args.max, - args.cfmt, - if (args.cfmt_max) |fm| fm else null, - args.flags, - ); -} -extern fn zguiDragIntRange2( - label: [*:0]const u8, - current_min: *i32, - current_max: *i32, - speed: f32, - min: i32, - max: i32, - cfmt: [*:0]const u8, - cfmt_max: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn DragScalarGen(comptime T: type) type { - return struct { - v: *T, - speed: f32 = 1.0, - min: ?T = null, - max: ?T = null, - cfmt: ?[:0]const u8 = null, - flags: SliderFlags = .{}, - }; -} -pub fn dragScalar(label: [:0]const u8, comptime T: type, args: DragScalarGen(T)) bool { - return zguiDragScalar( - label, - typeToDataTypeEnum(T), - args.v, - args.speed, - if (args.min) |vm| &vm else null, - if (args.max) |vm| &vm else null, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiDragScalar( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - speed: f32, - pmin: ?*const anyopaque, - pmax: ?*const anyopaque, - cfmt: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn DragScalarNGen(comptime T: type) type { - const ScalarType = @typeInfo(T).Array.child; - return struct { - v: *T, - speed: f32 = 1.0, - min: ?ScalarType = null, - max: ?ScalarType = null, - cfmt: ?[:0]const u8 = null, - flags: SliderFlags = .{}, - }; -} -pub fn dragScalarN(label: [:0]const u8, comptime T: type, args: DragScalarNGen(T)) bool { - const ScalarType = @typeInfo(T).Array.child; - const components = @typeInfo(T).Array.len; - return zguiDragScalarN( - label, - typeToDataTypeEnum(ScalarType), - args.v, - components, - args.speed, - if (args.min) |vm| &vm else null, - if (args.max) |vm| &vm else null, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiDragScalarN( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - components: i32, - speed: f32, - pmin: ?*const anyopaque, - pmax: ?*const anyopaque, - cfmt: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Regular Sliders -// -//-------------------------------------------------------------------------------------------------- -fn SliderFloatGen(comptime T: type) type { - return struct { - v: *T, - min: f32, - max: f32, - cfmt: [:0]const u8 = "%.3f", - flags: SliderFlags = .{}, - }; -} - -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( - label: [*:0]const u8, - v: *f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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( - label: [*:0]const u8, - v: *[2]f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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( - label: [*:0]const u8, - v: *[3]f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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( - label: [*:0]const u8, - v: *[4]f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -fn SliderIntGen(comptime T: type) type { - return struct { - v: *T, - min: i32, - max: i32, - cfmt: [:0]const u8 = "%d", - flags: SliderFlags = .{}, - }; -} - -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: *c_int, - min: c_int, - max: c_int, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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]c_int, - min: c_int, - max: c_int, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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]c_int, - min: c_int, - max: c_int, - cfmt: [*:0]const u8, - flags: SliderFlags, -) 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]c_int, - min: c_int, - max: c_int, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -fn SliderScalarGen(comptime T: type) type { - return struct { - v: *T, - min: T, - max: T, - cfmt: ?[:0]const u8 = null, - flags: SliderFlags = .{}, - }; -} -pub fn sliderScalar(label: [:0]const u8, comptime T: type, args: SliderScalarGen(T)) bool { - return zguiSliderScalar( - label, - typeToDataTypeEnum(T), - args.v, - &args.min, - &args.max, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiSliderScalar( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - pmin: *const anyopaque, - pmax: *const anyopaque, - cfmt: ?[*:0]const u8, - flags: SliderFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -fn SliderScalarNGen(comptime T: type) type { - const ScalarType = @typeInfo(T).Array.child; - return struct { - v: *T, - min: ScalarType, - max: ScalarType, - cfmt: ?[:0]const u8 = null, - flags: SliderFlags = .{}, - }; -} -pub fn sliderScalarN(label: [:0]const u8, comptime T: type, args: SliderScalarNGen(T)) bool { - const ScalarType = @typeInfo(T).Array.child; - const components = @typeInfo(T).Array.len; - return zguiSliderScalarN( - label, - typeToDataTypeEnum(ScalarType), - args.v, - components, - &args.min, - &args.max, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiSliderScalarN( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - components: i32, - pmin: *const anyopaque, - pmax: *const anyopaque, - cfmt: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn vsliderFloat(label: [:0]const u8, args: struct { - w: f32, - h: f32, - v: *f32, - min: f32, - max: f32, - cfmt: [:0]const u8 = "%.3f", - flags: SliderFlags = .{}, -}) 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, - w: f32, - h: f32, - v: *f32, - min: f32, - max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn vsliderInt(label: [:0]const u8, args: struct { - w: f32, - h: f32, - v: *i32, - min: i32, - max: i32, - cfmt: [:0]const u8 = "%d", - flags: SliderFlags = .{}, -}) bool { - return zguiVSliderInt(label, args.w, args.h, args.v, args.min, args.max, args.cfmt, args.flags); -} -extern fn zguiVSliderInt( - label: [*:0]const u8, - w: f32, - h: f32, - v: *i32, - min: c_int, - max: c_int, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn VSliderScalarGen(comptime T: type) type { - return struct { - w: f32, - h: f32, - v: *T, - min: T, - max: T, - cfmt: ?[:0]const u8 = null, - flags: SliderFlags = .{}, - }; -} -pub fn vsliderScalar(label: [:0]const u8, comptime T: type, args: VSliderScalarGen(T)) bool { - return zguiVSliderScalar( - label, - args.w, - args.h, - typeToDataTypeEnum(T), - args.v, - &args.min, - &args.max, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiVSliderScalar( - label: [*:0]const u8, - w: f32, - h: f32, - data_type: DataType, - pdata: *anyopaque, - pmin: *const anyopaque, - pmax: *const anyopaque, - cfmt: ?[*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -const SliderAngle = struct { - vrad: *f32, - deg_min: f32 = -360.0, - deg_max: f32 = 360.0, - cfmt: [:0]const u8 = "%.0f deg", - flags: SliderFlags = .{}, -}; -pub fn sliderAngle(label: [:0]const u8, args: SliderAngle) bool { - return zguiSliderAngle( - label, - args.vrad, - args.deg_min, - args.deg_max, - args.cfmt, - args.flags, - ); -} -extern fn zguiSliderAngle( - label: [*:0]const u8, - vrad: *f32, - deg_min: f32, - deg_max: f32, - cfmt: [*:0]const u8, - flags: SliderFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Input with Keyboard -// -//-------------------------------------------------------------------------------------------------- -pub const InputTextFlags = packed struct(c_int) { - chars_decimal: bool = false, - chars_hexadecimal: bool = false, - chars_uppercase: bool = false, - chars_no_blank: bool = false, - auto_select_all: bool = false, - enter_returns_true: bool = false, - callback_completion: bool = false, - callback_history: bool = false, - callback_always: bool = false, - callback_char_filter: bool = false, - allow_tab_input: bool = false, - ctrl_enter_for_new_line: bool = false, - no_horizontal_scroll: bool = false, - always_overwrite: bool = false, - read_only: bool = false, - password: bool = false, - no_undo_redo: bool = false, - chars_scientific: bool = false, - callback_resize: bool = false, - callback_edit: bool = false, - escape_clears_all: bool = false, - _padding: u11 = 0, -}; -//-------------------------------------------------------------------------------------------------- -pub const InputTextCallbackData = extern struct { - ctx: *Context, - event_flag: InputTextFlags, - flags: InputTextFlags, - user_data: ?*anyopaque, - event_char: Wchar, - event_key: Key, - buf: [*]u8, - buf_text_len: i32, - buf_size: i32, - buf_dirty: bool, - cursor_pos: i32, - selection_start: i32, - selection_end: i32, - - /// `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; - data.selection_end = data.buf_text_len; - } - - pub fn clearSelection(data: *InputTextCallbackData) void { - data.selection_start = data.buf_text_len; - data.selection_end = data.buf_text_len; - } - - pub fn hasSelection(data: InputTextCallbackData) bool { - return data.selection_start != data.selection_end; - } -}; - -pub const InputTextCallback = *const fn (data: *InputTextCallbackData) i32; -//-------------------------------------------------------------------------------------------------- -pub fn inputText(label: [:0]const u8, args: struct { - buf: [:0]u8, - flags: InputTextFlags = .{}, - callback: ?InputTextCallback = null, - user_data: ?*anyopaque = null, -}) bool { - return zguiInputText( - label, - args.buf.ptr, - args.buf.len + 1, // + 1 for sentinel - args.flags, - if (args.callback) |cb| cb else null, - args.user_data, - ); -} -extern fn zguiInputText( - label: [*:0]const u8, - buf: [*]u8, - buf_size: usize, - flags: InputTextFlags, - callback: ?*const anyopaque, - user_data: ?*anyopaque, -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn inputTextMultiline(label: [:0]const u8, args: struct { - buf: [:0]u8, - w: f32 = 0.0, - h: f32 = 0.0, - flags: InputTextFlags = .{}, - callback: ?InputTextCallback = null, - user_data: ?*anyopaque = null, -}) bool { - return zguiInputTextMultiline( - label, - args.buf.ptr, - args.buf.len + 1, // + 1 for sentinel - args.w, - args.h, - args.flags, - if (args.callback) |cb| cb else null, - args.user_data, - ); -} -extern fn zguiInputTextMultiline( - label: [*:0]const u8, - buf: [*]u8, - buf_size: usize, - w: f32, - h: f32, - flags: InputTextFlags, - callback: ?*const anyopaque, - user_data: ?*anyopaque, -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn inputTextWithHint(label: [:0]const u8, args: struct { - hint: [:0]const u8, - buf: [:0]u8, - flags: InputTextFlags = .{}, - callback: ?InputTextCallback = null, - user_data: ?*anyopaque = null, -}) bool { - return zguiInputTextWithHint( - label, - args.hint, - args.buf.ptr, - args.buf.len + 1, // + 1 for sentinel - args.flags, - if (args.callback) |cb| cb else null, - args.user_data, - ); -} -extern fn zguiInputTextWithHint( - label: [*:0]const u8, - hint: [*:0]const u8, - buf: [*]u8, - buf_size: usize, - flags: InputTextFlags, - callback: ?*const anyopaque, - user_data: ?*anyopaque, -) bool; -//-------------------------------------------------------------------------------------------------- -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 = .{}, -}) bool { - return zguiInputFloat( - label, - args.v, - args.step, - args.step_fast, - args.cfmt, - args.flags, - ); -} -extern fn zguiInputFloat( - label: [*:0]const u8, - v: *f32, - step: f32, - step_fast: f32, - cfmt: [*:0]const u8, - flags: InputTextFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -fn InputFloatGen(comptime T: type) type { - return struct { - v: *T, - cfmt: [:0]const u8 = "%.3f", - flags: InputTextFlags = .{}, - }; -} -pub fn inputFloat2(label: [:0]const u8, args: InputFloatGen([2]f32)) bool { - return zguiInputFloat2(label, args.v, args.cfmt, args.flags); -} -extern fn zguiInputFloat2( - label: [*:0]const u8, - v: *[2]f32, - cfmt: [*:0]const u8, - flags: InputTextFlags, -) 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( - label: [*:0]const u8, - v: *[3]f32, - cfmt: [*:0]const u8, - flags: InputTextFlags, -) 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( - label: [*:0]const u8, - v: *[4]f32, - cfmt: [*:0]const u8, - flags: InputTextFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -pub fn inputInt(label: [:0]const u8, args: struct { - v: *i32, - step: i32 = 1, - step_fast: i32 = 100, - flags: InputTextFlags = .{}, -}) bool { - return zguiInputInt(label, args.v, args.step, args.step_fast, args.flags); -} -extern fn zguiInputInt( - label: [*:0]const u8, - v: *c_int, - step: c_int, - step_fast: c_int, - flags: InputTextFlags, -) bool; - -//-------------------------------------------------------------------------------------------------- -fn InputIntGen(comptime T: type) type { - return struct { - v: *T, - flags: InputTextFlags = .{}, - }; -} -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]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]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]c_int, flags: InputTextFlags) bool; - -//-------------------------------------------------------------------------------------------------- -const InputDouble = struct { - v: *f64, - step: f64 = 0.0, - step_fast: f64 = 0.0, - cfmt: [:0]const u8 = "%.6f", - flags: InputTextFlags = .{}, -}; -pub fn inputDouble(label: [:0]const u8, args: InputDouble) bool { - return zguiInputDouble(label, args.v, args.step, args.step_fast, args.cfmt, args.flags); -} -extern fn zguiInputDouble( - label: [*:0]const u8, - v: *f64, - step: f64, - step_fast: f64, - cfmt: [*:0]const u8, - flags: InputTextFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn InputScalarGen(comptime T: type) type { - return struct { - v: *T, - step: ?T = null, - step_fast: ?T = null, - cfmt: ?[:0]const u8 = null, - flags: InputTextFlags = .{}, - }; -} -pub fn inputScalar(label: [:0]const u8, comptime T: type, args: InputScalarGen(T)) bool { - return zguiInputScalar( - label, - typeToDataTypeEnum(T), - args.v, - if (args.step) |s| &s else null, - if (args.step_fast) |sf| &sf else null, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiInputScalar( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - pstep: ?*const anyopaque, - pstep_fast: ?*const anyopaque, - cfmt: ?[*:0]const u8, - flags: InputTextFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -fn InputScalarNGen(comptime T: type) type { - const ScalarType = @typeInfo(T).Array.child; - return struct { - v: *T, - step: ?ScalarType = null, - step_fast: ?ScalarType = null, - cfmt: ?[:0]const u8 = null, - flags: InputTextFlags = .{}, - }; -} -pub fn inputScalarN(label: [:0]const u8, comptime T: type, args: InputScalarNGen(T)) bool { - const ScalarType = @typeInfo(T).Array.child; - const components = @typeInfo(T).Array.len; - return zguiInputScalarN( - label, - typeToDataTypeEnum(ScalarType), - args.v, - components, - if (args.step) |s| &s else null, - if (args.step_fast) |sf| &sf else null, - if (args.cfmt) |fmt| fmt else null, - args.flags, - ); -} -extern fn zguiInputScalarN( - label: [*:0]const u8, - data_type: DataType, - pdata: *anyopaque, - components: i32, - pstep: ?*const anyopaque, - pstep_fast: ?*const anyopaque, - cfmt: ?[*:0]const u8, - flags: InputTextFlags, -) bool; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Color Editor/Picker -// -//-------------------------------------------------------------------------------------------------- -pub const ColorEditFlags = packed struct(c_int) { - _reserved0: bool = false, - no_alpha: bool = false, - no_picker: bool = false, - no_options: bool = false, - no_small_preview: bool = false, - no_inputs: bool = false, - no_tooltip: bool = false, - no_label: bool = false, - no_side_preview: bool = false, - no_drag_drop: bool = false, - no_border: 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, - alpha_preview_half: bool = false, - hdr: bool = false, - display_rgb: bool = false, - display_hsv: bool = false, - display_hex: bool = false, - uint8: bool = false, - float: bool = false, - picker_hue_bar: bool = false, - picker_hue_wheel: bool = false, - input_rgb: bool = false, - input_hsv: bool = false, - - _padding: u3 = 0, - - pub const default_options = ColorEditFlags{ - .uint8 = true, - .display_rgb = true, - .input_rgb = true, - .picker_hue_bar = true, - }; -}; -//-------------------------------------------------------------------------------------------------- -const ColorEdit3 = struct { - col: *[3]f32, - flags: ColorEditFlags = .{}, -}; -pub fn colorEdit3(label: [:0]const u8, args: ColorEdit3) bool { - return zguiColorEdit3(label, args.col, args.flags); -} -extern fn zguiColorEdit3(label: [*:0]const u8, col: *[3]f32, flags: ColorEditFlags) bool; -//-------------------------------------------------------------------------------------------------- -const ColorEdit4 = struct { - col: *[4]f32, - flags: ColorEditFlags = .{}, -}; -pub fn colorEdit4(label: [:0]const u8, args: ColorEdit4) bool { - return zguiColorEdit4(label, args.col, args.flags); -} -extern fn zguiColorEdit4(label: [*:0]const u8, col: *[4]f32, flags: ColorEditFlags) bool; -//-------------------------------------------------------------------------------------------------- -const ColorPicker3 = struct { - col: *[3]f32, - flags: ColorEditFlags = .{}, -}; -pub fn colorPicker3(label: [:0]const u8, args: ColorPicker3) bool { - return zguiColorPicker3(label, args.col, args.flags); -} -extern fn zguiColorPicker3(label: [*:0]const u8, col: *[3]f32, flags: ColorEditFlags) bool; -//-------------------------------------------------------------------------------------------------- -const ColorPicker4 = struct { - col: *[4]f32, - flags: ColorEditFlags = .{}, - ref_col: ?[*]const f32 = null, -}; -pub fn colorPicker4(label: [:0]const u8, args: ColorPicker4) bool { - return zguiColorPicker4( - label, - args.col, - args.flags, - if (args.ref_col) |rc| rc else null, - ); -} -extern fn zguiColorPicker4( - label: [*:0]const u8, - col: *[4]f32, - flags: ColorEditFlags, - ref_col: ?[*]const f32, -) bool; -//-------------------------------------------------------------------------------------------------- -const ColorButton = struct { - col: [4]f32, - flags: ColorEditFlags = .{}, - w: f32 = 0.0, - h: f32 = 0.0, -}; -pub fn colorButton(desc_id: [:0]const u8, args: ColorButton) bool { - return zguiColorButton(desc_id, &args.col, args.flags, args.w, args.h); -} -extern fn zguiColorButton( - desc_id: [*:0]const u8, - col: *const [4]f32, - flags: ColorEditFlags, - w: f32, - h: f32, -) bool; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Trees -// -//-------------------------------------------------------------------------------------------------- -pub const TreeNodeFlags = packed struct(c_int) { - selected: bool = false, - framed: bool = false, - allow_overlap: bool = false, - no_tree_push_on_open: bool = false, - no_auto_open_on_log: bool = false, - default_open: bool = false, - open_on_double_click: bool = false, - open_on_arrow: bool = false, - leaf: bool = false, - bullet: bool = false, - frame_padding: bool = false, - span_avail_width: bool = false, - span_full_width: bool = false, - span_all_columns: bool = false, - nav_left_jumps_back_here: bool = false, - _padding: u17 = 0, - - pub const collapsing_header = TreeNodeFlags{ - .framed = true, - .no_tree_push_on_open = true, - .no_auto_open_on_log = true, - }; -}; -//-------------------------------------------------------------------------------------------------- -pub fn treeNode(label: [:0]const u8) bool { - return zguiTreeNode(label); -} -pub fn treeNodeFlags(label: [:0]const u8, flags: TreeNodeFlags) bool { - return zguiTreeNodeFlags(label, flags); -} -extern fn zguiTreeNode(label: [*:0]const u8) bool; -extern fn zguiTreeNodeFlags(label: [*:0]const u8, flags: TreeNodeFlags) bool; -//-------------------------------------------------------------------------------------------------- -pub fn treeNodeStrId(str_id: [:0]const u8, comptime fmt: []const u8, args: anytype) bool { - return zguiTreeNodeStrId(str_id, "%s", formatZ(fmt, args).ptr); -} -pub fn treeNodeStrIdFlags( - str_id: [:0]const u8, - flags: TreeNodeFlags, - comptime fmt: []const u8, - args: anytype, -) bool { - return zguiTreeNodeStrIdFlags(str_id, flags, "%s", formatZ(fmt, args).ptr); -} -extern fn zguiTreeNodeStrId(str_id: [*:0]const u8, fmt: [*:0]const u8, ...) bool; -extern fn zguiTreeNodeStrIdFlags( - str_id: [*:0]const u8, - flags: TreeNodeFlags, - fmt: [*:0]const u8, - ..., -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn treeNodePtrId(ptr_id: *const anyopaque, comptime fmt: []const u8, args: anytype) bool { - return zguiTreeNodePtrId(ptr_id, "%s", formatZ(fmt, args).ptr); -} -pub fn treeNodePtrIdFlags( - ptr_id: *const anyopaque, - flags: TreeNodeFlags, - comptime fmt: []const u8, - args: anytype, -) bool { - return zguiTreeNodePtrIdFlags(ptr_id, flags, "%s", formatZ(fmt, args).ptr); -} -extern fn zguiTreeNodePtrId(ptr_id: *const anyopaque, fmt: [*:0]const u8, ...) bool; -extern fn zguiTreeNodePtrIdFlags( - ptr_id: *const anyopaque, - flags: TreeNodeFlags, - fmt: [*:0]const u8, - ..., -) bool; -//-------------------------------------------------------------------------------------------------- -pub fn treePushStrId(str_id: [:0]const u8) void { - zguiTreePushStrId(str_id); -} -pub fn treePushPtrId(ptr_id: *const anyopaque) void { - zguiTreePushPtrId(ptr_id); -} -extern fn zguiTreePushStrId(str_id: [*:0]const u8) void; -extern fn zguiTreePushPtrId(ptr_id: *const anyopaque) void; -//-------------------------------------------------------------------------------------------------- -/// `pub fn treePop() void` -pub const treePop = zguiTreePop; -extern fn zguiTreePop() void; -//-------------------------------------------------------------------------------------------------- -const CollapsingHeaderStatePtr = struct { - pvisible: *bool, - flags: TreeNodeFlags = .{}, -}; -pub fn collapsingHeader(label: [:0]const u8, flags: TreeNodeFlags) bool { - return zguiCollapsingHeader(label, flags); -} -pub fn collapsingHeaderStatePtr(label: [:0]const u8, args: CollapsingHeaderStatePtr) bool { - return zguiCollapsingHeaderStatePtr(label, args.pvisible, args.flags); -} -extern fn zguiCollapsingHeader(label: [*:0]const u8, flags: TreeNodeFlags) bool; -extern fn zguiCollapsingHeaderStatePtr(label: [*:0]const u8, pvisible: *bool, flags: TreeNodeFlags) bool; -//-------------------------------------------------------------------------------------------------- -const SetNextItemOpen = struct { - is_open: bool, - cond: Condition = .none, -}; -pub fn setNextItemOpen(args: SetNextItemOpen) void { - zguiSetNextItemOpen(args.is_open, args.cond); -} -extern fn zguiSetNextItemOpen(is_open: bool, cond: Condition) void; -//-------------------------------------------------------------------------------------------------- -// -// Selectables -// -//-------------------------------------------------------------------------------------------------- -pub const SelectableFlags = packed struct(c_int) { - dont_close_popups: bool = false, - span_all_columns: bool = false, - allow_double_click: bool = false, - disabled: bool = false, - allow_overlap: bool = false, - _padding: u27 = 0, -}; -//-------------------------------------------------------------------------------------------------- -const Selectable = struct { - selected: bool = false, - flags: SelectableFlags = .{}, - w: f32 = 0, - h: f32 = 0, -}; -pub fn selectable(label: [:0]const u8, args: Selectable) bool { - return zguiSelectable(label, args.selected, args.flags, args.w, args.h); -} -extern fn zguiSelectable( - label: [*:0]const u8, - selected: bool, - flags: SelectableFlags, - w: f32, - h: f32, -) bool; -//-------------------------------------------------------------------------------------------------- -const SelectableStatePtr = struct { - pselected: *bool, - flags: SelectableFlags = .{}, - w: f32 = 0, - h: f32 = 0, -}; -pub fn selectableStatePtr(label: [:0]const u8, args: SelectableStatePtr) bool { - return zguiSelectableStatePtr(label, args.pselected, args.flags, args.w, args.h); -} -extern fn zguiSelectableStatePtr( - label: [*:0]const u8, - pselected: *bool, - flags: SelectableFlags, - w: f32, - h: f32, -) bool; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: List Boxes -// -//-------------------------------------------------------------------------------------------------- -const BeginListBox = struct { - w: f32 = 0.0, - h: f32 = 0.0, -}; -pub fn beginListBox(label: [:0]const u8, args: BeginListBox) bool { - return zguiBeginListBox(label, args.w, args.h); -} -/// `pub fn endListBox() void` -pub const endListBox = zguiEndListBox; -extern fn zguiBeginListBox(label: [*:0]const u8, w: f32, h: f32) bool; -extern fn zguiEndListBox() void; -//-------------------------------------------------------------------------------------------------- -// -// Widgets: Tables -// -//-------------------------------------------------------------------------------------------------- -pub const TableBorderFlags = packed struct(u4) { - inner_h: bool = false, - outer_h: bool = false, - inner_v: bool = false, - outer_v: bool = false, - - pub const h = TableBorderFlags{ - .inner_h = true, - .outer_h = true, - }; // Draw horizontal borders. - pub const v = TableBorderFlags{ - .inner_v = true, - .outer_v = true, - }; // Draw vertical borders. - pub const inner = TableBorderFlags{ - .inner_v = true, - .inner_h = true, - }; // Draw inner borders. - pub const outer = TableBorderFlags{ - .outer_v = true, - .outer_h = true, - }; // Draw outer borders. - pub const all = TableBorderFlags{ - .inner_v = true, - .inner_h = true, - .outer_v = true, - .outer_h = true, - }; // Draw all borders. -}; -pub const TableFlags = packed struct(c_int) { - resizable: bool = false, - reorderable: bool = false, - hideable: bool = false, - sortable: bool = false, - no_saved_settings: bool = false, - context_menu_in_body: bool = false, - row_bg: bool = false, - borders: TableBorderFlags = .{}, - no_borders_in_body: bool = false, - no_borders_in_body_until_resize: bool = false, - - // Sizing Policy - sizing: enum(u3) { - none = 0, - fixed_fit = 1, - fixed_same = 2, - stretch_prop = 3, - stretch_same = 4, - } = .none, - - // Sizing Extra Options - no_host_extend_x: bool = false, - no_host_extend_y: bool = false, - no_keep_columns_visible: bool = false, - precise_widths: bool = false, - - // Clipping - no_clip: bool = false, - - // Padding - pad_outer_x: bool = false, - no_pad_outer_x: bool = false, - no_pad_inner_x: bool = false, - - // Scrolling - scroll_x: bool = false, - scroll_y: bool = false, - - // Sorting - sort_multi: bool = false, - sort_tristate: bool = false, - - _padding: u4 = 0, -}; - -pub const TableRowFlags = packed struct(c_int) { - headers: bool = false, - - _padding: u31 = 0, -}; - -pub const TableColumnFlags = packed struct(c_int) { - // Input configuration flags - disabled: bool = false, - default_hide: bool = false, - default_sort: bool = false, - width_stretch: bool = false, - width_fixed: bool = false, - no_resize: bool = false, - no_reorder: bool = false, - no_hide: bool = false, - no_clip: bool = false, - no_sort: bool = false, - no_sort_ascending: bool = false, - no_sort_descending: bool = false, - no_header_label: bool = false, - no_header_width: bool = false, - prefer_sort_ascending: bool = false, - prefer_sort_descending: bool = false, - indent_enable: bool = false, - indent_disable: bool = false, - - _padding0: u6 = 0, - - // Output status flags, read-only via TableGetColumnFlags() - is_enabled: bool = false, - is_visible: bool = false, - is_sorted: bool = false, - is_hovered: bool = false, - - _padding1: u4 = 0, -}; - -pub const TableColumnSortSpecs = extern struct { - user_id: Ident, - index: i16, - sort_order: i16, - sort_direction: enum(u8) { - none = 0, - ascending = 1, // Ascending = 0->9, A->Z etc. - descending = 2, // Descending = 9->0, Z->A etc. - }, -}; - -pub const TableSortSpecs = *extern struct { - specs: [*]TableColumnSortSpecs, - count: c_int, - dirty: bool, -}; - -pub const TableBgTarget = enum(c_int) { - none = 0, - row_bg0 = 1, - row_bg1 = 2, - cell_bg = 3, -}; - -pub fn beginTable(name: [:0]const u8, args: struct { - column: i32, - flags: TableFlags = .{}, - outer_size: [2]f32 = .{ 0, 0 }, - inner_width: f32 = 0, -}) bool { - return zguiBeginTable(name, args.column, args.flags, &args.outer_size, args.inner_width); -} -extern fn zguiBeginTable( - str_id: [*:0]const u8, - column: c_int, - flags: TableFlags, - outer_size: *const [2]f32, - inner_width: f32, -) bool; - -pub fn endTable() void { - zguiEndTable(); -} -extern fn zguiEndTable() void; - -pub const TableNextRow = struct { - row_flags: TableRowFlags = .{}, - min_row_height: f32 = 0, -}; -pub fn tableNextRow(args: TableNextRow) void { - zguiTableNextRow(args.row_flags, args.min_row_height); -} -extern fn zguiTableNextRow(row_flags: TableRowFlags, min_row_height: f32) void; - -pub const tableNextColumn = zguiTableNextColumn; -extern fn zguiTableNextColumn() bool; - -pub const tableSetColumnIndex = zguiTableSetColumnIndex; -extern fn zguiTableSetColumnIndex(column_n: i32) bool; - -pub const TableSetupColumn = struct { - flags: TableColumnFlags = .{}, - init_width_or_height: f32 = 0, - user_id: Ident = 0, -}; -pub fn tableSetupColumn(label: [:0]const u8, args: TableSetupColumn) void { - zguiTableSetupColumn(label, args.flags, args.init_width_or_height, args.user_id); -} -extern fn zguiTableSetupColumn(label: [*:0]const u8, flags: TableColumnFlags, init_width_or_height: f32, user_id: Ident) void; - -pub const tableSetupScrollFreeze = zguiTableSetupScrollFreeze; -extern fn zguiTableSetupScrollFreeze(cols: i32, rows: i32) void; - -pub const tableHeadersRow = zguiTableHeadersRow; -extern fn zguiTableHeadersRow() void; - -pub fn tableHeader(label: [:0]const u8) void { - zguiTableHeader(label); -} -extern fn zguiTableHeader(label: [*:0]const u8) void; - -pub const tableGetSortSpecs = zguiTableGetSortSpecs; -extern fn zguiTableGetSortSpecs() ?TableSortSpecs; - -pub const tableGetColumnCount = zguiTableGetColumnCount; -extern fn zguiTableGetColumnCount() i32; - -pub const tableGetColumnIndex = zguiTableGetColumnIndex; -extern fn zguiTableGetColumnIndex() i32; - -pub const tableGetRowIndex = zguiTableGetRowIndex; -extern fn zguiTableGetRowIndex() i32; - -pub const TableGetColumnName = struct { - column_n: i32 = -1, -}; -pub fn tableGetColumnName(args: TableGetColumnName) [*:0]const u8 { - return zguiTableGetColumnName(args.column_n); -} -extern fn zguiTableGetColumnName(column_n: i32) [*:0]const u8; - -pub const TableGetColumnFlags = struct { - column_n: i32 = -1, -}; -pub fn tableGetColumnFlags(args: TableGetColumnFlags) TableColumnFlags { - return zguiTableGetColumnFlags(args.column_n); -} -extern fn zguiTableGetColumnFlags(column_n: i32) TableColumnFlags; - -pub const tableSetColumnEnabled = zguiTableSetColumnEnabled; -extern fn zguiTableSetColumnEnabled(column_n: i32, v: bool) void; - -pub fn tableSetBgColor(args: struct { - target: TableBgTarget, - color: u32, - column_n: i32 = -1, -}) void { - zguiTableSetBgColor(args.target, args.color, args.column_n); -} -extern fn zguiTableSetBgColor(target: TableBgTarget, color: c_uint, column_n: c_int) void; - -//-------------------------------------------------------------------------------------------------- -// -// Item/Widgets Utilities and Query Functions -// -//-------------------------------------------------------------------------------------------------- -pub fn isItemHovered(flags: HoveredFlags) bool { - return zguiIsItemHovered(flags); -} -/// `pub fn isItemActive() bool` -pub const isItemActive = zguiIsItemActive; -/// `pub fn isItemFocused() bool` -pub const isItemFocused = zguiIsItemFocused; -pub const MouseButton = enum(u32) { - left = 0, - right = 1, - middle = 2, -}; - -/// `pub fn isMouseDown(mouse_button: MouseButton) bool` -pub const isMouseDown = zguiIsMouseDown; -/// `pub fn isMouseClicked(mouse_button: MouseButton) bool` -pub const isMouseClicked = zguiIsMouseClicked; -/// `pub fn isMouseDoubleClicked(mouse_button: MouseButton) bool` -pub const isMouseDoubleClicked = zguiIsMouseDoubleClicked; -/// `pub fn isItemClicked(mouse_button: MouseButton) bool` -pub const isItemClicked = zguiIsItemClicked; -/// `pub fn isItemVisible() bool` -pub const isItemVisible = zguiIsItemVisible; -/// `pub fn isItemEdited() bool` -pub const isItemEdited = zguiIsItemEdited; -/// `pub fn isItemActivated() bool` -pub const isItemActivated = zguiIsItemActivated; -/// `pub fn isItemDeactivated bool` -pub const isItemDeactivated = zguiIsItemDeactivated; -/// `pub fn isItemDeactivatedAfterEdit() bool` -pub const isItemDeactivatedAfterEdit = zguiIsItemDeactivatedAfterEdit; -/// `pub fn isItemToggledOpen() bool` -pub const isItemToggledOpen = zguiIsItemToggledOpen; -/// `pub fn isAnyItemHovered() bool` -pub const isAnyItemHovered = zguiIsAnyItemHovered; -/// `pub fn isAnyItemActive() bool` -pub const isAnyItemActive = zguiIsAnyItemActive; -/// `pub fn isAnyItemFocused() bool` -pub const isAnyItemFocused = zguiIsAnyItemFocused; -extern fn zguiIsMouseDown(mouse_button: MouseButton) bool; -extern fn zguiIsMouseClicked(mouse_button: MouseButton) bool; -extern fn zguiIsMouseDoubleClicked(mouse_button: MouseButton) bool; -extern fn zguiIsItemHovered(flags: HoveredFlags) bool; -extern fn zguiIsItemActive() bool; -extern fn zguiIsItemFocused() bool; -extern fn zguiIsItemClicked(mouse_button: MouseButton) bool; -extern fn zguiIsItemVisible() bool; -extern fn zguiIsItemEdited() bool; -extern fn zguiIsItemActivated() bool; -extern fn zguiIsItemDeactivated() bool; -extern fn zguiIsItemDeactivatedAfterEdit() bool; -extern fn zguiIsItemToggledOpen() bool; -extern fn zguiIsAnyItemHovered() bool; -extern fn zguiIsAnyItemActive() bool; -extern fn zguiIsAnyItemFocused() bool; -//-------------------------------------------------------------------------------------------------- -// -// Color Utilities -// -//-------------------------------------------------------------------------------------------------- -pub fn colorConvertU32ToFloat4(in: u32) [4]f32 { - var rgba: [4]f32 = undefined; - zguiColorConvertU32ToFloat4(in, &rgba); - return rgba; -} - -pub fn colorConvertU32ToFloat3(in: u32) [3]f32 { - var rgba: [4]f32 = undefined; - zguiColorConvertU32ToFloat4(in, &rgba); - return .{ rgba[0], rgba[1], rgba[2] }; -} - -pub fn colorConvertFloat4ToU32(in: [4]f32) u32 { - return zguiColorConvertFloat4ToU32(&in); -} - -pub fn colorConvertFloat3ToU32(in: [3]f32) u32 { - return colorConvertFloat4ToU32(.{ in[0], in[1], in[2], 1 }); -} - -pub fn colorConvertRgbToHsv(r: f32, g: f32, b: f32) [3]f32 { - var hsv: [3]f32 = undefined; - zguiColorConvertRGBtoHSV(r, g, b, &hsv[0], &hsv[1], &hsv[2]); - return hsv; -} - -pub fn colorConvertHsvToRgb(h: f32, s: f32, v: f32) [3]f32 { - var rgb: [3]f32 = undefined; - zguiColorConvertHSVtoRGB(h, s, v, &rgb[0], &rgb[1], &rgb[2]); - return rgb; -} - -extern fn zguiColorConvertU32ToFloat4(in: u32, rgba: *[4]f32) void; -extern fn zguiColorConvertFloat4ToU32(in: *const [4]f32) u32; -extern fn zguiColorConvertRGBtoHSV(r: f32, g: f32, b: f32, out_h: *f32, out_s: *f32, out_v: *f32) void; -extern fn zguiColorConvertHSVtoRGB(h: f32, s: f32, v: f32, out_r: *f32, out_g: *f32, out_b: *f32) void; -//-------------------------------------------------------------------------------------------------- -// -// Inputs Utilities: Keyboard -// -//-------------------------------------------------------------------------------------------------- -pub fn isKeyDown(key: Key) bool { - return zguiIsKeyDown(key); -} - -extern fn zguiIsKeyDown(key: Key) bool; -//-------------------------------------------------------------------------------------------------- -// -// Helpers -// -//-------------------------------------------------------------------------------------------------- -var temp_buffer: ?std.ArrayList(u8) = null; - -pub fn format(comptime fmt: []const u8, args: anytype) []const u8 { - const len = std.fmt.count(fmt, args); - if (len > temp_buffer.?.items.len) temp_buffer.?.resize(len + 64) catch unreachable; - return std.fmt.bufPrint(temp_buffer.?.items, fmt, args) catch unreachable; -} -pub fn formatZ(comptime fmt: []const u8, args: anytype) [:0]const u8 { - const len = std.fmt.count(fmt ++ "\x00", args); - if (len > temp_buffer.?.items.len) temp_buffer.?.resize(len + 64) catch unreachable; - return std.fmt.bufPrintZ(temp_buffer.?.items, fmt, args) catch unreachable; -} -//-------------------------------------------------------------------------------------------------- -pub fn typeToDataTypeEnum(comptime T: type) DataType { - return switch (T) { - i8 => .I8, - u8 => .U8, - i16 => .I16, - u16 => .U16, - i32 => .I32, - u32 => .U32, - i64 => .I64, - u64 => .U64, - f32 => .F32, - f64 => .F64, - usize => switch (@sizeOf(usize)) { - 1 => .U8, - 2 => .U16, - 4 => .U32, - 8 => .U64, - else => @compileError("Unsupported usize length"), - }, - else => @compileError("Only fundamental scalar types allowed: " ++ @typeName(T)), - }; -} -//-------------------------------------------------------------------------------------------------- -// -// Menus -// -//-------------------------------------------------------------------------------------------------- -/// `pub fn beginMenuBar() bool` -pub const beginMenuBar = zguiBeginMenuBar; -/// `pub fn endMenuBar() void` -pub const endMenuBar = zguiEndMenuBar; -/// `pub fn beginMainMenuBar() bool` -pub const beginMainMenuBar = zguiBeginMainMenuBar; -/// `pub fn endMainMenuBar() void` -pub const endMainMenuBar = zguiEndMainMenuBar; - -pub fn beginMenu(label: [:0]const u8, enabled: bool) bool { - return zguiBeginMenu(label, enabled); -} -/// `pub fn endMenu() void` -pub const endMenu = zguiEndMenu; - -const MenuItem = struct { - shortcut: ?[:0]const u8 = null, - selected: bool = false, - enabled: bool = true, -}; -pub fn menuItem(label: [:0]const u8, args: MenuItem) bool { - return zguiMenuItem(label, if (args.shortcut) |s| s.ptr else null, args.selected, args.enabled); -} - -const MenuItemPtr = struct { - shortcut: ?[:0]const u8 = null, - selected: *bool, - enabled: bool = true, -}; -pub fn menuItemPtr(label: [:0]const u8, args: MenuItemPtr) bool { - return zguiMenuItemPtr(label, if (args.shortcut) |s| s.ptr else null, args.selected, args.enabled); -} - -extern fn zguiBeginMenuBar() bool; -extern fn zguiEndMenuBar() void; -extern fn zguiBeginMainMenuBar() bool; -extern fn zguiEndMainMenuBar() void; -extern fn zguiBeginMenu(label: [*:0]const u8, enabled: bool) bool; -extern fn zguiEndMenu() void; -extern fn zguiMenuItem(label: [*:0]const u8, shortcut: ?[*:0]const u8, selected: bool, enabled: bool) bool; -extern fn zguiMenuItemPtr(label: [*:0]const u8, shortcut: ?[*:0]const u8, selected: *bool, enabled: bool) bool; -//-------------------------------------------------------------------------------------------------- -// -// Popups -// -//-------------------------------------------------------------------------------------------------- -/// `pub fn beginTooltip() bool` -pub const beginTooltip = zguiBeginTooltip; -/// `pub fn endTooltip() void` -pub const endTooltip = zguiEndTooltip; -extern fn zguiBeginTooltip() bool; -extern fn zguiEndTooltip() void; - -/// `pub fn beginPopupContextWindow() bool` -pub const beginPopupContextWindow = zguiBeginPopupContextWindow; -/// `pub fn beginPopupContextItem() bool` -pub const beginPopupContextItem = zguiBeginPopupContextItem; -pub const PopupFlags = packed struct(c_int) { - mouse_button_left: bool = false, - mouse_button_right: bool = false, - mouse_button_middle: bool = false, - - _reserved0: bool = false, - _reserved1: bool = false, - - no_reopen: bool = false, - _reserved2: 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, - _padding: u21 = 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); -} -pub fn openPopup(str_id: [:0]const u8, flags: PopupFlags) void { - zguiOpenPopup(str_id, flags); -} -/// `pub fn beginPopup(str_id: [:0]const u8, flags: WindowFlags) bool` -pub const beginPopup = zguiBeginPopup; -/// `pub fn endPopup() void` -pub const endPopup = zguiEndPopup; -/// `pub fn closeCurrentPopup() void` -pub const closeCurrentPopup = zguiCloseCurrentPopup; -extern fn zguiBeginPopupContextWindow() bool; -extern fn zguiBeginPopupContextItem() bool; -extern fn zguiBeginPopupModal(name: [*:0]const u8, popen: ?*bool, flags: WindowFlags) bool; -extern fn zguiBeginPopup(str_id: [*:0]const u8, flags: WindowFlags) bool; -extern fn zguiEndPopup() void; -extern fn zguiOpenPopup(str_id: [*:0]const u8, flags: PopupFlags) void; -extern fn zguiCloseCurrentPopup() void; -//-------------------------------------------------------------------------------------------------- -// -// Tabs -// -//-------------------------------------------------------------------------------------------------- -pub const TabBarFlags = packed struct(c_int) { - reorderable: bool = false, - auto_select_new_tabs: bool = false, - tab_list_popup_button: bool = false, - no_close_with_middle_mouse_button: bool = false, - no_tab_list_scrolling_buttons: bool = false, - no_tooltip: bool = false, - fitting_policy_resize_down: bool = false, - fitting_policy_scroll: bool = false, - _padding: u24 = 0, -}; -pub const TabItemFlags = packed struct(c_int) { - unsaved_document: bool = false, - set_selected: bool = false, - no_close_with_middle_mouse_button: bool = false, - no_push_id: bool = false, - no_tooltip: bool = false, - no_reorder: bool = false, - leading: bool = false, - trailing: bool = false, - no_assumed_closure: bool = false, - _padding: u23 = 0, -}; -pub fn beginTabBar(label: [:0]const u8, flags: TabBarFlags) bool { - return zguiBeginTabBar(label, flags); -} -const BeginTabItem = struct { - p_open: ?*bool = null, - flags: TabItemFlags = .{}, -}; -pub fn beginTabItem(label: [:0]const u8, args: BeginTabItem) bool { - return zguiBeginTabItem(label, args.p_open, args.flags); -} -/// `void endTabItem() void` -pub const endTabItem = zguiEndTabItem; -/// `void endTabBar() void` -pub const endTabBar = zguiEndTabBar; -pub fn setTabItemClosed(tab_or_docked_window_label: [:0]const u8) void { - zguiSetTabItemClosed(tab_or_docked_window_label); -} - -extern fn zguiBeginTabBar(label: [*:0]const u8, flags: TabBarFlags) bool; -extern fn zguiBeginTabItem(label: [*:0]const u8, p_open: ?*bool, flags: TabItemFlags) bool; -extern fn zguiEndTabItem() void; -extern fn zguiEndTabBar() void; -extern fn zguiSetTabItemClosed(tab_or_docked_window_label: [*:0]const u8) void; -//-------------------------------------------------------------------------------------------------- -// -// Viewport -// -//-------------------------------------------------------------------------------------------------- -pub const Viewport = *opaque { - pub fn getPos(viewport: Viewport) [2]f32 { - var pos: [2]f32 = undefined; - zguiViewport_GetPos(viewport, &pos); - return pos; - } - extern fn zguiViewport_GetPos(viewport: Viewport, pos: *[2]f32) void; - - pub fn getSize(viewport: Viewport) [2]f32 { - var pos: [2]f32 = undefined; - zguiViewport_GetSize(viewport, &pos); - return pos; - } - extern fn zguiViewport_GetSize(viewport: Viewport, size: *[2]f32) void; - - pub fn getWorkPos(viewport: Viewport) [2]f32 { - var pos: [2]f32 = undefined; - zguiViewport_GetWorkPos(viewport, &pos); - return pos; - } - extern fn zguiViewport_GetWorkPos(viewport: Viewport, pos: *[2]f32) void; - - pub fn getWorkSize(viewport: Viewport) [2]f32 { - var pos: [2]f32 = undefined; - zguiViewport_GetWorkSize(viewport, &pos); - return pos; - } - extern fn zguiViewport_GetWorkSize(viewport: Viewport, size: *[2]f32) void; - - pub fn getCenter(viewport: Viewport) [2]f32 { - const pos = viewport.getPos(); - const size = viewport.getSize(); - return .{ - pos[0] + size[0] * 0.5, - pos[1] + size[1] * 0.5, - }; - } - - pub fn getWorkCenter(viewport: Viewport) [2]f32 { - const pos = viewport.getWorkPos(); - const size = viewport.getWorkSize(); - return .{ - pos[0] + size[0] * 0.5, - pos[1] + size[1] * 0.5, - }; - } -}; -pub const getMainViewport = zguiGetMainViewport; -extern fn zguiGetMainViewport() Viewport; -//-------------------------------------------------------------------------------------------------- -// -// Mouse Input -// -//-------------------------------------------------------------------------------------------------- -pub const MouseDragDelta = struct { - lock_threshold: f32 = -1.0, -}; -pub fn getMouseDragDelta(drag_button: MouseButton, args: MouseDragDelta) [2]f32 { - var delta: [2]f32 = undefined; - zguiGetMouseDragDelta(drag_button, args.lock_threshold, &delta); - return delta; -} -pub const resetMouseDragDelta = zguiResetMouseDragDelta; -extern fn zguiGetMouseDragDelta(button: MouseButton, lock_threshold: f32, delta: *[2]f32) void; -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(c_int) { - closed: bool = false, - _padding0: u3 = 0, - round_corners_top_left: bool = false, - round_corners_top_right: bool = false, - round_corners_bottom_left: bool = false, - round_corners_bottom_right: bool = false, - round_corners_none: bool = false, - _padding1: u23 = 0, - - pub const round_corners_top = DrawFlags{ - .round_corners_top_left = true, - .round_corners_top_right = true, - }; - - pub const round_corners_bottom = DrawFlags{ - .round_corners_bottom_left = true, - .round_corners_bottom_right = true, - }; - - pub const round_corners_left = DrawFlags{ - .round_corners_top_left = true, - .round_corners_bottom_left = true, - }; - - pub const round_corners_right = DrawFlags{ - .round_corners_top_right = true, - .round_corners_bottom_right = true, - }; - - pub const round_corners_all = DrawFlags{ - .round_corners_top_left = true, - .round_corners_top_right = true, - .round_corners_bottom_left = true, - .round_corners_bottom_right = true, - }; -}; - -pub const DrawCmd = extern struct { - clip_rect: [4]f32, - texture_id: TextureIdent, - vtx_offset: c_uint, - idx_offset: c_uint, - elem_count: c_uint, - user_callback: ?DrawCallback, - user_callback_data: ?*anyopaque, -}; - -pub const DrawCallback = *const fn (*const anyopaque, *const DrawCmd) callconv(.C) void; - -pub const getWindowDrawList = zguiGetWindowDrawList; -pub const getBackgroundDrawList = zguiGetBackgroundDrawList; -pub const getForegroundDrawList = zguiGetForegroundDrawList; - -pub const createDrawList = zguiCreateDrawList; -pub fn destroyDrawList(draw_list: DrawList) void { - if (draw_list.getOwnerName()) |owner| { - @panic(format("zgui: illegally destroying DrawList of {s}", .{owner})); - } - zguiDestroyDrawList(draw_list); -} - -extern fn zguiGetWindowDrawList() DrawList; -extern fn zguiGetBackgroundDrawList() DrawList; -extern fn zguiGetForegroundDrawList() DrawList; -extern fn zguiCreateDrawList() DrawList; -extern fn zguiDestroyDrawList(draw_list: DrawList) void; - -pub const DrawList = *opaque { - pub const getOwnerName = zguiDrawList_GetOwnerName; - extern fn zguiDrawList_GetOwnerName(draw_list: DrawList) ?[*:0]const u8; - - pub fn reset(draw_list: DrawList) void { - if (draw_list.getOwnerName()) |owner| { - @panic(format("zgui: illegally resetting DrawList of {s}", .{owner})); - } - zguiDrawList_ResetForNewFrame(draw_list); - } - extern fn zguiDrawList_ResetForNewFrame(draw_list: DrawList) void; - - pub fn clearMemory(draw_list: DrawList) void { - if (draw_list.getOwnerName()) |owner| { - @panic(format("zgui: illegally clearing memory DrawList of {s}", .{owner})); - } - zguiDrawList_ClearFreeMemory(draw_list); - } - extern fn zguiDrawList_ClearFreeMemory(draw_list: DrawList) void; - - //---------------------------------------------------------------------------------------------- - 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 { - const len: usize = @intCast(draw_list.getVertexBufferLength()); - return draw_list.getVertexBufferData()[0..len]; - } - - 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 { - const len: usize = @intCast(draw_list.getIndexBufferLength()); - return draw_list.getIndexBufferData()[0..len]; - } - - 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 getCmdBufferData = zguiDrawList_GetCmdBufferData; - extern fn zguiDrawList_GetCmdBufferData(draw_list: DrawList) [*]DrawCmd; - pub fn getCmdBuffer(draw_list: DrawList) []DrawCmd { - const len: usize = @intCast(draw_list.getCmdBufferLength()); - return draw_list.getCmdBufferData()[0..len]; - } - - pub const DrawListFlags = packed struct(c_int) { - anti_aliased_lines: bool = false, - anti_aliased_lines_use_tex: bool = false, - anti_aliased_fill: bool = false, - allow_vtx_offset: bool = false, - - _padding: u28 = 0, - }; - - pub const setDrawListFlags = zguiDrawList_SetFlags; - extern fn zguiDrawList_SetFlags(draw_list: DrawList, flags: DrawListFlags) void; - pub const getDrawListFlags = zguiDrawList_GetFlags; - extern fn zguiDrawList_GetFlags(draw_list: DrawList) DrawListFlags; - - //---------------------------------------------------------------------------------------------- - const ClipRect = struct { - pmin: [2]f32, - pmax: [2]f32, - intersect_with_current: bool = false, - }; - pub fn pushClipRect(draw_list: DrawList, args: ClipRect) void { - zguiDrawList_PushClipRect( - draw_list, - &args.pmin, - &args.pmax, - args.intersect_with_current, - ); - } - extern fn zguiDrawList_PushClipRect( - draw_list: DrawList, - clip_rect_min: *const [2]f32, - clip_rect_max: *const [2]f32, - intersect_with_current_clip_rect: bool, - ) void; - //---------------------------------------------------------------------------------------------- - pub const pushClipRectFullScreen = zguiDrawList_PushClipRectFullScreen; - extern fn zguiDrawList_PushClipRectFullScreen(draw_list: DrawList) void; - - pub const popClipRect = zguiDrawList_PopClipRect; - extern fn zguiDrawList_PopClipRect(draw_list: DrawList) void; - //---------------------------------------------------------------------------------------------- - pub const pushTextureId = zguiDrawList_PushTextureId; - extern fn zguiDrawList_PushTextureId(draw_list: DrawList, texture_id: TextureIdent) void; - - pub const popTextureId = zguiDrawList_PopTextureId; - extern fn zguiDrawList_PopTextureId(draw_list: DrawList) void; - //---------------------------------------------------------------------------------------------- - pub fn getClipRectMin(draw_list: DrawList) [2]f32 { - var v: [2]f32 = undefined; - zguiDrawList_GetClipRectMin(draw_list, &v); - return v; - } - extern fn zguiDrawList_GetClipRectMin(draw_list: DrawList, clip_min: *[2]f32) void; - - pub fn getClipRectMax(draw_list: DrawList) [2]f32 { - var v: [2]f32 = undefined; - zguiDrawList_GetClipRectMax(draw_list, &v); - return v; - } - extern fn zguiDrawList_GetClipRectMax(draw_list: DrawList, clip_min: *[2]f32) void; - //---------------------------------------------------------------------------------------------- - pub fn addLine(draw_list: DrawList, args: struct { - p1: [2]f32, - p2: [2]f32, - col: u32, - thickness: f32, - }) void { - zguiDrawList_AddLine(draw_list, &args.p1, &args.p2, args.col, args.thickness); - } - extern fn zguiDrawList_AddLine( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - col: u32, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - 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, - }) void { - zguiDrawList_AddRect( - draw_list, - &args.pmin, - &args.pmax, - args.col, - args.rounding, - args.flags, - args.thickness, - ); - } - extern fn zguiDrawList_AddRect( - draw_list: DrawList, - pmin: *const [2]f32, - pmax: *const [2]f32, - col: u32, - rounding: f32, - flags: DrawFlags, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addRectFilled(draw_list: DrawList, args: struct { - pmin: [2]f32, - pmax: [2]f32, - col: u32, - rounding: f32 = 0.0, - flags: DrawFlags = .{}, - }) void { - zguiDrawList_AddRectFilled( - draw_list, - &args.pmin, - &args.pmax, - args.col, - args.rounding, - args.flags, - ); - } - extern fn zguiDrawList_AddRectFilled( - draw_list: DrawList, - pmin: *const [2]f32, - pmax: *const [2]f32, - col: u32, - rounding: f32, - flags: DrawFlags, - ) void; - //---------------------------------------------------------------------------------------------- - 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, - }) void { - zguiDrawList_AddRectFilledMultiColor( - draw_list, - &args.pmin, - &args.pmax, - args.col_upr_left, - args.col_upr_right, - args.col_bot_right, - args.col_bot_left, - ); - } - extern fn zguiDrawList_AddRectFilledMultiColor( - draw_list: DrawList, - pmin: *const [2]f32, - pmax: *const [2]f32, - col_upr_left: c_uint, - col_upr_right: c_uint, - col_bot_right: c_uint, - col_bot_left: c_uint, - ) void; - //---------------------------------------------------------------------------------------------- - 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, - }) void { - zguiDrawList_AddQuad( - draw_list, - &args.p1, - &args.p2, - &args.p3, - &args.p4, - args.col, - args.thickness, - ); - } - extern fn zguiDrawList_AddQuad( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - p4: *const [2]f32, - col: u32, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addQuadFilled(draw_list: DrawList, args: struct { - p1: [2]f32, - p2: [2]f32, - p3: [2]f32, - p4: [2]f32, - col: u32, - }) void { - zguiDrawList_AddQuadFilled(draw_list, &args.p1, &args.p2, &args.p3, &args.p4, args.col); - } - extern fn zguiDrawList_AddQuadFilled( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - p4: *const [2]f32, - col: u32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addTriangle(draw_list: DrawList, args: struct { - p1: [2]f32, - p2: [2]f32, - p3: [2]f32, - col: u32, - thickness: f32 = 1.0, - }) void { - zguiDrawList_AddTriangle(draw_list, &args.p1, &args.p2, &args.p3, args.col, args.thickness); - } - extern fn zguiDrawList_AddTriangle( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - col: u32, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addTriangleFilled(draw_list: DrawList, args: struct { - p1: [2]f32, - p2: [2]f32, - p3: [2]f32, - col: u32, - }) void { - zguiDrawList_AddTriangleFilled(draw_list, &args.p1, &args.p2, &args.p3, args.col); - } - extern fn zguiDrawList_AddTriangleFilled( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - col: u32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addCircle(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - col: u32, - num_segments: i32 = 0, - thickness: f32 = 1.0, - }) 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: c_int, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addCircleFilled(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - col: u32, - num_segments: u16 = 0, - }) void { - zguiDrawList_AddCircleFilled(draw_list, &args.p, args.r, args.col, args.num_segments); - } - extern fn zguiDrawList_AddCircleFilled( - draw_list: DrawList, - center: *const [2]f32, - radius: f32, - col: u32, - num_segments: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addNgon(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - col: u32, - num_segments: u32, - thickness: f32 = 1.0, - }) 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: c_int, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addNgonFilled(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - col: u32, - num_segments: u32, - }) void { - zguiDrawList_AddNgonFilled(draw_list, &args.p, args.r, args.col, args.num_segments); - } - extern fn zguiDrawList_AddNgonFilled( - draw_list: DrawList, - center: *const [2]f32, - radius: f32, - col: u32, - num_segments: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addText(draw_list: DrawList, pos: [2]f32, col: u32, comptime fmt: []const u8, args: anytype) void { - const txt = format(fmt, args); - draw_list.addTextUnformatted(pos, col, txt); - } - pub fn addTextUnformatted(draw_list: DrawList, pos: [2]f32, col: u32, txt: []const u8) void { - zguiDrawList_AddText(draw_list, &pos, col, txt.ptr, txt.ptr + txt.len); - } - extern fn zguiDrawList_AddText( - draw_list: DrawList, - pos: *const [2]f32, - col: u32, - text: [*]const u8, - text_end: [*]const u8, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addPolyline(draw_list: DrawList, points: []const [2]f32, args: struct { - col: u32, - flags: DrawFlags = .{}, - thickness: f32 = 1.0, - }) void { - zguiDrawList_AddPolyline( - draw_list, - points.ptr, - @intCast(points.len), - args.col, - args.flags, - args.thickness, - ); - } - extern fn zguiDrawList_AddPolyline( - draw_list: DrawList, - points: [*]const [2]f32, - num_points: c_int, - col: u32, - flags: DrawFlags, - thickness: f32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addConvexPolyFilled( - draw_list: DrawList, - points: []const [2]f32, - col: u32, - ) void { - zguiDrawList_AddConvexPolyFilled( - draw_list, - points.ptr, - @intCast(points.len), - col, - ); - } - extern fn zguiDrawList_AddConvexPolyFilled( - draw_list: DrawList, - points: [*]const [2]f32, - num_points: c_int, - col: u32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addBezierCubic(draw_list: DrawList, args: struct { - p1: [2]f32, - p2: [2]f32, - p3: [2]f32, - p4: [2]f32, - col: u32, - thickness: f32 = 1.0, - num_segments: u32 = 0, - }) void { - zguiDrawList_AddBezierCubic( - draw_list, - &args.p1, - &args.p2, - &args.p3, - &args.p4, - args.col, - args.thickness, - args.num_segments, - ); - } - extern fn zguiDrawList_AddBezierCubic( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - p4: *const [2]f32, - col: u32, - thickness: f32, - num_segments: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - 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, - }) void { - zguiDrawList_AddBezierQuadratic( - draw_list, - &args.p1, - &args.p2, - &args.p3, - args.col, - args.thickness, - args.num_segments, - ); - } - extern fn zguiDrawList_AddBezierQuadratic( - draw_list: DrawList, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - col: u32, - thickness: f32, - num_segments: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - 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, - }) void { - zguiDrawList_AddImage( - draw_list, - user_texture_id, - &args.pmin, - &args.pmax, - &args.uvmin, - &args.uvmax, - args.col, - ); - } - extern fn zguiDrawList_AddImage( - draw_list: DrawList, - user_texture_id: TextureIdent, - pmin: *const [2]f32, - pmax: *const [2]f32, - uvmin: *const [2]f32, - uvmax: *const [2]f32, - col: u32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addImageQuad(draw_list: DrawList, user_texture_id: TextureIdent, args: struct { - p1: [2]f32, - p2: [2]f32, - p3: [2]f32, - p4: [2]f32, - uv1: [2]f32 = .{ 0, 0 }, - uv2: [2]f32 = .{ 1, 0 }, - uv3: [2]f32 = .{ 1, 1 }, - uv4: [2]f32 = .{ 0, 1 }, - col: u32 = 0xff_ff_ff_ff, - }) void { - zguiDrawList_AddImageQuad( - draw_list, - user_texture_id, - &args.p1, - &args.p2, - &args.p3, - &args.p4, - &args.uv1, - &args.uv2, - &args.uv3, - &args.uv4, - args.col, - ); - } - extern fn zguiDrawList_AddImageQuad( - draw_list: DrawList, - user_texture_id: TextureIdent, - p1: *const [2]f32, - p2: *const [2]f32, - p3: *const [2]f32, - p4: *const [2]f32, - uv1: *const [2]f32, - uv2: *const [2]f32, - uv3: *const [2]f32, - uv4: *const [2]f32, - col: u32, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn addImageRounded(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, - rounding: f32 = 4.0, - flags: DrawFlags = .{}, - }) void { - zguiDrawList_AddImageRounded( - draw_list, - user_texture_id, - &args.pmin, - &args.pmax, - &args.uvmin, - &args.uvmax, - args.col, - args.rounding, - args.flags, - ); - } - extern fn zguiDrawList_AddImageRounded( - draw_list: DrawList, - user_texture_id: TextureIdent, - pmin: *const [2]f32, - pmax: *const [2]f32, - uvmin: *const [2]f32, - uvmax: *const [2]f32, - col: u32, - rounding: f32, - flags: DrawFlags, - ) void; - //---------------------------------------------------------------------------------------------- - pub const pathClear = zguiDrawList_PathClear; - extern fn zguiDrawList_PathClear(draw_list: DrawList) void; - //---------------------------------------------------------------------------------------------- - pub fn pathLineTo(draw_list: DrawList, pos: [2]f32) void { - zguiDrawList_PathLineTo(draw_list, &pos); - } - extern fn zguiDrawList_PathLineTo(draw_list: DrawList, pos: *const [2]f32) void; - //---------------------------------------------------------------------------------------------- - pub fn pathLineToMergeDuplicate(draw_list: DrawList, pos: [2]f32) void { - zguiDrawList_PathLineToMergeDuplicate(draw_list, &pos); - } - extern fn zguiDrawList_PathLineToMergeDuplicate(draw_list: DrawList, pos: *const [2]f32) 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; - //---------------------------------------------------------------------------------------------- - pub fn pathStroke(draw_list: DrawList, args: struct { - col: u32, - flags: DrawFlags = .{}, - thickness: f32 = 1.0, - }) 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; - //---------------------------------------------------------------------------------------------- - pub fn pathArcTo(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - amin: f32, - amax: f32, - num_segments: u16 = 0, - }) void { - zguiDrawList_PathArcTo( - draw_list, - &args.p, - args.r, - args.amin, - args.amax, - args.num_segments, - ); - } - extern fn zguiDrawList_PathArcTo( - draw_list: DrawList, - center: *const [2]f32, - radius: f32, - amin: f32, - amax: f32, - num_segments: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn pathArcToFast(draw_list: DrawList, args: struct { - p: [2]f32, - r: f32, - 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: c_int, - a_max_of_12: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn pathBezierCubicCurveTo(draw_list: DrawList, args: struct { - p2: [2]f32, - p3: [2]f32, - p4: [2]f32, - 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: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - pub fn pathBezierQuadraticCurveTo(draw_list: DrawList, args: struct { - p2: [2]f32, - p3: [2]f32, - 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: c_int, - ) void; - //---------------------------------------------------------------------------------------------- - const PathRect = struct { - bmin: [2]f32, - bmax: [2]f32, - rounding: f32 = 0.0, - flags: DrawFlags = .{}, - }; - pub fn pathRect(draw_list: DrawList, args: PathRect) void { - zguiDrawList_PathRect(draw_list, &args.bmin, &args.bmax, args.rounding, args.flags); - } - extern fn zguiDrawList_PathRect( - draw_list: DrawList, - rect_min: *const [2]f32, - rect_max: *const [2]f32, - rounding: f32, - flags: DrawFlags, - ) 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, - b: [2]f32, - col: u32, - ) 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, - b: [2]f32, - uv_a: [2]f32, - uv_b: [2]f32, - col: u32, - ) 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, - b: [2]f32, - c: [2]f32, - d: [2]f32, - uv_a: [2]f32, - uv_b: [2]f32, - uv_c: [2]f32, - uv_d: [2]f32, - col: u32, - ) void { - return zguiDrawList_PrimQuadUV(draw_list, &a, &b, &c, &d, &uv_a, &uv_b, &uv_c, &uv_d, col); - } - extern fn zguiDrawList_PrimQuadUV( - draw_list: DrawList, - a: *const [2]f32, - b: *const [2]f32, - c: *const [2]f32, - d: *const [2]f32, - uv_a: *const [2]f32, - uv_b: *const [2]f32, - uv_c: *const [2]f32, - 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, - ) void; - - //---------------------------------------------------------------------------------------------- - - pub fn addCallback(draw_list: DrawList, callback: DrawCallback, callback_data: ?*anyopaque) void { - zguiDrawList_AddCallback(draw_list, callback, callback_data); - } - extern fn zguiDrawList_AddCallback(draw_list: DrawList, callback: DrawCallback, callback_data: ?*anyopaque) void; - pub fn addResetRenderStateCallback(draw_list: DrawList) void { - zguiDrawList_AddResetRenderStateCallback(draw_list); - } - extern fn zguiDrawList_AddResetRenderStateCallback(draw_list: DrawList) void; -}; - -fn Vector(comptime T: type) type { - return extern struct { - len: c_int, - capacity: c_int, - items: [*]T, - }; -} - -test { - 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/vendor/zgui/src/plot.zig b/vendor/zgui/src/plot.zig deleted file mode 100644 index 8d210f4..0000000 --- a/vendor/zgui/src/plot.zig +++ /dev/null @@ -1,596 +0,0 @@ -//-------------------------------------------------------------------------------------------------- -const assert = @import("std").debug.assert; -const gui = @import("gui.zig"); -//-------------------------------------------------------------------------------------------------- -pub fn init() void { - if (zguiPlot_GetCurrentContext() == null) { - _ = zguiPlot_CreateContext(); - } -} -pub fn deinit() void { - if (zguiPlot_GetCurrentContext() != null) { - zguiPlot_DestroyContext(null); - } -} -const Context = *opaque {}; - -extern fn zguiPlot_GetCurrentContext() ?Context; -extern fn zguiPlot_CreateContext() Context; -extern fn zguiPlot_DestroyContext(ctx: ?Context) void; -//-------------------------------------------------------------------------------------------------- -pub const Marker = enum(i32) { - none = -1, - circle = 0, - square, - diamond, - up, - down, - left, - right, - cross, - plus, - asterisk, -}; - -pub const Colormap = enum(u32) { - deep, - dark, - pastel, - paired, - viridis, - plasma, - hot, - cool, - pink, - jet, - twilight, - rd_bu, - br_b_g, - pi_y_g, - spectral, - greys, -}; - -pub const Style = extern struct { - line_weight: f32, - marker: Marker, - marker_size: f32, - marker_weight: f32, - fill_alpha: f32, - error_bar_size: f32, - error_bar_weight: f32, - digital_bit_height: f32, - digital_bit_gap: f32, - plot_border_size: f32, - minor_alpha: f32, - major_tick_len: [2]f32, - minor_tick_len: [2]f32, - major_tick_size: [2]f32, - minor_tick_size: [2]f32, - major_grid_size: [2]f32, - minor_grid_size: [2]f32, - plot_padding: [2]f32, - label_padding: [2]f32, - legend_padding: [2]f32, - legend_inner_padding: [2]f32, - legend_spacing: [2]f32, - mouse_pos_padding: [2]f32, - annotation_padding: [2]f32, - fit_padding: [2]f32, - plot_default_size: [2]f32, - plot_min_size: [2]f32, - - colors: [@typeInfo(StyleCol).Enum.fields.len][4]f32, - colormap: Colormap, - - use_local_time: bool, - use_iso_8601: bool, - use_24h_clock: bool, - - /// `pub fn init() Style` - pub const init = zguiPlotStyle_Init; - extern fn zguiPlotStyle_Init() Style; - - pub fn getColor(style: Style, idx: StyleCol) [4]f32 { - return style.colors[@intFromEnum(idx)]; - } - pub fn setColor(style: *Style, idx: StyleCol, color: [4]f32) void { - style.colors[@intFromEnum(idx)] = color; - } -}; -/// `pub fn getStyle() *Style` -pub const getStyle = zguiPlot_GetStyle; -extern fn zguiPlot_GetStyle() *Style; -//-------------------------------------------------------------------------------------------------- -pub const StyleCol = enum(u32) { - line, - fill, - marker_outline, - marker_fill, - error_bar, - frame_bg, - plot_bg, - plot_border, - legend_bg, - legend_border, - legend_text, - title_text, - inlay_text, - axis_text, - axis_grid, - axis_tick, - axis_bg, - axis_bg_hovered, - axis_bg_active, - selection, - crosshairs, -}; -const PushStyleColor4f = struct { - idx: StyleCol, - c: [4]f32, -}; -pub fn pushStyleColor4f(args: PushStyleColor4f) void { - zguiPlot_PushStyleColor4f(args.idx, &args.c); -} -const PushStyleColor1u = struct { - idx: StyleCol, - c: u32, -}; -pub fn pushStyleColor1u(args: PushStyleColor1u) void { - zguiPlot_PushStyleColor1u(args.idx, args.c); -} -const PopStyleColor = struct { - count: i32 = 1, -}; -pub fn popStyleColor(args: PopStyleColor) void { - zguiPlot_PopStyleColor(args.count); -} -extern fn zguiPlot_PushStyleColor4f(idx: StyleCol, col: *const [4]f32) void; -extern fn zguiPlot_PushStyleColor1u(idx: StyleCol, col: u32) void; -extern fn zguiPlot_PopStyleColor(count: i32) void; -//-------------------------------------------------------------------------------------------------- -pub const StyleVar = enum(u32) { - line_weight, // 1f - marker, // 1i - marker_size, // 1f - marker_weight, // 1f - fill_alpha, // 1f - error_bar_size, // 1f - error_bar_weight, // 1f - digital_bit_height, // 1f - digital_bit_gap, // 1f - plot_border_size, // 1f - minor_alpha, // 1f - major_tick_len, // 2f - minor_tick_len, // 2f - major_tick_size, // 2f - minor_tick_size, // 2f - major_grid_size, // 2f - minor_grid_size, // 2f - plot_padding, // 2f - label_padding, // 2f - legend_padding, // 2f - legend_inner_padding, // 2f - legend_spacing, // 2f - mouse_pos_padding, // 2f - annotation_padding, // 2f - fit_padding, // 2f - plot_default_size, // 2f - plot_min_size, // 2f -}; -const PushStyleVar1i = struct { - idx: StyleVar, - v: i32, -}; -pub fn pushStyleVar1i(args: PushStyleVar1i) void { - zguiPlot_PushStyleVar1i(args.idx, args.v); -} -const PushStyleVar1f = struct { - idx: StyleVar, - v: f32, -}; -pub fn pushStyleVar1f(args: PushStyleVar1f) void { - zguiPlot_PushStyleVar1f(args.idx, args.v); -} -const PushStyleVar2f = struct { - idx: StyleVar, - v: [2]f32, -}; -pub fn pushStyleVar2f(args: PushStyleVar2f) void { - zguiPlot_PushStyleVar2f(args.idx, &args.v); -} -const PopStyleVar = struct { - count: i32 = 1, -}; -pub fn popStyleVar(args: PopStyleVar) void { - zguiPlot_PopStyleVar(args.count); -} -extern fn zguiPlot_PushStyleVar1i(idx: StyleVar, v: i32) void; -extern fn zguiPlot_PushStyleVar1f(idx: StyleVar, v: f32) void; -extern fn zguiPlot_PushStyleVar2f(idx: StyleVar, v: *const [2]f32) void; -extern fn zguiPlot_PopStyleVar(count: i32) void; -//-------------------------------------------------------------------------------------------------- -pub const PlotLocation = packed struct(u32) { - north: bool = false, - south: bool = false, - west: bool = false, - east: bool = false, - _padding: u28 = 0, - - pub const north_west = PlotLocation{ .north = true, .west = true }; - pub const north_east = PlotLocation{ .north = true, .east = true }; - pub const south_west = PlotLocation{ .south = true, .west = true }; - pub const south_east = PlotLocation{ .south = true, .east = true }; -}; -pub const LegendFlags = packed struct(u32) { - no_buttons: bool = false, - no_highlight_item: bool = false, - no_highlight_axis: bool = false, - no_menus: bool = false, - outside: bool = false, - horizontal: bool = false, - _padding: u26 = 0, -}; -pub fn setupLegend(location: PlotLocation, flags: LegendFlags) void { - zguiPlot_SetupLegend(location, flags); -} -extern fn zguiPlot_SetupLegend(location: PlotLocation, flags: LegendFlags) void; -//-------------------------------------------------------------------------------------------------- -pub const AxisFlags = packed struct(u32) { - no_label: bool = false, - no_grid_lines: bool = false, - no_tick_marks: bool = false, - no_tick_labels: bool = false, - no_initial_fit: bool = false, - no_menus: bool = false, - no_side_switch: bool = false, - no_highlight: bool = false, - opposite: bool = false, - foreground: bool = false, - invert: bool = false, - auto_fit: bool = false, - range_fit: bool = false, - pan_stretch: bool = false, - lock_min: bool = false, - lock_max: bool = false, - _padding: u16 = 0, - - pub const lock = AxisFlags{ - .lock_min = true, - .lock_max = true, - }; - pub const no_decorations = AxisFlags{ - .no_label = true, - .no_grid_lines = true, - .no_tick_marks = true, - .no_tick_labels = true, - }; - pub const aux_default = AxisFlags{ - .no_grid_lines = true, - .opposite = true, - }; -}; -pub const Axis = enum(u32) { x1, x2, x3, y1, y2, y3 }; -pub const SetupAxis = struct { - label: ?[:0]const u8 = null, - flags: AxisFlags = .{}, -}; -pub fn setupAxis(axis: Axis, args: SetupAxis) void { - zguiPlot_SetupAxis(axis, if (args.label) |l| l else null, args.flags); -} -extern fn zguiPlot_SetupAxis(axis: Axis, label: ?[*:0]const u8, flags: AxisFlags) void; -//---------------------------------------------------------------------------------------------- -pub const Condition = enum(u32) { - none = @intFromEnum(gui.Condition.none), - always = @intFromEnum(gui.Condition.always), - once = @intFromEnum(gui.Condition.once), -}; -const SetupAxisLimits = struct { - min: f64, - max: f64, - cond: Condition = .once, -}; -pub fn setupAxisLimits(axis: Axis, args: SetupAxisLimits) void { - zguiPlot_SetupAxisLimits(axis, args.min, args.max, args.cond); -} -extern fn zguiPlot_SetupAxisLimits(axis: Axis, min: f64, max: f64, cond: Condition) void; -//---------------------------------------------------------------------------------------------- -/// `pub fn setupFinish() void` -pub const setupFinish = zguiPlot_SetupFinish; -extern fn zguiPlot_SetupFinish() void; -//---------------------------------------------------------------------------------------------- -pub const Flags = packed struct(u32) { - no_title: bool = false, - no_legend: bool = false, - no_mouse_text: bool = false, - no_inputs: bool = false, - no_menus: bool = false, - no_box_select: bool = false, - no_child: bool = false, - no_frame: bool = false, - equal: bool = false, - crosshairs: bool = false, - _padding: u22 = 0, - - pub const canvas_only = Flags{ - .no_title = true, - .no_legend = true, - .no_menus = true, - .no_box_select = true, - .no_mouse_text = true, - }; -}; -pub const BeginPlot = struct { - w: f32 = -1.0, - h: f32 = 0.0, - flags: Flags = .{}, -}; -pub fn beginPlot(title_id: [:0]const u8, args: BeginPlot) bool { - return zguiPlot_BeginPlot(title_id, args.w, args.h, args.flags); -} -extern fn zguiPlot_BeginPlot(title_id: [*:0]const u8, width: f32, height: f32, flags: Flags) bool; -//---------------------------------------------------------------------------------------------- -pub const LineFlags = packed struct(u32) { - _reserved0: bool = false, - _reserved1: bool = false, - _reserved2: bool = false, - _reserved3: bool = false, - _reserved4: bool = false, - _reserved5: bool = false, - _reserved6: bool = false, - _reserved7: bool = false, - _reserved8: bool = false, - _reserved9: bool = false, - segments: bool = false, - loop: bool = false, - skip_nan: bool = false, - no_clip: bool = false, - shaded: bool = false, - _padding: u17 = 0, -}; -fn PlotLineValuesGen(comptime T: type) type { - return struct { - v: []const T, - xscale: f64 = 1.0, - xstart: f64 = 0.0, - flags: LineFlags = .{}, - offset: i32 = 0, - stride: i32 = @sizeOf(T), - }; -} -pub fn plotLineValues(label_id: [:0]const u8, comptime T: type, args: PlotLineValuesGen(T)) void { - zguiPlot_PlotLineValues( - label_id, - gui.typeToDataTypeEnum(T), - args.v.ptr, - @as(i32, @intCast(args.v.len)), - args.xscale, - args.xstart, - args.flags, - args.offset, - args.stride, - ); -} -extern fn zguiPlot_PlotLineValues( - label_id: [*:0]const u8, - data_type: gui.DataType, - values: *const anyopaque, - count: i32, - xscale: f64, - xstart: f64, - flags: LineFlags, - offset: i32, - stride: i32, -) void; -//---------------------------------------------------------------------------------------------- -fn PlotLineGen(comptime T: type) type { - return struct { - xv: []const T, - yv: []const T, - flags: LineFlags = .{}, - offset: i32 = 0, - stride: i32 = @sizeOf(T), - }; -} -pub fn plotLine(label_id: [:0]const u8, comptime T: type, args: PlotLineGen(T)) void { - assert(args.xv.len == args.yv.len); - zguiPlot_PlotLine( - label_id, - gui.typeToDataTypeEnum(T), - args.xv.ptr, - args.yv.ptr, - @as(i32, @intCast(args.xv.len)), - args.flags, - args.offset, - args.stride, - ); -} -extern fn zguiPlot_PlotLine( - label_id: [*:0]const u8, - data_type: gui.DataType, - xv: *const anyopaque, - yv: *const anyopaque, - count: i32, - flags: LineFlags, - offset: i32, - stride: i32, -) void; -//---------------------------------------------------------------------------------------------- -pub const ScatterFlags = packed struct(u32) { - _reserved0: bool = false, - _reserved1: bool = false, - _reserved2: bool = false, - _reserved3: bool = false, - _reserved4: bool = false, - _reserved5: bool = false, - _reserved6: bool = false, - _reserved7: bool = false, - _reserved8: bool = false, - _reserved9: bool = false, - no_clip: bool = false, - _padding: u21 = 0, -}; -fn PlotScatterValuesGen(comptime T: type) type { - return struct { - v: []const T, - xscale: f64 = 1.0, - xstart: f64 = 0.0, - flags: ScatterFlags = .{}, - offset: i32 = 0, - stride: i32 = @sizeOf(T), - }; -} -pub fn plotScatterValues(label_id: [:0]const u8, comptime T: type, args: PlotScatterValuesGen(T)) void { - zguiPlot_PlotScatterValues( - label_id, - gui.typeToDataTypeEnum(T), - args.v.ptr, - @as(i32, @intCast(args.v.len)), - args.xscale, - args.xstart, - args.flags, - args.offset, - args.stride, - ); -} -extern fn zguiPlot_PlotScatterValues( - label_id: [*:0]const u8, - data_type: gui.DataType, - values: *const anyopaque, - count: i32, - xscale: f64, - xstart: f64, - flags: ScatterFlags, - offset: i32, - stride: i32, -) void; -//---------------------------------------------------------------------------------------------- -fn PlotScatterGen(comptime T: type) type { - return struct { - xv: []const T, - yv: []const T, - flags: ScatterFlags = .{}, - offset: i32 = 0, - stride: i32 = @sizeOf(T), - }; -} -pub fn plotScatter(label_id: [:0]const u8, comptime T: type, args: PlotScatterGen(T)) void { - assert(args.xv.len == args.yv.len); - zguiPlot_PlotScatter( - label_id, - gui.typeToDataTypeEnum(T), - args.xv.ptr, - args.yv.ptr, - @as(i32, @intCast(args.xv.len)), - args.flags, - args.offset, - args.stride, - ); -} -extern fn zguiPlot_PlotScatter( - label_id: [*:0]const u8, - data_type: gui.DataType, - xv: *const anyopaque, - yv: *const anyopaque, - count: i32, - flags: ScatterFlags, - offset: i32, - stride: i32, -) void; - -pub const ShadedFlags = packed struct(u32) { - _padding: u32 = 0, -}; -fn PlotShadedGen(comptime T: type) type { - return struct { - xv: []const T, - yv: []const T, - yref: f64 = 0.0, - flags: ShadedFlags = .{}, - offset: i32 = 0, - stride: i32 = @sizeOf(T), - }; -} -pub fn plotShaded(label_id: [:0]const u8, comptime T: type, args: PlotShadedGen(T)) void { - assert(args.xv.len == args.yv.len); - zguiPlot_PlotShaded( - label_id, - gui.typeToDataTypeEnum(T), - args.xv.ptr, - args.yv.ptr, - @as(i32, @intCast(args.xv.len)), - args.yref, - args.flags, - args.offset, - args.stride, - ); -} -extern fn zguiPlot_PlotShaded( - label_id: [*:0]const u8, - data_type: gui.DataType, - xv: *const anyopaque, - yv: *const anyopaque, - count: i32, - yref: f64, - flags: ShadedFlags, - offset: i32, - stride: i32, -) void; -//---------------------------------------------------------------------------------------------- -pub const DragToolFlags = packed struct(u32) { - no_cursors: bool = false, - no_fit: bool = false, - no_no_inputs: bool = false, - delayed: bool = false, - _padding: u28 = 0, -}; -const DragPoint = struct { - x: *f64, - y: *f64, - col: [4]f32, - size: f32 = 4, - flags: DragToolFlags = .{}, -}; -pub fn dragPoint(id: i32, args: DragPoint) bool { - return zguiPlot_DragPoint( - id, - args.x, - args.y, - &args.col, - args.size, - args.flags, - ); -} -extern fn zguiPlot_DragPoint(id: i32, x: *f64, y: *f64, *const [4]f32, size: f32, flags: DragToolFlags) bool; -//---------------------------------------------------------------------------------------------- -// PlotText -const PlotTextFlags = packed struct(u32) { - vertical: bool = false, - _padding: u31 = 0, -}; -const PlotText = struct { - x: f64, - y: f64, - pix_offset: [2]f32 = .{ 0, 0 }, - flags: PlotTextFlags = .{}, -}; -pub fn plotText(text: [*:0]const u8, args: PlotText) void { - zguiPlot_PlotText(text, args.x, args.y, &args.pix_offset, args.flags); -} -extern fn zguiPlot_PlotText( - text: [*:0]const u8, - x: f64, - y: f64, - pix_offset: *const [2]f32, - flags: PlotTextFlags, -) void; - -//---------------------------------------------------------------------------------------------- -/// `pub fn showDemoWindow(popen: ?*bool) void` -pub const showDemoWindow = zguiPlot_ShowDemoWindow; -extern fn zguiPlot_ShowDemoWindow(popen: ?*bool) void; -//---------------------------------------------------------------------------------------------- -/// `pub fn endPlot() void` -pub const endPlot = zguiPlot_EndPlot; -extern fn zguiPlot_EndPlot() void; -//---------------------------------------------------------------------------------------------- diff --git a/vendor/zgui/src/te.zig b/vendor/zgui/src/te.zig deleted file mode 100644 index efd1eab..0000000 --- a/vendor/zgui/src/te.zig +++ /dev/null @@ -1,255 +0,0 @@ -const std = @import("std"); -const zgui = @import("gui.zig"); -const te_enabled = @import("zgui_options").with_te; - -pub const Actions = enum(c_int) { - unknown = 0, - /// Move mouse - hover, - /// Move mouse and click - click, - /// Move mouse and double-click - double_click, - /// Check item if unchecked (Checkbox, MenuItem or any widget reporting ImGuiItemStatusFlags_Checkable) - check, - /// Uncheck item if checked - uncheck, - /// Open item if closed (TreeNode, BeginMenu or any widget reporting ImGuiItemStatusFlags_Openable) - open, - /// Close item if opened - close, - /// Start text inputing into a field (e.g. CTRL+Click on Drags/Slider, click on InputText etc.) - input, - /// Activate item with navigation - nav_activate, -}; - -pub const TestRunFlags = packed struct(c_int) { - /// Used internally to temporarily disable the GUI func (at the end of a test, etc) - gui_func_disable: bool = false, - /// Set when user selects "Run GUI func" - gui_func_only: bool = false, - no_success_mgs: bool = false, - no_stop_on_error: bool = false, - no_break_on_error: bool = false, - /// Disable input submission to let test submission raw input event (in order to test e.g. IO queue) - enable_raw_inputs: bool = false, - manual_run: bool = false, - command_line: bool = false, - _padding: u24 = 0, -}; - -pub const TestOpFlags = packed struct(c_int) { - // Don't check for HoveredId after aiming for a widget. A few situations may want this: while e.g. dragging or another items prevents hovering, or for items that don't use ItemHoverable() - no_check_hovered_id: bool = false, - /// Don't abort/error e.g. if the item cannot be found or the operation doesn't succeed. - no_error: bool = false, - /// Don't focus window when aiming at an item - no_focus_window: bool = false, - /// Disable automatically uncollapsing windows (useful when specifically testing Collapsing behaviors) - no_auto_uncollapse: bool = false, - /// Disable automatically opening intermediaries (e.g. ItemClick("Hello/OK") will automatically first open "Hello" if "OK" isn't found. Only works if ref is a string path. - no_auto_open_full_path: bool = false, - /// Used by recursing functions to indicate a second attempt - is_second_attempt: bool = false, - move_to_edge_l: bool = false, // Simple Dumb aiming helpers to test widget that care about clicking position. May need to replace will better functionalities. - move_to_edge_r: bool = false, - move_to_edge_u: bool = false, - move_to_edge_d: bool = false, - _padding: u22 = 0, -}; - -pub const CheckFlags = packed struct(c_int) { - silent_success: bool = false, - _padding: u31 = 0, -}; - -pub const RunSpeed = enum(c_int) { - /// Run tests as fast as possible (teleport mouse, skip delays, etc.) - fast = 0, - /// Run tests at human watchable speed (for debugging) - normal = 1, - /// Run tests with pauses between actions (for e.g. tutorials) - cinematic = 2, -}; - -pub const TestGroup = enum(c_int) { - unknown = -1, - tests = 0, - perfs = 1, -}; - -pub const Test = anyopaque; - -pub const TestEngine = opaque { - pub fn registerTest( - engine: *TestEngine, - category: [:0]const u8, - name: [:0]const u8, - src: std.builtin.SourceLocation, - comptime Callbacks: type, - ) *Test { - return zguiTe_RegisterTest( - engine, - category.ptr, - name.ptr, - src.file.ptr, - @intCast(src.line), - if (std.meta.hasFn(Callbacks, "gui")) - struct { - fn f(context: *TestContext) callconv(.C) void { - Callbacks.gui(context) catch undefined; - } - }.f - else - null, - if (std.meta.hasFn(Callbacks, "run")) - struct { - fn f(context: *TestContext) callconv(.C) void { - Callbacks.run(context) catch undefined; - } - }.f - else - null, - ); - } - - pub const showTestEngineWindows = zguiTe_ShowTestEngineWindows; - extern fn zguiTe_ShowTestEngineWindows(engine: *TestEngine, p_open: ?*bool) void; - - pub const setRunSpeed = zguiTe_EngineSetRunSpeed; - extern fn zguiTe_EngineSetRunSpeed(engine: *TestEngine, speed: RunSpeed) void; - - pub const stop = zguiTe_Stop; - extern fn zguiTe_Stop(engine: *TestEngine) void; - - pub const tryAbortEngine = zguiTe_TryAbortEngine; - extern fn zguiTe_TryAbortEngine(engine: *TestEngine) void; - - pub const postSwap = zguiTe_PostSwap; - extern fn zguiTe_PostSwap(engine: *TestEngine) void; - - pub const isTestQueueEmpty = zguiTe_IsTestQueueEmpty; - extern fn zguiTe_IsTestQueueEmpty(engine: *TestEngine) bool; - - pub const getResult = zguiTe_GetResult; - extern fn zguiTe_GetResult(engine: *TestEngine, count_tested: *c_int, count_success: *c_int) void; - - pub const printResultSummary = zguiTe_PrintResultSummary; - extern fn zguiTe_PrintResultSummary(engine: *TestEngine) void; - - pub fn queueTests(engine: *TestEngine, group: TestGroup, filter_str: [:0]const u8, run_flags: TestRunFlags) void { - zguiTe_QueueTests(engine, group, filter_str.ptr, run_flags); - } - extern fn zguiTe_QueueTests(engine: *TestEngine, group: TestGroup, filter_str: [*]const u8, run_flags: TestRunFlags) void; - - pub fn exportJunitResult(engine: *TestEngine, filename: [:0]const u8) void { - zguiTe_EngineExportJunitResult(engine, filename.ptr); - } - extern fn zguiTe_EngineExportJunitResult(engine: *TestEngine, filename: [*]const u8) void; -}; - -pub const TestContext = opaque { - pub fn setRef(ctx: *TestContext, ref: [:0]const u8) void { - return zguiTe_ContextSetRef(ctx, ref.ptr); - } - - pub fn windowFocus(ctx: *TestContext, ref: [:0]const u8) void { - return zguiTe_ContextWindowFocus(ctx, ref.ptr); - } - - pub fn yield(ctx: *TestContext, frame_count: i32) void { - return zguiTe_ContextYield(ctx, frame_count); - } - - pub fn itemAction(ctx: *TestContext, action: Actions, ref: [:0]const u8, flags: TestOpFlags, action_arg: ?*anyopaque) void { - return zguiTe_ContextItemAction(ctx, action, ref.ptr, flags, action_arg); - } - - pub fn itemInputStrValue(ctx: *TestContext, ref: [:0]const u8, value: [:0]const u8) void { - return zguiTe_ContextItemInputStrValue(ctx, ref.ptr, value.ptr); - } - - pub fn itemInputIntValue(ctx: *TestContext, ref: [:0]const u8, value: i32) void { - return zguiTe_ContextItemInputIntValue(ctx, ref.ptr, value); - } - - pub fn itemInputFloatValue(ctx: *TestContext, ref: [:0]const u8, value: f32) void { - return zguiTe_ContextItemInputFloatValue(ctx, ref.ptr, value); - } - - pub fn menuAction(ctx: *TestContext, action: Actions, ref: [*]const u8) void { - return zguiTe_ContextMenuAction(ctx, action, ref); - } - - pub fn dragAndDrop(ctx: *TestContext, ref_src: [:0]const u8, ref_dst: [:0]const u8, button: zgui.MouseButton) void { - return zguiTe_ContextDragAndDrop(ctx, ref_src.ptr, ref_dst.ptr, button); - } - - pub fn keyDown(ctx: *TestContext, key_chord: c_int) void { - return zguiTe_ContextKeyDown(ctx, key_chord); - } - - pub fn keyUp(ctx: *TestContext, key_chord: c_int) void { - return zguiTe_ContextKeyUp(ctx, key_chord); - } - - extern fn zguiTe_ContextSetRef(ctx: *TestContext, ref: [*]const u8) void; - extern fn zguiTe_ContextWindowFocus(ctx: *TestContext, ref: [*]const u8) void; - extern fn zguiTe_ContextYield(ctx: *TestContext, frame_count: c_int) void; - extern fn zguiTe_ContextMenuAction(ctx: *TestContext, action: Actions, ref: [*]const u8) void; - extern fn zguiTe_ContextItemAction(ctx: *TestContext, action: Actions, ref: [*]const u8, flags: TestOpFlags, action_arg: ?*anyopaque) void; - extern fn zguiTe_ContextItemInputStrValue(ctx: *TestContext, ref: [*]const u8, value: [*]const u8) void; - extern fn zguiTe_ContextItemInputIntValue(ctx: *TestContext, ref: [*]const u8, value: i32) void; - extern fn zguiTe_ContextItemInputFloatValue(ctx: *TestContext, ref: [*]const u8, value: f32) void; - extern fn zguiTe_ContextDragAndDrop(ctx: *TestContext, ref_src: [*]const u8, ref_dst: [*]const u8, button: zgui.MouseButton) void; - extern fn zguiTe_ContextKeyDown(ctx: *TestContext, key_chord: c_int) void; - extern fn zguiTe_ContextKeyUp(ctx: *TestContext, key_chord: c_int) void; -}; - -const ImGuiTestGuiFunc = fn (context: *TestContext) callconv(.C) void; -const ImGuiTestTestFunc = fn (context: *TestContext) callconv(.C) void; - -pub const createContext = zguiTe_CreateContext; -extern fn zguiTe_CreateContext() *TestEngine; - -pub const destroyContext = zguiTe_DestroyContext; -extern fn zguiTe_DestroyContext(engine: *TestEngine) void; - -extern fn zguiTe_Check(filename: [*]const u8, func: [*]const u8, line: u32, flags: CheckFlags, resul: bool, expr: [*]const u8) bool; - -pub fn check(src: std.builtin.SourceLocation, flags: CheckFlags, resul: bool, expr: [:0]const u8) bool { - return zguiTe_Check(src.file.ptr, src.fn_name.ptr, src.line, flags, resul, expr.ptr); -} - -pub extern fn zguiTe_RegisterTest( - engine: *TestEngine, - category: [*]const u8, - name: [*]const u8, - src: [*]const u8, - src_line: c_int, - gui_fce: ?*const ImGuiTestGuiFunc, - gui_test_fce: ?*const ImGuiTestTestFunc, -) *Test; - -pub fn checkTestError( - src: std.builtin.SourceLocation, - err: anyerror, -) void { - var buff: [128:0]u8 = undefined; - const msg = std.fmt.bufPrintZ(&buff, "Assert error: {}", .{err}) catch undefined; - _ = zguiTe_Check(src.file.ptr, src.fn_name.ptr, src.line, .{}, false, msg.ptr); -} - -var _te_engine: ?*TestEngine = null; -pub fn getTestEngine() ?*TestEngine { - return _te_engine; -} - -pub fn init() void { - _te_engine = createContext(); -} - -pub fn deinit() void { - destroyContext(_te_engine.?); -} diff --git a/vendor/zgui/src/zgui.cpp b/vendor/zgui/src/zgui.cpp deleted file mode 100644 index 658b009..0000000 --- a/vendor/zgui/src/zgui.cpp +++ /dev/null @@ -1,2708 +0,0 @@ -#include "imgui.h" - -#if ZGUI_IMPLOT -#include "implot.h" -#endif - -#if ZGUI_TE -#include "imgui_te_engine.h" -#include "imgui_te_context.h" -#include "imgui_te_ui.h" -#include "imgui_te_utils.h" -#include "imgui_te_exporters.h" -#endif - -#include "imgui_internal.h" - -#ifndef ZGUI_API -#define ZGUI_API -#endif - -extern "C" { - -/* -#include <stdio.h> - -ZGUI_API float zguiGetFloatMin(void) { - printf("__FLT_MIN__ %.32e\n", __FLT_MIN__); - return __FLT_MIN__; -} - -ZGUI_API float zguiGetFloatMax(void) { - printf("__FLT_MAX__ %.32e\n", __FLT_MAX__); - return __FLT_MAX__; -} -*/ - -ZGUI_API void zguiSetAllocatorFunctions( - void* (*alloc_func)(size_t, void*), - void (*free_func)(void*, void*) -) { - ImGui::SetAllocatorFunctions(alloc_func, free_func, nullptr); -} - -ZGUI_API void zguiSetNextWindowPos(float x, float y, ImGuiCond cond, float pivot_x, float pivot_y) { - ImGui::SetNextWindowPos({ x, y }, cond, { pivot_x, pivot_y }); -} - -ZGUI_API void zguiSetNextWindowSize(float w, float h, ImGuiCond cond) { - ImGui::SetNextWindowSize({ w, h }, cond); -} - -ZGUI_API void zguiSetNextWindowCollapsed(bool collapsed, ImGuiCond cond) { - ImGui::SetNextWindowCollapsed(collapsed, cond); -} - -ZGUI_API void zguiSetNextWindowFocus(void) { - ImGui::SetNextWindowFocus(); -} - -ZGUI_API void zguiSetNextWindowBgAlpha(float alpha) { - ImGui::SetNextWindowBgAlpha(alpha); -} - -ZGUI_API void zguiSetWindowFocus(const char* name) { - ImGui::SetWindowFocus(name); -} - -ZGUI_API void zguiSetKeyboardFocusHere(int offset) { - ImGui::SetKeyboardFocusHere(offset); -} - -ZGUI_API bool zguiBegin(const char* name, bool* p_open, ImGuiWindowFlags flags) { - return ImGui::Begin(name, p_open, flags); -} - -ZGUI_API void zguiEnd(void) { - ImGui::End(); -} - -ZGUI_API bool zguiBeginChild(const char* str_id, float w, float h, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags) { - return ImGui::BeginChild(str_id, { w, h }, child_flags, window_flags); -} - -ZGUI_API bool zguiBeginChildId(ImGuiID id, float w, float h, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags) { - return ImGui::BeginChild(id, { w, h }, child_flags, window_flags); -} - -ZGUI_API void zguiEndChild(void) { - ImGui::EndChild(); -} - -ZGUI_API float zguiGetScrollX(void) { - return ImGui::GetScrollX(); -} - -ZGUI_API float zguiGetScrollY(void) { - return ImGui::GetScrollY(); -} - -ZGUI_API void zguiSetScrollX(float scroll_x) { - ImGui::SetScrollX(scroll_x); -} - -ZGUI_API void zguiSetScrollY(float scroll_y) { - ImGui::SetScrollY(scroll_y); -} - -ZGUI_API float zguiGetScrollMaxX(void) { - return ImGui::GetScrollMaxX(); -} - -ZGUI_API float zguiGetScrollMaxY(void) { - return ImGui::GetScrollMaxY(); -} - -ZGUI_API void zguiSetScrollHereX(float center_x_ratio) { - ImGui::SetScrollHereX(center_x_ratio); -} - -ZGUI_API void zguiSetScrollHereY(float center_y_ratio) { - ImGui::SetScrollHereY(center_y_ratio); -} - -ZGUI_API void zguiSetScrollFromPosX(float local_x, float center_x_ratio) { - ImGui::SetScrollFromPosX(local_x, center_x_ratio); -} - -ZGUI_API void zguiSetScrollFromPosY(float local_y, float center_y_ratio) { - ImGui::SetScrollFromPosY(local_y, center_y_ratio); -} - -ZGUI_API bool zguiIsWindowAppearing(void) { - return ImGui::IsWindowAppearing(); -} - -ZGUI_API bool zguiIsWindowCollapsed(void) { - return ImGui::IsWindowCollapsed(); -} - -ZGUI_API bool zguiIsWindowFocused(ImGuiFocusedFlags flags) { - return ImGui::IsWindowFocused(flags); -} - -ZGUI_API bool zguiIsWindowHovered(ImGuiHoveredFlags flags) { - return ImGui::IsWindowHovered(flags); -} - -ZGUI_API void zguiGetWindowPos(float pos[2]) { - const ImVec2 p = ImGui::GetWindowPos(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiGetWindowSize(float size[2]) { - const ImVec2 s = ImGui::GetWindowSize(); - size[0] = s.x; - size[1] = s.y; -} - -ZGUI_API float zguiGetWindowWidth(void) { - return ImGui::GetWindowWidth(); -} - -ZGUI_API float zguiGetWindowHeight(void) { - return ImGui::GetWindowHeight(); -} - -ZGUI_API void zguiGetMouseDragDelta(ImGuiMouseButton button, float lock_threshold, float delta[2]) { - const ImVec2 d = ImGui::GetMouseDragDelta(button, lock_threshold); - delta[0] = d.x; - delta[1] = d.y; -} - -ZGUI_API void zguiResetMouseDragDelta(ImGuiMouseButton button) { - ImGui::ResetMouseDragDelta(button); -} - -ZGUI_API void zguiSpacing(void) { - ImGui::Spacing(); -} - -ZGUI_API void zguiNewLine(void) { - ImGui::NewLine(); -} - -ZGUI_API void zguiIndent(float indent_w) { - ImGui::Indent(indent_w); -} - -ZGUI_API void zguiUnindent(float indent_w) { - ImGui::Unindent(indent_w); -} - -ZGUI_API void zguiSeparator(void) { - ImGui::Separator(); -} - -ZGUI_API void zguiSeparatorText(const char* label) { - ImGui::SeparatorText(label); -} - -ZGUI_API void zguiSameLine(float offset_from_start_x, float spacing) { - ImGui::SameLine(offset_from_start_x, spacing); -} - -ZGUI_API void zguiDummy(float w, float h) { - ImGui::Dummy({ w, h }); -} - -ZGUI_API void zguiBeginGroup(void) { - ImGui::BeginGroup(); -} - -ZGUI_API void zguiEndGroup(void) { - ImGui::EndGroup(); -} - -ZGUI_API void zguiGetItemRectMax(float rect[2]) { - const ImVec2 r = ImGui::GetItemRectMax(); - rect[0] = r.x; - rect[1] = r.y; -} - -ZGUI_API void zguiGetItemRectMin(float rect[2]) { - const ImVec2 r = ImGui::GetItemRectMin(); - rect[0] = r.x; - rect[1] = r.y; -} - -ZGUI_API void zguiGetItemRectSize(float rect[2]) { - const ImVec2 r = ImGui::GetItemRectSize(); - rect[0] = r.x; - rect[1] = r.y; -} - -ZGUI_API void zguiGetCursorPos(float pos[2]) { - const ImVec2 p = ImGui::GetCursorPos(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API float zguiGetCursorPosX(void) { - return ImGui::GetCursorPosX(); -} - -ZGUI_API float zguiGetCursorPosY(void) { - return ImGui::GetCursorPosY(); -} - -ZGUI_API void zguiSetCursorPos(float local_x, float local_y) { - ImGui::SetCursorPos({ local_x, local_y }); -} - -ZGUI_API void zguiSetCursorPosX(float local_x) { - ImGui::SetCursorPosX(local_x); -} - -ZGUI_API void zguiSetCursorPosY(float local_y) { - ImGui::SetCursorPosY(local_y); -} - -ZGUI_API void zguiGetCursorStartPos(float pos[2]) { - const ImVec2 p = ImGui::GetCursorStartPos(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiGetCursorScreenPos(float pos[2]) { - const ImVec2 p = ImGui::GetCursorScreenPos(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiSetCursorScreenPos(float screen_x, float screen_y) { - ImGui::SetCursorScreenPos({ screen_x, screen_y }); -} - -ZGUI_API int zguiGetMouseCursor(void) { - return ImGui::GetMouseCursor(); -} - -ZGUI_API void zguiSetMouseCursor(int cursor) { - ImGui::SetMouseCursor(cursor); -} - -ZGUI_API void zguiGetMousePos(float pos[2]) { - const ImVec2 p = ImGui::GetMousePos(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiAlignTextToFramePadding(void) { - ImGui::AlignTextToFramePadding(); -} - -ZGUI_API float zguiGetTextLineHeight(void) { - return ImGui::GetTextLineHeight(); -} - -ZGUI_API float zguiGetTextLineHeightWithSpacing(void) { - return ImGui::GetTextLineHeightWithSpacing(); -} - -ZGUI_API float zguiGetFrameHeight(void) { - return ImGui::GetFrameHeight(); -} - -ZGUI_API float zguiGetFrameHeightWithSpacing(void) { - return ImGui::GetFrameHeightWithSpacing(); -} - -ZGUI_API bool zguiDragFloat( - const char* label, - float* v, - float v_speed, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragFloat(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragFloat2( - const char* label, - float v[2], - float v_speed, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragFloat2(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragFloat3( - const char* label, - float v[3], - float v_speed, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragFloat3(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragFloat4( - const char* label, - float v[4], - float v_speed, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragFloat4(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragFloatRange2( - const char* label, - float* v_current_min, - float* v_current_max, - float v_speed, - float v_min, - float v_max, - const char* format, - const char* format_max, - ImGuiSliderFlags flags -) { - return ImGui::DragFloatRange2( - label, - v_current_min, - v_current_max, - v_speed, - v_min, - v_max, - format, - format_max, - flags - ); -} - -ZGUI_API bool zguiDragInt( - const char* label, - int* v, - float v_speed, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragInt(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragInt2( - const char* label, - int v[2], - float v_speed, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragInt2(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragInt3( - const char* label, - int v[3], - float v_speed, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragInt3(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragInt4( - const char* label, - int v[4], - float v_speed, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragInt4(label, v, v_speed, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiDragIntRange2( - const char* label, - int* v_current_min, - int* v_current_max, - float v_speed, - int v_min, - int v_max, - const char* format, - const char* format_max, - ImGuiSliderFlags flags -) { - return ImGui::DragIntRange2( - label, - v_current_min, - v_current_max, - v_speed, - v_min, - v_max, - format, - format_max, - flags - ); -} - -ZGUI_API bool zguiDragScalar( - const char* label, - ImGuiDataType data_type, - void* p_data, - float v_speed, - const void* p_min, - const void* p_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::DragScalar(label, data_type, p_data, v_speed, p_min, p_max, format, flags); -} - -ZGUI_API bool zguiDragScalarN( - const char* label, - ImGuiDataType data_type, - void* p_data, - int components, - float v_speed, - const void* p_min, - const void* p_max, - const char* format, - ImGuiSliderFlags flags -) { - 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, - const char* items_separated_by_zeros, - int popup_max_height_in_items -) { - return ImGui::Combo(label, current_item, items_separated_by_zeros, popup_max_height_in_items); -} - -ZGUI_API bool zguiBeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags) { - return ImGui::BeginCombo(label, preview_value, flags); -} - -ZGUI_API void zguiEndCombo(void) { - ImGui::EndCombo(); -} - -ZGUI_API bool zguiBeginListBox(const char* label, float w, float h) { - return ImGui::BeginListBox(label, { w, h }); -} - -ZGUI_API void zguiEndListBox(void) { - ImGui::EndListBox(); -} - -ZGUI_API bool zguiSelectable(const char* label, bool selected, ImGuiSelectableFlags flags, float w, float h) { - return ImGui::Selectable(label, selected, flags, { w, h }); -} - -ZGUI_API bool zguiSelectableStatePtr( - const char* label, - bool* p_selected, - ImGuiSelectableFlags flags, - float w, - float h -) { - return ImGui::Selectable(label, p_selected, flags, { w, h }); -} - -ZGUI_API bool zguiSliderFloat( - const char* label, - float* v, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderFloat(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderFloat2( - const char* label, - float v[2], - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderFloat2(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderFloat3( - const char* label, - float v[3], - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderFloat3(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderFloat4( - const char* label, - float v[4], - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderFloat4(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderInt( - const char* label, - int* v, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderInt(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderInt2( - const char* label, - int v[2], - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderInt2(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderInt3( - const char* label, - int v[3], - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderInt3(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderInt4( - const char* label, - int v[4], - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderInt4(label, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiSliderScalar( - const char* label, - ImGuiDataType data_type, - void* p_data, - const void* p_min, - const void* p_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderScalar(label, data_type, p_data, p_min, p_max, format, flags); -} - -ZGUI_API bool zguiSliderScalarN( - const char* label, - ImGuiDataType data_type, - void* p_data, - int components, - const void* p_min, - const void* p_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderScalarN(label, data_type, p_data, components, p_min, p_max, format, flags); -} - -ZGUI_API bool zguiVSliderFloat( - const char* label, - float w, - float h, - float* v, - float v_min, - float v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::VSliderFloat(label, { w, h }, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiVSliderInt( - const char* label, - float w, - float h, - int* v, - int v_min, - int v_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::VSliderInt(label, { w, h }, v, v_min, v_max, format, flags); -} - -ZGUI_API bool zguiVSliderScalar( - const char* label, - float w, - float h, - ImGuiDataType data_type, - void* p_data, - const void* p_min, - const void* p_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::VSliderScalar(label, { w, h }, data_type, p_data, p_min, p_max, format, flags); -} - -ZGUI_API bool zguiSliderAngle( - const char* label, - float* v_rad, - float v_degrees_min, - float v_degrees_max, - const char* format, - ImGuiSliderFlags flags -) { - return ImGui::SliderAngle(label, v_rad, v_degrees_min, v_degrees_max, format, flags); -} - -ZGUI_API ImGuiInputTextCallbackData zguiInputTextCallbackData_Init(void) { - return ImGuiInputTextCallbackData(); -} - -ZGUI_API void zguiInputTextCallbackData_DeleteChars( - ImGuiInputTextCallbackData* data, - int pos, - int bytes_count -) { - data->DeleteChars(pos, bytes_count); -} - -ZGUI_API void zguiInputTextCallbackData_InsertChars( - ImGuiInputTextCallbackData* data, - int pos, - const char* text, - const char* text_end -) { - data->InsertChars(pos, text, text_end); -} - -ZGUI_API bool zguiInputText( - const char* label, - char* buf, - size_t buf_size, - ImGuiInputTextFlags flags, - ImGuiInputTextCallback callback, - void* user_data -) { - return ImGui::InputText(label, buf, buf_size, flags, callback, user_data); -} - -ZGUI_API bool zguiInputTextMultiline( - const char* label, - char* buf, - size_t buf_size, - float w, - float h, - ImGuiInputTextFlags flags, - ImGuiInputTextCallback callback, - void* user_data -) { - return ImGui::InputTextMultiline(label, buf, buf_size, { w, h }, flags, callback, user_data); -} - -ZGUI_API bool zguiInputTextWithHint( - const char* label, - const char* hint, - char* buf, - size_t buf_size, - ImGuiInputTextFlags flags, - ImGuiInputTextCallback callback, - void* user_data -) { - return ImGui::InputTextWithHint(label, hint, buf, buf_size, flags, callback, user_data); -} - -ZGUI_API bool zguiInputFloat( - const char* label, - float* v, - float step, - float step_fast, - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputFloat(label, v, step, step_fast, format, flags); -} - -ZGUI_API bool zguiInputFloat2( - const char* label, - float v[2], - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputFloat2(label, v, format, flags); -} - -ZGUI_API bool zguiInputFloat3( - const char* label, - float v[3], - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputFloat3(label, v, format, flags); -} - -ZGUI_API bool zguiInputFloat4( - const char* label, - float v[4], - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputFloat4(label, v, format, flags); -} - -ZGUI_API bool zguiInputInt( - const char* label, - int* v, - int step, - int step_fast, - ImGuiInputTextFlags flags -) { - return ImGui::InputInt(label, v, step, step_fast, flags); -} - -ZGUI_API bool zguiInputInt2(const char* label, int v[2], ImGuiInputTextFlags flags) { - return ImGui::InputInt2(label, v, flags); -} - -ZGUI_API bool zguiInputInt3(const char* label, int v[3], ImGuiInputTextFlags flags) { - return ImGui::InputInt3(label, v, flags); -} - -ZGUI_API bool zguiInputInt4(const char* label, int v[4], ImGuiInputTextFlags flags) { - return ImGui::InputInt4(label, v, flags); -} - -ZGUI_API bool zguiInputDouble( - const char* label, - double* v, - double step, - double step_fast, - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputDouble(label, v, step, step_fast, format, flags); -} - -ZGUI_API bool zguiInputScalar( - const char* label, - ImGuiDataType data_type, - void* p_data, - const void* p_step, - const void* p_step_fast, - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputScalar(label, data_type, p_data, p_step, p_step_fast, format, flags); -} - -ZGUI_API bool zguiInputScalarN( - const char* label, - ImGuiDataType data_type, - void* p_data, - int components, - const void* p_step, - const void* p_step_fast, - const char* format, - ImGuiInputTextFlags flags -) { - return ImGui::InputScalarN(label, data_type, p_data, components, p_step, p_step_fast, format, flags); -} - -ZGUI_API bool zguiColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) { - return ImGui::ColorEdit3(label, col, flags); -} - -ZGUI_API bool zguiColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags) { - return ImGui::ColorEdit4(label, col, flags); -} - -ZGUI_API bool zguiColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) { - return ImGui::ColorPicker3(label, col, flags); -} - -ZGUI_API bool zguiColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col) { - return ImGui::ColorPicker4(label, col, flags, ref_col); -} - -ZGUI_API bool zguiColorButton(const char* desc_id, const float col[4], ImGuiColorEditFlags flags, float w, float h) { - return ImGui::ColorButton(desc_id, { col[0], col[1], col[2], col[3] }, flags, { w, h }); -} - -ZGUI_API void zguiTextUnformatted(const char* text, const char* text_end) { - ImGui::TextUnformatted(text, text_end); -} - -ZGUI_API void zguiTextColored(const float col[4], const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ImGui::TextColoredV({ col[0], col[1], col[2], col[3] }, fmt, args); - va_end(args); -} - -ZGUI_API void zguiTextDisabled(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ImGui::TextDisabledV(fmt, args); - va_end(args); -} - -ZGUI_API void zguiTextWrapped(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ImGui::TextWrappedV(fmt, args); - va_end(args); -} - -ZGUI_API void zguiBulletText(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ImGui::BulletTextV(fmt, args); - va_end(args); -} - -ZGUI_API void zguiLabelText(const char* label, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - ImGui::LabelTextV(label, fmt, args); - va_end(args); -} - -ZGUI_API void zguiCalcTextSize( - const char* txt, - const char* txt_end, - bool hide_text_after_double_hash, - float wrap_width, - float* out_w, - float* out_h -) { - assert(out_w && out_h); - const ImVec2 s = ImGui::CalcTextSize(txt, txt_end, hide_text_after_double_hash, wrap_width); - *out_w = s.x; - *out_h = s.y; -} - -ZGUI_API bool zguiButton(const char* label, float x, float y) { - return ImGui::Button(label, { x, y }); -} - -ZGUI_API bool zguiSmallButton(const char* label) { - return ImGui::SmallButton(label); -} - -ZGUI_API bool zguiInvisibleButton(const char* str_id, float w, float h, ImGuiButtonFlags flags) { - return ImGui::InvisibleButton(str_id, { w, h }, flags); -} - -ZGUI_API bool zguiArrowButton(const char* str_id, ImGuiDir dir) { - return ImGui::ArrowButton(str_id, dir); -} - -ZGUI_API void zguiImage( - ImTextureID user_texture_id, - float w, - float h, - const float uv0[2], - const float uv1[2], - const float tint_col[4], - const float border_col[4] -) { - ImGui::Image( - user_texture_id, - { w, h }, - { uv0[0], uv0[1] }, - { uv1[0], uv1[1] }, - { tint_col[0], tint_col[1], tint_col[2], tint_col[3] }, - { border_col[0], border_col[1], border_col[2], border_col[3] } - ); -} - -ZGUI_API bool zguiImageButton( - const char* str_id, - ImTextureID user_texture_id, - float w, - float h, - const float uv0[2], - const float uv1[2], - const float bg_col[4], - const float tint_col[4] -) { - return ImGui::ImageButton( - str_id, - user_texture_id, - { w, h }, - { uv0[0], uv0[1] }, - { uv1[0], uv1[1] }, - { bg_col[0], bg_col[1], bg_col[2], bg_col[3] }, - { tint_col[0], tint_col[1], tint_col[2], tint_col[3] } - ); -} - -ZGUI_API void zguiBullet(void) { - ImGui::Bullet(); -} - -ZGUI_API bool zguiRadioButton(const char* label, bool active) { - return ImGui::RadioButton(label, active); -} - -ZGUI_API bool zguiRadioButtonStatePtr(const char* label, int* v, int v_button) { - return ImGui::RadioButton(label, v, v_button); -} - -ZGUI_API bool zguiCheckbox(const char* label, bool* v) { - return ImGui::Checkbox(label, v); -} - -ZGUI_API bool zguiCheckboxBits(const char* label, unsigned int* bits, unsigned int bits_value) { - return ImGui::CheckboxFlags(label, bits, bits_value); -} - -ZGUI_API void zguiProgressBar(float fraction, float w, float h, const char* overlay) { - return ImGui::ProgressBar(fraction, { w, h }, overlay); -} - -ZGUI_API ImGuiContext* zguiCreateContext(ImFontAtlas* shared_font_atlas) { - return ImGui::CreateContext(shared_font_atlas); -} - -ZGUI_API void zguiDestroyContext(ImGuiContext* ctx) { - ImGui::DestroyContext(ctx); -} - -ZGUI_API ImGuiContext* zguiGetCurrentContext(void) { - return ImGui::GetCurrentContext(); -} - -ZGUI_API void zguiSetCurrentContext(ImGuiContext* ctx) { - ImGui::SetCurrentContext(ctx); -} - -ZGUI_API void zguiNewFrame(void) { - ImGui::NewFrame(); -} - -ZGUI_API void zguiRender(void) { - ImGui::Render(); -} - -ZGUI_API ImDrawData* zguiGetDrawData(void) { - return ImGui::GetDrawData(); -} - -ZGUI_API void zguiShowDemoWindow(bool* p_open) { - ImGui::ShowDemoWindow(p_open); -} - -ZGUI_API void zguiBeginDisabled(bool disabled) { - ImGui::BeginDisabled(disabled); -} - -ZGUI_API void zguiEndDisabled(void) { - ImGui::EndDisabled(); -} - -ZGUI_API ImGuiStyle* zguiGetStyle(void) { - return &ImGui::GetStyle(); -} - -ZGUI_API ImGuiStyle zguiStyle_Init(void) { - return ImGuiStyle(); -} - -ZGUI_API void zguiStyle_ScaleAllSizes(ImGuiStyle* style, float scale_factor) { - style->ScaleAllSizes(scale_factor); -} - -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, ImU32 col) { - ImGui::PushStyleColor(idx, col); -} - -ZGUI_API void zguiPopStyleColor(int count) { - ImGui::PopStyleColor(count); -} - -ZGUI_API void zguiPushStyleVar1f(ImGuiStyleVar idx, float var) { - ImGui::PushStyleVar(idx, var); -} - -ZGUI_API void zguiPushStyleVar2f(ImGuiStyleVar idx, const float var[2]) { - ImGui::PushStyleVar(idx, { var[0], var[1] }); -} - -ZGUI_API void zguiPopStyleVar(int count) { - ImGui::PopStyleVar(count); -} - -ZGUI_API void zguiPushItemWidth(float item_width) { - ImGui::PushItemWidth(item_width); -} - -ZGUI_API void zguiPopItemWidth(void) { - ImGui::PopItemWidth(); -} - -ZGUI_API void zguiSetNextItemWidth(float item_width) { - ImGui::SetNextItemWidth(item_width); -} - -ZGUI_API void zguiSetItemDefaultFocus(void) { - ImGui::SetItemDefaultFocus(); -} - -ZGUI_API ImFont* zguiGetFont(void) { - return ImGui::GetFont(); -} - -ZGUI_API float zguiGetFontSize(void) { - return ImGui::GetFontSize(); -} - -ZGUI_API void zguiGetFontTexUvWhitePixel(float uv[2]) { - const ImVec2 cs = ImGui::GetFontTexUvWhitePixel(); - uv[0] = cs[0]; - uv[1] = cs[1]; -} - -ZGUI_API void zguiPushFont(ImFont* font) { - ImGui::PushFont(font); -} - -ZGUI_API void zguiPopFont(void) { - ImGui::PopFont(); -} - -ZGUI_API bool zguiTreeNode(const char* label) { - return ImGui::TreeNode(label); -} - -ZGUI_API bool zguiTreeNodeFlags(const char* label, ImGuiTreeNodeFlags flags) { - return ImGui::TreeNodeEx(label, flags); -} - -ZGUI_API bool zguiTreeNodeStrId(const char* str_id, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const bool ret = ImGui::TreeNodeV(str_id, fmt, args); - va_end(args); - return ret; -} - -ZGUI_API bool zguiTreeNodeStrIdFlags(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const bool ret = ImGui::TreeNodeExV(str_id, flags, fmt, args); - va_end(args); - return ret; -} - -ZGUI_API bool zguiTreeNodePtrId(const void* ptr_id, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const bool ret = ImGui::TreeNodeV(ptr_id, fmt, args); - va_end(args); - return ret; -} - -ZGUI_API bool zguiTreeNodePtrIdFlags(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const bool ret = ImGui::TreeNodeExV(ptr_id, flags, fmt, args); - va_end(args); - return ret; -} - -ZGUI_API bool zguiCollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) { - return ImGui::CollapsingHeader(label, flags); -} - -ZGUI_API bool zguiCollapsingHeaderStatePtr(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags) { - return ImGui::CollapsingHeader(label, p_visible, flags); -} - -ZGUI_API void zguiSetNextItemOpen(bool is_open, ImGuiCond cond) { - ImGui::SetNextItemOpen(is_open, cond); -} - -ZGUI_API void zguiTreePushStrId(const char* str_id) { - ImGui::TreePush(str_id); -} - -ZGUI_API void zguiTreePushPtrId(const void* ptr_id) { - ImGui::TreePush(ptr_id); -} - -ZGUI_API void zguiTreePop(void) { - ImGui::TreePop(); -} - -ZGUI_API void zguiPushStrId(const char* str_id_begin, const char* str_id_end) { - ImGui::PushID(str_id_begin, str_id_end); -} - -ZGUI_API void zguiPushStrIdZ(const char* str_id) { - ImGui::PushID(str_id); -} - -ZGUI_API void zguiPushPtrId(const void* ptr_id) { - ImGui::PushID(ptr_id); -} - -ZGUI_API void zguiPushIntId(int int_id) { - ImGui::PushID(int_id); -} - -ZGUI_API void zguiPopId(void) { - ImGui::PopID(); -} - -ZGUI_API ImGuiID zguiGetStrId(const char* str_id_begin, const char* str_id_end) { - return ImGui::GetID(str_id_begin, str_id_end); -} - -ZGUI_API ImGuiID zguiGetStrIdZ(const char* str_id) { - return ImGui::GetID(str_id); -} - -ZGUI_API ImGuiID zguiGetPtrId(const void* ptr_id) { - return ImGui::GetID(ptr_id); -} - -ZGUI_API void zguiSetClipboardText(const char* text) { - ImGui::SetClipboardText(text); -} - -ZGUI_API const char* zguiGetClipboardText(void) { - return ImGui::GetClipboardText(); -} - -ZGUI_API ImFont* zguiIoAddFontFromFileWithConfig( - const char* filename, - float size_pixels, - const ImFontConfig* config, - const ImWchar* ranges -) { - return ImGui::GetIO().Fonts->AddFontFromFileTTF(filename, size_pixels, config, ranges); -} - -ZGUI_API ImFont* zguiIoAddFontFromFile(const char* filename, float size_pixels) { - return ImGui::GetIO().Fonts->AddFontFromFileTTF(filename, size_pixels, nullptr, nullptr); -} - -ZGUI_API ImFont* zguiIoAddFontFromMemoryWithConfig( - void* font_data, - int font_size, - float size_pixels, - const ImFontConfig* config, - const ImWchar* ranges -) { - return ImGui::GetIO().Fonts->AddFontFromMemoryTTF(font_data, font_size, size_pixels, config, ranges); -} - -ZGUI_API ImFont* zguiIoAddFontFromMemory(void* font_data, int font_size, float size_pixels) { - ImFontConfig config = ImFontConfig(); - config.FontDataOwnedByAtlas = false; - return ImGui::GetIO().Fonts->AddFontFromMemoryTTF(font_data, font_size, size_pixels, &config, nullptr); -} - -ZGUI_API ImFontConfig zguiFontConfig_Init(void) { - return ImFontConfig(); -} - -ZGUI_API ImFont* zguiIoGetFont(unsigned int index) { - return ImGui::GetIO().Fonts->Fonts[index]; -} - -ZGUI_API void zguiIoSetDefaultFont(ImFont* font) { - ImGui::GetIO().FontDefault = font; -} - -ZGUI_API unsigned char *zguiIoGetFontsTexDataAsRgba32(int *width, int *height) { - unsigned char *font_pixels; - int font_width, font_height; - ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&font_pixels, &font_width, &font_height); - *width = font_width; - *height = font_height; - return font_pixels; -} - -ZGUI_API void zguiIoSetFontsTexId(ImTextureID id) { - ImGui::GetIO().Fonts->TexID = id; -} - -ZGUI_API ImTextureID zguiIoGetFontsTexId(void) { - return ImGui::GetIO().Fonts->TexID; -} - -ZGUI_API void zguiIoSetConfigWindowsMoveFromTitleBarOnly(bool enabled) { - ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = enabled; -} - -ZGUI_API bool zguiIoGetWantCaptureMouse(void) { - return ImGui::GetIO().WantCaptureMouse; -} - -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; -} - -ZGUI_API void zguiIoSetConfigFlags(ImGuiConfigFlags flags) { - ImGui::GetIO().ConfigFlags = flags; -} - -ZGUI_API void zguiIoSetDisplaySize(float width, float height) { - ImGui::GetIO().DisplaySize = { width, height }; -} - -ZGUI_API void zguiIoGetDisplaySize(float size[2]) { - const ImVec2 ds = ImGui::GetIO().DisplaySize; - size[0] = ds[0]; - size[1] = ds[1]; -} - -ZGUI_API void zguiIoSetDisplayFramebufferScale(float sx, float sy) { - ImGui::GetIO().DisplayFramebufferScale = { sx, sy }; -} - -ZGUI_API void zguiIoSetDeltaTime(float delta_time) { - ImGui::GetIO().DeltaTime = delta_time; -} - -ZGUI_API void zguiIoAddFocusEvent(bool focused) { - ImGui::GetIO().AddFocusEvent(focused); -} - -ZGUI_API void zguiIoAddMousePositionEvent(float x, float y) { - ImGui::GetIO().AddMousePosEvent(x, y); -} - -ZGUI_API void zguiIoAddMouseButtonEvent(ImGuiMouseButton button, bool down) { - ImGui::GetIO().AddMouseButtonEvent(button, down); -} - -ZGUI_API void zguiIoAddMouseWheelEvent(float x, float y) { - ImGui::GetIO().AddMouseWheelEvent(x, y); -} - -ZGUI_API void zguiIoAddKeyEvent(ImGuiKey key, bool down) { - ImGui::GetIO().AddKeyEvent(key, down); -} - -ZGUI_API void zguiIoAddInputCharactersUTF8(const char* utf8_chars) { - ImGui::GetIO().AddInputCharactersUTF8(utf8_chars); -} - -ZGUI_API void zguiIoSetKeyEventNativeData(ImGuiKey key, int keycode, int scancode) { - ImGui::GetIO().SetKeyEventNativeData(key, keycode, scancode); -} - -ZGUI_API void zguiIoAddCharacterEvent(unsigned int c) { - ImGui::GetIO().AddInputCharacter(c); -} - - -ZGUI_API bool zguiIsItemHovered(ImGuiHoveredFlags flags) { - return ImGui::IsItemHovered(flags); -} - -ZGUI_API bool zguiIsItemActive(void) { - return ImGui::IsItemActive(); -} - -ZGUI_API bool zguiIsItemFocused(void) { - return ImGui::IsItemFocused(); -} - -ZGUI_API bool zguiIsItemClicked(ImGuiMouseButton mouse_button) { - return ImGui::IsItemClicked(mouse_button); -} - -ZGUI_API bool zguiIsMouseDown(ImGuiMouseButton button) { - return ImGui::IsMouseDown(button); -} - -ZGUI_API bool zguiIsMouseClicked(ImGuiMouseButton button) { - return ImGui::IsMouseClicked(button); -} - -ZGUI_API bool zguiIsMouseDoubleClicked(ImGuiMouseButton button) { - return ImGui::IsMouseDoubleClicked(button); -} - -ZGUI_API bool zguiIsItemVisible(void) { - return ImGui::IsItemVisible(); -} - -ZGUI_API bool zguiIsItemEdited(void) { - return ImGui::IsItemEdited(); -} - -ZGUI_API bool zguiIsItemActivated(void) { - return ImGui::IsItemActivated(); -} - -ZGUI_API bool zguiIsItemDeactivated(void) { - return ImGui::IsItemDeactivated(); -} - -ZGUI_API bool zguiIsItemDeactivatedAfterEdit(void) { - return ImGui::IsItemDeactivatedAfterEdit(); -} - -ZGUI_API bool zguiIsItemToggledOpen(void) { - return ImGui::IsItemToggledOpen(); -} - -ZGUI_API bool zguiIsAnyItemHovered(void) { - return ImGui::IsAnyItemHovered(); -} - -ZGUI_API bool zguiIsAnyItemActive(void) { - return ImGui::IsAnyItemActive(); -} - -ZGUI_API bool zguiIsAnyItemFocused(void) { - return ImGui::IsAnyItemFocused(); -} - -ZGUI_API void zguiGetContentRegionAvail(float pos[2]) { - const ImVec2 p = ImGui::GetContentRegionAvail(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiGetContentRegionMax(float pos[2]) { - const ImVec2 p = ImGui::GetContentRegionMax(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiGetWindowContentRegionMin(float pos[2]) { - const ImVec2 p = ImGui::GetWindowContentRegionMin(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiGetWindowContentRegionMax(float pos[2]) { - const ImVec2 p = ImGui::GetWindowContentRegionMax(); - pos[0] = p.x; - pos[1] = p.y; -} - -ZGUI_API void zguiPushTextWrapPos(float wrap_pos_x) { - ImGui::PushTextWrapPos(wrap_pos_x); -} - -ZGUI_API void zguiPopTextWrapPos(void) { - ImGui::PopTextWrapPos(); -} - -ZGUI_API bool zguiBeginTabBar(const char* string, ImGuiTabBarFlags flags) { - return ImGui::BeginTabBar(string, flags); -} - -ZGUI_API bool zguiBeginTabItem(const char* string, bool* p_open, ImGuiTabItemFlags flags) { - return ImGui::BeginTabItem(string, p_open, flags); -} - -ZGUI_API void zguiEndTabItem(void) { - ImGui::EndTabItem(); -} - -ZGUI_API void zguiEndTabBar(void) { - ImGui::EndTabBar(); -} - -ZGUI_API void zguiSetTabItemClosed(const char* tab_or_docked_window_label) { - ImGui::SetTabItemClosed(tab_or_docked_window_label); -} - -ZGUI_API bool zguiBeginMenuBar(void) { - return ImGui::BeginMenuBar(); -} - -ZGUI_API void zguiEndMenuBar(void) { - ImGui::EndMenuBar(); -} - -ZGUI_API bool zguiBeginMainMenuBar(void) { - return ImGui::BeginMainMenuBar(); -} - -ZGUI_API void zguiEndMainMenuBar(void) { - ImGui::EndMainMenuBar(); -} - -ZGUI_API bool zguiBeginMenu(const char* label, bool enabled) { - return ImGui::BeginMenu(label, enabled); -} - -ZGUI_API void zguiEndMenu(void) { - ImGui::EndMenu(); -} - -ZGUI_API bool zguiMenuItem(const char* label, const char* shortcut, bool selected, bool enabled) { - return ImGui::MenuItem(label, shortcut, selected, enabled); -} - -ZGUI_API bool zguiMenuItemPtr(const char* label, const char* shortcut, bool* selected, bool enabled) { - return ImGui::MenuItem(label, shortcut, selected, enabled); -} - -ZGUI_API bool zguiBeginTooltip(void) { - return ImGui::BeginTooltip(); -} - -ZGUI_API void zguiEndTooltip(void) { - ImGui::EndTooltip(); -} - -ZGUI_API bool zguiBeginPopup(const char* str_id, ImGuiWindowFlags flags){ - return ImGui::BeginPopup(str_id, flags); -} - -ZGUI_API bool zguiBeginPopupContextWindow(void) { - return ImGui::BeginPopupContextWindow(); -} - -ZGUI_API bool zguiBeginPopupContextItem(void) { - return ImGui::BeginPopupContextItem(); -} - -ZGUI_API bool zguiBeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) { - return ImGui::BeginPopupModal(name, p_open, flags); -} - -ZGUI_API void zguiEndPopup(void) { - ImGui::EndPopup(); -} - -ZGUI_API void zguiOpenPopup(const char* str_id, ImGuiPopupFlags popup_flags) { - ImGui::OpenPopup(str_id, popup_flags); -} - -ZGUI_API void zguiCloseCurrentPopup(void) { - ImGui::CloseCurrentPopup(); -} -//-------------------------------------------------------------------------------------------------- -// -// Tables -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API bool zguiBeginTable( - const char* str_id, - int column, - ImGuiTableFlags flags, - const float outer_size[2], - float inner_width -) { - return ImGui::BeginTable(str_id, column, flags, { outer_size[0], outer_size[1] }, inner_width); -} - -ZGUI_API void zguiEndTable(void) { - ImGui::EndTable(); -} - -ZGUI_API void zguiTableNextRow(ImGuiTableRowFlags row_flags, float min_row_height) { - ImGui::TableNextRow(row_flags, min_row_height); -} - -ZGUI_API bool zguiTableNextColumn(void) { - return ImGui::TableNextColumn(); -} - -ZGUI_API bool zguiTableSetColumnIndex(int column_n) { - return ImGui::TableSetColumnIndex(column_n); -} - -ZGUI_API void zguiTableSetupColumn( - const char* label, - ImGuiTableColumnFlags flags, - float init_width_or_height, - ImGuiID user_id -) { - ImGui::TableSetupColumn(label, flags, init_width_or_height, user_id); -} - -ZGUI_API void zguiTableSetupScrollFreeze(int cols, int rows) { - ImGui::TableSetupScrollFreeze(cols, rows); -} - -ZGUI_API void zguiTableHeadersRow(void) { - ImGui::TableHeadersRow(); -} - -ZGUI_API void zguiTableHeader(const char* label) { - ImGui::TableHeader(label); -} - -ZGUI_API ImGuiTableSortSpecs* zguiTableGetSortSpecs(void) { - return ImGui::TableGetSortSpecs(); -} - -ZGUI_API int zguiTableGetColumnCount(void) { - return ImGui::TableGetColumnCount(); -} - -ZGUI_API int zguiTableGetColumnIndex(void) { - return ImGui::TableGetColumnIndex(); -} - -ZGUI_API int zguiTableGetRowIndex(void) { - return ImGui::TableGetRowIndex(); -} - -ZGUI_API const char* zguiTableGetColumnName(int column_n) { - return ImGui::TableGetColumnName(column_n); -} - -ZGUI_API ImGuiTableColumnFlags zguiTableGetColumnFlags(int column_n) { - return ImGui::TableGetColumnFlags(column_n); -} - -ZGUI_API void zguiTableSetColumnEnabled(int column_n, bool v) { - ImGui::TableSetColumnEnabled(column_n, v); -} - -ZGUI_API void zguiTableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n) { - ImGui::TableSetBgColor(target, color, column_n); -} -//-------------------------------------------------------------------------------------------------- -// -// Color Utilities -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API void zguiColorConvertU32ToFloat4(ImU32 in, float rgba[4]) { - const ImVec4 c = ImGui::ColorConvertU32ToFloat4(in); - rgba[0] = c.x; - rgba[1] = c.y; - rgba[2] = c.z; - rgba[3] = c.w; -} - -ZGUI_API ImU32 zguiColorConvertFloat4ToU32(const float in[4]) { - return ImGui::ColorConvertFloat4ToU32({ in[0], in[1], in[2], in[3] }); -} - -ZGUI_API void zguiColorConvertRGBtoHSV(float r, float g, float b, float* out_h, float* out_s, float* out_v) { - return ImGui::ColorConvertRGBtoHSV(r, g, b, *out_h, *out_s, *out_v); -} - -ZGUI_API void zguiColorConvertHSVtoRGB(float h, float s, float v, float* out_r, float* out_g, float* out_b) { - return ImGui::ColorConvertHSVtoRGB(h, s, v, *out_r, *out_g, *out_b); -} -//-------------------------------------------------------------------------------------------------- -// -// Inputs Utilities: Keyboard -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API bool zguiIsKeyDown(ImGuiKey key) { - return ImGui::IsKeyDown(key); -} -//-------------------------------------------------------------------------------------------------- -// -// DrawList -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API ImDrawList *zguiGetWindowDrawList(void) { - return ImGui::GetWindowDrawList(); -} - -ZGUI_API ImDrawList *zguiGetBackgroundDrawList(void) { - return ImGui::GetBackgroundDrawList(); -} - -ZGUI_API ImDrawList *zguiGetForegroundDrawList(void) { - return ImGui::GetForegroundDrawList(); -} - -ZGUI_API ImDrawList *zguiCreateDrawList(void) { - return IM_NEW(ImDrawList)(ImGui::GetDrawListSharedData()); -} - -ZGUI_API void zguiDestroyDrawList(ImDrawList *draw_list) { - IM_DELETE(draw_list); -} - -ZGUI_API const char *zguiDrawList_GetOwnerName(ImDrawList *draw_list) { - return draw_list->_OwnerName; -} - -ZGUI_API void zguiDrawList_ResetForNewFrame(ImDrawList *draw_list) { - draw_list->_ResetForNewFrame(); -} - -ZGUI_API void zguiDrawList_ClearFreeMemory(ImDrawList *draw_list) { - draw_list->_ClearFreeMemory(); -} - -ZGUI_API int zguiDrawList_GetVertexBufferLength(ImDrawList *draw_list) { - return draw_list->VtxBuffer.size(); -} -ZGUI_API ImDrawVert *zguiDrawList_GetVertexBufferData(ImDrawList *draw_list) { - return draw_list->VtxBuffer.begin(); -} - -ZGUI_API int zguiDrawList_GetIndexBufferLength(ImDrawList *draw_list) { - return draw_list->IdxBuffer.size(); -} -ZGUI_API ImDrawIdx *zguiDrawList_GetIndexBufferData(ImDrawList *draw_list) { - return draw_list->IdxBuffer.begin(); -} -ZGUI_API unsigned int zguiDrawList_GetCurrentIndex(ImDrawList *draw_list) { - return draw_list->_VtxCurrentIdx; -} - -ZGUI_API int zguiDrawList_GetCmdBufferLength(ImDrawList *draw_list) { - return draw_list->CmdBuffer.size(); -} -ZGUI_API ImDrawCmd *zguiDrawList_GetCmdBufferData(ImDrawList *draw_list) { - return draw_list->CmdBuffer.begin(); -} - -ZGUI_API void zguiDrawList_SetFlags(ImDrawList *draw_list, ImDrawListFlags flags) { - draw_list->Flags = flags; -} -ZGUI_API ImDrawListFlags zguiDrawList_GetFlags(ImDrawList *draw_list) { - return draw_list->Flags; -} - -ZGUI_API void zguiDrawList_PushClipRect( - ImDrawList* draw_list, - const float clip_rect_min[2], - const float clip_rect_max[2], - bool intersect_with_current_clip_rect -) { - draw_list->PushClipRect( - { clip_rect_min[0], clip_rect_min[1] }, - { clip_rect_max[0], clip_rect_max[1] }, - intersect_with_current_clip_rect - ); -} - -ZGUI_API void zguiDrawList_PushClipRectFullScreen(ImDrawList* draw_list) { - draw_list->PushClipRectFullScreen(); -} - -ZGUI_API void zguiDrawList_PopClipRect(ImDrawList* draw_list) { - draw_list->PopClipRect(); -} - -ZGUI_API void zguiDrawList_PushTextureId(ImDrawList* draw_list, ImTextureID texture_id) { - draw_list->PushTextureID(texture_id); -} - -ZGUI_API void zguiDrawList_PopTextureId(ImDrawList* draw_list) { - draw_list->PopTextureID(); -} - -ZGUI_API void zguiDrawList_GetClipRectMin(ImDrawList* draw_list, float clip_min[2]) { - const ImVec2 c = draw_list->GetClipRectMin(); - clip_min[0] = c.x; - clip_min[1] = c.y; -} - -ZGUI_API void zguiDrawList_GetClipRectMax(ImDrawList* draw_list, float clip_max[2]) { - const ImVec2 c = draw_list->GetClipRectMax(); - clip_max[0] = c.x; - clip_max[1] = c.y; -} - -ZGUI_API void zguiDrawList_AddLine( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - ImU32 col, - float thickness -) { - draw_list->AddLine({ p1[0], p1[1] }, { p2[0], p2[1] }, col, thickness); -} - -ZGUI_API void zguiDrawList_AddRect( - ImDrawList* draw_list, - const float pmin[2], - const float pmax[2], - ImU32 col, - float rounding, - ImDrawFlags flags, - float thickness -) { - draw_list->AddRect({ pmin[0], pmin[1] }, { pmax[0], pmax[1] }, col, rounding, flags, thickness); -} - -ZGUI_API void zguiDrawList_AddRectFilled( - ImDrawList* draw_list, - const float pmin[2], - const float pmax[2], - ImU32 col, - float rounding, - ImDrawFlags flags -) { - draw_list->AddRectFilled({ pmin[0], pmin[1] }, { pmax[0], pmax[1] }, col, rounding, flags); -} - -ZGUI_API void zguiDrawList_AddRectFilledMultiColor( - ImDrawList* draw_list, - const float pmin[2], - const float pmax[2], - ImU32 col_upr_left, - ImU32 col_upr_right, - ImU32 col_bot_right, - ImU32 col_bot_left -) { - draw_list->AddRectFilledMultiColor( - { pmin[0], pmin[1] }, - { pmax[0], pmax[1] }, - col_upr_left, - col_upr_right, - col_bot_right, - col_bot_left - ); -} - -ZGUI_API void zguiDrawList_AddQuad( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - const float p4[2], - 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); -} - -ZGUI_API void zguiDrawList_AddQuadFilled( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - const float p4[2], - ImU32 col -) { - draw_list->AddQuadFilled({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, { p4[0], p4[1] }, col); -} - -ZGUI_API void zguiDrawList_AddTriangle( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - ImU32 col, - float thickness -) { - draw_list->AddTriangle({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, col, thickness); -} - -ZGUI_API void zguiDrawList_AddTriangleFilled( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - ImU32 col -) { - draw_list->AddTriangleFilled({ p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, col); -} - -ZGUI_API void zguiDrawList_AddCircle( - ImDrawList* draw_list, - const float center[2], - float radius, - ImU32 col, - int num_segments, - float thickness -) { - draw_list->AddCircle({ center[0], center[1] }, radius, col, num_segments, thickness); -} - -ZGUI_API void zguiDrawList_AddCircleFilled( - ImDrawList* draw_list, - const float center[2], - float radius, - ImU32 col, - int num_segments -) { - draw_list->AddCircleFilled({ center[0], center[1] }, radius, col, num_segments); -} - -ZGUI_API void zguiDrawList_AddNgon( - ImDrawList* draw_list, - const float center[2], - float radius, - ImU32 col, - int num_segments, - float thickness -) { - draw_list->AddNgon({ center[0], center[1] }, radius, col, num_segments, thickness); -} - -ZGUI_API void zguiDrawList_AddNgonFilled( - ImDrawList* draw_list, - const float center[2], - float radius, - ImU32 col, - int num_segments -) { - draw_list->AddNgonFilled({ center[0], center[1] }, radius, col, num_segments); -} - -ZGUI_API void zguiDrawList_AddText( - ImDrawList* draw_list, - const float pos[2], - ImU32 col, - const char* text_begin, - const char* text_end -) { - draw_list->AddText({ pos[0], pos[1] }, col, text_begin, text_end); -} - -ZGUI_API void zguiDrawList_AddPolyline( - ImDrawList* draw_list, - const float points[][2], - int num_points, - ImU32 col, - ImDrawFlags flags, - float thickness -) { - draw_list->AddPolyline((const ImVec2*)&points[0][0], num_points, col, flags, thickness); -} - -ZGUI_API void zguiDrawList_AddConvexPolyFilled( - ImDrawList* draw_list, - const float points[][2], - int num_points, - ImU32 col -) { - draw_list->AddConvexPolyFilled((const ImVec2*)&points[0][0], num_points, col); -} - -ZGUI_API void zguiDrawList_AddBezierCubic( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - const float p4[2], - ImU32 col, - float thickness, - int num_segments -) { - draw_list->AddBezierCubic( - { p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, { p4[0], p4[1] }, col, thickness, num_segments - ); -} - -ZGUI_API void zguiDrawList_AddBezierQuadratic( - ImDrawList* draw_list, - const float p1[2], - const float p2[2], - const float p3[2], - ImU32 col, - float thickness, - int num_segments -) { - draw_list->AddBezierQuadratic( - { p1[0], p1[1] }, { p2[0], p2[1] }, { p3[0], p3[1] }, col, thickness, num_segments - ); -} - -ZGUI_API void zguiDrawList_AddImage( - ImDrawList* draw_list, - ImTextureID user_texture_id, - const float pmin[2], - const float pmax[2], - const float uvmin[2], - const float uvmax[2], - ImU32 col -) { - draw_list->AddImage( - user_texture_id, - { pmin[0], pmin[1] }, - { pmax[0], pmax[1] }, - { uvmin[0], uvmin[1] }, - { uvmax[0], uvmax[1] }, - col - ); -} - -ZGUI_API void zguiDrawList_AddImageQuad( - ImDrawList* draw_list, - ImTextureID user_texture_id, - const float p1[2], - const float p2[2], - const float p3[2], - const float p4[2], - const float uv1[2], - const float uv2[2], - const float uv3[2], - const float uv4[2], - ImU32 col -) { - draw_list->AddImageQuad( - user_texture_id, - { p1[0], p1[1] }, - { p2[0], p2[1] }, - { p3[0], p3[1] }, - { p4[0], p4[1] }, - { uv1[0], uv1[1] }, - { uv2[0], uv2[1] }, - { uv3[0], uv3[1] }, - { uv4[0], uv4[1] }, - col - ); -} - -ZGUI_API void zguiDrawList_AddImageRounded( - ImDrawList* draw_list, - ImTextureID user_texture_id, - const float pmin[2], - const float pmax[2], - const float uvmin[2], - const float uvmax[2], - ImU32 col, - float rounding, - ImDrawFlags flags -) { - draw_list->AddImageRounded( - user_texture_id, - { pmin[0], pmin[1] }, - { pmax[0], pmax[1] }, - { uvmin[0], uvmin[1] }, - { uvmax[0], uvmax[1] }, - col, - rounding, - flags - ); -} - -ZGUI_API void zguiDrawList_PathClear(ImDrawList* draw_list) { - draw_list->PathClear(); -} - -ZGUI_API void zguiDrawList_PathLineTo(ImDrawList* draw_list, const float pos[2]) { - draw_list->PathLineTo({ pos[0], pos[1] }); -} - -ZGUI_API void zguiDrawList_PathLineToMergeDuplicate(ImDrawList* draw_list, const float pos[2]) { - draw_list->PathLineToMergeDuplicate({ pos[0], pos[1] }); -} - -ZGUI_API void zguiDrawList_PathFillConvex(ImDrawList* draw_list, ImU32 col) { - draw_list->PathFillConvex(col); -} - -ZGUI_API void zguiDrawList_PathStroke(ImDrawList* draw_list, ImU32 col, ImDrawFlags flags, float thickness) { - draw_list->PathStroke(col, flags, thickness); -} - -ZGUI_API void zguiDrawList_PathArcTo( - ImDrawList* draw_list, - const float center[2], - float radius, - float a_min, - float a_max, - int num_segments -) { - draw_list->PathArcTo({ center[0], center[1] }, radius, a_min, a_max, num_segments); -} - -ZGUI_API void zguiDrawList_PathArcToFast( - ImDrawList* draw_list, - const float center[2], - float radius, - int a_min_of_12, - int a_max_of_12 -) { - draw_list->PathArcToFast({ center[0], center[1] }, radius, a_min_of_12, a_max_of_12); -} - -ZGUI_API void zguiDrawList_PathBezierCubicCurveTo( - ImDrawList* draw_list, - const float p2[2], - const float p3[2], - const float p4[2], - int num_segments -) { - draw_list->PathBezierCubicCurveTo({ p2[0], p2[1] }, { p3[0], p3[1] }, { p4[0], p4[1] }, num_segments); -} - -ZGUI_API void zguiDrawList_PathBezierQuadraticCurveTo( - ImDrawList* draw_list, - const float p2[2], - const float p3[2], - int num_segments -) { - draw_list->PathBezierQuadraticCurveTo({ p2[0], p2[1] }, { p3[0], p3[1] }, num_segments); -} - -ZGUI_API void zguiDrawList_PathRect( - ImDrawList* draw_list, - const float rect_min[2], - const float rect_max[2], - float rounding, - ImDrawFlags flags -) { - draw_list->PathRect({ rect_min[0], rect_min[1] }, { rect_max[0], rect_max[1] }, rounding, flags); -} - -ZGUI_API void zguiDrawList_PrimReserve( ImDrawList* draw_list, int idx_count, int vtx_count) { - draw_list->PrimReserve(idx_count, vtx_count); -} - -ZGUI_API void zguiDrawList_PrimUnreserve( ImDrawList* draw_list, int idx_count, int vtx_count) { - draw_list->PrimUnreserve(idx_count, vtx_count); -} - -ZGUI_API void zguiDrawList_PrimRect( - ImDrawList* draw_list, - const float a[2], - const float b[2], - ImU32 col -) { - draw_list->PrimRect({ a[0], a[1] }, { b[0], b[1] }, col); -} - -ZGUI_API void zguiDrawList_PrimRectUV( - ImDrawList* draw_list, - const float a[2], - const float b[2], - const float uv_a[2], - const float uv_b[2], - 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); -} - -ZGUI_API void zguiDrawList_PrimQuadUV( - ImDrawList* draw_list, - const float a[2], - const float b[2], - const float c[2], - const float d[2], - const float uv_a[2], - const float uv_b[2], - const float uv_c[2], - const float uv_d[2], - ImU32 col -) { - draw_list->PrimQuadUV( - { a[0], a[1] }, { b[0], b[1] }, { c[0], c[1] }, { d[0], d[1] }, - { uv_a[0], uv_a[1] }, { uv_b[0], uv_b[1] }, { uv_c[0], uv_c[1] }, { uv_d[0], uv_d[1] }, - col - ); -} - -ZGUI_API void zguiDrawList_PrimWriteVtx( - ImDrawList* draw_list, - const float pos[2], - const float uv[2], - ImU32 col -) { - draw_list->PrimWriteVtx({ pos[0], pos[1] }, { uv[0], uv[1] }, col); -} - -ZGUI_API void zguiDrawList_PrimWriteIdx( ImDrawList* draw_list, ImDrawIdx idx) { - draw_list->PrimWriteIdx(idx); -} - -ZGUI_API void zguiDrawList_AddCallback(ImDrawList* draw_list, ImDrawCallback callback, void* callback_data) { - draw_list->AddCallback(callback, callback_data); -} - -ZGUI_API void zguiDrawList_AddResetRenderStateCallback(ImDrawList* draw_list) { - draw_list->AddCallback(ImDrawCallback_ResetRenderState, NULL); -} -//-------------------------------------------------------------------------------------------------- -// -// Viewport -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API ImGuiViewport* zguiGetMainViewport(void) { - return ImGui::GetMainViewport(); -} - -ZGUI_API void zguiViewport_GetPos(ImGuiViewport* viewport, float p[2]) { - const ImVec2 pos = viewport->Pos; - p[0] = pos.x; - p[1] = pos.y; -} - -ZGUI_API void zguiViewport_GetSize(ImGuiViewport* viewport, float p[2]) { - const ImVec2 sz = viewport->Size; - p[0] = sz.x; - p[1] = sz.y; -} - -ZGUI_API void zguiViewport_GetWorkPos(ImGuiViewport* viewport, float p[2]) { - const ImVec2 pos = viewport->WorkPos; - p[0] = pos.x; - p[1] = pos.y; -} - -ZGUI_API void zguiViewport_GetWorkSize(ImGuiViewport* viewport, float p[2]) { - const ImVec2 sz = viewport->WorkSize; - p[0] = sz.x; - p[1] = sz.y; -} - -//-------------------------------------------------------------------------------------------------- -// -// Docking -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API ImGuiID zguiDockSpace(const char* str_id, float size[2], ImGuiDockNodeFlags flags) { - return ImGui::DockSpace(ImGui::GetID(str_id), {size[0], size[1]}, flags); -} - -ZGUI_API ImGuiID zguiDockSpaceOverViewport(const ImGuiViewport* viewport, ImGuiDockNodeFlags dockspace_flags) { - return ImGui::DockSpaceOverViewport(viewport, dockspace_flags); -} - - -//-------------------------------------------------------------------------------------------------- -// -// DockBuilder (Unstable internal imgui API, subject to change, use at own risk) -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API void zguiDockBuilderDockWindow(const char* window_name, ImGuiID node_id) { - ImGui::DockBuilderDockWindow(window_name, node_id); -} - -ZGUI_API ImGuiID zguiDockBuilderAddNode(ImGuiID node_id, ImGuiDockNodeFlags flags) { - return ImGui::DockBuilderAddNode(node_id, flags); -} - -ZGUI_API void zguiDockBuilderRemoveNode(ImGuiID node_id) { - ImGui::DockBuilderRemoveNode(node_id); -} - -ZGUI_API void zguiDockBuilderSetNodePos(ImGuiID node_id, float pos[2]) { - ImGui::DockBuilderSetNodePos(node_id, {pos[0], pos[1]}); -} - -ZGUI_API void zguiDockBuilderSetNodeSize(ImGuiID node_id, float size[2]) { - ImGui::DockBuilderSetNodeSize(node_id, {size[0], size[1]}); -} - -ZGUI_API ImGuiID zguiDockBuilderSplitNode( - ImGuiID node_id, - ImGuiDir split_dir, - float size_ratio_for_node_at_dir, - ImGuiID* out_id_at_dir, - ImGuiID* out_id_at_opposite_dir -) { - return ImGui::DockBuilderSplitNode( - node_id, - split_dir, - size_ratio_for_node_at_dir, - out_id_at_dir, - out_id_at_opposite_dir - ); -} - -ZGUI_API void zguiDockBuilderFinish(ImGuiID node_id) { - ImGui::DockBuilderFinish(node_id); -} - - -#if ZGUI_IMPLOT -//-------------------------------------------------------------------------------------------------- -// -// ImPlot -// -//-------------------------------------------------------------------------------------------------- -ZGUI_API ImPlotContext* zguiPlot_CreateContext(void) { - return ImPlot::CreateContext(); -} - -ZGUI_API void zguiPlot_DestroyContext(ImPlotContext* ctx) { - ImPlot::DestroyContext(ctx); -} - -ZGUI_API ImPlotContext* zguiPlot_GetCurrentContext(void) { - return ImPlot::GetCurrentContext(); -} - -ZGUI_API ImPlotStyle zguiPlotStyle_Init(void) { - return ImPlotStyle(); -} - -ZGUI_API ImPlotStyle* zguiPlot_GetStyle(void) { - return &ImPlot::GetStyle(); -} - -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, ImU32 col) { - ImPlot::PushStyleColor(idx, col); -} - -ZGUI_API void zguiPlot_PopStyleColor(int count) { - ImPlot::PopStyleColor(count); -} - -ZGUI_API void zguiPlot_PushStyleVar1i(ImPlotStyleVar idx, int var) { - ImPlot::PushStyleVar(idx, var); -} - -ZGUI_API void zguiPlot_PushStyleVar1f(ImPlotStyleVar idx, float var) { - ImPlot::PushStyleVar(idx, var); -} - -ZGUI_API void zguiPlot_PushStyleVar2f(ImPlotStyleVar idx, const float var[2]) { - ImPlot::PushStyleVar(idx, { var[0], var[1] }); -} - -ZGUI_API void zguiPlot_PopStyleVar(int count) { - ImPlot::PopStyleVar(count); -} - -ZGUI_API void zguiPlot_SetupLegend(ImPlotLocation location, ImPlotLegendFlags flags) { - ImPlot::SetupLegend(location, flags); -} - -ZGUI_API void zguiPlot_SetupAxis(ImAxis axis, const char* label, ImPlotAxisFlags flags) { - ImPlot::SetupAxis(axis, label, flags); -} - -ZGUI_API void zguiPlot_SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond) { - ImPlot::SetupAxisLimits(axis, v_min, v_max, cond); -} - -ZGUI_API void zguiPlot_SetupFinish(void) { - ImPlot::SetupFinish(); -} - -ZGUI_API bool zguiPlot_BeginPlot(const char* title_id, float width, float height, ImPlotFlags flags) { - return ImPlot::BeginPlot(title_id, { width, height }, flags); -} - -ZGUI_API void zguiPlot_PlotLineValues( - const char* label_id, - ImGuiDataType data_type, - const void* values, - int count, - double xscale, - double x0, - ImPlotLineFlags flags, - int offset, - int stride -) { - if (data_type == ImGuiDataType_S8) - ImPlot::PlotLine(label_id, (const ImS8*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U8) - ImPlot::PlotLine(label_id, (const ImU8*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_S16) - ImPlot::PlotLine(label_id, (const ImS16*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U16) - ImPlot::PlotLine(label_id, (const ImU16*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_S32) - ImPlot::PlotLine(label_id, (const ImS32*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U32) - ImPlot::PlotLine(label_id, (const ImU32*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_Float) - ImPlot::PlotLine(label_id, (const float*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_Double) - ImPlot::PlotLine(label_id, (const double*)values, count, xscale, x0, flags, offset, stride); - else - assert(false); -} - -ZGUI_API void zguiPlot_PlotLine( - const char* label_id, - ImGuiDataType data_type, - const void* xv, - const void* yv, - int count, - ImPlotLineFlags flags, - int offset, - int stride -) { - if (data_type == ImGuiDataType_S8) - ImPlot::PlotLine(label_id, (const ImS8*)xv, (const ImS8*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U8) - ImPlot::PlotLine(label_id, (const ImU8*)xv, (const ImU8*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_S16) - ImPlot::PlotLine(label_id, (const ImS16*)xv, (const ImS16*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U16) - ImPlot::PlotLine(label_id, (const ImU16*)xv, (const ImU16*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_S32) - ImPlot::PlotLine(label_id, (const ImS32*)xv, (const ImS32*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U32) - ImPlot::PlotLine(label_id, (const ImU32*)xv, (const ImU32*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_Float) - ImPlot::PlotLine(label_id, (const float*)xv, (const float*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_Double) - ImPlot::PlotLine(label_id, (const double*)xv, (const double*)yv, count, flags, offset, stride); - else - assert(false); -} - -ZGUI_API void zguiPlot_PlotScatter( - const char* label_id, - ImGuiDataType data_type, - const void* xv, - const void* yv, - int count, - ImPlotScatterFlags flags, - int offset, - int stride -) { - if (data_type == ImGuiDataType_S8) - ImPlot::PlotScatter(label_id, (const ImS8*)xv, (const ImS8*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U8) - ImPlot::PlotScatter(label_id, (const ImU8*)xv, (const ImU8*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_S16) - ImPlot::PlotScatter(label_id, (const ImS16*)xv, (const ImS16*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U16) - ImPlot::PlotScatter(label_id, (const ImU16*)xv, (const ImU16*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_S32) - ImPlot::PlotScatter(label_id, (const ImS32*)xv, (const ImS32*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_U32) - ImPlot::PlotScatter(label_id, (const ImU32*)xv, (const ImU32*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_Float) - ImPlot::PlotScatter(label_id, (const float*)xv, (const float*)yv, count, flags, offset, stride); - else if (data_type == ImGuiDataType_Double) - ImPlot::PlotScatter(label_id, (const double*)xv, (const double*)yv, count, flags, offset, stride); - else - assert(false); -} - -ZGUI_API void zguiPlot_PlotScatterValues( - const char* label_id, - ImGuiDataType data_type, - const void* values, - int count, - double xscale, - double x0, - ImPlotScatterFlags flags, - int offset, - int stride -) { - if (data_type == ImGuiDataType_S8) - ImPlot::PlotScatter(label_id, (const ImS8*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U8) - ImPlot::PlotScatter(label_id, (const ImU8*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_S16) - ImPlot::PlotScatter(label_id, (const ImS16*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U16) - ImPlot::PlotScatter(label_id, (const ImU16*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_S32) - ImPlot::PlotScatter(label_id, (const ImS32*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_U32) - ImPlot::PlotScatter(label_id, (const ImU32*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_Float) - ImPlot::PlotScatter(label_id, (const float*)values, count, xscale, x0, flags, offset, stride); - else if (data_type == ImGuiDataType_Double) - ImPlot::PlotScatter(label_id, (const double*)values, count, xscale, x0, flags, offset, stride); - else - assert(false); -} - -ZGUI_API void zguiPlot_PlotShaded( - const char* label_id, - ImGuiDataType data_type, - const void* xv, - const void* yv, - int count, - double yref, - ImPlotShadedFlags flags, - int offset, - int stride -) { - if (data_type == ImGuiDataType_S8) - ImPlot::PlotShaded(label_id, (const ImS8*)xv, (const ImS8*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_U8) - ImPlot::PlotShaded(label_id, (const ImU8*)xv, (const ImU8*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_S16) - ImPlot::PlotShaded(label_id, (const ImS16*)xv, (const ImS16*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_U16) - ImPlot::PlotShaded(label_id, (const ImU16*)xv, (const ImU16*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_S32) - ImPlot::PlotShaded(label_id, (const ImS32*)xv, (const ImS32*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_U32) - ImPlot::PlotShaded(label_id, (const ImU32*)xv, (const ImU32*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_Float) - ImPlot::PlotShaded(label_id, (const float*)xv, (const float*)yv, count, yref, flags, offset, stride); - else if (data_type == ImGuiDataType_Double) - ImPlot::PlotShaded(label_id, (const double*)xv, (const double*)yv, count, yref, flags, offset, stride); - else - assert(false); -} - -ZGUI_API void zguiPlot_ShowDemoWindow(bool* p_open) { - ImPlot::ShowDemoWindow(p_open); -} - -ZGUI_API void zguiPlot_EndPlot(void) { - ImPlot::EndPlot(); -} -ZGUI_API bool zguiPlot_DragPoint( - int id, - double* x, - double* y, - float col[4], - float size, - ImPlotDragToolFlags flags -) { - return ImPlot::DragPoint( - id, - x, - y, - (*(const ImVec4*)&(col[0])), - size, - flags - ); -} - -ZGUI_API void zguiPlot_PlotText( - const char* text, - double x, double y, - const float pix_offset[2], - ImPlotTextFlags flags=0 -) { - const ImVec2 p(pix_offset[0], pix_offset[1]); - ImPlot::PlotText(text, x, y, p, flags); -} -#endif /* #ifdef ZGUI_IMPLOT */ - -//-------------------------------------------------------------------------------------------------- -} /* extern "C" */ - - -#if ZGUI_TE -//-------------------------------------------------------------------------------------------------- -// -// ImGUI Test Engine -// -//-------------------------------------------------------------------------------------------------- -extern "C" -{ - - ZGUI_API void *zguiTe_CreateContext(void) - { - ImGuiTestEngine *e = ImGuiTestEngine_CreateContext(); - - ImGuiTestEngine_Start(e, ImGui::GetCurrentContext()); - ImGuiTestEngine_InstallDefaultCrashHandler(); - - return e; - } - - ZGUI_API void zguiTe_DestroyContext(ImGuiTestEngine *engine) - { - ImGuiTestEngine_DestroyContext(engine); - } - - ZGUI_API void zguiTe_EngineSetRunSpeed(ImGuiTestEngine *engine, ImGuiTestRunSpeed speed) - { - ImGuiTestEngine_GetIO(engine).ConfigRunSpeed = speed; - } - - ZGUI_API void zguiTe_EngineExportJunitResult(ImGuiTestEngine *engine, const char *filename) - { - ImGuiTestEngine_GetIO(engine).ExportResultsFilename = filename; - ImGuiTestEngine_GetIO(engine).ExportResultsFormat = ImGuiTestEngineExportFormat_JUnitXml; - } - - ZGUI_API void zguiTe_TryAbortEngine(ImGuiTestEngine *engine) - { - ImGuiTestEngine_TryAbortEngine(engine); - } - - ZGUI_API void zguiTe_Stop(ImGuiTestEngine *engine) - { - ImGuiTestEngine_Stop(engine); - } - - ZGUI_API void zguiTe_PostSwap(ImGuiTestEngine *engine) - { - ImGuiTestEngine_PostSwap(engine); - } - - ZGUI_API bool zguiTe_IsTestQueueEmpty(ImGuiTestEngine *engine) - { - return ImGuiTestEngine_IsTestQueueEmpty(engine); - } - - ZGUI_API void zguiTe_GetResult(ImGuiTestEngine *engine, int *count_tested, int *count_success) - { - int ct = 0; - int cs = 0; - ImGuiTestEngine_GetResult(engine, ct, cs); - *count_tested = ct; - *count_success = cs; - } - - ZGUI_API void zguiTe_PrintResultSummary(ImGuiTestEngine *engine) - { - ImGuiTestEngine_PrintResultSummary(engine); - } - - ZGUI_API void zguiTe_QueueTests(ImGuiTestEngine *engine, ImGuiTestGroup group, const char *filter_str, ImGuiTestRunFlags run_flags) - { - ImGuiTestEngine_QueueTests(engine, group, filter_str, run_flags); - } - - ZGUI_API void zguiTe_ShowTestEngineWindows(ImGuiTestEngine *engine, bool *p_open) - { - ImGuiTestEngine_ShowTestEngineWindows(engine, p_open); - } - - ZGUI_API void *zguiTe_RegisterTest(ImGuiTestEngine *engine, const char *category, const char *name, const char *src_file, int src_line, ImGuiTestGuiFunc *gui_fce, ImGuiTestTestFunc *gui_test_fce) - { - auto t = ImGuiTestEngine_RegisterTest(engine, category, name, src_file, src_line); - t->GuiFunc = gui_fce; - t->TestFunc = gui_test_fce; - return t; - } - - ZGUI_API bool zguiTe_Check(const char *file, const char *func, int line, ImGuiTestCheckFlags flags, bool result, const char *expr) - { - return ImGuiTestEngine_Check(file, func, line, flags, result, expr); - } - - // CONTEXT - - ZGUI_API void zguiTe_ContextSetRef(ImGuiTestContext *ctx, const char *ref) - { - ctx->SetRef(ref); - } - - ZGUI_API void zguiTe_ContextWindowFocus(ImGuiTestContext *ctx, const char *ref) - { - ctx->WindowFocus(ref); - } - - ZGUI_API void zguiTe_ContextItemAction(ImGuiTestContext *ctx, ImGuiTestAction action, const char *ref, ImGuiTestOpFlags flags = 0, void *action_arg = NULL) - { - ctx->ItemAction(action, ref, flags, action_arg); - } - - ZGUI_API void zguiTe_ContextItemInputStrValue(ImGuiTestContext *ctx, const char *ref, const char *value) - { - ctx->ItemInputValue(ref, value); - } - - ZGUI_API void zguiTe_ContextItemInputIntValue(ImGuiTestContext *ctx, const char *ref, int value) - { - ctx->ItemInputValue(ref, value); - } - - ZGUI_API void zguiTe_ContextItemInputFloatValue(ImGuiTestContext *ctx, const char *ref, float value) - { - ctx->ItemInputValue(ref, value); - } - - ZGUI_API void zguiTe_ContextYield(ImGuiTestContext *ctx, int frame_count) - { - ctx->Yield(frame_count); - } - - ZGUI_API void zguiTe_ContextMenuAction(ImGuiTestContext *ctx, ImGuiTestAction action, const char *ref) - { - ctx->MenuAction(action, ref); - } - - ZGUI_API void zguiTe_ContextDragAndDrop(ImGuiTestContext *ctx, const char *ref_src, const char *ref_dst, ImGuiMouseButton button) - { - ctx->ItemDragAndDrop(ref_src, ref_dst, button); - } - - ZGUI_API void zguiTe_ContextKeyDown(ImGuiTestContext *ctx, ImGuiKeyChord key_chord) - { - ctx->KeyDown(key_chord); - } - - ZGUI_API void zguiTe_ContextKeyUp(ImGuiTestContext *ctx, ImGuiKeyChord key_chord) - { - ctx->KeyUp(key_chord); - } - -} /* extern "C" */ -#endif |
