Skip to main content

layout

Macro layout 

Source
macro_rules! layout {
    (row(gap: $gap:expr) { $($children:tt)* }) => { ... };
    (row { $($children:tt)* }) => { ... };
    (col(gap: $gap:expr) { $($children:tt)* }) => { ... };
    (col { $($children:tt)* }) => { ... };
    (@root $dir:ident $($children:tt)*) => { ... };
    (@root_gap $dir:ident [$gap:expr] $($children:tt)*) => { ... };
    (@children $ctx:ident) => { ... };
    (@children $ctx:ident panel($kind:expr, grow: $val:expr, min: $min:expr, max: $max:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, grow: $val:expr, min: $min:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, grow: $val:expr, max: $max:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, grow: $val:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr, min: $min:expr, max: $max:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr, min: $min:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr, max: $max:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident row(gap: $gap:expr) { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@children $ctx:ident row { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@children $ctx:ident col(gap: $gap:expr) { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@children $ctx:ident col { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@nested $ctx:ident $dir:ident { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@nested_gap $ctx:ident $dir:ident [$gap:expr] { $($inner:tt)* } $($rest:tt)*) => { ... };
}
Expand description

Declarative macro for building layouts from a concise DSL.

Returns Result<Layout, PaneError>.

ยงSyntax

layout! {
    row(gap: 8.0) {
        panel("editor", grow: 2.0)
        col {
            panel("chat")
            panel("status", fixed: 3.0)
        }
    }
}
  • Root must be a single row or col.
  • Containers accept an optional (gap: N) parameter.
  • Bare panel("kind") defaults to grow(1.0).
  • panel("kind", grow: N) and panel("kind", fixed: N) set constraints.
  • Panels accept optional min: and max: after the primary constraint.