Giter Site home page Giter Site logo

agui's Introduction

Logo
An advanced, reactive UI library for Rust
Report a Bug ยท Request a Feature . Ask a Question


What is agui?

Agui is an advanced reactive GUI project for Rust, inspired by Flutter and taking some concepts from other related UI systems.

Important

This library is in the middle of a sizable rework and therefore is not currently in a state where usage is technically feasible. The docs are also very out of date and will be updated once this work is nearing completion.

๐Ÿ› ๏ธ Installation

Agui is available on crates.io, Rust's official package repository. Just add this to your Cargo.toml file:

[dependencies]
agui = "0.3" # ensure this is the latest version

๐Ÿš€ Usage

Docs for agui are under development, however you can check the examples directory for basic setup, and agui_primitives/agui_widgets for many examples on widget creation.

Creating new widgets

Currently, widgets are created using StatelessWidget, StatefulWidget, LayoutWidget, PaintWidget, and InheritedWidget derive macros, and by implementing their respective trait.

#[derive(Default, StatelessWidget)]
pub struct MyWidget {
    // Widget is the convention for passing children. Vec<Widget> should be used for passing variable amounts.
    pub child: Widget,
}

impl StatelessWidget for MyWidget {
    fn build(&self, ctx: &mut StatelessBuildContext<Self>) -> Widget {
        build! {
            <Button> {
                // Widgets are stored as Rcs, so cloning has little overhead
                child: self.child.clone(),
            }
        }
    }
}

What's build!?

The build! macro makes it significantly cleaner and easier to init new widgets. It gives a struct-like syntax for widget creation, and is the recommended way to build interfaces.

use agui::macros::build;

fn build(&self, ctx: &mut StatelessBuildContext) -> Widget {
    build! {
        <Button> {
            color: Color::from_rgba((1.0, 0.0, 1.0)),

            child: <Text> {
                text: "A Button"
            }
        }
    }
}

// is equivalent to:

fn build(&self, ctx: &mut StatelessBuildContext) -> Widget {
    Button::builder()
        .color(Color::from_rgba((1.0, 0.0, 1.0)))
        .child(
                Text::builder()
                    .text(String::from("A Button"))
                    .build()
                    .into_widget()
        )
        .build()
        .into_widget()
}

๐Ÿค Contributing

Contributions are encouraged, and very welcome. Feel free to check the issues page if you wish to do so!

Please go through existing issues and pull requests to check if somebody else is already working on it. Also, make sure to run cargo test before you commit your changes!

agui's People

Contributors

stumblinbear avatar lyricwulf avatar sommos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.