guido 0.6.0

A reactive Rust GUI library using wgpu for Wayland layer shell widgets
Documentation
//! Test TextInput widget with transforms
//!
//! Tests that text input works correctly when inside transformed containers:
//! - Click-to-position cursor works with rotation, scale, and translation
//! - Selection works correctly
//! - Visual rendering is correct

use guido::prelude::*;

fn main() {
    App::new().run(|app| {
        let input1 = create_signal(String::from("Normal input"));
        let input2 = create_signal(String::from("Rotated 15°"));
        let input3 = create_signal(String::from("Scaled 1.2x"));
        let input4 = create_signal(String::from("Translated"));
        let input5 = create_signal(String::from("All transforms"));

        let view = container()
            .background(Color::rgb(0.1, 0.1, 0.15))
            .padding(32.0)
            .layout(Flex::column().spacing(32.0))
            .child(
                container().child(
                    text("TextInput Transform Test")
                        .font_size(18.0)
                        .color(Color::WHITE),
                ),
            )
            // 1. Normal (no transform) - baseline
            .child(
                container()
                    .layout(Flex::column().spacing(4.0))
                    .child(
                        container().child(
                            text("No transform (baseline)")
                                .font_size(12.0)
                                .color(Color::rgb(0.6, 0.6, 0.7)),
                        ),
                    )
                    .child(
                        container()
                            .width(at_least(300.0))
                            .padding(8.0)
                            .background(Color::rgb(0.18, 0.18, 0.24))
                            .border(1.0, Color::rgb(0.3, 0.8, 0.3))
                            .corners(6.0)
                            .child(
                                text_input(input1)
                                    .cursor_color(Color::rgb(0.4, 0.8, 1.0))
                                    .font_size(14.0)
                                    .color(Color::WHITE),
                            ),
                    ),
            )
            // 2. Rotated container
            .child(
                container()
                    .layout(Flex::column().spacing(4.0))
                    .child(
                        container().child(
                            text("Rotated 15°")
                                .font_size(12.0)
                                .color(Color::rgb(0.6, 0.6, 0.7)),
                        ),
                    )
                    .child(
                        container()
                            .width(at_least(300.0))
                            .padding(8.0)
                            .background(Color::rgb(0.18, 0.18, 0.24))
                            .border(1.0, Color::rgb(0.8, 0.5, 0.3))
                            .corners(6.0)
                            .rotate(15.0)
                            .child(
                                text_input(input2)
                                    .cursor_color(Color::rgb(0.4, 0.8, 1.0))
                                    .font_size(14.0)
                                    .color(Color::WHITE),
                            ),
                    ),
            )
            // 3. Scaled container
            .child(
                container()
                    .layout(Flex::column().spacing(4.0))
                    .child(
                        container().child(
                            text("Scaled 1.2x")
                                .font_size(12.0)
                                .color(Color::rgb(0.6, 0.6, 0.7)),
                        ),
                    )
                    .child(
                        container()
                            .width(at_least(250.0))
                            .padding(8.0)
                            .background(Color::rgb(0.18, 0.18, 0.24))
                            .border(1.0, Color::rgb(0.3, 0.5, 0.8))
                            .corners(6.0)
                            .scale(1.2)
                            .child(
                                text_input(input3)
                                    .cursor_color(Color::rgb(0.4, 0.8, 1.0))
                                    .font_size(14.0)
                                    .color(Color::WHITE),
                            ),
                    ),
            )
            // 4. Translated container
            .child(
                container()
                    .layout(Flex::column().spacing(4.0))
                    .child(
                        container().child(
                            text("Translated (50, 10)")
                                .font_size(12.0)
                                .color(Color::rgb(0.6, 0.6, 0.7)),
                        ),
                    )
                    .child(
                        container()
                            .width(at_least(300.0))
                            .padding(8.0)
                            .background(Color::rgb(0.18, 0.18, 0.24))
                            .border(1.0, Color::rgb(0.8, 0.8, 0.3))
                            .corners(6.0)
                            .translate((50.0, 10.0))
                            .child(
                                text_input(input4)
                                    .cursor_color(Color::rgb(0.4, 0.8, 1.0))
                                    .font_size(14.0)
                                    .color(Color::WHITE),
                            ),
                    ),
            )
            // 5. All transforms combined: translate + rotate + scale
            .child(
                container()
                    .layout(Flex::column().spacing(4.0))
                    .child(
                        container().child(
                            text("Translate(20,5) + Rotate(-10°) + Scale(0.9)")
                                .font_size(12.0)
                                .color(Color::rgb(0.6, 0.6, 0.7)),
                        ),
                    )
                    .child(
                        container()
                            .width(at_least(300.0))
                            .padding(8.0)
                            .background(Color::rgb(0.18, 0.18, 0.24))
                            .border(1.0, Color::rgb(0.8, 0.3, 0.8))
                            .corners(6.0)
                            .translate((20.0, 5.0))
                            .rotate(-10.0)
                            .scale(0.9)
                            .child(
                                text_input(input5)
                                    .cursor_color(Color::rgb(0.4, 0.8, 1.0))
                                    .font_size(14.0)
                                    .color(Color::WHITE),
                            ),
                    ),
            )
            // Instructions
            .child(
                container().child(
                    text("Click in each input to test cursor positioning")
                        .font_size(11.0)
                        .color(Color::rgb(0.5, 0.5, 0.6)),
                ),
            );

        app.add_surface(
            SurfaceConfig::new()
                .width(550)
                .height(680)
                .anchor(Anchor::TOP | Anchor::LEFT)
                .layer(Layer::Top)
                .namespace("text-input-transform-test")
                .background_color(Color::rgb(0.1, 0.1, 0.15)),
            move || view,
        );
    });
}