Rust GUI library inspired by SwiftUI.
This library emphasises the usage of declarative syntax for clean & simple UI development.
This project was created as a means of exploring declarative UI syntax.
RustUI is not intended for real-world use.
I created RustUI to learn Rust, SDL2, and to explore UI libraries. Much refactoring is needed for further development.
See testing.rs for library capabilities and syntax.
Note that you will need a custom bitmap image to replace both instances of "temp_logo_low_quality.bmp" (simply change that string to the new image path).
Different executables can be tested by including them in /src/bin.
Run them via cargo run --bin file_name
For simplification, a script can be created to enter this command and any parameters.
Early development
The following items are required to run RustUI projects:
Download the above dependencies and place into project root directory (with Cargo.toml
)
Check for distribution-specific development packages/repos for the required libraries
- When using text, place the .ttf font in /res/font/
- In
font.rs
, updatedefault_font
for theFontParams
struct
- See Projects
- Font Management:
- When a font is needed, query font map
- if not found, load font and store for future use
- 90% of this library's CPU usage is font loading each frame (caused by Rust's SDL2 library lifetime usage)
- Persistent State:
- Persist widget state between view-generation cycles
- User would no longer need to maintain that widget's state
- Consider a map of widget id -> widget data
- Enforces unique ids
- Can use a trait to get data that needs to persist
- How to get this data back from the map?
- Persist widget state between view-generation cycles
- Persistent State Alternative:
- Do not generate new view, instead update view and re-layout
- Implement a signal for view change to generate new view
- Would then only lose state when new view is obtained
- Implement ECS for widgets and views (see widgets/widget.rs & views/view.rs)
- What must each widget share?
- What must each view share?
- What do both share?
- Scaling for high resolution/dpi displays
- Better GFX:
- Rounded rects
- Circles
- Cursors
- Basic Widgets:
- Drop Menu
- Radio Buttons
- Basic Views:
- Menubar
- Header/Footer
- Basic Components:
- Dividers
- Nested fixed-size views scrollable via scrollbars
- Basic Utilities:
- File Browser
- Message/Dialog Boxes
- Documentation:
- Finish documenting and add examples
- Build Script:
- Extract SDL2 libs for Windows
- Generate docs (and provide option to open)
- Run script
- Make these optional via flags
- Add a GridView macro with respective methods (like tkinter)
- Implement
font.rs
(separate widgets, backend, and font). - Stabilize FPS (without fixed loop dealys) -- implement delta time
- Implement graphics
- Image rendering
- Eventually, consider SVG rendering
- Use images for buttons
- How to handle varying width/height?
- Image rendering
- Run callbacks on separate threads
- At some point, should be able to simply pass a canvas and render UI to existing canvas
- This will require a different render cycle, as the user will define the run-loop
- Support multiple windows