add comments to DynamicRenderElementMap

This commit is contained in:
dragonn 2022-01-19 22:02:35 +01:00
parent 2b1e389495
commit dea000921b
1 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,7 @@ pub type DynamicRenderElements<R> =
pub(super) type SpaceElem<R> = pub(super) type SpaceElem<R> =
dyn SpaceElement<R, <R as Renderer>::Frame, <R as Renderer>::Error, <R as Renderer>::TextureId>; dyn SpaceElement<R, <R as Renderer>::Frame, <R as Renderer>::Error, <R as Renderer>::TextureId>;
/// Helper struct for iterating over diffrent layers of `DynamicRenderElements`
pub(super) struct DynamicRenderElementMap<'a, R: Renderer>(pub(super) &'a [DynamicRenderElements<R>]); pub(super) struct DynamicRenderElementMap<'a, R: Renderer>(pub(super) &'a [DynamicRenderElements<R>]);
impl<'a, R> DynamicRenderElementMap<'a, R> impl<'a, R> DynamicRenderElementMap<'a, R>
@ -44,30 +45,37 @@ where
R::Error: 'static, R::Error: 'static,
R::Frame: 'static, R::Frame: 'static,
{ {
/// Iterate over `DynamicRenderElements` with layer `RenderLayer::Bottom`
pub fn iter_bottom(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_bottom(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::Bottom) self.iter_layer(RenderLayer::Bottom)
} }
/// Iterate over `DynamicRenderElements with layer `RenderLayer::AboveBackground`
pub fn iter_above_background(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_above_background(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::AboveBackground) self.iter_layer(RenderLayer::AboveBackground)
} }
/// Iterate over `DynamicRenderElements` with layer `RenderLayer::BeforeWindows`
pub fn iter_before_windows(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_before_windows(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::BeforeWindows) self.iter_layer(RenderLayer::BeforeWindows)
} }
/// Iterate over `DynamicRenderElements` with layer `RenderLayer::AfterWindows`
pub fn iter_after_windows(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_after_windows(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::AfterWindows) self.iter_layer(RenderLayer::AfterWindows)
} }
/// Iterate over `DynamicRenderElements` with layer `RenderLayer::BeforeOverlay`
pub fn iter_before_overlay(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_before_overlay(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::BeforeOverlay) self.iter_layer(RenderLayer::BeforeOverlay)
} }
/// Iterate over `DynamicRenderElements` with layer `RenderLayer::Top`
pub fn iter_top(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_top(&'a self) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
self.iter_layer(RenderLayer::Top) self.iter_layer(RenderLayer::Top)
} }
/// Iterate over `DynamicRenderElements` with provided `layer`
pub fn iter_layer(&'a self, layer: RenderLayer) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> { pub fn iter_layer(&'a self, layer: RenderLayer) -> Box<dyn Iterator<Item = &SpaceElem<R>> + 'a> {
Box::new( Box::new(
self.0 self.0