• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    Rust
  • License
    Mozilla Public Li...
  • Created about 5 years ago
  • Updated about 2 years ago

Reviews

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

Repository Details

A webrender-based UI framework with a moxie frontend

Moxie Native

Warning: This is a work in progress and not yet usable for nontrivial applications.

This is a framework for building GUI applications written in Rust. It renders using Webrender, instead of relying on other UI toolkits like Gtk or on a web browser. This gives you control over how your application looks, but may lose some native look and feel.

The front-facing API is built using Moxie, a framework for declaratively defining UI similar to React.

Features

  • Relatively small footprint (4.8MB for a hello world app).
  • Declaratively specify UI instead of manually managing state.
  • Not based on immediate mode UI.
  • Targeted towards real world desktop applications.
  • Styling system for specifying the appearance of elements.

Future plans

Example

// Get all the types and macros needed for concise code
use moxie::state;
use moxie_native::prelude::*;

define_style! {
    // Define a style for an element. Uses a proc macro for css-like syntax.
    static MY_STYLE = {
        // Easily specify units on measurements, and do simple calculations with them.
        text_size: 25 px + 1 vh,
        padding: 10 px,
        // Enums
        direction: horizontal,
        // Colors allow rgb and rgba syntax.
        background_color: rgb(66, 135, 245),
        text_color: rgb(255, 255, 255),

        // Selectors can be used to add conditional styling.
        if state: hover {
            background_color: rgb(112, 167, 255),
        }
    };
}

// This attribute is used to introduce a new nesting context, which lets the
// runtime efficiently keep track of object states over multiple renders.
#[topo::nested]
// This is the root component, which is expected to return an App element.
fn my_app() -> Node<App> {
    // Declare a state variable, this works kind of like a React useState() hook.
    let (current_count, click_count) = state(|| 0usize);

    // Clone the state so we can access it from the closure.
    let on_click = move |_: &ClickEvent| {
        // Updating the state will trigger a re-render.
        click_count.update(|count| Some(count + 1));
    };

    // The mox! macro lets us use nice syntax for declaring elements.
    // This acts like JSX in React.
    mox! {
        <app>
            <window title="Devtools Demo">
                <view>
                    // Every element has a style attribute which can be used to add a style.
                    <button style={MY_STYLE} on_click={on_click}>
                        // Text can only inside of spans. Attributes and parent-child
                        // relationships are checked at compile time to ensure validity.
                        <span>
                            "Click me! Total clicks: "
                            // Formatting can be done inline using this shorthand syntax.
                            {% "{}", current_count}
                        </span>
                    </button>
                </view>
            </window>
        </app>
    }
}

fn main() {
    // The entrypoint to the application is creating a runtime and starting it.
    let runtime = moxie_native::Runtime::new(my_app);
    runtime.start();
}

Community

Discussion about moxie-native mostly happens in the moxie Discord server: https://discord.gg/W4rMQZQ

You can find me (Tiffany#0725) there and I'll answer any questions that come up.

Images

What would a GUI crate be without screenshots.

Calc example

calc example

Readme demo example

readme_demo example

Test example

test example

License

Mozilla Public License, version 2.

Contributing

  • Agree to license your contribution under the terms of the license.
  • Follow the code of conduct.
  • Check the issues and projects tabs for things to work on, or ask me (@tiffany352).

More Repositories

1

rink-rs

Unit conversion tool and library written in rust
Rust
445
star
2

twitter-archive-browser

Desktop app for browsing your Twitter Archive
JavaScript
65
star
3

Roblox-Tag-Editor

A plugin for manipulating CollectionService in Roblox Studio.
Lua
59
star
4

godot-starlight

Render 100,000 stars in 3D space in realtime
GDScript
37
star
5

unicode-visualizer-web

Web tool for inspecting Unicode strings
HTML
29
star
6

RobloxComponentSystem

An Entity Component System for Roblox.
Lua
28
star
7

Roblox-Terrain-Generator

A terrain generator framework for Roblox
Lua
11
star
8

frscript

A concatenative scripting language with a type system
Rust
10
star
9

recycle-list-view

Recycle list view implementation for Roact
Lua
8
star
10

RoactStudioWidgets

A reimplementation of the Terrain Tools Studio widgets using Roact.
Lua
7
star
11

react-rs

Experiment in creating a react-like in rust
Rust
6
star
12

frp-rust

Implementing FRP in Rust
Rust
6
star
13

tifflang

A toy programming language
Rust
6
star
14

Roact-Editor

My December 2018 Hack Week project
Lua
5
star
15

InvisibleItemFrames

A Spigot plugin for invisible item frames in survival.
Java
4
star
16

is-same

A trait for comparing object identities
Rust
3
star
17

tiffbot-2

This might be the first project I ever wrote in Rust, probably built using rustc 0.4.
Rust
2
star
18

permuto

Permuto Programming Language
Haskell
2
star
19

roblox-lenses

A library for creating dynamically updating mappings from the data model into arbitrarily shaped tables
Lua
2
star
20

personal-organizer

A personal organizer web app
TypeScript
2
star
21

susurrus

Noise implementation in Rust
Rust
2
star
22

tiffcolors

VS code theme for people with deuteranopia (red-green colorblindness)
2
star
23

wasm-rs

WebAssembly binary format parser in Rust
Rust
1
star
24

tiffbot

An IRC bot in neat (https://github.com/FeepingCreature/fcc) using std.irc (my IRC library)
Lua
1
star
25

sui

The Sane User Interface Library
C
1
star
26

nobility

NBT decoder in Rust
Rust
1
star
27

typescript-node-template

A template app for building a web app written in Typescript for both frontend and backend, using Node.JS + React
TypeScript
1
star