Files
moon-gpui/README.md
T
SpriteandClaude Opus 5.5 cca9a49c51 M2 layout: LayoutEngine on Milky2018/chicle, conformance suite
- layout: port of GPUI's TaffyLayoutEngine (request_layout,
  request_measured_layout, compute_layout, layout_bounds,
  stretch_auto_size_to_fill) and LayoutStyle::to_taffy, with rem resolution
  and device-pixel snapping (round_half_toward_zero, stroke snapping, ceiled
  measured sizes). No cross-frame node cache yet (needs element ids, M6).
- Depend on Milky2018/chicle 0.6.3, the maintained successor of
  moon_taffy (which no longer compiles), instead of vendoring.
- conformance/chicle: standalone module running moon_taffy's 1,038 taffy
  fixtures against chicle; all pass on wasm, wasm-gc, js and native.
- card example now lays out its content with the engine.
- Docs: PORTING.md M2 status, revised decision 3, M2 deviations; README;
  NOTICE attribution for the conformance fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:09:49 +00:00

2.5 KiB

moon-gpui

A port of GPUI, the GPU-accelerated UI framework of the Zed editor, to MoonBit.

Status: early. The pure-logic foundation is in place; nothing renders yet. See docs/PORTING.md for the architecture mapping and the roadmap.

Package GPUI source Status
experiments/gpui/geometry geometry.rs, ContentMask Ported (units, Point/Size/Bounds/Edges/Corners, lengths)
experiments/gpui/color color.rs Ported (Rgba/Hsla, hex parsing, Background)
experiments/gpui/scene scene.rs, bounds_tree.rs Ported (primitives, draw ordering, layers, batching, replay)
experiments/gpui/font font descriptors in text_system.rs Ported (Font, weights, styles, features, fallbacks)
experiments/gpui/style style.rs, styled.rs, Refineable, gpui_macros style helpers Ported (Style/StyleRefinement, the full Styled fluent API)
experiments/gpui/layout taffy.rs Ported on Milky2018/chicle (flexbox, grid, block)

Example

Nothing renders yet. src/examples/card resolves a style written with GPUI's fluent API, lays the card and its (fake-measured) text out with the layout engine, paints it into a Scene, and prints the layout and the draw batches:

moon run src/examples/card --target js
@style.StyleRefinement::new()
  .flex().flex_col().gap_2().p_4()
  .w(@geometry.px(320.0))
  .rounded_lg().border_1().border_color(@color.rgb(0xd0d7de))
  .bg(@color.rgb(0xffffff)).shadow_md()
  .text_color(@color.rgb(0x1f2328)).text_sm()

The first example that renders in the browser comes with milestone M8; see the roadmap.

Generated code

src/style/style_generated.mbt, styled_generated.mbt and styled_extend_generated.mbt are generated by tools/gen_style.py, which stands in for GPUI's Rust macros. Do not edit them by hand; change the script or src/style/styled.mbt, then run:

python3 tools/gen_style.py && moon fmt

Layout conformance

conformance/chicle is a standalone module with 1,038 taffy layout fixtures for the layout engine dependency. Run it before changing the chicle version: cd conformance/chicle && moon test --target all.

Testing

All packages are pure MoonBit and are tested on every backend:

moon check --target all
moon test --target all
moon fmt

License

Apache-2.0, like GPUI itself. See LICENSE and NOTICE.