M0: WIT package, MoonBit components, JS host, docs, CI (#1)
CI / test (push) Successful in 19s
CI / test (push) Successful in 19s
This commit was merged in pull request #1.
This commit is contained in:
1 parent
e5548fc067
commit
880ecd4102
141 files changed
+9681
-1
No files matched your search
@@ -0,0 +1,57 @@
|
||||
///| `moonplasma:desktop/panel-layout` for the reference shell. Geometry is in
|
||||
/// lib/panel (pure, unit-tested); this adapts the WIT records.
|
||||
|
||||
///|
|
||||
pub fn compute_layout(screen : @types.Size, slots : Array[Slot]) -> Layout {
|
||||
let t = @theme.get_tokens()
|
||||
let margin = 5
|
||||
let ins = slots.map(s => @panel.SlotIn::{
|
||||
id: s.id,
|
||||
pref_w: s.preferred.w.reinterpret_as_int(),
|
||||
pref_h: s.preferred.h.reinterpret_as_int(),
|
||||
min_w: s.min_width.reinterpret_as_int(),
|
||||
stretch: s.stretch,
|
||||
end_align: match s.align {
|
||||
START => false
|
||||
END => true
|
||||
},
|
||||
})
|
||||
match @panel.layout(
|
||||
screen.w.reinterpret_as_int(),
|
||||
screen.h.reinterpret_as_int(),
|
||||
t.panel_height.reinterpret_as_int(),
|
||||
margin,
|
||||
t.spacing.reinterpret_as_int(),
|
||||
ins,
|
||||
) {
|
||||
// Fail loudly: a trap surfaces in the host as a component error.
|
||||
Err(e) => abort("panel layout failed: " + e)
|
||||
Ok(l) => {
|
||||
panel: @ui.rect(l.x, l.y, l.w, l.h),
|
||||
placements: l.placements.map(p => { id: p.id, rect: @ui.rect(p.x, p.y, p.w, p.h) }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn render_panel(_screen : @types.Size, panel : @types.Rect) -> Array[@types.DrawOp] {
|
||||
@shell.render_panel(panel, @theme.get_tokens())
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn popup_position(
|
||||
screen : @types.Size,
|
||||
panel : @types.Rect,
|
||||
anchor : @types.Rect,
|
||||
popup : @types.Size,
|
||||
) -> @types.Rect {
|
||||
let (x, y) = @panel.popup_position(
|
||||
screen.w.reinterpret_as_int(),
|
||||
panel.y,
|
||||
anchor.x,
|
||||
popup.w.reinterpret_as_int(),
|
||||
popup.h.reinterpret_as_int(),
|
||||
8,
|
||||
)
|
||||
@ui.rect(x, y, popup.w.reinterpret_as_int(), popup.h.reinterpret_as_int())
|
||||
}
|
||||
Reference in new issue
Block a user