package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.tree/Tree/Layout_input/index.html
Module Tree.Layout_inputSource
Layout input constraints passed from parent to child during layout computation.
Layout input encapsulates the sizing constraints, hints, and execution mode that govern how a child node computes its layout. Parent nodes construct layout inputs based on their own constraints, available space, and the child's position in the layout tree, then pass them down when invoking child layout algorithms.
Key components include execution mode (full layout vs. size-only computation), sizing mode (whether to apply style constraints), requested axes, known dimensions for constraint solving, parent size for percentage resolution, available space for wrapping decisions, and margin collapsibility flags for CSS Block layout.
type t = {run_mode : Run_mode.t;(*Execution mode determining whether to compute full layout or size only.
*)sizing_mode : Sizing_mode.t;(*Whether to apply inherent size styles (width, height, min/max constraints, aspect ratio) or measure content size only.
*)axis : Requested_axis.t;(*Requested axis dimensions.
*)Horizontal,Vertical, orBoth.known_dimensions : float option Geometry.size;(*Fixed dimensions acting as hard constraints during layout.
When
*)widthisSome w, layout treats the width as fixed atwand computes the height accordingly. When both areSome, this represents final layout with exact dimensions, and the node performs positioning without further size computation.parent_size : float option Geometry.size;(*Parent container dimensions for resolving percentage-based sizes.
When a style specifies
*)width: 50%, this value provides the reference for computing the absolute pixel width.available_space : Available_space.t Geometry.size;(*Available space for layout, acting as a soft constraint.
Used primarily for wrapping decisions in Flexbox and intrinsic sizing in Grid. Can be
*)Definite pixel_count,Min_content, orMax_content.vertical_margins_are_collapsible : bool Geometry.line;(*Margin collapsibility for top and bottom margins.
Specific to CSS Block layout's margin collapsing algorithm. Both fields are typically
*)falsefor Flexbox and Grid layouts.
}val make :
run_mode:Run_mode.t ->
sizing_mode:Sizing_mode.t ->
axis:Requested_axis.t ->
known_dimensions:float option Geometry.size ->
parent_size:float option Geometry.size ->
available_space:Available_space.t Geometry.size ->
vertical_margins_are_collapsible:bool Geometry.line ->
tmake ~run_mode ~sizing_mode ~axis ~known_dimensions ~parent_size ~available_space ~vertical_margins_are_collapsible creates a layout input.
run_mode t returns the execution mode.
sizing_mode t returns the sizing mode.
axis t returns the requested axis.
known_dimensions t returns the known dimensions.
parent_size t returns the parent size.
available_space t returns the available space.
vertical_margins_are_collapsible t returns margin collapsibility flags.
hidden is a layout input for nodes with Display.None.
Sets run_mode to Perform_hidden_layout, which causes the node to receive a zero-sized layout without computing children. Other fields are set to defaults: Inherent_size sizing mode, Both axis, no known dimensions or parent size, Max_content available space, and non-collapsible margins.
compare a b compares layout inputs lexicographically.
Compares fields in order: run_mode, sizing_mode, axis, known_dimensions, parent_size, available_space, and vertical_margins_are_collapsible. Returns a negative integer if a < b, zero if a = b, and a positive integer if a > b.
pp fmt t pretty-prints t to fmt.