[][src]Struct kas::widget::List

pub struct List<D: Directional, W: Widget> { /* fields omitted */ }

A generic row/column widget

This type is generic over both directionality and the type of child widgets. Essentially, it is a Vec which also implements the Widget trait.

Row and Column are parameterisations with set directionality.

BoxList (and its derivatives BoxRow, BoxColumn) parameterise W = Box<dyn Widget>, thus supporting individually boxed child widgets. This allows use of multiple types of child widget at the cost of extra allocation, and requires dynamic dispatch of methods.

Configuring and resizing elements is O(n) in the number of children. Drawing and event handling is O(log n) in the number of children (assuming only a small number are visible at any one time).

For fixed configurations of child widgets, make_widget can be used instead. make_widget has the advantage that it can support child widgets of multiple types without allocation and via static dispatch, but the disadvantage that drawing and event handling are O(n) in the number of children.

Methods

impl<D: Directional + Default, W: Widget> List<D, W>[src]

pub fn new(widgets: Vec<W>) -> Self[src]

Construct a new instance

This constructor is available where the direction is determined by the type: for D: Directional + Default. In other cases, use List::new_with_direction.

impl<D: Directional, W: Widget> List<D, W>[src]

pub fn new_with_direction(direction: D, widgets: Vec<W>) -> Self[src]

Construct a new instance with explicit direction

pub fn direction(&self) -> Direction[src]

Get the direction of contents

pub fn is_empty(&self) -> bool[src]

True if there are no child widgets

pub fn len(&self) -> usize[src]

Returns the number of child widgets

pub fn capacity(&self) -> usize[src]

Returns the number of elements the vector can hold without reallocating.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more elements to be inserted into the list. See documentation of Vec::reserve.

pub fn clear(&mut self) -> TkAction[src]

Remove all child widgets

Triggers a reconfigure action if any widget is removed.

pub fn push(&mut self, widget: W) -> TkAction[src]

Append a child widget

Triggers a reconfigure action.

pub fn pop(&mut self) -> (Option<W>, TkAction)[src]

Remove the last child widget

Returns None if there are no children. Otherwise, this triggers a reconfigure before the next draw operation.

Triggers a reconfigure action if any widget is removed.

pub fn insert(&mut self, index: usize, widget: W) -> TkAction[src]

Inserts a child widget position index

Panics if index > len.

Triggers a reconfigure action.

pub fn remove(&mut self, index: usize) -> (W, TkAction)[src]

Removes the child widget at position index

Panics if index is out of bounds.

Triggers a reconfigure action.

pub fn replace(&mut self, index: usize, widget: W) -> (W, TkAction)[src]

Replace the child at index

Panics if index is out of bounds.

Triggers a reconfigure action.

pub fn extend<T: IntoIterator<Item = W>>(&mut self, iter: T) -> TkAction[src]

Append child widgets from an iterator

Triggers a reconfigure action if any widgets are added.

pub fn resize_with<F: Fn(usize) -> W>(&mut self, len: usize, f: F) -> TkAction[src]

Resize, using the given closure to construct new widgets

Triggers a reconfigure action.

pub fn retain<F: FnMut(&W) -> bool>(&mut self, f: F) -> TkAction[src]

Retain only widgets satisfying predicate f

See documentation of Vec::retain.

Triggers a reconfigure action if any widgets are removed.

pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a W>[src]

Iterate over childern

Trait Implementations

impl<D: Clone + Directional, W: Clone + Widget> Clone for List<D, W>[src]

impl<D: Debug + Directional, W: Debug + Widget> Debug for List<D, W>[src]

impl<D: Default + Directional, W: Default + Widget> Default for List<D, W>[src]

impl<D: Directional, W: Widget> Handler for List<D, W>[src]

type Msg = <W as Handler>::Msg

Type of message returned by this widget Read more

impl<D: Directional, W: Widget> Index<usize> for List<D, W>[src]

type Output = W

The returned type after indexing.

impl<D: Directional, W: Widget> IndexMut<usize> for List<D, W>[src]

impl<D: Directional, W: Widget> Layout for List<D, W>[src]

impl<D: Directional, W: Widget> SendEvent for List<D, W>[src]

impl<D: Directional, W: Widget> Widget for List<D, W>[src]

impl<D: Directional, W: Widget> WidgetChildren for List<D, W>[src]

impl<D: Directional, W: Widget> WidgetConfig for List<D, W>[src]

impl<D: Directional, W: Widget> WidgetCore for List<D, W>[src]

Auto Trait Implementations

impl<D, W> RefUnwindSafe for List<D, W> where
    D: RefUnwindSafe,
    W: RefUnwindSafe

impl<D, W> Send for List<D, W> where
    D: Send,
    W: Send

impl<D, W> Sync for List<D, W> where
    D: Sync,
    W: Sync

impl<D, W> Unpin for List<D, W> where
    D: Unpin,
    W: Unpin

impl<D, W> UnwindSafe for List<D, W> where
    D: UnwindSafe,
    W: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
    Scheme: ApproxScheme
[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
    Dst: ApproxFrom<Src, Scheme>,
    Scheme: ApproxScheme
[src]

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, Dst> ConvAsUtil<Dst> for T[src]

impl<T> ConvUtil for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<Src> TryFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<Src, Dst> TryInto<Dst> for Src where
    Dst: TryFrom<Src>, 
[src]

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<Src> ValueFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Src, Dst> ValueInto<Dst> for Src where
    Dst: ValueFrom<Src>, 
[src]

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.