Sign in

    native-gui

    MoonBit 跨平台桌面 GUI 框架:一套代码直出 Windows / Linux / macOS 原生窗口,托盘/通知/快捷键/输入法/自启等系统能力开箱即用,moon add 后零配置

    gui
    desktop
    native
    cross-platform
    moonbit
    Download zip
    Author
    Version
    0.2.0
    License
    MIT
    Last updated
    7 hours ago
    Downloads
    29

    #native-gui

    A cross-platform desktop GUI framework for MoonBit — one codebase ships native windows on Windows / Linux / macOS, desktop capabilities ready to use, zero config after moon add. Windows, pixels, the event loop, layout and every widget belong to the library itself and are written in pure MoonBit; no libyue dependency. Platform specifics converge in five thin C layers: windows, text, image decoding, WebView, media.

    Formerly moonbit-libyue (renamed 2026-10). The mooncakes package is NoahLiu/native-gui and all existing import paths are unchanged.

    Demo board

    #Highlights

    • Self-drawn widgets, one look everywhere — the library's own rasterizer draws every control, so rendering is identical across platforms; light/dark mode and the system accent colour are followed by default, and the theme is fully customizable.
    • Declarative UI with reactive state — describe the interface as a tree of @widget.Node values and mount it with one mount_window call; keep state in Store / Signal and bound spots refresh themselves.
    • Desktop-grade system integration — tray, notifications, native menus, global shortcuts, message boxes, file dialogs, drag & drop (in-app and cross-application), clipboard, autostart, idle detection and OS queries (volume, power, monitors, browser history, installed apps…) behind one @sys / @shell facade.
    • Content batteries included — 20 chart types with a cross-cutting interactive layer, a GFM Markdown view and multi-language code highlighting in the box; the embedded WebView (JS interop, custom protocols, DOM capture, policy hooks) and the audio/video engine (subtitles, speed control) live in the optional modules gui-webview / gui-media.
    • Honest degradation — every capability family exposes a probe and returns a structured Unsupported / NotFound on environments that lack it, instead of crashing or pretending success.
    • Pay only for what you import — 15 packages in this module; an unimported package never enters your binary. Heavier optional capabilities (the WebView and the media engine) live in their own modules, outside the default dependency closure entirely.

    #Usage

    moon add NoahLiu/native-gui

    Import the packages you need in moon.pkg (e.g. NoahLiu/native-gui/ui as @ui) and mount a window:

    fn main {
    let app = match @ui.mount_window(
    [@ui.text("Hello, MoonBit!", font_size=18.0)],
    title="Hello, MoonBit!",
    width=400,
    height=300,
    ) {
    None => return // no window backend or no display service on this host
    Some(a) => a
    }
    app.run()
    }

    Runnable examples in this repository, from shallow to deep:

    moon run examples/hello # a minimal window moon run examples/hello-themed # the themed widget set moon run examples/showcase # full demo board: components + system probes + extended charts, 15 pages moon run examples/browser # embedded WebView browser (demo menu + status bar)

    Each showcase page is its own source file under examples/showcase/pages/ — the best copy-paste material library.

    #Packages

    ImportAliasContents
    NoahLiu/native-gui/base@basePlatform-free primitives: Store / Signal / ListStore, focus stack, key codes, tick/prof
    NoahLiu/native-gui/shell@shellSystem-capability shell: menus, global hotkeys, tray, notifications, reveal, the loop scheduler and read-only platform probes
    NoahLiu/native-gui/widget@widgetSelf-drawn widget host: layout mapping, hit-testing, event routing, paint walk, declarative Node, overlays, drag & drop, input mapping, the App pump
    .../native-gui/ui@uiSelf-drawn widgets and the component library: forms, display, navigation, date, tables & virtual lists, entries, scroll, overlays, code view, declarative layer
    .../native-gui/render@renderRasterizer — a pure-MoonBit software raster (path / fill / blend / gradient) plus a Cairo backend; bitmaps, canvas, images, PNG
    .../native-gui/text@textText layer: font families, fonts, attributed text and range attributes (Pango / DirectWrite)
    .../native-gui/theme@themeTheme system: palette derivation + change subscription
    .../native-gui/icons@iconsVector icon system (800+ icons)
    .../native-gui/sys@sysOS capabilities facade
    .../native-gui/input@inputEditing core and key codes
    .../native-gui/win@winPlatform window backend (Win32 / GTK3 C stubs)
    .../native-gui/dbus@dbusLinux D-Bus bridge (tray SNI, notifications, logind / upower, media, network…)
    .../native-gui/chart@chartCharts plus the interactive layer
    .../native-gui/mdview@mdviewMarkdown rendering view
    .../native-gui/style@styleStyle layer: stylesheets as MoonBit values — Style rule blocks, hover / active / focus states, transitions

    Optional capabilities in separate modules (a plain moon add of this module never drags them in):

    ModuleContents
    NoahLiu/gui-mediaAudio/video engine (ffmpeg decode + miniaudio output) and the player component
    NoahLiu/gui-webviewEmbedded WebView (WebKitGTK / WebView2), extracted from this module's web subpackage on 2026-10-16

    #Platform support

    WindowsLinuxmacOS
    Status✅ 10 / 11✅ X11 mainline🟨 backend merged, on-device verification closing
    NotesGUI-subsystem exe: double-click opens no console windowCommitted span deepin 20 ~ Ubuntu 26, staying on GTK3; Wayland sessions run, X11-dependent capabilities degrade per sessionCocoa / CoreText / ImageIO / WKWebView merged into master; on-device visual verification still closing, not yet part of the outward promise

    #Roadmap

    Where this library is heading, in order of current effort (see the public roadmap for the full picture):

    1. Lower the barrier to entry — a shortest path from "install moon" to "a window on screen" on the docs homepage, per-platform prerequisites in one sentence, build errors that carry their own fix hints.
    2. Credibility — CI gates on Linux and Windows for every batch, on-device verification checklists, and a version promise: the stable-surface list (what will not break within 1.x) and the 1.0 cut-off are being defined.
    3. Content — usage documentation rewritten for the self-drawn stack (tutorials, a per-component guide with screenshots), continuously expanded examples.
    4. Platform coverage — closing on-device verification for macOS; verifying the Linux compatibility span floor by floor (deepin 20 as the floor, Ubuntu 26 as the ceiling).

    Explicit non-goals: accessibility APIs, GTK4 / Qt backends, and platform-native widget skins — the self-drawn stack is the product.

    Versioning: at 0.x the interfaces still evolve per batch; breaking changes are recorded in commit messages and the docs ship in the same batch.

    #Documentation

    MIT License.