Which GUI crate?
from Charger8232@lemmy.ml to rust@programming.dev on 23 Sep 01:07
https://lemmy.ml/post/36537722

I can’t figure out which crate(s) I should be using to create GUI applications. I only want to create simple 2D games like Conway’s Game of Life, so I don’t need anything fancy. At most I would like to be able to easily create polygons.

I’ve already looked at Are we game yet?, but it would be a waste of time to learn 20 different crates in order to decide on which one to use. Bevy is far too heavy and doesn’t even work if you are low on memory. SDL3 isn’t natively supported without some workarounds (but SDL2 is fine). Winit tries to use insecure X11 unless I manually add it as a dependency with the Wayland feature. I plan to eventually learn GTK4+Adwaitta, but that’s unnecessary for simple games.

GUI in Rust seams like a mess. There’s so many crates ranging from simple to complicated. Information becomes outdated quickly, so LLMs often fail to help. There’s few clear comparisons between crates to help you decide, so it becomes a headache. I’m just looking for a modern, safe, easy, minimal GUI crate.

Does anyone have any advice?

#rust

threaded - newest

quaff@lemmy.ca on 23 Sep 01:57 next collapse

The IRC client, Halloy uses iced.rs and that is a very beautiful client. Also, the upcoming Cosmic Desktop major version uses Iced as well. So that maybe a good indicator where efforts are heading.

ISO@lemmy.zip on 23 Sep 05:02 next collapse

Not my area of expertise, but egui may suit your use-case better than the usual candidates.

alzymologist@sopuli.xyz on 23 Sep 06:04 next collapse

GUI is just a mess. I think bevy is to-go though, it could be tuned a lot to turn down memory demand. Otherwise, use system level stuff, like web-based ui or Qt wrap.

At least that’s what I ended up thinking after struggling with same question.

asudox@lemmy.asudox.dev on 23 Sep 07:43 next collapse

Slint is a cross platform one.

Iced and egui are also an option.

sukhmel@programming.dev on 23 Sep 07:48 next collapse

I tried to build simple UI with floem, slint, and iced.

  1. slint seems to allow to do the most, it’s GNU GPL, and it allows you to move boilerplate to separate *.slint files much like Qt, imo.
  2. floem seemed the most flexible to me, but it requires attaching signals everywhere manually.
  3. iced seemed the easiest to use, but not exactly too flexible. I think some looks of the already simple UI I wanted to create were not possible there.

You can check out my repo to see if it helps to answer your question. And yeah, I know the features shouldn’t be mutually exclusive 🌚

INeedMana@piefed.zip on 23 Sep 08:29 next collapse

Personally I would start with plain SDL2 and then add GTK. Both of them are language-agnostic, so you are learning something that you can use in other projects too. And are widely used, so while the Rust binds might add some spiciness to the mix, it should be easier to search for clues

TehPers@beehaw.org on 23 Sep 09:44 next collapse

The title seems a bit confusing. Do you want a game library, or a GUI library?

Assuming you’re doing game dev, bevy is probably the furthest along, though there are a few alternatives. You can enable only the features and plugins you need to lower the memory footprint, though it’s not clear to me how low of memory you’re looking for.

As far as I know, everything uses winit. If you need the feature enabled, you can add it as a dependency directly (in Cargo.toml) and enable the feature.

If you’re having a hard time, maybe consider a completed game engine. Have you looked at Godot? Does it need to be in Rust?

calcopiritus@lemmy.world on 23 Sep 17:36 next collapse

When I want to draw raw polygons, I use wgpu. When I want a GUI I used iced. And when I want both, I use wgpu+imgui.

Learning wgpu is quite steep, and it has tons of boilerplate. So unless you’re certain that you will use it a lot. I would just use iced.

When I say wgpu I mean wgpu+winit. Though winit is quite simple and light. So the main part is wgpu.

dipdowel@feddit.nl on 26 Sep 18:52 next collapse

Hi. Please take a look at Graph1. It may potentially be what you’re looking for: graph1.codument.com

It is designed for (simple) animated graphics projects. A considerable improvement in displaying pixel fonts is planned to be rolled out in 2-3 weeks.

sukhmel@programming.dev on 04 Oct 14:51 collapse

Just wanted to get back to tell that I tried graph1 to mess around with non-linear projection, it seemed like an interesting crate but it felt like it’s a bit too low level for doing a GUI with it.

blazebra@programming.dev on 26 Sep 19:55 collapse

Currently I use WxWidgets and Cocoa for macOS.

The best would probably be pure native UI with static/dynamic library in Rust for logic. Sounds hard, but it’s the best option in my opinion.

My 2 cents is below. Your decision depends on your tasks, preferences and targets.

  • GPU framework maybe fast, but accessibility at 0
  • HTML backend is nice, but I can’t choice other than native, which limits me quite hard for target user base. And I don’t like JS if not strictly required (it’s a personal preference).
  • GTK on macOS and windows is quite hard to install and I don’t like visuals
  • QT is in grey zone if static (non-GPL project), and I haven’t found good way to bundle it if dynamic
  • ImGUI is nice but I don’t know if they support HiDPI monitors and accessibility is not the highest
  • fltk is nice, but 1) many things you’ll have to write by you own, rewriting sometimes from FLTK2 C++ code… and community could be more chill and friendly
  • Windows Metro UI… probably no crates
  • Win32 API GUI works perfect
  • Swift… probably yes, but it’s very OS-dependent
  • Cocoa — very nice for macOS.
  • current stop is WxWidgets: small, embedded, look… ok for now.
  • there’s some framework for iOS and Android, looks fine for me, but not my target ATM.
blazebra@programming.dev on 26 Sep 20:13 collapse

I’ve forgot slint. Same as QT