use crate::{Event, EventCtx, EventLike, EventManager, HasEvents, HasUi, IdLike}; pub trait HasRsc: Sized + 'static { type Rsc: HasEvents + HasUi; fn rsc(&self) -> &Self::Rsc; fn rsc_mut(&mut self) -> &mut Self::Rsc; fn run_event(&mut self, id: impl IdLike, data: &mut ::Data<'_>) where Self: 'static, { let f = self.rsc_mut().events().get_type::().run_fn(id); f(EventCtx { state: self, data }) } fn events(&mut self) -> &mut EventManager { self.rsc_mut().events() } } impl HasUi for R { fn ui_ref(&self) -> &crate::Ui { self.rsc().ui_ref() } fn ui(&mut self) -> &mut crate::Ui { self.rsc_mut().ui() } }