use iced::widget::{column, *};
use iced::{Center, Color, Fill, Theme, border, color};
fn main() -> iced::Result {
iced::application(|| (), update, view)
.window_size((500, 500))
.run()
}
fn update(_: &mut (), _: ()) {}
fn view(_: &()) -> impl Widget<()> {
let swatch = |c: Color| {
container("")
.width(32)
.height(32)
.style(move |_| container::background(c))
};
let colors = [
color!(0xff0000),
color!(0x00ff00),
color!(0x0000ff),
color!(0xffff00),
Color::BLACK,
Color::WHITE,
];
container(
column![
text("Hello, World!").size(20).color(Color::WHITE),
row(colors.map(swatch)).spacing(8),
]
.spacing(12)
.align_x(Center),
)
.center(Fill)
.style(panel)
}
fn panel(_: &Theme) -> container::Style {
container::background(color!(0x505050)).border(border::color(color!(0x0000ff)).width(1))
}
Also this is a pretty shit example because it's mostly showing styling... and in any sane app, you have a predefined themeThe typical GUI example is a counter
Syntax is rarely a reason to choose a language
If Rust feels "ugly" to you, may I suggest you consider how that comes from lack of familiarity, rather than an intrinsic shortcoming of the language?
use dioxus::native::{Config, LogicalSize, WindowAttributes};
use dioxus::prelude::*;
fn main() {
let window = WindowAttributes::default().with_surface_size(LogicalSize::new(500.0, 500.0));
let config = Config::new().with_window_attributes(window);
dioxus::native::launch_cfg(app, vec![], vec![Box::new(config)]);
}
fn app() -> Element {
rsx! {
Stylesheet { href: asset!("/assets/tailwind.css") }
HelloWorld { text: "World" }
}
}
#[component]
fn HelloWorld(text: String) -> Element {
rsx! {
div { class: "flex flex-col gap-3 bg-[#505050] size-[500px] justify-center items-center shadow-lg border border-[#0000ff] text-xl text-white",
"Hello, {text}!"
div { class: "flex gap-2",
div { class: "size-8 bg-[red]" }
div { class: "size-8 bg-[lime]" }
div { class: "size-8 bg-[blue]" }
div { class: "size-8 bg-[yellow]" }
div { class: "size-8 bg-black" }
div { class: "size-8 bg-white" }
}
}
}
}
You can also use standard CSS if you prefer it over tailwind. And if you wanted to deduplicate, the 6 divs can be written in a loop like so: for color in ["red", "lime", "blue", "yellow", "black", "white"] {
div { width: "32px", height: "32px", background_color: color }
}> move |_| container::background(c)
There's no way anyone can see this and thinks it is legible
We're looking forward to using this at ArtCraft. We've already forked egui (and we're going to try to upstream our work). Even so, we find lots of things we cannot use egui for.
GPUI is essential for some of the work we're doing.
> No screenshots on web site, docs, or repo
If you are posting a GUI product of any kind.
Put together a demo.
And then, put the link right at top where everyone can find it. Not buried in a help document on page 66.
I know they have one, i've seen it. Couldn't say how to find it again.
visual examples seen as an afterthought instead of a prerequisite
these are the people that cried ageism for the last 15 years not noticing their rejection was actually because they railed against javascript being used outside of jquery
Now they’ve finally found a way to skip from C++ straight to Rust for frontend work
hope the community picks it up and makes it more convincing and accessible, with visual aids
I feel like naming a library after either GPUI/GPUGUI make talking about this technique difficult. And the technique didn’t originate in this library.
I don't know anything about <other_open_source_Rust_GUI>, but I expect the documentation to be half-baked, and if I look at the GitHub repo the most recent activity is going to be somebody who made a bug report 6 weeks ago and nobody has responded to it yet.
The team behind the software matters and a team with funding is appealing.
You'd be surprised what throwing just 1 or 2 people at marketing can do to get visibility.
Compared to just a group of engineers crunching out code.
The group of engineers might be building something great, but its just a tree falling the forest. Nobody hears it. You have to spend some time broadcasting it, making demo's, posting about it.
edit: Slint has good accessibility support too, but it's commercial for commercial projects.
1. egui (30.3M total / 9.2M last 90 days) (note: immediate mode)
https://crates.io/crates/egui
2. Iced (3.2M / 770k)
https://crates.io/crates/iced
3. Slint (2.4M / 955k) (note: GPL/commercial license)
https://crates.io/crates/slint
5. Dioxus Native (181k / 26k)
https://crates.io/crates/dioxus-native
6. Freya (49k / 12k)
https://crates.io/crates/freya
7. Floem (45k / 15k)
https://crates.io/crates/floem
8. Vizia (7k / 700)
https://crates.io/crates/vizia
All of those options are technically superior to GPUI in my subjective opinion. GPUI focusses pretty narrowly on Zed's use case, and suffers from severe NIH syndrome (so has put a bunch of time and effort into building things that already exist as crates in the Rust ecosystem).GPUI does have a pretty nice component library. And of course an excellent code editing control. And it's... fine. But I wouldn't choose it over the other options.
This is why people are flocking to it. Nothing else really matters.
https://refract.rs https://crates.io/crates/refract https://refract.rs/examples/chat
In the past month 1 person has made commits.
What does it matter if it's superior?
Actually, AI has come into existence since I last looked at it, so maybe docs aren't needed anymore?
honourable mention to slint, seems mature and good but I’ve never personally used it.
you can make it work for whatever usecase you want. that's the beauty of oss.
Thus far, it has also been quite fast hitting my performance targets which were also quite aggressive. The only real issue I’ve had is memory usage is higher than I’d like but it’s still 1/3rd of what I’d get if I was using Electron… and if I’m remembering right it’s mostly because of the driver stack.
I need to figure out what I plan on doing with the app when this first version is finished: open sourcing it, charging for it, or some combination of the two. Though I can’t imagine not trying to upstream or release the accessibility work.
ref: https://gpui-ce.github.io/
edit: lmao downvotes for this? what even is this community anymore?
[1]: https://github.com/iamnbutler/gpuikit, https://github.com/gpui-archipelago/gpui-unofficial