slint-ui-templates 0.1.0

Composable Slint UI building blocks — mother-child pattern, token-driven
Documentation
/// Grid configuration loading and deserialization from TOML target files.
pub mod config;
/// Zone model representing the runtime layout grid with rows and columns.
pub mod zone;

pub use config::TargetConfig;
pub use zone::ZoneModel;

use std::path::Path;

/// Loads a target TOML file and converts its grid config into a `ZoneModel`.
pub fn load_target(path: &Path) -> Result<ZoneModel, Box<dyn std::error::Error>> {
    let config = TargetConfig::load(path)?;
    Ok(ZoneModel::from_config(&config.grid))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn load_desktop_target() {
        let zones = load_target(Path::new("config/desktop.toml")).unwrap();
        assert_eq!(zones.rows.len(), 3);
        assert_eq!(zones.total_row_ratio(), 12);
    }
}