Skip to main content

UiList

Struct UiList 

Source
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

Source

pub fn new() -> Self

An empty list, in the default view.

Source

pub fn set_view(&mut self, view: UiView)

Draws what is pushed from now on in view, until the next call.

Source

pub fn view(&self) -> UiView

The view of what is pushed now.

Source

pub fn sprite(&mut self, sprite: SpriteDraw)

Adds sprite, its position and size in UI units.

Source

pub fn text(&mut self, draw: TextDraw, text: &str)

Adds text, drawn as draw says, its position in UI units.

Source

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.

Source

pub fn len(&self) -> usize

How many sprites and texts there are.

Source

pub fn is_empty(&self) -> bool

Whether there are none.

Source

pub fn clear(&mut self)

Empties the list, keeping its capacity, and puts the view back to the default.

Source

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.

Trait Implementations§

Source§

impl Clone for UiList

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UiList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UiList

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for UiList

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for UiList

Auto Trait Implementations§

§

impl Forget for UiList

§

impl Freeze for UiList

§

impl Move for UiList

§

impl RefUnwindSafe for UiList

§

impl Send for UiList

§

impl Sync for UiList

§

impl Unpin for UiList

§

impl UnsafeUnpin for UiList

§

impl UnwindSafe for UiList

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.