A UI layout engine for MoonBit
Dependencies
space: [640, 360]
layout:
Dashboard:
size: [320, 180]
padding: 16
gap: { column: 12 }
children:
- Sidebar:
width: 100
- Content:
grow: 1///|
test {
let chicle : @Milky2018/chicle/tree.ChicleTree[Unit] = @Milky2018/chicle/tree.ChicleTree()
let child = chicle.new_leaf(@Milky2018/chicle/style.Style::default())
let root = chicle.new_with_children(
@Milky2018/chicle/style.Style::default().with_size(
@Milky2018/chicle/geometry.Size(
width=@Milky2018/chicle/style_helpers.length(100.0),
height=@Milky2018/chicle/style_helpers.length(100.0),
),
),
[child],
)
chicle.compute_layout(root, @Milky2018/chicle/geometry.Size::max_content())
let layout = chicle.layout(root)
assert_eq(layout.size.width, 100.0)
assert_eq(layout.size.height, 100.0)
}pub(all) struct LayoutDocument {
version : Int
available_space : Size[AvailableSpace]
root : LayoutNode
}impl ToJson for LayoutDocumentimpl FromJson for LayoutDocumentpub(all) struct LayoutResultNode {
id : String
label : String
parent_id : String?
depth : Int
layout : Layout
}impl ToJson for LayoutResultNodeA UI layout engine for MoonBit
Dependencies