use std::collections::VecDeque;
use crate::{Command, Data, Env, Event, Target, WindowId};
pub struct DelegateCtx<'a> {
pub(crate) command_queue: &'a mut VecDeque<(Target, Command)>,
}
impl<'a> DelegateCtx<'a> {
pub fn submit_command(
&mut self,
command: impl Into<Command>,
target: impl Into<Option<Target>>,
) {
let command = command.into();
let target = target.into().unwrap_or(Target::Global);
self.command_queue.push_back((target, command))
}
}
#[allow(unused)]
pub trait AppDelegate<T: Data> {
fn event(
&mut self,
ctx: &mut DelegateCtx,
window_id: WindowId,
event: Event,
data: &mut T,
env: &Env,
) -> Option<Event> {
Some(event)
}
fn command(
&mut self,
ctx: &mut DelegateCtx,
target: &Target,
cmd: &Command,
data: &mut T,
env: &Env,
) -> bool {
true
}
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) {}
}