Layout

termflow.tui.Layout
See theLayout companion enum
object Layout

Attributes

Companion
enum
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Layout.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def border(top: Layout, left: Layout, center: Layout, right: Layout, bottom: Layout, gap: Int): Layout

Fluent constructor for a Border. Pass null (or omit) any zone you don't need; non-null arguments are wrapped in Some.

Fluent constructor for a Border. Pass null (or omit) any zone you don't need; non-null arguments are wrapped in Some.

Attributes

def cell(vnode: VNode, colSpan: Int, rowSpan: Int): GridCell

Convenience constructor for a GridCell wrapping a bare VNode. Equivalent to GridCell(Elem(vnode), colSpan, rowSpan).

Convenience constructor for a GridCell wrapping a bare VNode. Equivalent to GridCell(Elem(vnode), colSpan, rowSpan).

Attributes

def column(gap: Int)(children: VNode*): Layout

Fluent constructor for a Column over bare VNodes. Each vnode is auto-wrapped in an Elem.

Fluent constructor for a Column over bare VNodes. Each vnode is auto-wrapped in an Elem.

Attributes

def grid(columns: Int, rowGap: Int, colGap: Int)(children: VNode*): Layout

Fluent constructor for a Grid over bare VNodes. Every vnode becomes a 1×1 cell. Use the Grid case directly when you need colSpan / rowSpan control.

Fluent constructor for a Grid over bare VNodes. Every vnode becomes a 1×1 cell. Use the Grid case directly when you need colSpan / rowSpan control.

Layout.grid(columns = 3, rowGap = 1, colGap = 2)(
 TextNode(1.x, 1.y, List("a".text)),
 TextNode(1.x, 1.y, List("b".text)),
 TextNode(1.x, 1.y, List("c".text)),
 TextNode(1.x, 1.y, List("d".text))
)

Attributes

def measure(layout: Layout): (Int, Int)

Natural size of a layout, ignoring any container it will be placed in.

Natural size of a layout, ignoring any container it will be placed in.

Public for tests and for callers who want to size a surrounding box from measured layout dimensions.

Attributes

def measureVNode(v: VNode): (Int, Int)

Natural (width, height) of a concrete VNode.

Natural (width, height) of a concrete VNode.

Attributes

def resolve(layout: Layout, at: Coord): List[VNode]

Resolve a layout into absolute-positioned VNodes starting at at.

Resolve a layout into absolute-positioned VNodes starting at at.

The instance method Layout.resolve delegates here — prefer calling the method form for readability.

Attributes

def resolveTo(layout: Layout, at: Coord, availableWidth: Int, availableHeight: Int): List[VNode]

Resolve a layout into absolute-positioned VNodes with optional axis-size constraints.

Resolve a layout into absolute-positioned VNodes with optional axis-size constraints.

Pass -1 for either dimension to mean "no constraint" — Fill children in that axis fall back to their natural size, exactly the old behaviour. Passing a non-negative value enables Fill to consume whatever's left after fixed-size siblings; multiple Fill siblings split the remainder evenly (any leftover cells go to the last Fill child so totals add up exactly).

Value parameters

at

Top-left of the layout's allocated rectangle.

availableHeight

Height budget for the major axis of a Column. -1 = unbounded.

availableWidth

Width budget for the major axis of a Row (or just the layout, for an outermost call). -1 = unbounded.

Attributes

def resolveTracked[Id](layout: Layout, at: Coord, availableWidth: Int, availableHeight: Int): (List[VNode], HitTest[Id])

Resolve a layout into both (VNode list, hit-test registry). The registry is populated from any Layout.Zone wrappers encountered during resolution, so apps wiring mouse interaction can map a click coordinate back to a logical zone without recomputing rectangles.

Resolve a layout into both (VNode list, hit-test registry). The registry is populated from any Layout.Zone wrappers encountered during resolution, so apps wiring mouse interaction can map a click coordinate back to a logical zone without recomputing rectangles.

Zones outside the resolver's wrapping always pick up a real rectangle regardless of availableWidth / availableHeight: the tracked rect uses each subtree's resolved size, so Layout.Fill children record their post-fill rectangle, not their natural size.

Type parameter Id declares the registry's id type at the call site. Because of JVM erasure the cast is unchecked at runtime — apps are responsible for using uniform id types within a single tracked layout tree (sealed enums / strings / ints; not mixed). Mixing id types and recovering the right ones from the registry requires the caller to pattern-match on each entry's runtime value.

Value parameters

at

Top-left of the layout's allocated rectangle.

availableHeight

Height budget along the major axis. -1 = unbounded.

availableWidth

Width budget along the major axis. -1 = unbounded (same convention as resolveTo).

layout

Layout to resolve.

Attributes

def row(gap: Int)(children: VNode*): Layout

Fluent constructor for a Row over bare VNodes. Each vnode is auto-wrapped in an Elem.

Fluent constructor for a Row over bare VNodes. Each vnode is auto-wrapped in an Elem.

Layout.row(gap = 1)(
 TextNode(1.x, 1.y, List(Text("A", Style()))),
 TextNode(1.x, 1.y, List(Text("B", Style())))
)

Attributes

def translate(v: VNode, dx: Int, dy: Int): VNode

Translate a VNode by (dx, dy), including any nested BoxNode children so that relative offsets are preserved.

Translate a VNode by (dx, dy), including any nested BoxNode children so that relative offsets are preserved.

Exposed for tests; the resolver uses it internally for Elem nodes.

Attributes

def zone(id: Any, content: Layout): Layout

Tag content with a hit-test id. Sugar for Zone that lets the wrapper read like a method call:

Tag content with a hit-test id. Sugar for Zone that lets the wrapper read like a method call:

Layout.zone("submit", Layout.Elem(buttonNode))

Attributes

def zone(id: Any, vnode: VNode): Layout

Tag a bare VNode with a hit-test id, lifting it into Elem.

Tag a bare VNode with a hit-test id, lifting it into Elem.

Attributes

Extensions

Extensions

extension (v: VNode)

Extension lifting a VNode into a Layout.Elem.

Extension lifting a VNode into a Layout.Elem.

Attributes