• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

yakui is a declarative Rust UI library for games

yakui

yakui is a declarative Rust UI library for games.

Actions status Latest version Documentation Patreon
 

yakui is a work in progress. Feedback is welcome, but mind the dragons, sharp edges, and exposed nails!

yakui combines a layout model inspired by Flutter with the ease-of-use of an immediate mode UI library like Dear Imgui or egui.

yakui has the following priorities:

  1. Flexibility — yakui must be able to represent any widget
  2. Ergonomics — yakui must be terse, but must enable the user to go outside the box
  3. Performance — yakui must be fast enough to use in a shipping game
yakui panels demo — cargo run panels

Table of Contents

Getting Started

Add the yakui crate to your project:

cargo add yakui

Create a yakui::Yakui when your game starts:

let mut yak = yakui::Yakui::new();

Call start(), create your UI, then call finish():

yak.start();

yakui::center(|| {
    yakui::text(32.0, "Hello, world!");
});

yak.finish();

Finally, call paint() and feed the result to your renderer:

your_renderer.draw(yak.paint());

You can use the yakui-winit and yakui-wgpu crates to integrate with winit and wgpu, respectively.

Examples

Example setup code for yakui is available in crates/bootstrap.

You can run examples with cargo run --example <example name>. Check out crates/yakui/examples to get a list of available examples.

Many of the examples look like this:

fn app() {
    yakui::column(|| {
        yakui::text(32.0, "Hello, world!");

        if yakui::button("Click me!").clicked {
            println!("Button clicked.");
        }
    })
}

In these examples, the app function is run every frame, processing input and updating the UI. This replicates how games tend to work.

Rationale

yakui exists to fill two roles in the Rust game UI ecosystem:

  1. A library for prototype, development, or debug game UI
  2. A library for building polished, custom game UI

Most importantly, yakui provides a smooth transition from #1 to #2. When you reach the phase of your game's development where custom UI makes sense, you shouldn't need to throw out your existing UI code or technology. You should be able to incrementally improve the look, fit, and feel of your UI.

While Rust has multiple libraries aimed at debug or development UI, they do not place an emphasis on being capable for building good custom game UI. None of them provide a gradual path for converting from UI suitable for a game prototype into polished UI for a quality shipping game. All of yakui's built-in widgets are created using public APIs and are easy to compose, extend, or fork.

Many Rust UI libraries have expanded their scope to become desktop application toolkits. This leaves their core proficiency half-baked. yakui will always be focused on practical problems encountered building game UI.

Most attempts at building UI libraries have limited layout capabilities, making some kinds of widgets impossible to express. yakui is built upon Flutter's layout protocol, which can efficiently handle both bottom-up and top-down sizing when appropriate.

Architecture

yakui stands on the shoulders of giants.

It takes heavy inspiration from:

  • React — Declarative UI as a mainstream paradigm
  • Flutter — Single pass layout model, composable layout widgets
  • Moxie — Constructing UI as a tree of topologically-aware functions

A frame in yakui is divided up into distinct phases:

  1. Event Phase
    • Events are piped from the application into yakui and tested against the current DOM.
    • Widgets can sink or bubble events. Events bubble by default, and any events that bubble are given back to the application.
  2. Update Phase
    • This phase is started when Yakui::start is called. This binds the DOM to the current thread.
    • Functions are called that declare widgets and their current state.
    • Widgets that existed last frame are updated with new props, the input to a widget.
    • Widgets that didn't exist are created from props.
  3. Layout Phase
    • This phase is started when Yakui::finish is called. This unbinds the DOM from the current thread.
    • Each widget has its layout function run once, depth first.
    • Each widget is asked what events it is interested in receiving, like mouse or keyboard events.
  4. Paint Phase
    • This phase is started when Yakui::paint is called.
    • Each widget has its paint function run once, depth first.
    • Paint information is stored in the Paint DOM, which a renderer can use to draw the current set of widgets.

Crates

yakui is modular to support different kinds of users.

yakui

The yakui crate bundles together yakui-core with yakui-widgets to provide a pleasant out of the box experience.

If you're writing a game and want to use yakui, this is the crate to start with.

yakui-core

The yakui-core crate defines the DOM, layout, painting, and input, but provides no built-in widgets nor bindings to other libraries.

If you're working on a library that depends on yakui like a renderer or platform crate, this is the crate to use.

yakui-widgets

The yakui-widgets crate is a collection of built-in widgets for yakui. This includes layout primitives, text rendering, and basic form controls.

You should usually not depend on yakui-widgets directly. Instead, depend on yakui if you want to use these widgets, or yakui-core if you don't need widgets.

yakui-winit

The yakui-winit crate contains bindings for use with winit.

yakui-wgpu

The yakui-wgpu crate is a yakui renderer that uses wgpu.

yakui-vulkan

The yakui-vulkan crate is a yakui renderer that uses Vulkan via ash

yakui-app

The yakui-app crate is a wrapper around yakui-winit and yakui-wgpu intended to make getting started with yakui easier.

If you are writing your own integration for yakui, this crate is a good learning resource to reference.

Games Using yakui

There are a handful of games already using yakui for their UI. Here are a couple:

Name

yakui is all lowercase.

yakui is pronounced however you want to pronounce it. Here are some suggestions:

  • ya-KOO-ee (like a sneeze)
  • yak-yew-eye (like a marketing executive)
  • ya-kwee (like a funny French word)

Minimum Supported Rust Version (MSRV)

yakui currently supports the latest stable version of Rust. Once yakui has matured, the MSRV will be pinned and updated only when it provides a large improvement.

License

Licensed under either of

at your option.

Contribution

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 dual licensed as above, without any additional terms or conditions.

More Repositories

1

aftman

