• Stars
    star
    5,873
  • Rank 6,893 (Top 0.2 %)
  • Language
    Rust
  • License
    Mozilla Public Li...
  • Created almost 7 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

Desktop GUI Framework

Azul - Desktop GUI framework

CI Coverage Status LICENSE Rust Compiler Version dependency status

Azul is a free, functional, reactive GUI framework for Rust, C and C++, built using the WebRender rendering engine and a CSS / HTML-like document object model for rapid development of beautiful, native desktop applications

Website | Releases | User guide | API documentation | Video demo | Matrix Chat

Features

Azul uses webrender (the rendering engine behind Firefox) to render your UI, so it supports lots of common CSS features like:

  • gradients (linear, radial, conic)
  • box shadows
  • SVG filters
  • composition operators (multiply, darken, etc.)
  • border styling
  • border-radii
  • scrolling / automatic overflow
  • CSS transforms

See the list of supported CSS keys / values for more info.

On top of that, Azul features...

  • lots of built-in widgets (Button, TextInput, CheckBox, ColorInput, TextInput, NumberInput)
  • embedding OpenGL textures
  • simplified HTML-like relative/absolute layout system based on CSS flexbox
  • 60+ FPS animations via Animation API
  • cross-platform native dialogs
  • cross-platform text shaping and rendering
  • SVG parsing and rendering
  • shape tesselation for rendering large numbers of 2D lines, circles, rects, shapes, etc. in a single draw call
  • managing off-main-thread tasks for I/O
  • dynamic linking via shared library*
  • usable from Rust, C, C++ and Python via auto-generated API bindings**
  • HTML-to-Rust compilation for fast prototyping / hot reload

* static linking not yet available

** C++ bindings and Python are not yet stabilized and might not work depending on the branch you're using. They will be stabilized before the release.

Screenshots

image image image image

Hello World

Python

from azul import *

class DataModel:
    def __init__(self, counter):
        self.counter = counter

def render_dom(data, info):
    
    label = Dom.text("{}".format(data.counter))
    label.set_inline_style("font-size: 50px;")
    
    button = Button("Increment counter")
    button.set_on_click(data, increment_counter)

    dom = Dom.body()
    dom.add_child(label)
    dom.add_child(button.dom())

    return dom.style(Css.empty())

def increment_counter(data, info):
    data.counter += 1;
    return Update.RefreshDom

app = App(DataModel(5), AppConfig(LayoutSolver.Default))
app.run(WindowCreateOptions(render_dom))

Rust

use azul::prelude::*;
use azul::widgets::{button::Button, label::Label};

struct DataModel {
    counter: usize,
}

extern "C" 
fn render_dom(data: &mut RefAny, _: &mut LayoutInfo) -> StyledDom {

    let data = data.downcast_ref::<DataModel>()?;

    let label = Dom::text(format!("{}", data.counter))
        .with_inline_style("font-size: 50px;");
        
    let button = Button::new("Increment counter")
        .onmouseup(increment_counter, data.clone());

    Dom::body()
    .with_child(label)
    .with_child(button.dom())
    .style(Css::empty())
}

extern "C" 
fn increment_counter(data: &mut RefAny, _: &mut CallbackInfo) -> Update {
    let mut data = data.downcast_mut::<DataModel>()?;
    data.counter += 1;
    Update::RefreshDom // call render_dom() again
}

fn main() {
    let initial_data = RefAny::new(DataModel { counter: 0 });
    let app = App::new(initial_data, AppConfig::default());
    app.run(WindowCreateOptions::new(render_dom));
}

C

#include "azul.h"

typedef struct {
    uint32_t counter;
} DataModel;

void DataModel_delete(DataModel* restrict A) { }
AZ_REFLECT(DataModel, DataModel_delete);

AzStyledDom render_dom(AzRefAny* data, AzLayoutInfo* info) {

    DataModelRef d = DataModelRef_create(data);
    if !(DataModel_downcastRef(data, &d)) {
        return AzStyledDom_empty();
    }
    
    char buffer [20];
    int written = snprintf(buffer, 20, "%d", d->counter);
    AzString const labelstring = AzString_copyFromBytes(&buffer, 0, written);
    AzDom label = AzDom_text(labelstring);
    AzString const inline_css = AzString_fromConstStr("font-size: 50px;");
    AzDom_setInlineStyle(&label, inline_css);
    
    AzString const buttontext = AzString_fromConstStr("Increment counter");
    AzButton button = AzButton_new(buttontext, AzRefAny_clone(data));
    AzButton_setOnClick(&button, incrementCounter);

    AzDom body = Dom_body();
    AzDom_addChild(body, AzButton_dom(&button));
    AzDom_addChild(body, label);
    
    AzCss global_css = AzCss_empty();
    return AzDom_style(body, global_css);
}

