pub struct UiList { /* private fields */ }Expand description
The UI of a frame (RenderFrame::ui): sprites
and texts in UI units, each drawn in the UiView set when it was
pushed, after the world, at the output’s resolution.
Order. They are drawn by layer, then by depth, then in the order
they were pushed, sprites and texts alike: a window’s panel, then its
labels, then the next window over them. Higher layers are in front of
lower ones; at one layer, a SortMode::Fixed depth orders them, and
SortMode::YSort is depth 0: nothing is sorted by its y on screen.
A text’s glyphs keep their text’s place, grouped by page.
Views. UiList::set_view sets the scale and the clip of what is
pushed after it. It holds until the next call, across the systems that
push, so a system that draws UI sets its own view first. The view
before the first call is UiView::default: pixel UI, unclipped. A
view changes nothing of the order: a clip only cuts.
Cost. Runs of one texture, one program and one view, in that order, are one draw each: a panel then a label then a panel are three. A quad wholly outside its view’s clip, or with no pixels, is not drawn, though a text is laid out whole. The list keeps its buffers when cleared, so a frame that pushes what the last did allocates nothing.
Implementations§
Source§impl UiList
impl UiList
Sourcepub fn set_view(&mut self, view: UiView)
pub fn set_view(&mut self, view: UiView)
Draws what is pushed from now on in view, until the next call.
Sourcepub fn sprite(&mut self, sprite: SpriteDraw)
pub fn sprite(&mut self, sprite: SpriteDraw)
Adds sprite, its position and size in UI units.
Sourcepub fn text(&mut self, draw: TextDraw, text: &str)
pub fn text(&mut self, draw: TextDraw, text: &str)
Adds text, drawn as draw says, its position in UI units.
Sourcepub fn write(&mut self, draw: TextDraw, args: Arguments<'_>)
pub fn write(&mut self, draw: TextDraw, args: Arguments<'_>)
Adds the text args formats, as TextList::write does: with no
allocation once the list has held as much. A text whose formatting
fails is left out.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Empties the list, keeping its capacity, and puts the view back to the default.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (UiDraw<'_>, UiView)> + '_
pub fn iter(&self) -> impl ExactSizeIterator<Item = (UiDraw<'_>, UiView)> + '_
The sprites and texts, in the order they were pushed, each with its view: for checking what a UI drew without drawing it.