axon-ui
axon-ui
Section titled βaxon-uiβImmediate-mode GUI framework for Axon.
axon-ui is a declarative, immediate-mode GUI framework written in pure Axon. It provides OS window creation, GPU-accelerated rendering, a flexbox layout engine, input handling, and a standard widget library β all targeting the M11/M12/M19 milestones.
| Phase | Status | Notes |
|---|---|---|
| Scaffolding (M11.0) | β This PR | Directory structure, module stubs, docs |
| UI Framework (M11) | π Planned | Window, GPU backend, flexbox, input |
| Widgets (M12) | π Planned | Button, Label, TextInput, containers |
| Theming | π§ WIP | Python reference impl in axon_ui/theme.py |
| WASM (M19) | π Planned | Browser deployment |
Directory Structure
Section titled βDirectory Structureβaxon-ui/βββ src/ # Axon source files (the framework itself)β βββ context.axs # UI state management (M11)β βββ layout.axs # Flexbox layout engine (M11)β βββ input.axs # Event handling & hit-testing (M11)β βββ widgets.axs # Standard widget library (M12)ββββ tests/ # Testsβ βββ test_layout.axs # Layout engine tests (Axon)β βββ test_input.axs # Event handling tests (Axon)β βββ test_golden_runner.py # Golden file test harness (Python)β βββ test_theme.py # Theme API tests (Python reference)β βββ test_theme_api.py # Theme inheritance testsβ βββ test_theme_properties.py # Property-based theme testsβ βββ test_widgets.py # Widget tests (Python reference)β βββ test_widget_contracts.py # Widget contract testsβ βββ test_widgets_properties.py # Property-based widget testsβ βββ test_layout_properties.py # Property-based layout testsβ βββ test_metrics.py # Metrics collection testsβ βββ golden/ # Golden files for snapshot testsβ βββ conftest.py # Pytest fixturesββββ axon_ui/ # Python reference implementationβ βββ __init__.pyβ βββ theme.py # Theme + ThemeResolver (M12 theming)β βββ widgets.py # Widget base + standard widgetsββββ docs/β βββ architecture.md # Framework architecture overviewβ βββ theming.md # Theme API referenceβ βββ widgets.md # Widget referenceβ βββ api/ # Planned API docs (Axon formatter strips comments)β β βββ README.mdβ β βββ context.mdβ β βββ layout.mdβ β βββ input.mdβ β βββ widgets.mdβ βββ TESTING.md # Test workflowβ βββ CONTRIBUTING.md # Contributor guideβ βββ ci-pipeline.md # CI pipeline referenceβ βββ metrics.md # Metrics collectionββββ metrics/ # Collected metrics outputβββ tools/ # Build/CI helper scriptsβββ requirements-dev.txt # Python dev dependenciesβββ .gitlab-ci.yml # CI configurationβββ README.md # This fileModule Overview
Section titled βModule Overviewβsrc/context.axs β UI State Management (M11)
Section titled βsrc/context.axs β UI State Management (M11)βApplication-level state management: stores, signals, and reactive updates.
Planned API:
(store initial-state)β create a new state store(get store)β read current state(set store value)β replace state(update store fn)β transform state via fn(signal initial-value)β create a reactive signal(bind signal view-fn)β bind a view to a signal
src/layout.axs β Flexbox Layout Engine (M11)
Section titled βsrc/layout.axs β Flexbox Layout Engine (M11)βCSS flexbox subset for laying out widget trees. Takes widgets with layout properties and produces absolute positions/sizes.
Planned API:
(layout root-widget max-width max-height)β compute layout(flex-direction "row" | "column")(justify-content "start" | "center" | "end" | "space-between")(align-items "start" | "center" | "end" | "stretch")(gap px)
src/input.axs β Event Handling (M11)
Section titled βsrc/input.axs β Event Handling (M11)βEvent dispatch for user input: mouse clicks, keyboard, focus, form submit. Events bubble up the widget tree with preventDefault/stopPropagation.
Planned API:
(event-loop)β start the event loop(dispatch event widget-tree)β dispatch a single event(on-click widget handler)β register click handler(on-change widget handler)β register change handler(on-submit widget handler)β register submit handler(on-key widget handler)β register key handler
Event types: click, dblclick, change, submit, keydown, keyup,
focus, blur.
src/widgets.axs β Standard Widget Library (M12)
Section titled βsrc/widgets.axs β Standard Widget Library (M12)βStandard UI widgets, all inheriting from a common base and supporting theming.
Planned widgets:
(button "text" (on-click handler))β clickable button(label "text")β static text display(text-input placeholder value handler)β single-line text field(checkbox checked handler)β boolean toggle(select options selected handler)β dropdown selector(vstack children)β vertical stack container(hstack children)β horizontal stack container(container child)β generic container with padding
Python Reference Implementation
Section titled βPython Reference ImplementationβThe axon_ui/ directory contains a Python reference implementation of the
theming and widget subsystems. This serves as:
- A specification for the Axon implementation (what the API should look like)
- A testable target β the Python tests verify the API contract
- A fallback β apps that need UI now can use the Python version while the Axon version is under construction
The Python and Axon implementations should stay in sync API-wise.
Internationalization (axon_ui/i18n/)
Section titled βInternationalization (axon_ui/i18n/)βA standards-based i18n/l10n layer β ICU MessageFormat catalogs, CLDR plural
rules, locale-aware number/currency/percent formatting, RTL layout mirroring,
and a reactive LocaleProvider for runtime locale switching. Pure-Python with
zero required dependencies (optional Babel backend for full CLDR). See
docs/i18n.md and the runnable Arabic/Hebrew demo
examples/i18n_demo.py.
Animation engine (axon_ui/animation.py)
Section titled βAnimation engine (axon_ui/animation.py)βA declarative animation layer (Issue #24) β the full Robert-Penner easing set
plus a CSS-style cubic_bezier solver, a shape-agnostic Tween (scalars,
vectors/colours, dicts), damped-harmonic Spring physics with mid-flight
interruption, Sequence/Parallel timelines, and a fixed-timestep Driver
for reproducible sampling. Pure-Python, deterministic, no GPU/windowing
dependency. GPU-accelerated compositing of the animated properties is a
follow-up (needs the renderer backend #9). See docs/animation.md.
Drag-and-drop (axon_ui/drag_drop.py)
Section titled βDrag-and-drop (axon_ui/drag_drop.py)βA semantic drag-and-drop model (Issue #16) β DragData payloads (text, files,
text/uri-list, arbitrary MIME), DropTarget regions with half-open hit-testing
and payload-type acceptance, and a DragDropManager that turns pointer motion
into edge-triggered on_drag_enter/over/leave/on_drop callbacks with
topmost-wins z-order and sourceβtarget effect negotiation. Pure-Python,
deterministic. The native OS drag FFI is a follow-up (needs the window/event
loop #8); this ships the model + the DND_PLATFORM_MAP protocol spec the binding
layer targets. See docs/drag-drop.md.
Native system dialogs (axon_ui/dialogs.py)
Section titled βNative system dialogs (axon_ui/dialogs.py)βA semantic model for OS file/message dialogs (Issue #15) β FileDialog
(open / open-files / save / pick-directory) with FileDialogFilter glob
matching and save-mode extension enforcement, MessageDialog (info /
warning / error / question) with stock DialogButton sets and default /
cancel button routing, a DialogResponse carrying paths-or-button plus the
accepted/cancelled/path conveniences, and a DialogManager that owns
the in-flight dialog and validates native-layer responses before accepting.
Pure-Python, deterministic, zero third-party deps. The native OS FFI
(NSOpenPanel/NSSavePanel, IFileDialog, GtkFileChooserDialog /
xdg-desktop-portal) is a follow-up (needs the window/event loop #8); this
ships the model + the DIALOG_PLATFORM_MAP backend spec the binding layer
targets. See docs/dialogs.md.
CI Infrastructure
Section titled βCI Infrastructureβ| Job | Template | Status | Purpose |
|---|---|---|---|
pipeline:status | β | β Active | Verifies CI connectivity, counts .axs files |
test:axon-e2e | axon-library.yml | β Active | Runs golden file tests on .axs files |
test:axon-check | axon-library.yml | β Active | Axon type checking on .axs files |
test:axon-format | axon-library.yml | β Active | Code formatting check on .axs files |
test:python | β | β Active | Runs the Python test suite (theme, widgets, etc.) |
metrics:library | metrics-collector.yml | β Active | Collects lines-of-code and module count metrics |
performance:regression-check | perf-thresholds.yml | β οΈ allow_failure | Binary size and compile time gates |
The test:axon-* jobs are now active because .axs source files exist
(in stub form). They will run the golden file tests and type/format checks
as the stubs grow into real implementations.
Milestone Roadmap
Section titled βMilestone Roadmapβ| Milestone | Focus | Key Tickets |
|---|---|---|
| M11 | UI Framework core | context/state, flexbox, input/hit-test, window, GPU backend |
| M12 | Widgets & tooling | widget set, font/text, theming, bundler |
| M19 | WASM canvas backend | WASM backend for browser deployment |
See the GitLab issues for detailed acceptance criteria on each ticket.
Running Tests
Section titled βRunning Testsβ# Python tests (theme, widgets, properties)pip install -r requirements-dev.txtpython -m pytest tests/ -v
# Axon tests (when .axs files have real implementations)# CI runs these automatically via test:axon-e2e, test:axon-check, test:axon-formatSee docs/TESTING.md for the full test workflow.
Contributing
Section titled βContributingβSee docs/CONTRIBUTING.md for contributor onboarding, and docs/architecture.md for the planned architecture.
Part of the Axon Ecosystem
Section titled βPart of the Axon Ecosystemβ| Package | Description | Status |
|---|---|---|
| axon-lang | Compiler & runtime | β Active |
| axon-std | Standard library | β Active |
| axon-pkg | Package manager | π§ WIP |
| axon-ui | GUI framework | π Scaffolding |
| axon-web | HTTP framework (M14) | π Scaffolding |
License
Section titled βLicenseβSee project license file.