Pixel-widgets
pixel-widgets is a user interface library focused on use for games. It's architecture is inspired by elm, since it's very fitting for rust mutability patterns.
Features
- Very compact and easy API
- Render agnostic rendering
- wgpu based renderer included
- Styling using stylesheets
- Built in widgets
Check out the examples to get started quickly.
Overview
User interfaces in pixel-widgets are all defined by implementing a Model
, serving as the data model
for your user interface. The model then has to implement some methods:
view
- for generating a tree of ui widgets. These are retained for as long as the model is not mutated. Ui widgets generate messages when they are interacted with, which leads us to the next method:update
- modifies the model based on a message that was generated by the view
Other ways of updating the ui, such as futures and subscriptions will be be coming in the future.
Quick start
Setting up a ui with pixel-widgets is easy. You start with defining a model.
use *;
Then, we have to define a message type. The message type should be able to tell us what happend in the ui.
And finally, we must implement Model
on our state
use *;
// Now that we have a model that can be used with pixel-widgets,
// we can pass it to the sandbox to quickly see some results!
async