godoru 0.1.0

UI Framework for Rust using Godot
use crate::{AppTheme, Container, NoAction, Renderer};

#[derive(Clone, Debug, PartialEq)]
pub struct WindowOptions<A = NoAction> {
    pub id: String,
    pub title: String,
    pub size: WindowSize,
    pub transparent: bool,
    pub decorations: bool,
    pub renderer: Renderer,
    pub root: Container<A>,
    pub theme: AppTheme,
}

impl<A: Clone> WindowOptions<A> {
    pub fn new(id: impl Into<String>) -> Self {
        let id = id.into();
        Self {
            title: id.clone(),
            id,
            size: WindowSize {
                width: 1280,
                height: 720,
            },
            transparent: false,
            decorations: true,
            renderer: Renderer::Default,
            root: Container::withId("MainContainer"),
            theme: AppTheme::default(),
        }
    }

    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = title.into();
        self
    }

    pub fn size(mut self, width: u32, height: u32) -> Self {
        self.size = WindowSize { width, height };
        self
    }

    pub fn transparent(mut self, transparent: bool) -> Self {
        self.transparent = transparent;
        self
    }

    pub fn decorations(mut self, decorations: bool) -> Self {
        self.decorations = decorations;
        self
    }

    pub fn renderer(mut self, renderer: Renderer) -> Self {
        self.renderer = renderer;
        self
    }

    pub fn root(mut self, root: Container<A>) -> Self {
        self.root = root;
        self
    }

    pub fn theme(mut self, theme: AppTheme) -> Self {
        self.theme = theme;
        self
    }
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WindowSize {
    pub width: u32,
    pub height: u32,
}