open_ui

Crates.ioopen_ui
lib.rsopen_ui
version1.4.0
sourcesrc
created_at2022-07-17 22:01:32.999087
updated_at2022-08-11 13:38:54.92143
description🕹 Build cross-platform GUI apps with Rust
homepagehttps://github.com/craigfay/open_ui
repositoryhttps://github.com/craigfay/open_ui
max_upload_size
id627389
size63,612
Craig Fay (craigfay)

documentation

README

Welcome! 👋

OpenUI is a developer friendly Rust library for creating cross-platform GUI apps. This is a great choice for anyone who doesn't want to work directly with OpenGL, or wrappers like Glutin and Glium, and for anyone who doesn't need an entire desktop web framework like Electron or Tauri.

Try It Yourself! 🕹

It's extremely easy to try out the OpenUI example project, a 1980's-style Snake Game. Use the arrow keys and spacebar to play.

git clone git@github.com:craigfay/open_ui.git && cd open_ui
cargo run

Developer Installation 💽

Add OpenUI as a dependency in any Cargo project:

# Cargo.toml
[dependencies]
open_ui = "*"

Build Your Own App with OpenUI 🧱

To create a Rust program that renders a UI, simply define a struct that implements the UIController interface:

use open_ui::UIController;

// Define a struct to hold your application data
struct SnakeGame {};


// Implement the `UIController` interface to define application behavior
impl UIController for SnakeGame {

    fn blueprint(&self) -> UIBlueprint {
        // This function wil be called once before the application opens,
        // and determines the initial settings of the rendering window.
    }

    fn next_frame(&mut self) -> Option<&RgbaImage> {
        // This function will be called called every frame,
        // and returns the contents of the next render-able frame,
        // or `None` if the application should terminate.
    }

    fn process_events(&mut self, events: &Vec<UIEvent>) {
        // This function will be called every frame, receiving
        // input events, and usually responding by modifying state.
    }
}

Then, pass an instance of that struct into UI::launch():

use open_ui::UI;

fn main() {
    let application = SnakeGame::new();
    UI::launch(application);
}

Caveats

OpenUI does all its work on the CPU, and does not attempt (at this time) to leverage GPU acceleration. This means that its probably not suitable for workloads involving realistic 3D rendering. That said, OpenUI is more than capable of handling almost any 2D graphics workload on modern machines.

Resources 📖

Commit count: 185

cargo fmt