Struct modalkit::ui::FocusList

source ·
pub struct FocusList<T> { /* private fields */ }
Expand description

List of items that tracks a current and previous focus.

Implementations§

source§

impl<T> FocusList<T>

source

pub fn new(items: Vec<T>) -> Self

Create a new FocusList given an original set of items.

source

pub fn len(&self) -> usize

Returns how many items are in this list.

source

pub fn is_empty(&self) -> bool

Indicates whether this list is empty.

source

pub fn get(&self) -> Option<&T>

Get a reference to the currently focused item.

source

pub fn get_mut(&mut self) -> Option<&mut T>

Get a mutable reference to the currently focused item.

source

pub fn pos(&self) -> usize

Get the currently focused position in this list.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>

Iterate over mutable references to the items in this list.

source

pub fn iter(&self) -> impl Iterator<Item = &T>

Iterate over references to the items in this list.

source

pub fn try_close<E, F>( &mut self, target: &TabTarget, f: F, ctx: &EditContext, ) -> Result<(), E>
where F: FnMut(&mut T) -> Result<(), E>,

Try closing targeted items using f until one fails or all targets are closed.

If the target cannot be closed, focus will be moved to it.

source

pub fn target( &self, change: &FocusChange, ctx: &EditContext, ) -> Option<(usize, MoveDir1D)>

Determine the index of the item targeted by a given FocusChange.

The MoveDir1D value returned indicates which side of the index to insert at.

source

pub fn insert(&mut self, idx: usize, side: MoveDir1D, item: T)

Insert an item before or after a given index.

source

pub fn remove(&mut self, idx: usize)

Remove the item located at a given index.

source

pub fn remove_current(&mut self)

Remove the currently focused item.

source

pub fn focus(&mut self, change: &FocusChange, ctx: &EditContext)

Switch focus to a new item.

source

pub fn transfer(&mut self, change: &FocusChange, ctx: &EditContext)

Move the currently focused item to a new position.

source

pub fn push(&mut self, item: T)

Push a new item onto the end of this list.

Trait Implementations§

source§

impl<T> AsRef<[T]> for FocusList<T>

source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Default for FocusList<T>

source§

fn default() -> Self

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

impl<T> From<T> for FocusList<T>

source§

fn from(item: T) -> Self

Converts to this type from the input type.
source§

impl<T> Index<usize> for FocusList<T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &T

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FocusList<T>

§

impl<T> RefUnwindSafe for FocusList<T>
where T: RefUnwindSafe,

§

impl<T> Send for FocusList<T>
where T: Send,

§

impl<T> Sync for FocusList<T>
where T: Sync,

§

impl<T> Unpin for FocusList<T>
where T: Unpin,

§

impl<T> UnwindSafe for FocusList<T>
where T: UnwindSafe,

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<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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>,

§

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>,

§

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.
source§

impl<T> Any for T
where T: Any,