Struct kas_widgets::List [−][src]
pub struct List<D: Directional, W: Widget> { /* fields omitted */ }
Expand description
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.
Implementations
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
.
Set the direction of contents
Construct a new instance with explicit direction
Returns the number of elements the vector can hold without reallocating.
Reserves capacity for at least additional
more elements to be inserted
into the list. See documentation of Vec::reserve
.
Remove all child widgets
Triggers a reconfigure action if any widget is removed.
Append a child widget
Triggers a reconfigure action.
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.
Removes the child widget at position index
Panics if index
is out of bounds.
Triggers a reconfigure action.
Append child widgets from an iterator
Triggers a reconfigure action if any widgets are added.
Resize, using the given closure to construct new widgets
Triggers a reconfigure action.
Retain only widgets satisfying predicate f
See documentation of Vec::retain
.
Triggers a reconfigure action if any widgets are removed.
Get the index of the child which is an ancestor of id
, if any
Trait Implementations
Record first identifier Read more
Get the number of child widgets
Get a reference to a child widget by index, or None
if the index is
out of bounds. Read more
Mutable variant of get Read more
Check whether id
is a descendant Read more
Find the child which is an ancestor of this id
, if any Read more
Find the leaf (lowest descendant) with this id
, if any Read more
Find the leaf (lowest descendant) with this id
, if any Read more
Walk through all widgets, calling f
once on each. Read more
Walk through all widgets, calling f
once on each. Read more
Get self as type Any
(mutable)
Get the name of the widget struct
Erase type
Erase type
Get whether the widget is disabled
Set the disabled state of a widget Read more
Set disabled state (chaining) Read more
Construct InputState
Read more
Auto Trait Implementations
impl<D, W> RefUnwindSafe for List<D, W> where
D: RefUnwindSafe,
W: RefUnwindSafe,
impl<D, W> UnwindSafe for List<D, W> where
D: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
pub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
pub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
pub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
pub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
pub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
pub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more