Current state of Agui #23
-
Hello, I was planning to write a barebone Flutter clone in Rust to help me develop user interfaces for my hobby projects when, during my initial research, I learned about the existence of Agui, which appears to go in a very similar direction to what I had intended. I don't mind coming up with my own user theme and set of widgets since many of those required by my projects need to be custom-built anyway. While browsing the Agui source code for examples, I found implementations for the Button and TextField widgets, except those appear to depend on types that were deprecated a few months back (such as PaintContext & Layout). I'd like to familiarize myself better with Agui by restoring the functionality of these two widgets as an exploratory step. How would you suggest I go about this? (i.e. Where was the PaintContext functionality moved? etc) Would you rate Agui in its current state as complete enough to implement a decent set of interactive widgets (e.g. sliders, combo box, scrollbars, tabbed views, etc) and build a moderately complex desktop application above it all? And if not, what are the missing bits and pieces? Thanks for your help, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Unfortunately the answer is not so simple as you might hope. I don't have a ton of time to pump into this due to work obligations and I'm pretty far into a sizable rework of data flow, event handling, and yanking out morphorm in favor of direct layout calculations, along with decoupling windowing and rendering from the engine itself. A lot of that work has already been done! Inherited widgets are working quite nicely, winit windowing is in its own crate, as is the vello integration, but these are only a month old at best so need some general work. Heck, the vello integration doesn't even properly support textures, yet, but it's on my relatively short todo-list. My current priorities are unfortunately blockers for any actual use-cases. I need to re-implement mouse events/gestures, focusing, and keyboard event handling. All of these relied on inherited widgets being completed so I can get them into the tree without hacks, and inherited widgets took me a good long time to figure out a way I was happy with implementing them. Once that's done (or at least in a usable state), re-implementing the controls (I likely will yank out Button and TextField in favor of significantly more generic, composable widgets) and adding new ones is absolutely the next priority. Beyond that is improving the graphical capabilities of the painting system, even if vello doesn't properly support what I need it to do just yet. As a more general subject, I'm trying to figure out how I actually want users to build interfaces. The Even further down the line: hot-reload is a stretch goal, but haven't put a ton of time looking into it just yet. At any rate: with the pace I'm going on this, I don't see the things you need being implemented any time in the next few months considering I'm working alone, but it'll happen eventually! Side note: "barebones flutter" is actually surprisingly difficult! I'm actually around two years into this, working on it on-and-off, and I'm still not to what I would consider "barebones." (Though that's definitely completely my fault. I've been a stickler for performance and ensuring I uphold some invariants so that the engine can optimize rebuilds as much as possible). I'd put that landmark following proper mouse, focus, and keyboard handling. |
Beta Was this translation helpful? Give feedback.
-
First and foremost, a massive thank you for your quick and comprehensive response. In regard to your side note, I absolutely agree that calling it "barebone" is a misnomer. I'm fully aware of the monumental effort it takes to reimplement Flutter (even if it's just a modest chunk of it) in any language, let alone idiomatic Rust. Therefore, I was pumped to come across your diligent work on this. It's worth noting that some voices online had previously dismissed the idea of crafting a Flutter-like toolkit for Rust, citing the object-oriented nature of Flutter and the unique characteristics of Dart as blockers. However, your work on Agui seems primed to prove the doubters wrong! Out of all the ongoing efforts to create a native GUI toolkit tailored for Rust, yours displays the most promising potential in my opinion. Having dabbled in various GUI toolkits in the past (you name it, I've likely tinkered with it), I must admit that Flutter remains one of the most pleasant development experiences I had. Consequently, I'm eagerly looking forward to what Agui might achieve. With that said, I genuinely wish I could contribute to this remarkable effort. However, I must confess that I'm still a relative newcomer to Rust. While I'm working on transitioning from my C++ background and immersing myself in Rust's ecosystem, I recognize that there are certain ingrained habits I need to shed before I can confidently produce elegant Rust code. Simply put, I'm not yet at the proficiency level where my contributions could make a significant impact on this project. Nonetheless, I'll be closely tracking its progress and have every intention of adopting it at a later stage. Hopefully, my abilities with Rust will have slightly improved by then so that I might be able to help you in some capacity. Wishing you the best of luck with this project, and looking forward to future interactions! |
Beta Was this translation helpful? Give feedback.
-
I've come across that sentiment previously and definitely see where they're coming from! It requires an unfortunate amount of dynamic dispatch (unavoidable, but still more than I'd like), and all widgets must be reference counted since all widgets have the capability of rebuilding themselves at any time (the engine must be able to refer to it directly). This means when building your UI, all widgets need to be wrapped in With that said, feel there's a case to be made that for sizable interfaces the benefits of not updating the entire tree when rebuilding far outweighs the downsides of DD. Though it does lock agui out of some embedded environments. Some of flutter's implementation has to be reworked to fit Rust's coding style, though things have worked with few deviations thus far. Heck, the whole Flex implementation was essentially copied 1:1\! |
Beta Was this translation helpful? Give feedback.
-
Hey there, I wanted to discuss with you about a specific issue I've been grappling with pertaining to Flutter on Rust. One of the key factors in how Flutter efficiently handles rebuilds relies on Dart's implementation of the keyword For instance...
When you create an instance of Coming from a background in C++, this behaviour closely resembles the
Output:
However, Rust, while highly capable, seems to be more stringent in what it permits to be declared as |
Beta Was this translation helpful? Give feedback.
-
Just out of curiosity, why does Agui use inherited widgets for input events? When I look at the Flutter documentation, it seems like all input-related widgets (like Listener, MouseRegion, Semantics, etc.) ultimately boil down to SingleChildRenderObjectWidget. This approach makes sense since render object widgets are the only ones that have knowledge about their screen dimensions (for hit testing). I admit I haven't delved deep into Flutter's source code but I'm guessing that when the PlatformDispatcher fires an event, it likely traverses the render object tree (or focus node tree for keyboard events) to determine which widget shall receive the event so I was wondering what is the role of inherited widgets in this process. Thanks. |
Beta Was this translation helpful? Give feedback.
Unfortunately the answer is not so simple as you might hope. I don't have a ton of time to pump into this due to work obligations and I'm pretty far into a sizable rework of data flow, event handling, and yanking out morphorm in favor of direct layout calculations, along with decoupling windowing and rendering from the engine itself.
A lot of that work has already been done! Inherited widgets are working quite nicely, winit windowing is in its own crate, as is the vello integration, but these are only a month old at best so need some general work. Heck, the vello integration doesn't even properly support textures, yet, but it's on my relatively short todo-list.
My current priorities are u…