Struct gtk4::FlowBox

source ·
#[repr(transparent)]
pub struct FlowBox { /* private fields */ }
Expand description

A FlowBox puts child widgets in reflowing grid.

For instance, with the horizontal orientation, the widgets will be arranged from left to right, starting a new row under the previous row when necessary. Reducing the width in this case will require more rows, so a larger height will be requested.

Likewise, with the vertical orientation, the widgets will be arranged from top to bottom, starting a new column to the right when necessary. Reducing the height will require more columns, so a larger width will be requested.

The size request of a FlowBox alone may not be what you expect; if you need to be able to shrink it along both axes and dynamically reflow its children, you may have to wrap it in a ScrolledWindow to enable that.

The children of a FlowBox can be dynamically sorted and filtered.

Although a FlowBox must have only FlowBoxChild children, you can add any kind of widget to it via insert(), and a FlowBoxChild widget will automatically be inserted between the box and the widget.

Also see ListBox.

CSS nodes

flowbox
├── flowboxchild
│   ╰── <child>
├── flowboxchild
│   ╰── <child>
┊
╰── [rubberband]

FlowBox uses a single CSS node with name flowbox. FlowBoxChild uses a single CSS node with name flowboxchild. For rubberband selection, a subnode with name rubberband is used.

Accessibility

FlowBox uses the AccessibleRole::Grid role, and FlowBoxChild uses the AccessibleRole::GridCell role.

Implements

WidgetExt, glib::ObjectExt, AccessibleExt, BuildableExt, ConstraintTargetExt, OrientableExt, WidgetExtManual, AccessibleExtManual

Implementations§

Creates a FlowBox.

Returns

a new FlowBox

Creates a new builder-pattern struct instance to construct FlowBox objects.

This method returns an instance of FlowBoxBuilder which can be used to create FlowBox objects.

Available on crate feature v4_6 only.

Adds @child to the end of @self.

If a sort function is set, the widget will actually be inserted at the calculated position.

See also: insert().

child

the Widget to add

Binds @model to @self.

If @self was already bound to a model, that previous binding is destroyed.

The contents of @self are cleared and then filled with widgets that represent items from @model. @self is updated whenever @model changes. If @model is None, @self is left empty.

It is undefined to add or remove widgets directly (for example, with insert()) while @self is bound to a model.

Note that using a model is incompatible with the filtering and sorting functionality in FlowBox. When using a model, filtering and sorting should be implemented by the model.

model

the GListModel to be bound to @self

create_widget_func

a function that creates widgets for items

Returns whether children activate on single clicks.

Returns

true if children are activated on single click, false otherwise

Gets the nth child in the @self.

idx

the position of the child

Returns

the child widget, which will always be a FlowBoxChild or None in case no child widget with the given index exists.

Gets the child in the (@x, @y) position.

Both @x and @y are assumed to be relative to the origin of @self.

x

the x coordinate of the child

y

the y coordinate of the child

Returns

the child widget, which will always be a FlowBoxChild or None in case no child widget exists for the given x and y coordinates.

Gets the horizontal spacing.

Returns

the horizontal spacing

Returns whether the box is homogeneous.

Returns

true if the box is homogeneous.

Gets the maximum number of children per line.

Returns

the maximum number of children per line

Gets the minimum number of children per line.

Returns

the minimum number of children per line

Gets the vertical spacing.

Returns

the vertical spacing

Creates a list of all selected children.

Returns

A GList containing the Widget for each selected child. Free with g_list_free() when done.

Gets the selection mode of @self.

Returns

the SelectionMode

Inserts the @widget into @self at @position.

If a sort function is set, the widget will actually be inserted at the calculated position.

If @position is -1, or larger than the total number of children in the @self, then the @widget will be appended to the end.

widget

the Widget to add

position

the position to insert @child in

Updates the filtering for all children.

Call this function when the result of the filter function on the @self is changed due to an external factor. For instance, this would be used if the filter function just looked for a specific search term, and the entry with the string has changed.

Updates the sorting for all children.

Call this when the result of the sort function on @self is changed due to an external factor.

Available on crate feature v4_6 only.

Adds @child to the start of @self.

If a sort function is set, the widget will actually be inserted at the calculated position.

