#![deny(missing_docs)]
#![deny(missing_copy_implementations)]
#![allow(unstable)]
extern crate input;
extern crate quack;
extern crate event_loop;
use input::Input;
use quack::{ ActOn, GetFrom, SetAt };
pub use event_loop::*;
pub struct Title(pub String);
#[derive(Copy)]
pub struct Samples(pub u8);
#[derive(Copy)]
pub struct Fullscreen(pub bool);
#[derive(Copy)]
pub struct ExitOnEsc(pub bool);
#[derive(Copy)]
pub struct CaptureCursor(pub bool);
#[derive(Copy)]
pub struct DrawSize(pub [u32; 2]);
pub struct WindowSettings {
pub title: String,
pub size: [u32; 2],
pub samples: u8,
pub fullscreen: bool,
pub exit_on_esc: bool,
}
impl WindowSettings {
pub fn default() -> WindowSettings {
WindowSettings {
title: "Piston".to_string(),
size: [640, 480],
samples: 0,
fullscreen: false,
exit_on_esc: true,
}
}
}
pub struct NoWindow {
should_close: bool,
title: String,
}
impl NoWindow {
pub fn new(settings: WindowSettings) -> NoWindow {
let title = settings.title.clone();
NoWindow {
should_close: false,
title: title,
}
}
}
impl ActOn<()> for (SwapBuffers, NoWindow) {
type Action = SwapBuffers;
type Object = NoWindow;
fn act_on(_action: SwapBuffers, _window: &mut NoWindow) {}
}
impl ActOn<Option<Input>> for (PollEvent, NoWindow) {
type Action = PollEvent;
type Object = NoWindow;
fn act_on(_action: PollEvent, _window: &mut NoWindow)
-> Option<Input> { None }
}
impl GetFrom for (ShouldClose, NoWindow) {
type Property = ShouldClose;
type Object = NoWindow;
fn get_from(obj: &NoWindow) -> ShouldClose {
ShouldClose(obj.should_close)
}
}
impl GetFrom for (Size, NoWindow) {
type Property = Size;
type Object = NoWindow;
fn get_from(_obj: &NoWindow) -> Size {
Size([0, 0])
}
}
impl SetAt for (CaptureCursor, NoWindow) {
type Property = CaptureCursor;
type Object = NoWindow;
fn set_at(_val: CaptureCursor, _window: &mut NoWindow) {}
}
impl SetAt for (ShouldClose, NoWindow) {
type Property = ShouldClose;
type Object = NoWindow;
fn set_at(ShouldClose(val): ShouldClose, window: &mut NoWindow) {
window.should_close = val;
}
}
impl GetFrom for (DrawSize, NoWindow) {
type Property = DrawSize;
type Object = NoWindow;
fn get_from(obj: &NoWindow) -> DrawSize {
let Size(val) = <(Size, NoWindow) as GetFrom>::get_from(obj);
DrawSize(val)
}
}
impl GetFrom for (Title, NoWindow) {
type Property = Title;
type Object = NoWindow;
fn get_from(obj: &NoWindow) -> Title {
Title(obj.title.clone())
}
}
impl SetAt for (Title, NoWindow) {
type Property = Title;
type Object = NoWindow;
fn set_at(Title(val): Title, window: &mut NoWindow) {
window.title = val;
}
}
impl GetFrom for (ExitOnEsc, NoWindow) {
type Property = ExitOnEsc;
type Object = NoWindow;
fn get_from(_obj: &NoWindow) -> ExitOnEsc {
ExitOnEsc(false)
}
}
impl SetAt for (ExitOnEsc, NoWindow) {
type Property = ExitOnEsc;
type Object = NoWindow;
fn set_at(_: ExitOnEsc, _window: &mut NoWindow) {}
}