pub struct Grid<W: Widget> { /* private fields */ }
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).

There is no protection against multiple widgets occupying the same cell. If this does happen, the last widget in that cell will appear on top, but overlapping widget drawing may not be pretty.

Alternatives

Where the entries are fixed, also consider custom Widget implementations.

Performance

Most operations are O(n) in the number of children.

Messages

If a handler is specified via Self::on_message then this handler is called when a child pushes a message.

Implementations

Construct a new instance

Construct a new instance

Assign a child message handler

This handler (if any) is called when a child pushes a message: f(mgr, index), where index is the child’s index.

Assign a child message handler (inline style)

This handler is called when a child pushes a message: f(mgr, index), where index is the child’s index.

Get grid dimensions

The numbers of rows, columns and spans is determined automatically.

Access layout storage

Use Self::dimensions to get expected dimensions.

Construct via a builder

Edit an existing grid via a builder

This may be used to edit children before window construction. It may also be used from a running UI, but in this case a full reconfigure of the window’s widgets is required (triggered by the the return value, TkAction::RECONFIGURE).

True if there are no child widgets

Returns the number of child widgets

Returns a reference to the child, if any

Returns a mutable reference to the child, if any

Iterate over childern

Mutably iterate over childern

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Creates a value from an iterator. Read more

The returned type after indexing.

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

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

Get size rules for the given axis Read more

Set size and position Read more

Translate a coordinate to a WidgetId Read more

Draw a widget and its children Read more

Handler for messages from children/descendants Read more

Pre-configuration Read more

Configure widget Read more

Is this widget navigable via Tab key? Read more

Get translation of children relative to this widget Read more

Navigation in spatial order Read more

Handle an event sent to this widget Read more

Potentially steal an event before it reaches a child Read more

Handle an event sent to child index but left unhandled Read more

Handler for scrolling Read more

Get the number of child widgets Read more

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

Find the child which is an ancestor of this id, if any Read more

Make an identifier for a child Read more

Get the widget’s identifier Read more

Get the widget’s region, relative to its parent.

Get the name of the widget struct

Erase type

Erase type

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Cast from Self to T Read more

Try converting from Self to T Read more

Try approximate conversion from Self to T Read more

Cast approximately from Self to T Read more

Cast to integer, truncating Read more

Cast to the nearest integer Read more

Cast the floor to an integer Read more

Cast the ceiling to an integer Read more

Try converting to integer with truncation Read more

Try converting to the nearest integer Read more

Try converting the floor to an integer Read more

Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the widget’s identifier Read more

Test widget identifier for equality Read more

Display as “StructName#WidgetId”

Check whether id is self or a descendant Read more

Check whether id is not self and is a descendant Read more

Find the descendant with this id, if any

Find the descendant with this id, if any