Aftman, the prodigal sequel to Foreman
Rust
113
star
2

luajit-request

Simple HTTPS for LuaJIT!
Lua
73
star
3

crevice

Rust crate to generate GLSL structs with explicitly-initialized padding bytes
Rust
65
star
4

thunderdome

Arena type inspired by generational-arena
Rust
63
star
5

luanoid

Alternative to Roblox Humanoids written entirely in Lua
Lua
61
star
6

love-microphone

Simple microphone support for LÖVE
Lua
60
star
7

lemur

Partial implementation of Roblox API in Lua
Lua
55
star
8

luajit-ffipp

(PROTOTYPE) A proof-of-concept C++ FFI for LuaJIT
Lua
30
star
9

nonmax

Rust crate that provides number types similar to std's NonZero* types, but that cannot hold a type's maximum value instead.
Rust
23
star
10

rdc-project

A demo project for RDC 2018 demonstrating Roact and Rodux usage
Lua
22
star
11

roblox-lua-promise

(NO LONGER MAINTAINED) An implementation of promises akin to JavaScript's Promises/A+
Lua
22
star
12

postcss-sassy-import

PostCSS imports like Sass, with extras!
JavaScript
16
star
13

roads

Rojo tech demo
Lua
15
star
14

mab

Style-preserving Lua parser in Rust
Rust
14
star
15

baste

Alternate Lua module system
Lua
13
star
16

snax

JSX-like syntax for proc macro authors
Rust
12
star
17

shunting-rust

An example implementation of the Shunting-yard algorithm in Rust
Rust
11
star
18

ritz

Simple virtual DOM library for Rust with JSX-like syntax powered by Snax
Rust
10
star
19

roact-motion-prototype

A prototype animation implementation similar to React Motion
Lua
8
star
20

keybee

Semantic input library for games in Rust
Rust
7
star
21

global-keys

Global key hooks for LÖVE
Lua
7
star
22

rbx-character-controller

Turned into a hack week 2018 project: https://github.com/LPGhatguy/luanoid
Lua
7
star
23

asink

Primitives for async programming for Roblox Lua
Lua
7
star
24

rukt

Constraint-based box layout engine
Lua
6
star
25

rbxfs

Sync Roblox scripts from the filesystem for easy editing!
Lua
6
star
26

roact-patterns

Examples of common patterns in Roact
Lua
6
star
27

textbox

Logic-only library to manage text box state in Lua UI libraries
Lua
6
star
28

magic-school-bus

Cross-platform TUI filesystem browser with Vi-like keybinds
Rust
5
star
29

small-roblox-libraries

Collection of small, useful Roblox Lua libraries with permissive licenses and no dependencies
Lua
5
star
30

type-layout

Aids debugging Rust type layout
Rust
5
star
31

matchmaker

Version-chooser frontend for LÖVE
Lua
4
star
32

rojo-cicd-test

https://www.roblox.com/my/groups.aspx?gid=4653149
Shell
4
star
33

joyton

Experimenting with ideas for rebindable, semantic input for Roblox games
Lua
4
star
34

rbxpacker

Generates installer packages for Roblox Lua libraries
Lua
4
star
35

rust-c-compiler

Following https://norasandler.com/2017/11/29/Write-a-Compiler.html in Rust
Rust
4
star
36

soquid

A templating framework for Lua
Lua
4
star
37

luajit-stb

(out-of-date) bindings to Sean Barrett's Tool Box (stb) libraries for LuaJIT's FFI
C
3
star
38

all-term

Terminal abstraction library for Rust
Rust
3
star
39

love-polyfill

(LEGACY) LÖVE future features in pure Lua
Lua
3
star
40

lcore

(LEGACY) A modern Lua framework. Made obsolete by Carbon.
Lua
3
star
41

fhtagn

programming environment
JavaScript
3
star
42

rojo-plugin

Merged back into Rojo repository -- https://github.com/LPGhatguy/rojo
Lua
3
star
43

lua-async-http

WIP: Async HTTP interface for Lua 5.1 written in Rust
Rust
3
star
44

parcel-ssg-example

Example of generating a truly static website with Parcel.
JavaScript
2
star
45

roact-windowing

A dead-simple example of how to make a windowed list with Roact
Lua
2
star
46

luajit-benchmarks

Benchmarks of LuaJIT things for reference
Lua
2
star
47

graphite

Integrated into Carbon: https://github.com/lua-carbon/carbon
Lua
2
star
48

igloo

Immutability helpers for Roblox Lua
Lua
2
star
49

rust-lua51-sys

Rust bindings to Lua 5.1.5
C
2
star
50

lpg.space-old

Website hosted at lpg.space.
JavaScript
2
star
51

roact-layout-gadgets

(WIP) Gadgets and components that help lay out complicated interfaces with Roact
Lua
2
star
52

teensy-rust-experiment

Bootstrapping Rust from scratch on the Teensy 3.6
Rust
2
star
53

lua-symbolics

(LEGACY) A symbolic math library for Lua
Lua
2
star
54

aoc2019

Advent of Code 2019 solutions
Rust
1
star
55

coprime-monte-carlo

Monte Carlo simulation of coprime integers on [1, 2^64 - 1]; estimates 1 / zeta(2)
Rust
1
star
56

horriblesoftware.com

Oh, Grandmother, what horrible software you have!
HTML
1
star
57

skyrim-controlmap-editor

Command line tool for working with Skyrim's `controlmap.txt` files.
Rust
1
star
58

rbxplorer

(WIP) Browser-based model/place explorer with Rust, WebAssembly, and React
JavaScript
1
star
59

MSE-Docs

Documentation for MSE (Legacy)
1
star
60

stormtide

something something card game rules engine
Rust
1
star
61

ld48-depth-first-search

1
star