use crate::core::types::Rect;
use crate::layout::LayoutManager;
use crate::layout::docking::DockPanel;
use super::builder::RgbaIcon;
use crate::platform::types::CornerStyle;
pub use crate::layout::window::WindowKey;
#[derive(Debug, Clone)]
pub struct WindowSpec {
pub key: WindowKey,
pub title: String,
pub size: (u32, u32),
pub min_size: Option<(u32, u32)>,
pub decorations: bool,
pub background: u32,
pub icon: Option<RgbaIcon>,
pub corner_style: CornerStyle,
pub border_color: Option<u32>,
pub shadow: Option<bool>,
pub tick_rate: Option<crate::render::TickRate>,
}
impl WindowSpec {
pub fn new(key: impl Into<WindowKey>, title: impl Into<String>) -> Self {
Self {
key: key.into(),
title: title.into(),
size: (1280, 800),
min_size: Some((400, 300)),
decorations: false,
background: 0xFF_FF_FF_FF,
icon: None,
corner_style: CornerStyle::Default,
border_color: None,
shadow: None,
tick_rate: None,
}
}
pub fn tick_rate(mut self, rate: crate::render::TickRate) -> Self {
self.tick_rate = Some(rate);
self
}
pub fn size(mut self, w: u32, h: u32) -> Self { self.size = (w, h); self }
pub fn min_size(mut self, w: u32, h: u32) -> Self { self.min_size = Some((w, h)); self }
pub fn decorations(mut self, on: bool) -> Self { self.decorations = on; self }
pub fn background(mut self, argb: u32) -> Self { self.background = argb; self }
pub fn icon(mut self, icon: RgbaIcon) -> Self { self.icon = Some(icon); self }
pub fn corner_style(mut self, style: CornerStyle) -> Self {
self.corner_style = style;
self
}
pub fn border_color(mut self, color: u32) -> Self {
self.border_color = Some(color);
self
}
pub fn shadow(mut self, on: bool) -> Self {
self.shadow = Some(on);
self
}
}
pub struct WindowCtx<'a, P: DockPanel> {
pub key: &'a WindowKey,
pub layout: &'a mut LayoutManager<P>,
pub render: &'a mut dyn crate::render::RenderContext,
pub rect: Rect,
pub render_control: &'a mut dyn super::render_control::RenderControl,
}