Skip to content

Commit 48a245c

Browse files
committed
Add Convert button
1 parent 19bcf53 commit 48a245c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/main.zig

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ pub fn main() !void {
2828
zgui.init(gpa);
2929
defer zgui.deinit();
3030

31-
_ = zgui.io.addFontFromFile("content/Roboto-Medium.ttf", 16.0);
31+
// _ = zgui.io.addFontFromFile("content/Roboto-Medium.ttf", 26.0);
32+
// _ = zgui.io.addFontFromFile("content/FiraCode-Medium.ttf", 26.0);
33+
_ = zgui.io.addFontFromFile("content/ProggyClean.ttf", 26.0);
3234

3335
zgui.backend.init(
3436
window,
@@ -40,13 +42,36 @@ pub fn main() !void {
4042
while (!window.shouldClose()) {
4143
zglfw.pollEvents();
4244

45+
zgui.backend.newFrame(
46+
gctx.swapchain_descriptor.width,
47+
gctx.swapchain_descriptor.height,
48+
);
49+
50+
// Set the starting window position and size to custom values
51+
zgui.setNextWindowPos(.{ .x = 20.0, .y = 20.0, .cond = .first_use_ever });
52+
zgui.setNextWindowSize(.{ .w = -1.0, .h = -1.0, .cond = .first_use_ever });
53+
54+
if (zgui.begin("Button list", .{})) {
55+
if (zgui.button("Convert", .{ .w = 200.0 })) {
56+
std.debug.print("Converting...\n", .{});
57+
}
58+
}
59+
zgui.end();
60+
4361
const swapchain_texv = gctx.swapchain.getCurrentTextureView();
4462
defer swapchain_texv.release();
4563

4664
const commands = commands: {
4765
const encoder = gctx.device.createCommandEncoder(null);
4866
defer encoder.release();
4967

68+
// GUI pass
69+
{
70+
const pass = zgpu.beginRenderPassSimple(encoder, .load, swapchain_texv, null, null, null);
71+
defer zgpu.endReleasePass(pass);
72+
zgui.backend.draw(pass);
73+
}
74+
5075
break :commands encoder.finish(null);
5176
};
5277
defer commands.release();

0 commit comments

Comments
 (0)