Struct kas_widgets::Grid [−][src]
pub struct Grid<W: Widget> { /* fields omitted */ }
Expand description
A generic grid widget
Child widgets are displayed in a grid, according to each child’s
GridChildInfo
. This allows spans and overlapping widgets. The numbers
of rows and columns is determined automatically while the sizes of rows and
columns are determined based on their contents (including special handling
for spans, mostly with good results).
Note that all child widgets are stored in a list internally. The order of widgets in that list does not affect display position, but does have a few effects: (a) widgets may be accessed in this order via indexing, (b) widgets are configured and drawn in this order, (c) navigating through widgets with the Tab key currently uses the list order (though it may be changed in the future to use display order).
Most operations (configuring, resizing and drawing) are O(n) in the number of children. This type is generic over the type of child widgets.
For fixed layouts, an alternative is to construct a custom widget with
kas::macros::make_widget
which can also perform event handling.
Implementations
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.
Add a widget to a particular cell
This is just a convenient way to construct a GridChildInfo
.
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.
pub fn resize_with<F: Fn(usize) -> (W, GridChildInfo)>(
&mut self,
len: usize,
f: F
) -> TkAction
pub fn resize_with<F: Fn(usize) -> (W, GridChildInfo)>(
&mut self,
len: usize,
f: F
) -> TkAction
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<W> RefUnwindSafe for Grid<W> where
W: RefUnwindSafe,
impl<W> UnwindSafe for Grid<W> where
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