Struct gtk4::FlowBox[][src]

pub struct FlowBox(_);
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.

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 ot 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.

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

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

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.

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

the granularity fo 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 <kbd>Ctrl</kbd>-<kbd>a</kbd>.

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 <kbd>Ctrl</kbd>-<kbd>Space</kbd>.

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 <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>a</kbd>.

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 !=.

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

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

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Same as emit but takes Value for the arguments.

Emit signal by its name.

Same as emit_by_name but takes Value for the arguments.

Emit signal with details by signal id.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Returns a SendValue clone of self.

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.