use kas::event::TimerHandle;
use kas::prelude::*;
use std::time::Duration;
#[autoimpl(Deref, DerefMut using self.cx)]
pub struct AdaptEventCx<'a: 'b, 'b> {
cx: &'b mut EventCx<'a>,
id: Id,
}
impl<'a: 'b, 'b> AdaptEventCx<'a, 'b> {
#[inline]
pub fn new(cx: &'b mut EventCx<'a>, id: Id) -> Self {
AdaptEventCx { cx, id }
}
#[inline]
pub fn id(&self) -> Id {
self.id.clone()
}
#[inline]
pub fn is_disabled(&self) -> bool {
self.cx.is_disabled(&self.id)
}
#[inline]
pub fn set_disabled(&mut self, state: bool) {
self.cx.set_disabled(self.id.clone(), state);
}
#[inline]
pub fn request_timer(&mut self, handle: TimerHandle, delay: Duration) {
self.cx.request_timer(self.id.clone(), handle, delay);
}
#[inline]
pub fn request_frame_timer(&mut self, handle: TimerHandle) {
self.cx.request_frame_timer(self.id.clone(), handle);
}
}
#[autoimpl(Deref, DerefMut using self.cx)]
pub struct AdaptConfigCx<'a: 'b, 'b> {
cx: &'b mut ConfigCx<'a>,
id: Id,
}
impl<'a: 'b, 'b> AdaptConfigCx<'a, 'b> {
#[inline]
pub fn new(cx: &'b mut ConfigCx<'a>, id: Id) -> Self {
AdaptConfigCx { cx, id }
}
#[inline]
pub fn id(&self) -> Id {
self.id.clone()
}
#[inline]
pub fn is_disabled(&self) -> bool {
self.cx.is_disabled(&self.id)
}
#[inline]
pub fn set_disabled(&mut self, state: bool) {
self.cx.set_disabled(self.id.clone(), state);
}
#[inline]
pub fn request_timer(&mut self, handle: TimerHandle, delay: Duration) {
self.cx.request_timer(self.id.clone(), handle, delay);
}
#[inline]
pub fn request_frame_timer(&mut self, handle: TimerHandle) {
self.cx.request_frame_timer(self.id.clone(), handle);
}
}