This is a very simple UI library building upon ggez game library. It was originally written for personal use with my own Rust gamedev projets. The whole library is very much work-in-progress.
Message based communication with both internal (a user clicks a button) and external (a resource amount in your game changes) sources. Messages are handled internally with a customizable message handler, allowing you to change the look and content of your UI to react to user interaction or game state changes. All internal messages are also returned from the message handling function of your top UI element, allowing your game state to react to user inputs.
Stack-based scene manager eases the work with multiple scenes in a single game significantly by handling changes of main game state and appropriate drawing of (stacked) scenes.
Sprite struct automates drawing an animated sprite with multiple variants (e.g. an attacking, walking, ... character) and can be loaded from a single spritesheet file.
Drag & Drop
Possibly docs.rs and crates.io releaes.
I am maintaining this project mostly for my own purposes. You may not actually want to use this, but hey, it's public. Bug fixes are not guaranteed and features ~~may be~~ are lacking, as they are most precisely what I wanted from a UI library, which may not neccessarily be what you want.
TODO
The following rules guide how an element in MooEye tries to size itself.
Any element will always stay within the bound given by its layout::size
.
draw_to_rectangle
is called with is too small, the element will not display (but may still consume space).layout::size
modifiersIf the given rectangle is too large, the element will not grow above its layout::size
and instead align as according to its layout::alignment
.
An additional size requirement may be given not by the layout
, but by the content
of the element. Here, the upper bounds will (so far) be ignored, but the element will try to respect the lower bounds when adjusting its size. These content bounds are mostly used to containers respect the space requirements of their children.
If bounds are too large for this conent limit, the element will still fit itself to the bounds and deal with the unneeded space accordingly. E.g., a container might give too-large rectangles to its children, causing them too act as described above.
Elements with the preserve_ratio
flag of their layout
set to true will only display their content in the ratio of the lower limits of their layout::size
. Their background will be drawn as normal, and the element will then scale down in the dimension that would have been stretched more in order to fit onto this background.
## License
MIT License