chore: update to 2a0400ade5535001bfc09e0e7531515e232be6e7
This commit is contained in:
59
src/backend_dx12.zig
Normal file
59
src/backend_dx12.zig
Normal file
@@ -0,0 +1,59 @@
|
||||
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;
|
||||
35
src/backend_glfw.zig
Normal file
35
src/backend_glfw.zig
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
@@ -1,4 +1,6 @@
|
||||
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
|
||||
@@ -6,33 +8,28 @@ pub fn init(
|
||||
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,
|
||||
font_srv_cpu_desc_handle: backend_dx12.D3D12_CPU_DESCRIPTOR_HANDLE,
|
||||
font_srv_gpu_desc_handle: backend_dx12.D3D12_GPU_DESCRIPTOR_HANDLE,
|
||||
) void {
|
||||
if (!ImGui_ImplGlfw_InitForOther(window, true)) {
|
||||
@panic("failed to init glfw for imgui");
|
||||
}
|
||||
|
||||
if (!ImGui_ImplDX12_Init(
|
||||
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,
|
||||
)) {
|
||||
@panic("failed to init d3d12 for imgui");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui_ImplDX12_Shutdown();
|
||||
backend_dx12.deinit();
|
||||
backend_glfw.deinit();
|
||||
}
|
||||
|
||||
pub fn newFrame(fb_width: u32, fb_height: u32) void {
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui_ImplDX12_NewFrame();
|
||||
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);
|
||||
@@ -44,31 +41,5 @@ pub fn draw(
|
||||
graphics_command_list: *const anyopaque, // *ID3D12GraphicsCommandList
|
||||
) void {
|
||||
gui.render();
|
||||
ImGui_ImplDX12_RenderDrawData(gui.getDrawData(), graphics_command_list);
|
||||
backend_dx12.render(gui.getDrawData(), graphics_command_list);
|
||||
}
|
||||
|
||||
pub const D3D12_CPU_DESCRIPTOR_HANDLE = extern struct {
|
||||
ptr: c_ulonglong,
|
||||
};
|
||||
|
||||
pub const D3D12_GPU_DESCRIPTOR_HANDLE = extern struct {
|
||||
ptr: c_ulonglong,
|
||||
};
|
||||
|
||||
extern fn ImGui_ImplGlfw_InitForOther(window: *const anyopaque, install_callbacks: bool) bool;
|
||||
extern fn ImGui_ImplGlfw_NewFrame() void;
|
||||
extern fn ImGui_ImplGlfw_Shutdown() void;
|
||||
extern fn ImGui_ImplDX12_Init(
|
||||
device: *const anyopaque, // ID3D12Device
|
||||
num_frames_in_flight: u32,
|
||||
rtv_format: u32, // DXGI_FORMAT
|
||||
cbv_srv_heap: *const anyopaque, // ID3D12DescriptorHeap
|
||||
font_srv_cpu_desc_handle: D3D12_CPU_DESCRIPTOR_HANDLE,
|
||||
font_srv_gpu_desc_handle: D3D12_GPU_DESCRIPTOR_HANDLE,
|
||||
) bool;
|
||||
extern fn ImGui_ImplDX12_Shutdown() void;
|
||||
extern fn ImGui_ImplDX12_NewFrame() void;
|
||||
extern fn ImGui_ImplDX12_RenderDrawData(
|
||||
draw_data: *const anyopaque, // *ImDrawData
|
||||
graphics_command_list: *const anyopaque, // *ID3D12GraphicsCommandList
|
||||
) void;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
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 {
|
||||
if (!ImGui_ImplGlfw_InitForOpenGL(window, true)) {
|
||||
unreachable;
|
||||
}
|
||||
backend_glfw.initOpenGL(window);
|
||||
|
||||
ImGui_ImplOpenGL3_Init(@ptrCast(glsl_version));
|
||||
}
|
||||
@@ -18,12 +17,12 @@ pub fn init(
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
backend_glfw.deinit();
|
||||
}
|
||||
|
||||
pub fn newFrame(fb_width: u32, fb_height: u32) void {
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
backend_glfw.newFrame();
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
|
||||
gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height)));
|
||||
@@ -37,9 +36,8 @@ pub fn draw() void {
|
||||
ImGui_ImplOpenGL3_RenderDrawData(gui.getDrawData());
|
||||
}
|
||||
|
||||
extern fn ImGui_ImplGlfw_InitForOpenGL(window: *const anyopaque, install_callbacks: bool) bool;
|
||||
extern fn ImGui_ImplGlfw_NewFrame() void;
|
||||
extern fn ImGui_ImplGlfw_Shutdown() void;
|
||||
// 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;
|
||||
|
||||
@@ -1,33 +1,40 @@
|
||||
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, // WGPUDevice
|
||||
wgpu_swap_chain_format: u32, // WGPUTextureFormat
|
||||
wgpu_depth_format: u32, // WGPUTextureFormat
|
||||
wgpu_device: *const anyopaque, // wgpu.Device
|
||||
wgpu_swap_chain_format: u32, // wgpu.TextureFormat
|
||||
wgpu_depth_format: u32, // wgpu.TextureFormat
|
||||
) void {
|
||||
if (!ImGui_ImplGlfw_InitForOther(window, true)) {
|
||||
unreachable;
|
||||
}
|
||||
backend_glfw.init(window);
|
||||
|
||||
if (!ImGui_ImplWGPU_Init(wgpu_device, 1, wgpu_swap_chain_format, wgpu_depth_format)) {
|
||||
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();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
backend_glfw.deinit();
|
||||
}
|
||||
|
||||
pub fn newFrame(fb_width: u32, fb_height: u32) void {
|
||||
ImGui_ImplWGPU_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
backend_glfw.newFrame();
|
||||
|
||||
gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height)));
|
||||
gui.io.setDisplaySize(@floatFromInt(fb_width), @floatFromInt(fb_height));
|
||||
gui.io.setDisplayFramebufferScale(1.0, 1.0);
|
||||
|
||||
gui.newFrame();
|
||||
@@ -38,17 +45,23 @@ pub fn draw(wgpu_render_pass: *const anyopaque) void {
|
||||
ImGui_ImplWGPU_RenderDrawData(gui.getDrawData(), wgpu_render_pass);
|
||||
}
|
||||
|
||||
// Those functions are defined in `imgui_impl_glfw.cpp` and 'imgui_impl_wgpu.cpp`
|
||||
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_ImplGlfw_InitForOther(window: *const anyopaque, install_callbacks: bool) bool;
|
||||
extern fn ImGui_ImplGlfw_NewFrame() void;
|
||||
extern fn ImGui_ImplGlfw_Shutdown() void;
|
||||
extern fn ImGui_ImplWGPU_Init(
|
||||
device: *const anyopaque, // WGPUDevice
|
||||
num_frames_in_flight: u32,
|
||||
rt_format: u32, // WGPUTextureFormat
|
||||
wgpu_depth_format: u32, // WGPUTextureFormat
|
||||
) bool;
|
||||
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;
|
||||
|
||||
48
src/backend_win32_dx12.zig
Normal file
48
src/backend_win32_dx12.zig
Normal file
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
267
src/gui.zig
267
src/gui.zig
@@ -5,13 +5,16 @@
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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"),
|
||||
.win32_dx12 => .{}, // TODO:
|
||||
.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;
|
||||
@@ -26,6 +29,7 @@ pub const DrawVert = extern struct {
|
||||
color: u32,
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator) void {
|
||||
if (zguiGetCurrentContext() == null) {
|
||||
mem_allocator = allocator;
|
||||
@@ -37,6 +41,10 @@ pub fn init(allocator: std.mem.Allocator) void {
|
||||
|
||||
temp_buffer = std.ArrayList(u8).init(allocator);
|
||||
temp_buffer.?.resize(3 * 1024 + 1) catch unreachable;
|
||||
|
||||
if (te_enabled) {
|
||||
te.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn deinit() void {
|
||||
@@ -44,6 +52,12 @@ pub fn deinit() void {
|
||||
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| {
|
||||
@@ -124,7 +138,13 @@ pub const ConfigFlags = packed struct(c_int) {
|
||||
nav_no_capture_keyboard: bool = false,
|
||||
no_mouse: bool = false,
|
||||
no_mouse_cursor_change: bool = false,
|
||||
user_storage: u14 = 0,
|
||||
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,
|
||||
@@ -147,6 +167,7 @@ pub const FontConfig = extern struct {
|
||||
merge_mode: bool,
|
||||
font_builder_flags: c_uint,
|
||||
rasterizer_multiply: f32,
|
||||
rasterizer_density: f32,
|
||||
ellipsis_char: Wchar,
|
||||
name: [40]u8,
|
||||
dst_font: *Font,
|
||||
@@ -326,7 +347,7 @@ pub const DrawData = *extern struct {
|
||||
cmd_lists_count: c_int,
|
||||
total_idx_count: c_int,
|
||||
total_vtx_count: c_int,
|
||||
cmd_lists: [*]DrawList,
|
||||
cmd_lists: Vector(DrawList),
|
||||
display_pos: [2]f32,
|
||||
display_size: [2]f32,
|
||||
framebuffer_scale: [2]f32,
|
||||
@@ -334,7 +355,7 @@ pub const DrawData = *extern struct {
|
||||
pub const Font = *opaque {};
|
||||
pub const Ident = u32;
|
||||
pub const TextureIdent = *anyopaque;
|
||||
pub const Wchar = u16;
|
||||
pub const Wchar = if (@import("zgui_options").use_wchar32) u32 else u16;
|
||||
pub const Key = enum(c_int) {
|
||||
none = 0,
|
||||
tab = 512,
|
||||
@@ -409,6 +430,18 @@ pub const Key = enum(c_int) {
|
||||
f10,
|
||||
f11,
|
||||
f12,
|
||||
f13,
|
||||
f14,
|
||||
f15,
|
||||
f16,
|
||||
f17,
|
||||
f18,
|
||||
f19,
|
||||
f20,
|
||||
f21,
|
||||
f22,
|
||||
f23,
|
||||
f24,
|
||||
apostrophe,
|
||||
comma,
|
||||
minus,
|
||||
@@ -443,6 +476,9 @@ pub const Key = enum(c_int) {
|
||||
keypad_enter,
|
||||
keypad_equal,
|
||||
|
||||
app_back,
|
||||
app_forward,
|
||||
|
||||
gamepad_start,
|
||||
gamepad_back,
|
||||
gamepad_faceleft,
|
||||
@@ -483,6 +519,7 @@ pub const Key = enum(c_int) {
|
||||
mod_super = 1 << 15,
|
||||
mod_mask_ = 0xf000,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub const WindowFlags = packed struct(c_int) {
|
||||
no_title_bar: bool = false,
|
||||
@@ -501,12 +538,11 @@ pub const WindowFlags = packed struct(c_int) {
|
||||
no_bring_to_front_on_focus: bool = false,
|
||||
always_vertical_scrollbar: bool = false,
|
||||
always_horizontal_scrollbar: bool = false,
|
||||
always_use_window_padding: bool = false,
|
||||
_removed: u1 = 0,
|
||||
no_nav_inputs: bool = false,
|
||||
no_nav_focus: bool = false,
|
||||
unsaved_document: bool = false,
|
||||
_padding: u11 = 0,
|
||||
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{
|
||||
@@ -521,6 +557,20 @@ pub const WindowFlags = packed struct(c_int) {
|
||||
.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,
|
||||
@@ -629,7 +679,12 @@ 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);
|
||||
}
|
||||
@@ -651,19 +706,19 @@ extern fn zguiEnd() void;
|
||||
const BeginChild = struct {
|
||||
w: f32 = 0.0,
|
||||
h: f32 = 0.0,
|
||||
border: bool = false,
|
||||
flags: WindowFlags = .{},
|
||||
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.border, args.flags);
|
||||
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.border, args.flags);
|
||||
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, border: bool, flags: WindowFlags) bool;
|
||||
extern fn zguiBeginChildId(id: Ident, w: f32, h: f32, border: bool, flags: WindowFlags) bool;
|
||||
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`
|
||||
@@ -720,7 +775,8 @@ pub const FocusedFlags = packed struct(c_int) {
|
||||
root_window: bool = false,
|
||||
any_window: bool = false,
|
||||
no_popup_hierarchy: bool = false,
|
||||
_padding: u28 = 0,
|
||||
dock_hierarchy: bool = false,
|
||||
_padding: u27 = 0,
|
||||
|
||||
pub const root_and_child_windows = FocusedFlags{ .root_window = true, .child_windows = true };
|
||||
};
|
||||
@@ -730,22 +786,27 @@ pub const HoveredFlags = packed struct(c_int) {
|
||||
root_window: bool = false,
|
||||
any_window: bool = false,
|
||||
no_popup_hierarchy: bool = false,
|
||||
_reserved0: 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: 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: u18 = 0,
|
||||
_padding: u14 = 0,
|
||||
|
||||
pub const rect_only = HoveredFlags{
|
||||
.allow_when_blocked_by_popup = true,
|
||||
.allow_when_blocked_by_active_item = true,
|
||||
.allow_when_overlapped = 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 };
|
||||
};
|
||||
@@ -812,6 +873,79 @@ 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
|
||||
@@ -847,6 +981,8 @@ pub const Style = extern struct {
|
||||
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,
|
||||
@@ -855,6 +991,7 @@ pub const Style = extern struct {
|
||||
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,
|
||||
@@ -864,6 +1001,13 @@ pub const Style = extern struct {
|
||||
|
||||
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;
|
||||
@@ -922,6 +1066,8 @@ pub const StyleCol = enum(c_int) {
|
||||
tab_active,
|
||||
tab_unfocused,
|
||||
tab_unfocused_active,
|
||||
docking_preview,
|
||||
docking_empty_bg,
|
||||
plot_lines,
|
||||
plot_lines_hovered,
|
||||
plot_histogram,
|
||||
@@ -996,11 +1142,13 @@ pub const StyleVar = enum(c_int) {
|
||||
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 {
|
||||
@@ -1227,8 +1375,14 @@ pub fn getItemRectMin() [2]f32 {
|
||||
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
|
||||
@@ -1502,31 +1656,35 @@ pub fn comboFromEnum(
|
||||
/// i32 (the underlying imgui restriction)
|
||||
current_item: anytype,
|
||||
) bool {
|
||||
const item_names = comptime lbl: {
|
||||
const item_type = @typeInfo(@TypeOf(current_item.*));
|
||||
switch (item_type) {
|
||||
.Enum => |e| {
|
||||
var str: [:0]const u8 = "";
|
||||
|
||||
for (e.fields) |f| {
|
||||
str = str ++ f.name ++ "\x00";
|
||||
}
|
||||
break :lbl str;
|
||||
},
|
||||
else => {
|
||||
@compileError("Error: current_item must be a pointer-to-an-enum, not a " ++ @TypeOf(current_item));
|
||||
},
|
||||
}
|
||||
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)),
|
||||
};
|
||||
|
||||
var item: i32 = @intCast(@intFromEnum(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.* = @enumFromInt(item);
|
||||
current_item.* = index_to_enum[@intCast(item)];
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1545,7 +1703,8 @@ pub const ComboFlags = packed struct(c_int) {
|
||||
height_largest: bool = false,
|
||||
no_arrow_button: bool = false,
|
||||
no_preview: bool = false,
|
||||
_padding: u25 = 0,
|
||||
width_fit_preview: bool = false,
|
||||
_padding: u24 = 0,
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const BeginCombo = struct {
|
||||
@@ -2235,7 +2394,7 @@ pub const InputTextCallbackData = extern struct {
|
||||
pub const InputTextCallback = *const fn (data: *InputTextCallbackData) i32;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn inputText(label: [:0]const u8, args: struct {
|
||||
buf: []u8,
|
||||
buf: [:0]u8,
|
||||
flags: InputTextFlags = .{},
|
||||
callback: ?InputTextCallback = null,
|
||||
user_data: ?*anyopaque = null,
|
||||
@@ -2243,7 +2402,7 @@ pub fn inputText(label: [:0]const u8, args: struct {
|
||||
return zguiInputText(
|
||||
label,
|
||||
args.buf.ptr,
|
||||
args.buf.len,
|
||||
args.buf.len + 1, // + 1 for sentinel
|
||||
args.flags,
|
||||
if (args.callback) |cb| cb else null,
|
||||
args.user_data,
|
||||
@@ -2259,7 +2418,7 @@ extern fn zguiInputText(
|
||||
) bool;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn inputTextMultiline(label: [:0]const u8, args: struct {
|
||||
buf: []u8,
|
||||
buf: [:0]u8,
|
||||
w: f32 = 0.0,
|
||||
h: f32 = 0.0,
|
||||
flags: InputTextFlags = .{},
|
||||
@@ -2269,7 +2428,7 @@ pub fn inputTextMultiline(label: [:0]const u8, args: struct {
|
||||
return zguiInputTextMultiline(
|
||||
label,
|
||||
args.buf.ptr,
|
||||
args.buf.len,
|
||||
args.buf.len + 1, // + 1 for sentinel
|
||||
args.w,
|
||||
args.h,
|
||||
args.flags,
|
||||
@@ -2290,7 +2449,7 @@ extern fn zguiInputTextMultiline(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn inputTextWithHint(label: [:0]const u8, args: struct {
|
||||
hint: [:0]const u8,
|
||||
buf: []u8,
|
||||
buf: [:0]u8,
|
||||
flags: InputTextFlags = .{},
|
||||
callback: ?InputTextCallback = null,
|
||||
user_data: ?*anyopaque = null,
|
||||
@@ -2299,7 +2458,7 @@ pub fn inputTextWithHint(label: [:0]const u8, args: struct {
|
||||
label,
|
||||
args.hint,
|
||||
args.buf.ptr,
|
||||
args.buf.len,
|
||||
args.buf.len + 1, // + 1 for sentinel
|
||||
args.flags,
|
||||
if (args.callback) |cb| cb else null,
|
||||
args.user_data,
|
||||
@@ -2620,7 +2779,7 @@ extern fn zguiColorButton(
|
||||
pub const TreeNodeFlags = packed struct(c_int) {
|
||||
selected: bool = false,
|
||||
framed: bool = false,
|
||||
allow_item_overlap: bool = false,
|
||||
allow_overlap: bool = false,
|
||||
no_tree_push_on_open: bool = false,
|
||||
no_auto_open_on_log: bool = false,
|
||||
default_open: bool = false,
|
||||
@@ -2631,8 +2790,9 @@ pub const TreeNodeFlags = packed struct(c_int) {
|
||||
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: u18 = 0,
|
||||
_padding: u17 = 0,
|
||||
|
||||
pub const collapsing_header = TreeNodeFlags{
|
||||
.framed = true,
|
||||
@@ -2732,7 +2892,7 @@ pub const SelectableFlags = packed struct(c_int) {
|
||||
span_all_columns: bool = false,
|
||||
allow_double_click: bool = false,
|
||||
disabled: bool = false,
|
||||
allow_item_overlap: bool = false,
|
||||
allow_overlap: bool = false,
|
||||
_padding: u27 = 0,
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -3245,11 +3405,13 @@ pub const PopupFlags = packed struct(c_int) {
|
||||
_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: u23 = 0,
|
||||
_padding: u21 = 0,
|
||||
|
||||
pub const any_popup = PopupFlags{ .any_popup_id = true, .any_popup_level = true };
|
||||
};
|
||||
@@ -3297,7 +3459,8 @@ pub const TabItemFlags = packed struct(c_int) {
|
||||
no_reorder: bool = false,
|
||||
leading: bool = false,
|
||||
trailing: bool = false,
|
||||
_padding: u24 = 0,
|
||||
no_assumed_closure: bool = false,
|
||||
_padding: u23 = 0,
|
||||
};
|
||||
pub fn beginTabBar(label: [:0]const u8, flags: TabBarFlags) bool {
|
||||
return zguiBeginTabBar(label, flags);
|
||||
@@ -4380,6 +4543,14 @@ pub const DrawList = *opaque {
|
||||
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;
|
||||
|
||||
|
||||
255
src/te.zig
Normal file
255
src/te.zig
Normal file
@@ -0,0 +1,255 @@
|
||||
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.?);
|
||||
}
|
||||
241
src/zgui.cpp
241
src/zgui.cpp
@@ -4,6 +4,16 @@
|
||||
#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
|
||||
@@ -51,6 +61,10 @@ 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);
|
||||
}
|
||||
@@ -63,12 +77,12 @@ ZGUI_API void zguiEnd(void) {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiBeginChild(const char* str_id, float w, float h, bool border, ImGuiWindowFlags flags) {
|
||||
return ImGui::BeginChild(str_id, { w, h }, border, flags);
|
||||
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, bool border, ImGuiWindowFlags flags) {
|
||||
return ImGui::BeginChild(id, { w, h }, border, 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) {
|
||||
@@ -213,6 +227,12 @@ ZGUI_API void zguiGetItemRectMin(float rect[2]) {
|
||||
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;
|
||||
@@ -2208,6 +2228,66 @@ ZGUI_API void zguiViewport_GetWorkSize(ImGuiViewport* viewport, float p[2]) {
|
||||
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
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
@@ -2473,3 +2553,156 @@ ZGUI_API void zguiPlot_PlotText(
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
} /* 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
|
||||
|
||||
Reference in New Issue
Block a user