2020-04-05 21:12:14 +00:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
|
|
|
pub struct WindowId(Uuid);
|
|
|
|
|
|
|
|
impl WindowId {
|
2020-06-25 23:02:21 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
WindowId(Uuid::new_v4())
|
|
|
|
}
|
|
|
|
|
2020-07-25 06:04:45 +00:00
|
|
|
pub fn primary() -> Self {
|
|
|
|
WindowId(Uuid::from_u128(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_primary(&self) -> bool {
|
|
|
|
*self == WindowId::primary()
|
|
|
|
}
|
|
|
|
|
2020-04-05 21:12:14 +00:00
|
|
|
pub fn to_string(&self) -> String {
|
|
|
|
self.0.to_simple().to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 06:04:45 +00:00
|
|
|
impl Default for WindowId {
|
|
|
|
fn default() -> Self {
|
|
|
|
WindowId::primary()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-22 20:21:39 +00:00
|
|
|
#[derive(Debug)]
|
2020-04-05 21:12:14 +00:00
|
|
|
pub struct Window {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub width: u32,
|
|
|
|
pub height: u32,
|
|
|
|
pub title: String,
|
|
|
|
pub vsync: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Window {
|
2020-06-25 23:02:21 +00:00
|
|
|
pub fn new(id: WindowId, window_descriptor: &WindowDescriptor) -> Self {
|
2020-04-05 21:12:14 +00:00
|
|
|
Window {
|
2020-06-25 23:02:21 +00:00
|
|
|
id,
|
2020-04-05 21:12:14 +00:00
|
|
|
height: window_descriptor.height,
|
|
|
|
width: window_descriptor.width,
|
|
|
|
title: window_descriptor.title.clone(),
|
|
|
|
vsync: window_descriptor.vsync,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowDescriptor {
|
|
|
|
pub width: u32,
|
|
|
|
pub height: u32,
|
|
|
|
pub title: String,
|
|
|
|
pub vsync: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for WindowDescriptor {
|
|
|
|
fn default() -> Self {
|
|
|
|
WindowDescriptor {
|
|
|
|
title: "bevy".to_string(),
|
|
|
|
width: 1280,
|
|
|
|
height: 720,
|
|
|
|
vsync: true,
|
|
|
|
}
|
|
|
|
}
|
2020-04-06 23:15:59 +00:00
|
|
|
}
|