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)* }) => { ... };
    (grid($($config:tt)*) { $($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, $($mods:tt)+) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, grow: $val:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr, $($mods:tt)+) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr, fixed: $val:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident panel($kind:expr) $($rest:tt)*) => { ... };
    (@children $ctx:ident grid($($config:tt)*) { $($inner:tt)* } $($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)*) => { ... };
    (@apply $c:expr, min: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, min: $v:expr) => { ... };
    (@apply $c:expr, max: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, max: $v:expr) => { ... };
    (@apply $c:expr, min_width: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, min_width: $v:expr) => { ... };
    (@apply $c:expr, max_width: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, max_width: $v:expr) => { ... };
    (@apply $c:expr, min_height: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, min_height: $v:expr) => { ... };
    (@apply $c:expr, max_height: $v:expr, $($rest:tt)+) => { ... };
    (@apply $c:expr, max_height: $v:expr) => { ... };
    (@apply $c:expr, align: $v:ident, $($rest:tt)+) => { ... };
    (@apply $c:expr, align: $v:ident) => { ... };
    (@apply $c:expr, size_mode: $v:ident, $($rest:tt)+) => { ... };
    (@apply $c:expr, size_mode: $v:ident) => { ... };
    (@apply $c:expr, size_mode: fit_content($v:expr), $($rest:tt)+) => { ... };
    (@apply $c:expr, size_mode: fit_content($v:expr)) => { ... };
    (@grid_config columns: $n:expr $(, $($rest:tt)*)?) => { ... };
    (@grid_config auto_fit: $w:expr $(, $($rest:tt)*)?) => { ... };
    (@grid_config auto_fill: $w:expr $(, $($rest:tt)*)?) => { ... };
    (@grid_apply $g:expr) => { ... };
    (@grid_apply $g:expr, gap: $v:expr $(, $($rest:tt)*)?) => { ... };
    (@grid_apply $g:expr, auto_rows: true $(, $($rest:tt)*)?) => { ... };
    (@grid_children $gctx:ident) => { ... };
    (@grid_children $gctx:ident panel($kind:expr, span: $n:expr) $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident panel($kind:expr, full_width: true) $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident panel($kind:expr, grow: $val:expr) $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident panel($kind:expr, fixed: $val:expr) $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident panel($kind:expr) $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident row(gap: $gap:expr) { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident row { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident col(gap: $gap:expr) { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident col { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@grid_children $gctx:ident grid($($config:tt)*) { $($inner:tt)* } $($rest:tt)*) => { ... };
    (@align start) => { ... };
    (@align center) => { ... };
    (@align end) => { ... };
    (@align stretch) => { ... };
    (@size_mode min_content) => { ... };
    (@size_mode max_content) => { ... };
}
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 modifiers after the primary constraint: min:, max:, min_width:, max_width:, min_height:, max_height:, align:.
  • Align values: start, center, end, stretch.