use std::collections::VecDeque;
use crate::{Command, Data, Env, Event, WindowId};
pub struct DelegateCtx<'a> {
pub(crate) source_id: WindowId,
pub(crate) command_queue: &'a mut VecDeque<(WindowId, Command)>,
}
impl<'a> DelegateCtx<'a> {
pub fn submit_command(&mut self, command: Command, window_id: impl Into<Option<WindowId>>) {
let window_id = window_id.into().unwrap_or(self.source_id);
self.command_queue.push_back((window_id, command))
}
}
#[allow(unused)]
pub trait AppDelegate<T: Data> {
fn event(
&mut self,
event: Event,
data: &mut T,
env: &Env,
ctx: &mut DelegateCtx,
) -> Option<Event> {
Some(event)
}
fn window_added(&mut self, id: WindowId, data: &mut T, env: &Env, ctx: &mut DelegateCtx) {}
fn window_removed(&mut self, id: WindowId, data: &mut T, env: &Env, ctx: &mut DelegateCtx) {}
}