Skip to main content

Selector

Struct Selector 

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

Shows at most one of its children.

You can change which node is selected as visible, or set no child to be visible. If you wish to have multiple children visible at once, wrap all of them in Hiders and your choice of container.

The minimum size of the selector is the minimum size of the selected child, or 0 if none is selected.

Implementations§

Source§

impl Selector

Source

pub fn new() -> Self

Create an empty Selector with no children, no selection, and alignment (Begin, Begin).

Source

pub fn with_child(self, index: NodeIndex) -> Self

Add a new child to the list. If there are no other children, the new child will be selected.

Source

pub fn with_align(self, align: (Alignment, Alignment)) -> Self

Set the horizontal and vertical alignment of the container, not the children.

Source

pub fn add_child(&mut self, index: NodeIndex)

Add a child to the list.

Source

pub fn len(&self) -> usize

Returns the number of children in the list.

Source

pub fn is_empty(&self) -> bool

Returns true if the list is empty.

Equivalent to len() == 0.

Source

pub fn remove_child(&mut self, index: usize, tree: &mut UiTree) -> bool

Remove a child from the list. If the child is currently selected, the selection is removed.

Returns true if the child was removed.

Source

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

Move a child to a new index. Lower indices are visited first.

Returns true if the child was moved.

Source

pub fn get_child_index(&self, index: usize) -> Option<NodeIndex>

Returns the tree index associated with a child at a given list index.

Source

pub fn get_selected(&self) -> Option<NodeIndex>

Returns the tree index of the currently-selected node.

Source

pub fn get_selected_index(&self) -> Option<usize>

Returns the list index of the currently-selected node.

Source

pub fn set_selected(&mut self, child: NodeIndex)

Sets the selected node to the given tree index.

Source

pub fn set_selected_index(&mut self, index: usize)

Sets the selected node to the given list index.

Source

pub fn unselect(&mut self)

Removes the selection.

Trait Implementations§

Source§

impl Default for Selector

Source§

fn default() -> Self

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

impl UiNode for Selector

Source§

fn get_align(&self) -> (Alignment, Alignment)

Get the alignment of the node.
Source§

fn get_align_mut(&mut self) -> (&mut Alignment, &mut Alignment)

Get a mutable reference to the alignment of the node.
Source§

fn calculate_min_size(&self, tree: &UiTree) -> (f32, f32)

Calculate the minimum size of the node. Read more
Source§

fn calculate_rects(&self, cache: &NodeCache, tree: &UiTree) -> Vec<Rect>

Recalculate the position and size of child nodes, in the same order and count as get_visible_children. Read more
Source§

fn get_children(&self) -> Vec<NodeIndex>

Get all children of the node, if applicable.
Source§

fn get_visible_children(&self) -> Vec<NodeIndex>

Get all visible children of the node, if applicable. 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.