Module: ui.layout.flex

Source: ./ui/layout/flex.reef


Overview

ui/layout/flex.reef - CSS Flexbox-inspired layout Part of reef-stdlib UI module

Supported by flex_layout_children (single line):

  • direction: Row / Column (packing order; reverse variants pack like non-reverse for now — see is_reversed note below)
  • grow / shrink / basis on children
  • gap / row_gap / column_gap / padding
  • justify_content: Start, End, Center, SpaceBetween, SpaceAround, SpaceEvenly
  • align_items + per-child align_self (Auto inherits parent align_items)

Not yet applied by the layout pass (fields retained for API stability):

  • wrap / flex_row_wrap / flex_column_wrap — always single-line
  • align_content — multi-line only; ignored until wrap exists
  • RowReverse / ColumnReverse packing order
  • AlignItems_Baseline — falls back to Start

Types

FlexDirection (enum)

Variants:

  • Row
  • RowReverse
  • Column
  • ColumnReverse

FlexWrap (enum)

Variants:

  • NoWrap
  • Wrap
  • WrapReverse

JustifyContent (enum)

Variants:

  • Start
  • End
  • Center
  • SpaceBetween
  • SpaceAround
  • SpaceEvenly

AlignItems (enum)

Variants:

  • Auto
  • Start
  • End
  • Center
  • Stretch
  • Baseline

AlignContent (enum)

Variants:

  • Start
  • End
  • Center
  • SpaceBetween
  • SpaceAround
  • Stretch

FlexBasis (enum)

Variants:

  • Auto
  • Fixed(float)
  • Percent(float)

FlexChild

Fields:

Name Type
grow float
shrink float
basis FlexBasis
align_self AlignItems

FlexLayout

Fields:

Name Type
direction FlexDirection
wrap FlexWrap
justify_content JustifyContent
align_items AlignItems
align_content AlignContent
gap float
row_gap float
column_gap float
padding_top float
padding_right float
padding_bottom float
padding_left float

FlexChildSize

Fields:

Name Type
width float
height float
flex FlexChild

Functions

fn flex_direction_row(): FlexDirection

fn flex_direction_row_reverse(): FlexDirection

fn flex_direction_column(): FlexDirection

fn flex_direction_column_reverse(): FlexDirection

fn is_row(d: FlexDirection): bool

fn is_row_reverse(d: FlexDirection): bool

fn is_column(d: FlexDirection): bool

fn is_column_reverse(d: FlexDirection): bool

fn is_horizontal_flex(d: FlexDirection): bool

fn is_reversed(d: FlexDirection): bool

fn flex_no_wrap(): FlexWrap

fn flex_wrap(): FlexWrap

Sets FlexLayout.wrap only; flex_layout_children still packs a single line.

fn flex_wrap_reverse(): FlexWrap

fn justify_start(): JustifyContent

fn justify_end(): JustifyContent

fn justify_center(): JustifyContent

fn justify_space_between(): JustifyContent

fn justify_space_around(): JustifyContent

fn justify_space_evenly(): JustifyContent

fn align_items_auto(): AlignItems

Prefer for FlexChild.align_self. On FlexLayout.align_items, treated as Stretch.

fn align_items_start(): AlignItems

fn align_items_end(): AlignItems

fn align_items_center(): AlignItems

fn align_items_stretch(): AlignItems

fn align_items_baseline(): AlignItems

fn align_content_start(): AlignContent

fn align_content_end(): AlignContent

fn align_content_center(): AlignContent

fn align_content_space_between(): AlignContent

fn align_content_space_around(): AlignContent

fn align_content_stretch(): AlignContent

fn flex_basis_auto(): FlexBasis

fn flex_basis_fixed(value: float): FlexBasis

fn flex_basis_percent(value: float): FlexBasis

fn flex_child_default(): FlexChild

fn flex_child_grow(grow: float): FlexChild

fn flex_child_shrink(shrink: float): FlexChild

fn flex_child_fixed(size: float): FlexChild

fn flex_child_full(grow: float, shrink: float, basis: FlexBasis, align_self: AlignItems): FlexChild

fn flex_child_get_grow(c: FlexChild): float

fn flex_child_get_shrink(c: FlexChild): float

fn flex_child_get_basis(c: FlexChild): FlexBasis

fn flex_child_get_align_self(c: FlexChild): AlignItems

fn flex_row(): FlexLayout

fn flex_column(): FlexLayout

fn flex_row_wrap(): FlexLayout

Convenience constructors: set wrap=Wrap but layout is still single-line.

fn flex_column_wrap(): FlexLayout

fn flex_layout_full(direction: FlexDirection, wrap: FlexWrap, justify_content: JustifyContent, align_items: AlignItems, align_content: AlignContent, gap: float, row_gap: float, column_gap: float, padding_top: float, padding_right: float, padding_bottom: float, padding_left: float): FlexLayout

fn flex_with_gap(f: FlexLayout, gap: float): FlexLayout

fn flex_with_padding(f: FlexLayout, all: float): FlexLayout

fn flex_with_justify(f: FlexLayout, justify: JustifyContent): FlexLayout

fn flex_with_align_items(f: FlexLayout, align: AlignItems): FlexLayout

fn flex_child_size(width: float, height: float, flex: FlexChild): FlexChildSize

fn flex_child_size_simple(width: float, height: float): FlexChildSize

fn flex_layout_children(f: FlexLayout, constraints: layout.Constraints, child_sizes: [FlexChildSize], child_count: int): layout.LayoutResult

fn calculate_basis(f: FlexLayout, cs: FlexChildSize, main_available: float): float

fn get_main_gap(f: FlexLayout): float

fn get_cross_gap(f: FlexLayout): float

fn resolve_align(parent_items: AlignItems, align_self: AlignItems): AlignItems

Resolve child align_self against parent align_items (Auto → parent; parent Auto → Stretch).

fn justify_free_space(main_available: float, total_main: float): float

free_space = main_available - packed main size (after grow/shrink). Negative → 0 for justify.

fn calculate_cross_position(align: AlignItems, cross_start: float, cross_available: float, cross_size: float): float

fn calculate_flex_total_size(f: FlexLayout, final_sizes: [float], child_sizes: [FlexChildSize], child_count: int): core.Size

fn flex_preferred_size(f: FlexLayout, child_sizes: [FlexChildSize], child_count: int): core.Size


Procedures

proc position_children(f: FlexLayout, child_sizes: [FlexChildSize], final_sizes: [float], child_count: int, main_available: float, cross_available: float, children: [layout.ChildLayout])


Generated by reefc doc