See also: insert().

child

the Widget to add

Removes a child from @self.

widget

the child widget to remove

Select all children of @self, if the selection mode allows it.

Selects a single child of @self, if the selection mode allows it.

child

a child of @self

Calls a function for each selected child.

Note that the selection cannot be modified from within this function.

func

the function to call for each selected child

If @single is true, children will be activated when you click on them, otherwise you need to double-click.

single

true to emit child-activated on a single click

Sets the horizontal space to add between children.

spacing

the spacing to use

By setting a filter function on the @self one can decide dynamically which of the children to show.

For instance, to implement a search function that only shows the children matching the search terms.

The @filter_func will be called for each child after the call, and it will continue to be called each time a child changes (via FlowBoxChildExt::changed()) or when invalidate_filter() is called.

Note that using a filter function is incompatible with using a model (see bind_model()).

filter_func

callback that lets you filter which children to show

Hooks up an adjustment to focus handling in @self.

The adjustment is also used for autoscrolling during rubberband selection. See ScrolledWindow::hadjustment() for a typical way of obtaining the adjustment, and set_vadjustment() for setting the vertical adjustment.

The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.

adjustment

an adjustment which should be adjusted when the focus is moved among the descendents of @container

Sets whether or not all children of @self are given equal space in the box.

homogeneous

true to create equal allotments, false for variable allotments

Sets the maximum number of children to request and allocate space for in @self’s orientation.

Setting the maximum number of children per line limits the overall natural size request to be no more than @n_children children long in the given orientation.

n_children

the maximum number of children per line

Sets the minimum number of children to line up in @self’s orientation before flowing.

n_children

the minimum number of children per line

Sets the vertical space to add between children.

spacing

the spacing to use

Sets how selection works in @self.

mode

the new selection mode

Hooks up an adjustment to focus handling in @self.

The adjustment is also used for autoscrolling during rubberband selection. See ScrolledWindow::vadjustment() for a typical way of obtaining the adjustment, and set_hadjustment() for setting the horizontal adjustment.

The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.

adjustment

an adjustment which should be adjusted when the focus is moved among the descendents of @container

Unselect all children of @self, if the selection mode allows it.

Unselects a single child of @self, if the selection mode allows it.

child

a child of @self

Emitted when the user activates the @box_.

This is a keybinding signal.

Emitted when a child has been activated by the user.

child

the child that is activated

Emitted when the user initiates a cursor movement.

This is a keybinding signal. Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifier does not. There are too many key combinations to list them all here.

  • , , , move by individual children
  • Home, End move to the ends of the box
  • PgUp, PgDn move vertically by pages
step

the granularity of the move, as a MovementStep

count

the number of @step units to move

extend

whether to extend the selection

modify

whether to modify the selection

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted to select all children of the box, if the selection mode permits it.

This is a keybinding signal.

The default bindings for this signal is Ctrl-a.

Emitted when the set of selected children changes.

Use selected_foreach() or selected_children() to obtain the selected children.

Emitted to toggle the selection of the child that has the focus.

This is a keybinding signal.

The default binding for this signal is Ctrl-Space.

Emitted to unselect all children of the box, if the selection mode permits it.

This is a keybinding signal.

The default bindings for this signal is Ctrl-Shift-a.

By setting a sort function on the @self, one can dynamically reorder the children of the box, based on the contents of the children.

The @sort_func will be called for each child after the call, and will continue to be called each time a child changes (via FlowBoxChildExt::changed()) and when invalidate_sort() is called.

Note that using a sort function is incompatible with using a model (see bind_model()).

sort_func

the sort function

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
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Returns the type identifier of Self.

Auto Trait Implementations§

Blanket Implementations§

Updates an array of accessible properties. Read more
Updates an array of accessible relations. Read more
Updates an array of accessible states. Read more
Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T. Read more
Upcasts an object to a reference of its superclass or interface T. Read more
Tries to downcast to a subclass or interface implementor T. Read more
Tries to downcast to a reference of its subclass or interface implementor T. Read more
Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Casts to T unconditionally. Read more
Casts to &T unconditionally. 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.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Runs the dispose mechanism of the object. Read more
Ensures that the type has been registered with the type system.
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
Converts the given value to a String. 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.