Quark - GUI toolkit made for Zig focused on simplicity

,

GUI toolkit made for Zig focused on simplicity

That tagline is soo gonna change in the future.

Quark is a Vulkan-based GUI toolkit framework designed for those who needs a UI that’s nice and simple—visually and in code without the extra overhead other frameworks has.

This isn’t my first time trying to do a project related allowing people to create GUI *, but this one is the one I’m most proud of. There’s still some bugs and all, I’m fixing some of them right now and overall making the usage of coding with Quark easier for everybody in the process.

Quark is a hybrid GUI—between retained and immediate mode, because I want the best of both worlds :). So far—there’s two application that uses Quark as it’s GUI framework—in which, both of them are mine. Both of which is currently rswlsr (the one i’m working on currently) and Cazic.

Here’s a working-in-progress image of rswlsr, a really simple wayland screen recoderer:

Quark currently has about 15 widgets (I’m not gonna recount, my podcast is more important) ranging from a simple Button and Text to Image and Canvas.

I’m open to criticism—I want this project to get better and better overtime, not a burden for people developing their application with it. So anything you like, love, or hate about this project—please tell me about it.
Any bug fixes or issues would really be appreciated as well.

I don’t know what else to say really, I hope I’ve said enough. This is my first post overall and showcasing this library to the masses is something I’m kinda scared of, but you just gotta push through, huh?

Supported Zig versions

Right now—0.16.x.
It’ll always support the most up-to-date stable release of Zig as long this project exists. Support for older Zig versions aren’t in mind, right now at least.

AI / LLM usage disclosure

Claude was involved in creating the first “draft” of Quark (v4[r3])—which is about 6 months ago. It was somewhat encouraged that you could use AI for coding assistant or to impl something that’s on that big of a scale (take for example—300 lines of Vulkan) but starting two weeks ago, the usage of AI isn’t allowed anymore, as I’ve realised that yeha… AI isn’t a tool you must depend on all the time.—And AI just can’t code to save it’s life unless it’s web slop.

This project isn’t “vibe-coded” or anything, I build on top of what was there in the first draft.

12 Likes

As a marketing tip, I think you should put an image on the readme of a sample program using the gui. When people hear about a gui, the first thing people expect to see is the gui.

9 Likes

True true—there needs to be a showcase image, thanks for the info! :0
They are images in the examples/ folder but they aren’t “worthy” of being displayed on the main README.md

3 Likes

Whenever I hear about a new “GUI” toolkit, my immediate questions are about:

  • What platforms are supported and tested?
  • What’s the paradigm (retained, immediate, mixed)?
  • What does it look like? Show pictures.
  • What widgets do you support? Show pictures.
  • What human interface input devices do you support? (touch, pen, IME, …)
  • Text? (Unicode, BIDI, font linking, editing, rich text)
  • Internationalization?
  • Accessibility?
  • Performance, memory usage, and allocation strategy.
4 Likes

What platforms are supported and tested?

Just Linux right now, Wayland

What’s the paradigm

It’s a Hybrid

What does it look like?

You can look at the pictures available in the examples folder—Quark - GUI toolkit made for Zig focused on simplicity - #3 by xan. Other projects that are made with Quark are rswlsr and Cazic.


^ WIP version of rswlsr.

What widgets do you support?

you can check by going in the src/Widget/ folder.

What human interface input devices do you support?

Just KB and Mouse

Text? (Unicode, BIDI, font linking, editing, rich text)

via FreeType2. no BIDI, Rich Text is a widget in Quark

Internationalization?

No i18n, I’m the only one working on this library right now and I only speak English.

Accessibility?

Not planned right now, this GUI toolkit is still small and there’s other things to do right now than doing accessibility.

Performance, memory usage, and allocation strategy.

There’s text width caching, texture caching, like—performance is a number one priority for Quark.

5 Likes

some of these questions should be answered either in the top post here or in the README of your repo.

2 Likes

yeha—you’re right. I’m still working on the docs and all so no time soon I’ll post them in the repo.

1 Like

Since you said you are open to (constructive) criticism:

Based on your examples, it looks like you handle event dispatch via assigning integer id’s to widgets. While this avoids the classic callback hell of something like Qt, I don’t think it would be particularly maintainable for a project with hundreds to thousands of widgets. I believe dvui uses the source location builtin to generate an id, which is more maintainable, but I am not sure if that would work with your design.

The “hybrid” retained mode and immediate mode API also feels rather primitive; like I am programming against a basic 2D renderer. What makes immediate mode APIs great is that rendering and logic is localized, but you have this weird split where the event loop is separate from the layout and view logic, while it still feels like immediate mode “layout”.

