guido 0.12.0

A reactive Rust GUI library using wgpu for Wayland layer shell widgets
Documentation
//! Multi-surface example demonstrating multiple layer shell surfaces.
//!
//! This example shows how to create multiple surfaces at startup:
//! - A top status bar
//! - A bottom dock
//!
//! Both surfaces share the same reactive signals.

use guido::prelude::*;

fn main() {
    App::new().run(|app| {
        // Shared signal that can be updated from any surface
        let count = create_signal(0);

        app.add_surface(
            // Top status bar
            SurfaceConfig::new()
                .height(32)
                .anchor(Anchor::TOP | Anchor::LEFT | Anchor::RIGHT)
                .layer(Layer::Top)
                .namespace("status-bar")
                .background_color(Color::rgb(0.1, 0.1, 0.15)),
            move || {
                container()
                    .height(fill())
                    .layout(
                        Flex::row()
                            .spacing(8.0)
                            .main_alignment(MainAlignment::SpaceBetween)
                            .cross_alignment(CrossAlignment::Center),
                    )
                    .padding([0.0, 16.0])
                    .child(
                        container().child(
                            text("Multi-Surface Demo")
                                .font_size(14.0)
                                .color(Color::WHITE),
                        ),
                    )
                    .child(
                        container().child(
                            text(move || format!("Count: {}", count.get()))
                                .font_size(14.0)
                                .color(Color::WHITE),
                        ),
                    )
            },
        );
        // Bottom dock
        app.add_surface(
            SurfaceConfig::new()
                .height(48)
                .anchor(Anchor::BOTTOM | Anchor::LEFT | Anchor::RIGHT)
                .layer(Layer::Top)
                .namespace("dock")
                .background_color(Color::rgb(0.15, 0.15, 0.2)),
            move || {
                container()
                    .height(fill())
                    .layout(Flex::row().spacing(16.0).center())
                    .children([
                        container()
                            .background(Color::rgb(0.3, 0.3, 0.4))
                            .padding([8.0, 16.0])
                            .corners(8.0)
                            .when_hovered(|s| s.lighter(0.1))
                            .when_pressed(|s| s.ripple())
                            .on_click(move || count.update(|c| *c += 1))
                            .child(text("+").font_size(16.0).color(Color::WHITE)),
                        container()
                            .background(Color::rgb(0.3, 0.3, 0.4))
                            .padding([8.0, 16.0])
                            .corners(8.0)
                            .when_hovered(|s| s.lighter(0.1))
                            .when_pressed(|s| s.ripple())
                            .on_click(move || count.update(|c| *c -= 1))
                            .child(text("-").font_size(16.0).color(Color::WHITE)),
                        container()
                            .background(Color::rgb(0.4, 0.2, 0.2))
                            .padding([8.0, 16.0])
                            .corners(8.0)
                            .when_hovered(|s| s.lighter(0.1))
                            .when_pressed(|s| s.ripple())
                            .on_click(move || count.set(0))
                            .child(text("Reset").font_size(16.0).color(Color::WHITE)),
                    ])
            },
        );
    });
}