moonegui — an immediate-mode GUI toolkit for MoonBit (after egui): context, layout, widgets, and a backend-agnostic list of shapes to paint.
if @widget.button(ui, "Press me").clicked {
clicks = clicks + 1
}
clicks_shown = @widget.slider(ui, clicks_shown, low=0, high=10).0
name = @widget.edit(ui, name, hint="your name").0| Package | What it does |
|---|---|
| emath | Vec2, Rect, Align, Margin, and the interpolation everything else is built from |
| id | Ids derived from a parent and a piece of salt, which is what connects a widget to the same widget last frame |
| input | The events a host hands over, folded once a frame into the state widgets ask questions of |
| mem | What survives a frame: focus, the widget being dragged, and a value per widget, tidied at the end of every frame |
| paint | Colours, strokes, fonts, and the five shapes a frame is made of |
| layout | Placers: where the next widget goes, in four directions, aligned or stretched across the flow |
| hit | What the pointer is over, and the Response a widget answers with |
| text | Breaking, aligning, eliding, and turning a click into a caret position |
| ctx | The frame itself, and Ui — the value you spend the frame with |
| widget | Label, heading, separator, button, checkbox, radio, slider and text field |
| back | The backend contract: three ways to measure, nine to draw, and a recorder that writes them down |
| back/web | What both browser backends share: the surface, the text metrics, and the input coming the other way |
| back/canvas | A frame painted on a 2D canvas |
| back/html | The same frame as elements in the document, for pages that want selectable text and the rest of what H5 already has |
{ "deps": { "moonbitstack/moonegui": "0.1.0" } }let canvas : @canvas.Canvas = @canvas.Canvas::new()
let context = @ctx.Ctx::new(canvas)
canvas.listen()
// then, once a frame:
let out = context.run(canvas.raw(now, dt), fn(ui) {
@widget.heading(ui, "moonegui") |> ignore
if @widget.button(ui, "Press me").clicked {
clicks = clicks + 1
}
})
canvas.clear(context.style().background)
@back.play(out.shapes, canvas)moon build --target js
python -m http.server 8741
# then open http://127.0.0.1:8741/examples/browser/index.html
# and the same page as elements: .../index.html?htmlmoon check --target all --deny-warn
moon test --target allInstall
Download zipmoonegui — an immediate-mode GUI toolkit for MoonBit (after egui): context, layout, widgets, and a backend-agnostic list of shapes to paint.