Raxol.UI.Layout.ViewNodes (Raxol v2.8.0)

View Source

Layout for the View DSL nodes that are declarations rather than primitives (#1129).

Raxol.View.Components builds input, list, progress, select, radio_group, textarea, tabs and modal nodes, and Raxol.Core.Renderer.View builds border, scroll and shadow nodes, as plain data that MCP and the accessibility projection read field by field. The layout engine had no clause for any of them, so each drew a blank region.

lower/2 rewrites a declaration into the text, row, column and box primitives the engine lays out and measures, keeping its :id. scroll and shadow depend on the space they are given, so they are laid out here directly (process_scroll/3, process_shadow/3), each with a matching measure.

Summary

Functions

Rewrites a declaration node into the primitives that draw it, in the space it is laid out in.

Node types lower/2 rewrites into layout primitives.

Measures a scroll node: its viewport, or its content where unset.

Measures a shadow node: its children plus the shadow offset.

Lays out a scroll node: its children in a :viewport-sized window (the given space when unset), shifted by :offset and clipped to the window, with a vertical scrollbar in the last column when :scrollbars is on and the content is taller than the window.

Lays out a shadow node: its children at their measured size, and the part of a same-sized block of the shadow colour, offset by :offset, that they do not cover (a strip to their right and one below them).

Types

lowered_type()

@type lowered_type() ::
  :border
  | :input
  | :list
  | :modal
  | :progress
  | :radio_group
  | :select
  | :tabs
  | :textarea

Functions

lower(node, space)

@spec lower(%{:type => lowered_type(), optional(atom()) => term()}, map()) :: %{
  :type => :box | :column | :row | :text | :text_input,
  optional(atom()) => term()
}

Rewrites a declaration node into the primitives that draw it, in the space it is laid out in.

lowered_types()

@spec lowered_types() :: [lowered_type(), ...]

Node types lower/2 rewrites into layout primitives.

measure_scroll(node, available_space)

@spec measure_scroll(map(), map()) :: Raxol.UI.Layout.Engine.measurement()

Measures a scroll node: its viewport, or its content where unset.

measure_shadow(node, available_space)

@spec measure_shadow(map(), map()) :: Raxol.UI.Layout.Engine.measurement()

Measures a shadow node: its children plus the shadow offset.

process_scroll(node, space, acc)

Lays out a scroll node: its children in a :viewport-sized window (the given space when unset), shifted by :offset and clipped to the window, with a vertical scrollbar in the last column when :scrollbars is on and the content is taller than the window.

process_shadow(node, space, acc)

Lays out a shadow node: its children at their measured size, and the part of a same-sized block of the shadow colour, offset by :offset, that they do not cover (a strip to their right and one below them).