Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork222
fschutt/azul
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Azul is a free, functional, reactive GUI framework for Rust, C and C++,built using the WebRender rendering engine and a CSS / HTML-like documentobject model for rapid development of beautiful, native desktop applications
Azul useswebrender (the rendering engine behindFirefox) 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 thelist 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 viaAnimation 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 dependingon the branch you're using. They will be stabilized before the release.
fromazulimport*classDataModel:def__init__(self,counter):self.counter=counterdefrender_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())returndom.style(Css.empty())defincrement_counter(data,info):data.counter+=1;returnUpdate.RefreshDomapp=App(DataModel(5),AppConfig(LayoutSolver.Default))app.run(WindowCreateOptions(render_dom))
use azul::prelude::*;use azul::widgets::{button::Button, label::Label};structDataModel{counter:usize,}extern"C"fnrender_dom(data:&mutRefAny, _:&mutLayoutInfo) ->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"fnincrement_counter(data:&mutRefAny, _:&mutCallbackInfo) ->Update{letmut data = data.downcast_mut::<DataModel>()?; data.counter +=1;Update::RefreshDom// call render_dom() again}fnmain(){let initial_data =RefAny::new(DataModel{counter:0});let app =App::new(initial_data,AppConfig::default()); app.run(WindowCreateOptions::new(render_dom));}
#include"azul.h"typedefstruct {uint32_tcounter;}DataModel;voidDataModel_delete(DataModel* restrictA) { }AZ_REFLECT(DataModel,DataModel_delete);AzStyledDomrender_dom(AzRefAny*data,AzLayoutInfo*info) {DataModelRefd=DataModelRef_create(data);if !(DataModel_downcastRef(data,&d)) {returnAzStyledDom_empty(); }charbuffer [20];intwritten=snprintf(buffer,20,"%d",d->counter);AzStringconstlabelstring=AzString_copyFromBytes(&buffer,0,written);AzDomlabel=AzDom_text(labelstring);AzStringconstinline_css=AzString_fromConstStr("font-size: 50px;");AzDom_setInlineStyle(&label,inline_css);AzStringconstbuttontext=AzString_fromConstStr("Increment counter");AzButtonbutton=AzButton_new(buttontext,AzRefAny_clone(data));AzButton_setOnClick(&button,incrementCounter);AzDombody=Dom_body();AzDom_addChild(body,AzButton_dom(&button));AzDom_addChild(body,label);AzCssglobal_css=AzCss_empty();returnAzDom_style(body,global_css);}UpdateincrementCounter(RefAny*data,CallbackInfo*event) {DataModelRefMutd=DataModelRefMut_create(data);if !(DataModel_downcastRefMut(data,&d)) {returnUpdate_DoNothing; }d->ptr.counter+=1;DataModelRefMut_delete(&d);returnUpdate_RefreshDom;}intmain() {DataModelmodel= { .counter=5 };AzAppapp=AzApp_new(DataModel_upcast(model),AzAppConfig_default());AzApp_run(app,AzWindowCreateOptions_new(render_dom));return0;}
Azul is licensed under the MPL-2.0. Which means that yes, you can buildproprietary applications using azul without having to publish your code:you only have to publish changes made tothe library itself.
Copyright 2017 - current Felix Schütt
About
Desktop GUI Framework
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.