Function zng_wgt_grid::columns

source ·
pub fn columns(cells: impl UiNodeList)
Expand description

c Column definitions.

You can define columns with any widget, but the Column! widget is recommended. The column widget width defines the width of the cells assigned to it, the Column::width property can be used to enforce a width, otherwise the column is sized by the widest cell.

The grid uses the WIDGET_SIZE value to select one of three layout modes for columns:

  • Default, used for columns that do not set width or set it to Length::Default.
  • Exact, used for columns that set the width to an unit that is exact or only depends on the grid context.
  • Leftover, used for columns that set width to a lft value.

The column layout follows these steps:

1 - All Exact column widgets are layout, their final width defines the column width. 2 - All cell widgets with span 1 in Default columns are measured, the widest defines the fill width constrain, the columns are layout using this constrain, the final width defines the column width. 3 - All Leftover cells are layout with the leftover grid width divided among all columns in this mode.

So given the columns 200 | 1.lft() | 1.lft() and grid width of 1000 with spacing 5 the final widths are 200 | 395 | 395, for 200 + 5 + 395 + 5 + 395 = 1000.

Note that the column widget is not the parent of the cells that match it, the column widget is rendered under cell and row widgets. Properties like padding and align only affect the column visual, not the cells, similarly contextual properties like text_color don’t affect the cells.

§Capture-Only

This property is capture-only, it only defines a property signature, it does not implement any behavior by itself. Widgets can capture and implement this property as part of their intrinsics, otherwise it will have no effect if set on a widget that does not implement it.