use flo_binding::*;
pub trait FloWindowProperties {
fn title(&self) -> BindRef<String>;
fn size(&self) -> BindRef<(u64, u64)>;
fn fullscreen(&self) -> BindRef<bool>;
fn has_decorations(&self) -> BindRef<bool>;
fn mouse_pointer(&self) -> BindRef<MousePointer>;
}
#[derive(Clone, Copy, PartialEq)]
pub enum MousePointer {
None,
SystemDefault
}
impl FloWindowProperties for () {
fn title(&self) -> BindRef<String> { BindRef::from(bind("flo_draw".to_string())) }
fn size(&self) -> BindRef<(u64, u64)> { BindRef::from(bind((1024, 768))) }
fn fullscreen(&self) -> BindRef<bool> { BindRef::from(bind(false)) }
fn has_decorations(&self) -> BindRef<bool> { BindRef::from(bind(true)) }
fn mouse_pointer(&self) -> BindRef<MousePointer> { BindRef::from(bind(MousePointer::SystemDefault)) }
}
impl<'a> FloWindowProperties for &'a str {
fn title(&self) -> BindRef<String> { BindRef::from(bind(self.to_string())) }
fn size(&self) -> BindRef<(u64, u64)> { BindRef::from(bind((1024, 768))) }
fn fullscreen(&self) -> BindRef<bool> { BindRef::from(bind(false)) }
fn has_decorations(&self) -> BindRef<bool> { BindRef::from(bind(true)) }
fn mouse_pointer(&self) -> BindRef<MousePointer> { BindRef::from(bind(MousePointer::SystemDefault)) }
}
#[derive(Clone)]
pub struct WindowProperties {
pub title: BindRef<String>,
pub size: BindRef<(u64, u64)>,
pub fullscreen: BindRef<bool>,
pub has_decorations: BindRef<bool>,
pub mouse_pointer: BindRef<MousePointer>
}
impl WindowProperties {
pub fn from<T: FloWindowProperties>(properties: &T) -> WindowProperties {
WindowProperties {
title: properties.title(),
size: properties.size(),
fullscreen: properties.fullscreen(),
has_decorations: properties.has_decorations(),
mouse_pointer: properties.mouse_pointer()
}
}
}
impl FloWindowProperties for WindowProperties {
fn title(&self) -> BindRef<String> { self.title.clone() }
fn size(&self) -> BindRef<(u64, u64)> { self.size.clone() }
fn fullscreen(&self) -> BindRef<bool> { self.fullscreen.clone() }
fn has_decorations(&self) -> BindRef<bool> { self.has_decorations.clone() }
fn mouse_pointer(&self) -> BindRef<MousePointer> { self.mouse_pointer.clone() }
}