A `GtkFlowBox` 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 `GtkFlowBox` 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 `GtkScrolledWindow` to enable that.
The children of a `GtkFlowBox` can be dynamically sorted and filtered.
Although a `GtkFlowBox` must have only `GtkFlowBoxChild` children, you can add any kind of widget to it via [method@Gtk.FlowBox.insert], and a
`GtkFlowBoxChild` widget will automatically be inserted between the box and the widget.
Also see [class@Gtk.ListBox].
CSS nodes
``` flowbox ├── flowboxchild │ ╰── <child> ├── flowboxchild │ ╰── <child> ┊ ╰── [rubberband]
```
`GtkFlowBox` uses a single CSS node with name flowbox. `GtkFlowBoxChild` uses a single CSS node with name flowboxchild. For rubberband
selection, a subnode with name rubberband is used.
Accessibility
`GtkFlowBox` uses the gtk_accessible_role_grid role, and `GtkFlowBoxChild` uses the
gtk_accessible_role_grid_cell role.
- public void append (Widget child)
Adds child
to the end of this
.
- public void bind_model (ListModel? model, owned FlowBoxCreateWidgetFunc? create_widget_func)
Binds model
to this.
- public bool get_activate_on_single_click ()
Returns whether children activate on single clicks.
- public unowned FlowBoxChild? get_child_at_index (int idx)
Gets the nth child in the this.
- public unowned FlowBoxChild? get_child_at_pos (int x, int y)
Gets the child in the (x
, y
) position.
- public uint get_column_spacing ()
Gets the horizontal spacing.
- public bool get_homogeneous ()
Returns whether the box is homogeneous.
- public uint get_max_children_per_line ()
Gets the maximum number of children per line.
- public uint get_min_children_per_line ()
Gets the minimum number of children per line.
- public uint get_row_spacing ()
Gets the vertical spacing.
- public List<unowned FlowBoxChild> get_selected_children ()
Creates a list of all selected children.
- public SelectionMode get_selection_mode ()
Gets the selection mode of this.
- public void insert (Widget widget, int position)
Inserts the widget
into this
at position
.
- public void invalidate_filter ()
Updates the filtering for all children.
- public void invalidate_sort ()
Updates the sorting for all children.
- public void prepend (Widget child)
Adds child
to the start of this
.
- public void remove (Widget widget)
Removes a child from this.
- public void remove_all ()
Removes all children from this.
- public void select_child (FlowBoxChild child)
Selects a single child of this, if the
selection mode allows it.
- public void selected_foreach (FlowBoxForeachFunc func)
Calls a function for each selected child.
- public void set_activate_on_single_click (bool single)
If single
is true, children
will be activated when you click on them, otherwise you need to double-click.
- public void set_column_spacing (uint spacing)
Sets the horizontal space to add between children.
- public void set_filter_func (owned FlowBoxFilterFunc? filter_func)
By setting a filter function on the this
one can decide dynamically which of the children to show.
- public void set_hadjustment (Adjustment adjustment)
Hooks up an adjustment to focus handling in this
.
- public void set_homogeneous (bool homogeneous)
Sets whether or not all children of this
are given equal space in the box.
- public void set_max_children_per_line (uint n_children)
Sets the maximum number of children to request and allocate space for in
this’s orientation.
- public void set_min_children_per_line (uint n_children)
Sets the minimum number of children to line up in
this’s orientation before flowing.
- public void set_row_spacing (uint spacing)
Sets the vertical space to add between children.
- public void set_selection_mode (SelectionMode mode)
Sets how selection works in this.
- public void set_sort_func (owned FlowBoxSortFunc? sort_func)
By setting a sort function on the this,
one can dynamically reorder the children of the box, based on the contents of the children.
- public void set_vadjustment (Adjustment adjustment)
Hooks up an adjustment to focus handling in this
.
- public void unselect_child (FlowBoxChild child)
Unselects a single child of this, if the
selection mode allows it.