Skip to main content

LayerStack

Struct LayerStack 

Source
pub struct LayerStack { /* private fields */ }
Expand description

An ordered stack of map layers, rendered bottom-to-top.

Implementations§

Source§

impl LayerStack

Source

pub fn new() -> Self

Create an empty layer stack.

Source

pub fn from_vec(layers: Vec<Box<dyn Layer>>) -> Self

Create a layer stack from an existing vector of layers.

Source

pub fn push(&mut self, layer: Box<dyn Layer>)

Add a layer on top of the stack.

Source

pub fn insert(&mut self, index: usize, layer: Box<dyn Layer>)

Insert a layer at a specific index (0 = bottom).

Source

pub fn remove(&mut self, index: usize) -> Option<Box<dyn Layer>>

Remove a layer by index. Returns it if valid.

Source

pub fn remove_by_name(&mut self, name: &str) -> Option<Box<dyn Layer>>

Remove a layer by name. Returns it if found.

Source

pub fn move_up(&mut self, index: usize) -> bool

Move a layer up (toward the top of the stack / rendered last).

Returns true if the layer was moved.

Source

pub fn move_down(&mut self, index: usize) -> bool

Move a layer down (toward the bottom of the stack / rendered first).

Returns true if the layer was moved.

Source

pub fn index_of(&self, name: &str) -> Option<usize>

Find a layer by name and return its index.

Source

pub fn get(&self, index: usize) -> Option<&dyn Layer>

Get a layer by index.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Box<dyn Layer>>

Get a layer mutably by index.

Source

pub fn len(&self) -> usize

Number of layers.

Source

pub fn is_empty(&self) -> bool

Whether there are no layers.

Source

pub fn iter(&self) -> impl Iterator<Item = &dyn Layer> + '_

Iterate layers bottom-to-top.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Box<dyn Layer>>

Iterate layers mutably.

Trait Implementations§

Source§

impl Default for LayerStack

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.