fui_macros

Macros for FUI UI Framework


Keywords
gui, widgets, ui, mvvm, framework
Licenses
SSPL-1.0/BSD-3-Clause-Attribution

Documentation

fui

Crates.io Version Docs.rs Version LGPL-2.1-or-later WITH WxWindows-exception-3.1

FUI Logo

MVVM Rust UI Framework Library.

Documentation

FUI's documentation

Crates

fui_core Crates.io Version

Core library of FUI MVVM UI Framework.

fui_macros Crates.io Version

Macros for FUI UI Framework.

fui_controls Crates.io Version

Standard controls for FUI UI Framework.

fui_controls_media Crates.io Version

Media controls for FUI UI Framework.

fui_app Crates.io Version

Application backend of FUI UI Framework.

Screenshots

Note! The visual aspect of the library is a subject to change. Margins are missing. You can also write your own styles and make it look completely different.

Screenshot1 Screenshot2

Features

  • cross-platform (currently: Windows, Linux)
  • renderer agnostic (sample integration with OpenGL)
  • MVVM model with properties, bindings, observable collections
  • you do not care about redraw calls
  • ui! macro for easier view creation
  • extensive styling (style can change behavior)

Example

#![windows_subsystem = "windows"]

use fui_app::*;
use fui_controls::*;
use fui_core::*;
use fui_macros::ui;

use std::cell::RefCell;
use std::rc::Rc;

use typed_builder::TypedBuilder;
use typemap::TypeMap;
use winit::window::WindowBuilder;

struct MainViewModel {
    pub counter: Property<i32>,
}

impl MainViewModel {
    pub fn new() -> Rc<RefCell<Self>> {
        Rc::new(RefCell::new(MainViewModel {
            counter: Property::new(0),
        }))
    }

    pub fn increase(&mut self) {
        self.counter.change(|c| c + 1);
    }
}

impl ViewModel for MainViewModel {
    fn create_view(view_model: &Rc<RefCell<Self>>) -> Rc<RefCell<dyn ControlObject>> {
        let vm: &mut MainViewModel = &mut view_model.borrow_mut();

        ui!(
            Horizontal {
                Text { text: (&vm.counter, |counter| format!("Counter {}", counter)) },
                Button {
                    clicked: Callback::new(view_model, |vm, _| vm.increase()),
                    Text { text: "Increase" }
                },
            }
        )
    }
}

fn main() -> anyhow::Result<()> {
    let mut app = Application::new("Example: button").unwrap();

    app.add_window(
        WindowBuilder::new().with_title("Example: button"),
        MainViewModel::new(),
    )?;

    app.run();

    Ok(())
}

More examples

License

Licensed under

It's essentially the GNU L-GPL except it allows static linking and distributing derived works in binary form on the user's own terms.

The project is partially based on code from other projects:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.