this post was submitted on 27 Jul 2023
20 points (95.5% liked)

Rust

6032 readers
2 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

I just attempted to write up a simple Minesweeper game with Iced. No bells or whistles, but it works:

https://github.com/veniamin-ilmer/minesweeper

On one hand, I find it pretty cool I built a clear cross platform GUI with actual functionality, within only 200 lines of code.

On the other hand, I can't help but see how inefficient it seems. If I ever need to modify any of the objects, I need to redraw all of them. The structure of the view method makes me think it is very difficult for Iced to maintain a "virtual DOM" to only make delta changes.

Am I wrong? Is there a more efficient way to do this in Iced?

Edit: I just found this - https://github.com/iced-rs/iced/pull/1284

As the library matures, the need for some kind of persistent widget data (see #553) between view calls becomes more apparent (e.g. incremental rendering, animations, accessibility, etc.).

If we are going to end up having persistent widget data anyways... There is no reason to have impure, stateful widgets anymore!

So it seems like Iced plans to have an internal "persistent widget storage", which in abstracted away from the user. But it is quite unclear to me how they would accomplish this, considering the view method doesn't provide an ID for any of its objects, so it would not be easy for Iced to determine the difference between updates.

you are viewing a single comment's thread
view the rest of the comments
[–] torcherist 1 points 1 year ago (2 children)

Have you looked at Bevy before? There is a popular Rust YouTuber that posts videos of his Bevy projects. Definitely look there for inspiration.

[–] [email protected] 4 points 1 year ago

Bevy is awesome, but I don't think it's really designed to be used as a retained-mode UI framework. I know it's on their roadmap to support traditional UIs (or at least was at one point), but as it is right now, it's primarily useful for making games which require regular re-renders of the entire screen.

[–] [email protected] 1 points 1 year ago (1 children)
[–] torcherist 2 points 1 year ago