cotis_utils/traits.rs
1use crate::math::Dimensions;
2
3/// Combined renderer context required by Cotis integrations.
4///
5/// This is a marker supertrait over [`CotisWindowContext`] and
6/// [`CotisFrameContext`]. Any type that implements both subtraits automatically
7/// implements this trait as well; renderers only need to implement window
8/// dimensions and delta time.
9pub trait CotisRenderContext: CotisWindowContext + CotisFrameContext {}
10
11impl<T> CotisRenderContext for T where T: CotisWindowContext + CotisFrameContext {}
12
13/// Provides current window dimensions in pixels.
14pub trait CotisWindowContext {
15 /// Returns the current drawable window dimensions.
16 ///
17 /// Layout managers call this value during frame preparation to size the root
18 /// layout context.
19 fn window_dimensions(&self) -> Dimensions;
20}
21
22/// Provides frame timing data.
23pub trait CotisFrameContext {
24 /// Returns delta time in seconds since the previous frame.
25 fn get_delta_time(&self) -> f32;
26}