aura-gui 0.2.2

UI nativa acelerada por GPU para escritorio, Android e iOS, en un solo crate: estilo tipo Tailwind, componentes, sombras, animaciones y agentes de IA. Reposo a cero. Licencia AGPL-3.0 o comercial.
//! Lo que la ventana deja listo sin que la app lo pida: atajos de los widgets y raĆ­z con el ancho y el tema.

use aura_ui::core::Action;
use aura_ui::prelude::*;
use aura_ui::view::key_context::KeyContext;
use aura_ui::view::keymap::KeymapMatch;

fn resolve(keystroke: &str, context: &str) -> KeymapMatch {
    let window = Window::new(Theme::dark(), Size::new(px(400.0), px(300.0)), 1.0);
    window.keymap.resolve(&[keystroke.to_owned()], &[KeyContext::parse(context)])
}

#[test]
fn los_atajos_de_los_widgets_vienen_puestos() {
    assert_eq!(resolve("backspace", "TextInput"), KeymapMatch::Action(Action("input::Backspace")));
    assert_eq!(resolve("mod-a", "TextInput"), KeymapMatch::Action(Action("input::SelectAll")));
    assert_eq!(resolve("down", "Picker"), KeymapMatch::Action(Action("picker::SelectNext")));
    assert_eq!(resolve("escape", "ContextMenu"), KeymapMatch::Action(Action("menu::Cancel")));
}

struct Ancha;

impl View for Ancha {
    fn view(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
        div().h(px(50.0)).bg(Token::Accent)
    }
}

#[test]
fn la_vista_raiz_ocupa_el_ancho_sin_w_full() {
    let mut window = Window::new(Theme::dark(), Size::new(px(400.0), px(300.0)), 1.0);
    window.set_root(Ancha);
    window.draw(None);

    let quad = window.scene().quads.last().expect("la vista pinta su fondo");
    assert_eq!(quad.bounds, [0.0, 0.0, 400.0, 50.0]);
}

struct Centrada;

impl View for Centrada {
    fn view(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
        div().page().center().child(div().size(px(20.0)).bg(Token::Accent))
    }
}

#[test]
fn page_y_center_centran_en_la_ventana() {
    let mut window = Window::new(Theme::dark(), Size::new(px(400.0), px(300.0)), 1.0);
    window.set_root(Centrada);
    window.draw(None);

    let quad = window.scene().quads.last().expect("el hijo pinta su fondo");
    assert_eq!(quad.bounds, [190.0, 140.0, 20.0, 20.0]);
}