Sign in

    mizchi/crater/node does not have a README file

    IntrinsicSize

    pub(all) struct IntrinsicSize {
    min_width : Double
    max_width : Double
    min_height : Double
    max_height : Double
    }

    Intrinsic size measurement result

    IntrinsicSize::default

    fn IntrinsicSize::default() -> IntrinsicSize

    Default intrinsic size for leaf nodes without measure function Matches Taffy behavior: empty/unmeasured nodes have zero intrinsic size

    Layout

    pub(all) struct Layout {
    id : String
    x : Double
    y : Double
    width : Double
    height : Double
    margin :
    Rect
    [Double]
    padding :
    Rect
    [Double]
    border :
    Rect
    [Double]
    overflow_x :
    Overflow

    overflow_y :
    Overflow

    children : Array[Layout]
    text : String?
    }

    Complete layout result for a node

    Layout::to_bounding_rect

    LayoutContext

    pub(all) struct LayoutContext {
    available_width : Double
    available_height : Double?
    sizing_mode : SizingMode
    viewport_width : Double
    viewport_height : Double
    }

    Context for layout computation

    LayoutDispatchFunc

    pub(all) type LayoutDispatchFunc (Node, LayoutContext) -> Layout

    Layout dispatch function type Used to delegate layout computation to the appropriate algorithm based on display type

    LayoutDispatchFunc::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn LayoutDispatchFunc::inner(self : LayoutDispatchFunc) -> ((Node, LayoutContext) -> Layout)
    Convert newtype to its underlying type, automatically derived.

    LayoutResult

    pub(all) struct LayoutResult {
    layout : Layout
    warnings : Array[LayoutWarning]
    }

    Result of layout computation with warnings

    LayoutWarning

    pub(all) enum LayoutWarning {
    UnsupportedFloat(String)
    UnsupportedPosition(String)
    UnsupportedDisplay(String)
    }

    Warnings emitted during layout computation

    MeasureFunc

    pub(all) struct MeasureFunc {
    func : (Double, Double) -> IntrinsicSize
    }

    Measure function type - called to determine intrinsic size of a node Parameters: (available_width, available_height) -> IntrinsicSize

    Node

    pub struct Node {
    id : String
    uid : Int
    style :
    Style

    children : Array[Node]
    measure : MeasureFunc?
    text : String?
    }

    A node in the layout tree

    Node::leaf

    fn Node::leaf(id : String, style :
    Style
    ) -> Node

    Node::new

    fn Node::new(id : String, style :
    Style
    , children : Array[Node]) -> Node

    Node::text

    fn Node::text(id : String, style :
    Style
    , measure : MeasureFunc, content : String) -> Node

    Create a text node with content

    Node::with_measure

    fn Node::with_measure(id : String, style :
    Style
    , measure : MeasureFunc, text? : String) -> Node

    Create a leaf node with a custom measure function Optional text parameter for alt text (images) or other content

    Node::with_uid

    fn Node::with_uid(id : String, uid : Int, style :
    Style
    , children : Array[Node]) -> Node

    Create a node with a specific uid (for incremental layout)

    Node::with_uid_and_measure

    fn Node::with_uid_and_measure(id : String, uid : Int, style :
    Style
    , children : Array[Node], measure : MeasureFunc?, text : String?) -> Node

    Create a node with a specific uid and measure function

    SizingMode

    pub(all) enum SizingMode {
    Definite
    MaxContent
    }

    Sizing mode for layout computation Definite: Use available space (normal flow) MaxContent: Use intrinsic max-content (shrink-to-fit)
    impl Eq for SizingMode

    dispatch_layout

    fn dispatch_layout(node : Node, ctx : LayoutContext) -> Layout

    Compute layout for a node using the global dispatcher Falls back to returning a minimal layout if no dispatcher is set

    get_layout_dispatcher

    fn get_layout_dispatcher() -> LayoutDispatchFunc?

    Get the global layout dispatcher (for checking if it's set)

    set_layout_dispatcher

    fn set_layout_dispatcher(f : LayoutDispatchFunc) -> Unit

    Set the global layout dispatcher

    Source Files