- Notifications
You must be signed in to change notification settings - Fork5
Themable Immediate Mode User Interface Toolkit in Rust
License
Grokmoo/thyme
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Thyme is a Graphical User Interface (GUI) library written in pure, safe, Rust. All widgets are rendered using image sources, instead of the line art more commonly used by other Immediate Mode GUIs. The image definitions, fonts, and style attributes are all specified in a unified theme. This is generally drawn from a file, but anySerde compatible source should work. Live Reload is supported for asset files for a more efficient workflow.
A composite image showcasing three different themes:
Thyme produces a set of Draw Lists which are sent to a swappable graphics backend - currentlyGlium andRaw GL are supported. We have previously supportedwgpu but the rate of change there has been too great for the author to keep up and support is not current. The I/O backend is also swappable - although currently onlywinit is supported. Fonts are rendered to a texture on the GPU usingrusttype.
Performance is acceptable or better for most use cases, with the complete cycle of generating the widget tree, creating the draw data, and rendering taking less than 1 ms for quite complex UIs.
The demo contains an example role playing game (RPG) character generator program that uses many of the features of Thyme.
git clone https://github.com/Grokmoo/thyme.gitcd thymecargo run --example demo_glium --features glium_backend# Run demo using gliumcargo run --example demo_gl --features gl_backend# Run demo using OpenGL
Run the hello_world example with either Glium or GL:
cargo run --example hello_glium --features glium_backendcargo run --example hello_gl --features gl_backend
Add the following to your Cargo.toml file:
[dependencies]thyme = {version ="0.7",features = ["glium_backend"] }
Seehello_glium for the bare minimum to get started with your preferred renderer. As a starting point, you can copy thedata folder into your own project and import the resources there, as in the example.
See thedocs for the full API reference as well as theme definition format.
At its core, Thyme is an immediate mode GUI library similar to other libraries such asDear ImGui. However,unlike many of those libraries Thyme is focused on extreme customizability and flexibility needed for production applications, especially games.
With Thyme, you can customize exactly how you want your UI to look and operate. Thyme also focuses a great deal on being performant, while stillretaining the benefits of a true immediate mode GUI. Thyme also implements a number of tricks granting more layout flexibility than traditionalimmediate mode libraries, although there are still some limitations.
This flexibility comes at the cost of needing to specify theme, font, and image files. But, Thyme comes with some such files as examples to help youget started. Separating assets out in this manner can also significantly improve your workflow, especially with Thyme's built in support for livereload. This strikes a balance, enabling very fast iteration on layout and appearance while still keeping your UI logic in compiled Rust code.
This flexibility does come at a cost, of course - There is quite a bit of overhead in getting started compared to similar libraries. Once you get up andrunning, though, the overhead is fairly minor. Performance is also very good and should be at least on-par with other immediate mode GUIs.
Thyme comes with a library of widgets similar to most UI libraries. However, Thyme's widgets are written entirely using the public API, so thesource
for these can serve as examples and templates for your own custom widgets.
It is also written from scratch in 100% Rust!
Licensed under Apache License, Version 2.0, (LICENSE orhttp://www.apache.org/licenses/LICENSE-2.0).
Note that some of the sample theme images are licensed under a Creative Commons license, seeattribution.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
About
Themable Immediate Mode User Interface Toolkit in Rust