Update incrementCounter(RefAny* data, CallbackInfo* event) {
    DataModelRefMut d = DataModelRefMut_create(data);
    if !(DataModel_downcastRefMut(data, &d)) {
        return Update_DoNothing;
    }
    d->ptr.counter += 1;
    DataModelRefMut_delete(&d);
    return Update_RefreshDom;
}

int main() {
    DataModel model = { .counter = 5 };
    AzApp app = AzApp_new(DataModel_upcast(model), AzAppConfig_default());
    AzApp_run(app, AzWindowCreateOptions_new(render_dom));
    return 0;
}

License

Azul is licensed under the MPL-2.0. Which means that yes, you can build proprietary applications using azul without having to publish your code: you only have to publish changes made to the library itself.

Copyright 2017 - current Felix Schütt

More Repositories

1

printpdf

An easy-to-use library for writing PDF in Rust
Rust
790
star
2

mystery-of-the-blend-backup

Backup repo of the "Mystery of the blend article"
50
star
3

rust-fontconfig

Pure-Rust rewrite of the Linux fontconfig library (no system dependencies) - using ttf-parser and allsorts
Rust
40
star
4

fastblur

Fast (linear time) implementation of the Gaussian Blur algorithm in Rust
Rust
39
star
5

moment-shadow-mapping

Moment shadow mapping walkthrough (description only)
26
star
6

proj5

Coordinate projection library
Rust
25
star
7

wtaskman

Task manager
Rust
13
star
8

polyclip

Library for efficient boolean operations on polygons in Rust
Rust
12
star
9

xlib-programming-rust

Minimal Xlib / OpenGL programming examples in Rust
RenderScript
9
star
10

dbflib

DBF library for reading and writing dBase III to dBase VII files. Only .dbf file support.
C++
8
star
11

LudumDare40

Ludum Dare 40
Rust
5
star
12

lua-jit-sys

System bindings for LuaJIT
C
5
star
13

vlc-static-rs

Modified vlc-rs fork that uses DLL loading to create Rust bindings for libvlc
Rust
5
star
14

clipboard2

Improved clipboard handling (similar to rust-clipboard)
Rust
5
star
15

wacom-sys

Bindgen-generated Rust bindings for libwacom 0.18.1
Rust
5
star
16

clipper-rs

Rust port of the clipper library - http://www.angusj.com/delphi/clipper.php
C++
5
star
17

quadtree-f32

Very simple, no-dependency quadtree implementation
Rust
4
star
18

simplify-rs

Line / Bezier simplification algorithm
Rust
4
star
19

opengl-software-renderer

NOT MY CODE! very old SGI code of an OpenGL software renderer, just for backup purposes
C
4
star
20

material-icons

Rust bindings (codepoint mappings) for the Google Material Icons font (https://material.io/tools/icons/)
Rust
4
star
21

polylabel-mini

Minimal fork of polylabel-rs with 0 dependencies
Rust
3
star
22

wacom

Rust
3
star
23

marching-squares

Parallelized marching squares algorithm for constructing closed isolines / contour lines
Rust
3
star
24

tesseract-static-rs

Library to link leptonica / tesseract statically into Rust binaries for easy distribution
Rust
3
star
25

gsr-jit

Test JIT compiler
Rust
3
star
26

street_index

Street index to CSV converter
Rust
3
star
27

pygame3-colors

HTML
2
star
28

servo_gui_test

A test of embedding the servo rendering engine as a desktop GUI
CSS
2
star
29

mdedit

Markdown editor using azul - test project
Rust
2
star
30

wkb-raster

Library to serialize raster data into PostGIS well-known-binary (WKB) format
Rust
2
star
31

beziercurve-wkt

Extension to serialize / deserialize bezier curves to and from strings, in a WKT-like format
Rust
2
star
32

layout2d

Preliminary GridBag / Flex UI system for Rust
Rust
2
star
33

libloading-mini

Micro version of libloading that only calls dlopen / dlsym / dlclose. No error checking, singlethreaded only.
Rust
2
star
34

wasmtest

Execute a Python script with wasmer
Rust
1
star
35

dockerdeploy-actix

Test repo to learn how to deploy an example actix server to Docker Hub using GitHub Actions
Dockerfile
1
star
36

nuke-dir

Rust
1
star
37

tesseract-wasmer

Port of tesseract.wasm to run without JS using Wasmer in Rust
JavaScript
1
star
38

mapedit-old

The old C++ source for mapedit, an X11-based map editing application
C++
1
star
39

azul.rs

azul.rs website
HTML
1
star