Also, I wouldn’t make claims like “low overhead compared to other frameworks” unless you actually went and measured it. It frankly makes me take your code not that seriously, but today I am feeling charitable.

My advice would be to commit to one style. The separate event loop and view feels more similar to something like Elm architectures. Those improve the ergonomics via message passing which is more general than event handlers.

3 Likes

https://codeberg.org/pparaxan/quark/issues/21
Thanks for the criticism, yeha—it’s understandable.

1 Like

Changes has been pushed to master, thanks for the feedback.

I was actually going to test this since just making a random claim saying your GUI toolkit is faster while it could not could be bad rep, but I lost the markdown file I made about it and since then I just kinda moved on from doing that all over again.
Yeha—I shouldn’t have claimed first.

1 Like

Well done! My son who is also 16 cannot do anything close :smiley: to this :person_facepalming:

I think it depends on the language you’re using, [the project you’re working on] how clean the code is, and how much time you’ll dedicate to a single project.

When I started making projects in Rust around ~13, I thought it’d work out for me in the end because that’s what everybody was using—I thought Rust was “the future.” But after I found Zig, it’s like… somebody injected me*h into me—like something just lid up in my mind, and just like that I instantly became in love w/ it (It did took me like 5 months to learn the build system alone however—it’s also Zig after all). Now—even though Zig is in alpha still, I feel like I could spend a year learning its features, types, and still come out happy (and sane).

Well done! My son who is also 16 cannot do anything close :smiley: to this :person_facepalming:

I don’t think I deserve that, as I wouldn’t say I’ve made this 100% by myself. Again—I did used AI to create the first draft. But while learning Zig, that draft ended up teaching me a lot about the language, take for example—Source File Structs I read the docs for that one, but you get the point. At the time, I was still in school, like—I didn’t have that much time to learn a new language, and with Zig being in alpha, meaning that there weren’t that much as learning resources available… Look—I didn’t want to wait years before building something in Zig that I was actually proud of.

I know AI is still a very, and I mean a very controversial topic, but that’s mostly the reason of what kept me working on this project, and no—by that I don’t mean like “ChatGPT, uhh—Add a feature that goes like <x>” and just committing like I did hard work. When I started the project—to be blunt I was bored. Quark wasn’t even meant to be a GUI toolkit—it started as a WebView wrapper like Tauri :skull:. I wasn’t a GUI toolkit person and what the hell is “graphics programming?”.

Though, instead of just letting AI blindly do all the work, I used like what any normal person would… made it teach me on what’s happening because at the end of the day—I genuinely still wanted to learn Zig, and now I’m guessing GUI development. As I’ve said before—I don’t think AI is something you should depend on, but it can be an useful tool for learning and improving. Over the past six months alone—when I pushed the code of the first draft, it has taught me a a lot amount about Vulkan, the layout system, how widgets interact with said layout system and mostly Zig itself. It actually helped me understand some features and concepts of the language that I’d probably take a more longer time to discover on my own.

Anyway I need to stop talking, might as well be writing documentation for Quark… which I can’t bother w/, but I think you get the point.

tl;dr: it depends if your son is actually committed to this and the ways he’ll used to learn, idk man I’m 16 myself, why am I saying this like I’m a father or something?

2 Likes

Sorry to hijack the thread. Do you know of a library that has BIDI and internationalization support?

Like GUI?—QT?
If you meant something related to text—as like an engine, maybe Harfbuzz?

I mean—if there’s this much need of support for BIDI, I might as well try to impl it for Quark.

a gui. I think qt is what I needed but was looking maybe there is an immediate more library. Thanks

ah, ohkay then

Hey, congrats on your toolkit.
Are you just 16 ? Double congrats!!! When I was 16 I was learning basic. I wonder if that was what made me mentally mutilated, as Dijkstra said :thinking:
Anyway, I have 2 questions:

  1. You say it depends on Wayland but you list Vulkan and FreeType2. I know, it is possible, but I just wanted you to clarify, please;
  2. Does the TextField widget support password masking (replacing input characters with dots/asterisks) ? From what I could see, not yet, right ? Is it in your radar ?
    Thanks.
1 Like

Oh my… :eyes:

Noted.

OH CRAP, yes it is on my radar—I’ve totally forgotten about that. Not sure why I didn’t note that down because I’m working on a project that has a login system, and making the password just visible like that is a recipe for disaster…

Thanks for telling me—https://codeberg.org/pparaxan/quark/issues/25

1 Like