use super::{AppStats, OpenOutcome, WindowInfo, WindowKey, WindowOptions, WindowStatus, Windows};
use std::sync::Arc;
use winit::window::Window;
pub struct Frame<'a> {
pub(crate) window: &'a Arc<Window>,
pub(crate) key: &'a WindowKey,
pub(crate) info: WindowInfo,
pub(crate) windows: Windows<'a>,
pub(crate) device_resets: u64,
pub(crate) device_loss: Option<&'a str>,
}
impl<'a> Frame<'a> {
pub fn window(&self) -> &Arc<Window> {
self.window
}
pub fn window_key(&self) -> &WindowKey {
self.key
}
pub fn is_main(&self) -> bool {
self.windows.main_key() == self.key
}
pub fn info(&self) -> &WindowInfo {
&self.info
}
pub fn windows(&mut self) -> &mut Windows<'a> {
&mut self.windows
}
pub fn open_window(
&mut self,
key: impl Into<WindowKey>,
options: WindowOptions,
) -> OpenOutcome {
self.windows.open(key, options)
}
pub fn close_window(&mut self, key: impl Into<WindowKey>) {
self.windows.close(key);
}
pub fn close_this_window(&mut self) {
self.windows.close(self.key.clone());
}
pub fn request_close(&mut self) {
self.windows.request_close(self.key.clone());
}
pub fn window_status(&self, key: &WindowKey) -> Option<&WindowStatus> {
self.windows.status(key)
}
pub fn stats(&self) -> AppStats {
self.windows.stats()
}
pub fn device_resets(&self) -> u64 {
self.device_resets
}
pub fn last_device_loss(&self) -> Option<&str> {
self.device_loss
}
pub fn close(&mut self) {
self.windows.control.exit_after_present = true;
}
}