mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
23 lines
719 B
Rust
23 lines
719 B
Rust
//! Groupings of elements.
|
|
use crate::*;
|
|
|
|
/// A function or closure that emits renderables.
|
|
pub trait Collector<E: Engine>: Send + Sync + Fn(&mut dyn FnMut(&dyn Render<E>)) {}
|
|
|
|
/// Any function or closure that emits renderables for the given engine matches [CollectCallback].
|
|
impl<E, F> Collector<E> for F
|
|
where E: Engine, F: Send + Sync + Fn(&mut dyn FnMut(&dyn Render<E>)) {}
|
|
|
|
pub trait Render<E: Engine> {
|
|
fn area (&self, to: E::Area) -> E::Area;
|
|
fn render (&self, to: &mut E::Output);
|
|
}
|
|
|
|
impl<E: Engine, C: Content<E>> Render<E> for C {
|
|
fn area (&self, to: E::Area) -> E::Area {
|
|
Content::area(self, to)
|
|
}
|
|
fn render (&self, to: &mut E::Output) {
|
|
Content::render(self, to)
|
|
}
|
|
}
|