Skip to content

vizia/vizia

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vizia


Vizia is a declarative GUI framework for the Rust programming language.



At a Glance

A simple counter application. Run with cargo run --example counter.

// Define some model data
#[derive(Lens)]
pub struct AppData {
    count: i32,
}

// Define events to mutate the data
pub enum AppEvent {
    Increment,
}

// Describe how the data can be mutated
impl Model for AppData {
    fn event(&mut self, _: &mut Context, event: &mut Event) {
        event.map(|app_event, _| match app_event {
            AppEvent::Increment => {
                self.count += 1;
            }
        });
    }
}

Application::new(|cx| {
    // Build the model data into the tree
    AppData { count: 0 }.build(cx);

    HStack::new(cx, |cx| {
        // Declare a button which emits an event
        Button::new(cx, 
          |cx| cx.emit(AppEvent::Increment), 
          |cx| Label::new(cx, "Increment")
        );
        
        // Declare a label which is bound to part of the model, updating if it changes
        Label::new(cx, AppData::count)
            .width(Pixels(50.0));
    })
    .child_space(Stretch(1.0))
    .col_between(Pixels(50.0));
})
.title("Counter")
.inner_size((400, 100))
.run();

Features

  • Multiplatform (Windows, Linux, MacOS, Web)
  • Declarative API
  • Reactive event-driven data system
  • Flexible layout engine, powered by morphorm
  • GPU rendering, powered by femtovg
  • CSS styling with hot reloading
  • Property animations
  • Audio plugin GUI development

Running the Examples

A full list of examples is included in the repository.

To run an example with the winit (default) windowing backend:

cargo run --release --example name_of_example

To run an example with the baseview windowing backend:

cargo run --release --example name_of_example --no-default-features --features baseview

Web

To run an example as a web application, first ensure that the wasm32-unknown-unknown toolchain is installed:

rustup target add wasm32-unknown-unknown

Then run an example with the following:

cargo run-wasm --release --example name_of_example

NOTE - Some examples are not compatible with the web target.

Contributing and Community

For help with vizia, or to get involved with contributing to the project, come join us on our discord.

License and Attribution

Vizia is licensed under MIT.

Fonts used in Vizia:

Vizia logo designed by Lunae Somnia.