High-performance, pure MoonBit Immediate-Mode GUI library for WebAssembly, Canvas, and Games.
# Install the latest stable release
moon add LING71671/moon-egui
# Or pin to an exact version
moon add LING71671/moon-egui@0.5.5{
"import": [
"LING71671/moon-egui/src/core",
"LING71671/moon-egui/src/widgets",
"LING71671/moon-egui/src/composite",
"LING71671/moon-egui/src/draw",
"LING71671/moon-egui/src/math",
"LING71671/moon-egui/src/color"
]
}fn update_ui(ctx : @core.UIContext, state : AppState) {
// 1. Global top-level application menu bar (src/composite)
@composite.menu_bar(ctx, fn(top) {
@composite.menu(top, "File", fn(menu) {
if @composite.menu_item(menu, "New Project").clicked { state.new_project() }
if @composite.menu_item(menu, "Save Config").clicked { state.save() }
})
@composite.menu(top, "View", fn(menu) {
if @composite.menu_item(menu, "Toggle Theme").clicked { state.toggle_theme() }
})
})
// 2. Floating draggable inspector window (src/widgets)
@widgets.window(ctx, "Console & Properties", @math.Vec2::new(50.0, 50.0), @math.Vec2::new(300.0, 420.0), fn(win) {
let _ = win.label("Welcome to moon-egui")
if @widgets.button(win, "Trigger Action").clicked {
state.counter 1
}
// Blender-style DragValue adjustment
let (gravity, _) = @widgets.drag_value(win, "Gravity", state.gravity, speed=0.1, min=0.0, max=20.0)
state.gravity = gravity
let (collision, _) = @widgets.checkbox(win, "Enable Collision", state.collision_enabled)
state.collision_enabled = collision
// Collapsible telemetry panel
@widgets.collapsing_header(win, "render_monitor", "Runtime Monitor", false, fn(panel) {
let (_, _) = @composite.sparkline(panel, "fps", state.fps_history)
@widgets.progress_bar(panel, state.progress)
})
}))
})
}[ Input Events ]
• Pointer coordinates & button state
• Keyboard keys & modifiers
• Mouse wheel scroll delta
│
▼
[ moon-egui Core ]
• Input state machine (Hover, Active, Focused)
• Linear cursor layout & AABB hit-testing
• Scissor clip rectangle stack
• Immediate-mode widget evaluation
│
▼
[ DrawCmd Stream ]
• DrawCmd::Rect(x, y, w, h, color, radius)
• DrawCmd::Text(x, y, text, size, color)
• DrawCmd::Line(x1, y1, x2, y2, color, width)
• DrawCmd::Clip(x, y, w, h)
│
▼
[ Render Backends ]
• HTML5 Canvas 2D (Default Wasm bridge)
• WebGL / WebGPU (Planned)
• Native Windowing (Raylib / SDL / Minifb)For full milestone metrics and acceptance criteria, see ROADMAP.md (English).
| Document | Description | Key Focus |
|---|---|---|
| Roadmap & Milestones (中文) | Timeline & Deliverables | Hackathon milestones, acceptance criteria, long-term evolution |
| Architecture Whitepaper (中文) | Engine Internals | Widget ID hashing, frame lifecycle, cursor layout, clip stack |
| API Reference Manual (中文) | Developer API Docs | UIContext method signatures, layout protocols, Painter API |
| Design System & Tokens (中文) | Visual Tokens | Color schemes, typography scales, spacing rules, state styles |
| Style Guide (中文) | Coding Standards | Block syntax (///\|), naming, visibility, .mbti contracts |
| Contributing Guide (中文) | Engineering Protocols | Development workflow, test guidelines, Conventional Commits |
| Changelog (中文) | Release History | Notable changes and release tracking |
Install
Download zipHigh-performance, pure MoonBit Immediate-Mode GUI library for WebAssembly, Canvas, and Games.