MCPcopy Index your code
hub / github.com/Stumblinbear/agui

github.com/Stumblinbear/agui @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
455 symbols 929 edges 68 files 54 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<a href="https://github.com/stumblinbear/agpu">
    <img src="https://github.com/Stumblinbear/agui/raw/v0.3.0/github/logo.webp" alt="Logo" width="128" />
</a>



An advanced, reactive UI library for Rust



<a href="https://github.com/stumblinbear/agui/issues/new?assignees=&labels=bug&template=BUG_REPORT.md&title=bug%3A+">
    Report a Bug
</a>
·
<a href="https://github.com/stumblinbear/agui/issues/new?assignees=&labels=enhancement&template=FEATURE_REQUEST.md&title=feat%3A+">
    Request a Feature
</a>
.
<a href="https://github.com/stumblinbear/agui/discussions">
    Ask a Question
</a>






<a href="https://github.com/stumblinbear/agui/actions/workflows/rust.yml">
    <img src="https://img.shields.io/github/workflow/status/stumblinbear/agui/CI?style=flat-square">
</a>
<a href="https://crates.io/crates/agui">
    <img src="https://img.shields.io/crates/v/agui?style=flat-square&logo=rust">
</a>
<a href="https://docs.rs/agui">
    <img src="https://img.shields.io/docsrs/agui?style=flat-square">
</a>

What is agui?

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

WARNING

Agui is very much still in heavy active development. The API will likely change, and it has yet to go under rigorous testing. However, that's not to say it's not ready for moderate use.

🛠️ 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 agui_agpu/examples directory for basic setup, and agui_widgets for many examples on widget creation.

Creating new widgets

Currently, widgets are created using a Widget derive macro, and by implementing the WidgetBuilder trait.

#[derive(Default, Widget)]
// The default layout type is "column" but we want it to be a "row" instead.
pub struct MyWidget {
    // We can define parameters, here.
    pub layout: Ref<Layout>,
}

impl WidgetBuilder for MyWidget {
    // Widgets can return nothing, one or more children, or an error. BuildResult is the enum we use to cover those possibilities.
    fn build(&self, ctx: &WidgetContext) -> BuildResult {
        // `ctx.set_layout` is what we use to define this widget's layout parameters.
        ctx.set_layout_type(LayoutType::Row.into());

        // `ctx.set_layout` is what we use to define this widget's layout parameters.
        ctx.set_layout(Ref::clone(&self.layout));

        build! {
            Button { }
        }
    }
}

What's build!?

The build! macro makes it significantly cleaner and easier to init new widgets. All it does is initialize unset fields in a struct to their Default::default(), and add .into() to the struct itself.

// It allows us to turn this:

fn build(&self, ctx: &WidgetContext) -> BuildResult {
    BuildResult::One(
        Button {
            layout: Layout::default(),
            color: Color::default(),
            child: Text {
                text: String::from("A Button")
            }
        }
    )
}

// Into this:

use agui::macros::build;

fn build(&self, ctx: &WidgetContext) -> BuildResult {
    build!{
        Button {
            child: Text {
                text: String::from("A Button")
            }
        }
    }
}

A more complex widget implementation (featuring global state and computed values) can be seen in the Button widget.

Functional Widgets are coming soon, which will make creating them even easier.

🤝 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!

Extension points exported contracts — how you extend this code

WidgetBuilder (Interface)
Implements the widget's `build()` method. [10 implementers]
agui_core/src/widget.rs
WidgetRenderPass (Interface)
(no doc) [4 implementers]
agui_agpu/src/render/mod.rs
Style (Interface)
(no doc) [1 implementers]
agui_widgets/src/state/theme.rs
WidgetPlugin (Interface)
A plugin for the widget system. [2 implementers]
agui_core/src/plugin/mod.rs
ProviderExt (Interface)
(no doc) [1 implementers]
agui_widgets/src/plugins/provider.rs
WidgetType (Interface)
Makes internal type information available at runtime. [1 implementers]
agui_core/src/widget.rs
ConsumerExt (Interface)
(no doc) [1 implementers]
agui_widgets/src/plugins/provider.rs
Widget (Interface)
The combined Widget implementation, required to be used within the `WidgetBuilder`. [1 implementers]
agui_core/src/widget.rs

Core symbols most depended-on inside this repo

into
called by 66
agui_core/src/widget.rs
get
called by 50
agui_core/src/context/tree.rs
get
called by 37
agui_core/src/ui/mod.rs
id
called by 27
agui_core/src/widget.rs
add
called by 27
agui_core/src/context/tree.rs
try_get
called by 25
agui_core/src/ui/mod.rs
get_context
called by 19
agui_agpu/src/lib.rs
write
called by 17
agui_core/src/context/ref.rs

Shape

Method 330
Class 67
Function 29
Enum 18
Interface 11

Languages

Rust100%

Modules by API surface

agui_core/src/context/cache.rs51 symbols
agui_core/src/ui/node.rs37 symbols
agui_core/src/ui/mod.rs32 symbols
agui_core/src/context/tree.rs32 symbols
agui_core/src/context/mod.rs27 symbols
agui_core/src/unit/layout.rs26 symbols
agui_core/src/widget.rs21 symbols
agui_core/src/context/notifiable.rs16 symbols
agui_agpu/src/lib.rs15 symbols
agui_widgets/src/state/keyboard.rs11 symbols
agui_primitives/src/text/mod.rs10 symbols
agui_core/src/reference.rs9 symbols

For agents

$ claude mcp add agui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact