# Changelog

[English](CHANGELOG.md) | [中文](CHANGELOG_zh.md)

All notable changes to `moon-egui` will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [0.3.0] - 2026-09-13

### Breaking Changes
- **All widget calls migrate to the layered namespaces**: the `ctx.button(...)` style `UIContext` methods are gone; use `@widgets.button(ctx, ...)` / `@composite.knob(ctx, ...)` instead, and import widgets from `src/widgets` / `src/composite` rather than `src/core`. The `src/lib.mbt` facade keeps every type re-exported. See `docs/API_DESIGN.md` and `ARCH-06`.

### Fixed
- **Cursor contract**: every interactive surface reports a semantic cursor (buttons/labels/tabs = `pointer`, sliders = `ew-resize` / `ns-resize`, splitters = `col-resize` / `row-resize`, window title bars = `move`, text = `text`, HSV area = `crosshair`); fixes five missing spots (ColorPicker, window title bar, DockArea tabs, Toast close, Sparkline hover) and **benchmark.html, whose host never applied the cursor at all**, now synced every frame via `FrameOutput.cursor`.
- **Hit tests unified through `is_hovered`**: removed 21 raw `rect.contains(mouse_pos)` hit tests so widgets stop reacting while scrolled out of a `scroll_area` or covered by windows/foreground layers (the three intentional modal outside-click checks keep raw geometry).
- **Popups no longer swallow their own hover**: context menu / command palette / toast registered hover blockers over themselves, so from the second frame on `is_hovered` failed - menu rows could not be selected, the palette wheel died, a toast close cross became unclickable. Their interaction phases now run in the foreground scope, with frame-two regression tests.
- **Global scale coverage**: `Knob` and `ColorPicker` ignored `WidgetStyle.scale` (hard-coded literal geometry); both follow it now, locked by "scale 2 geometry is exactly twice scale 1" regression tests.
- **Build script entry anchoring**: the loose symbol match in `scripts/build_demo.*` bound `window.moon_step` to `Knob::step`, silently breaking the CAD page; the pattern now anchors the `examples/canvas` module and the bundle was rebuilt.
- **Docs and site examples migrated**: README (zh/en), `docs/API_DESIGN*`, `docs/ARCHITECTURE*`, `docs/README_en` and the four site pages (docs / wiki / index / gallery) - about 160 examples now teach the new namespace API.

### Added
- **Immediate-Mode Plotting Suite (`Plot` & `BarChart`)**:
  - `UIContext::plot` supporting multi-series composite rendering (`PlotSeriesKind::Line`, `PlotSeriesKind::Scatter`, `PlotSeriesKind::Area`) with automatic bounds calculation, adaptive grid subdivisions, numeric coordinate tick labels, hover crosshairs, and data value tooltips.
  - `UIContext::bar_chart` featuring dynamic column width calculation, proportional gutter spacing, category axis labels, hover highlight indicators, and value capsule indicators.
- **Keyboard Navigation & Scrubbing for `DragValue`**:
  - Added ArrowLeft/ArrowDown (decrement) and ArrowRight/ArrowUp (increment) keyboard navigation when focused.
  - Multiplier acceleration: Shift key for fine-stepping (0.1x) and Ctrl key for coarse-stepping (10x).
  - Explicit visual focus ring (`@color.Color::border_focus()`).
- **Geometry & Sizing Design Token Normalization**:
  - Formalized widget dimensions across `WidgetStyle` (`progress_bar_h`, `tooltip_pad_x`, `tooltip_pad_y`, `tooltip_radius`, `window_title_bar_h`, `combo_box_w`, `combo_box_h`, `collapsing_header_h`, `collapsing_header_indent`, `tab_bar_h`, `tab_bar_pad_x`, `drag_value_w`, `drag_value_h`, `color_picker_w`, `color_picker_btn_h`, `breadcrumb_h`, `breadcrumb_sep_gap`, `plot_default_w`, `plot_default_h`, `plot_pad_left`, `plot_pad_right`, `plot_pad_top`, `plot_pad_bottom`, `bar_chart_default_w`, `bar_chart_default_h`, `bar_chart_gap`).
  - Added semantic palette tokens `Color::grid_line()`, `Color::guideline_wash()`, and `Color::plot_crosshair()`.
- **Vertical Channel Fader Regulator (`Fader` & `FaderInt`)**:
  - Implemented `UIContext::fader` and `UIContext::fader_int` for audio and parameter mixing channels.
  - Features recessed track groove, calibrated tick marks, tactile fader cap with center indicator line, vertical drag delta, scroll wheel stepping, Shift (0.1x) / Ctrl (10x) modifiers, Arrow/Home/End keyboard navigation, and Alt+Click reset.
  - Added semantic design tokens `Color::fader_track_bg()`, `Color::fader_tick()`, `Color::fader_cap_line()`, and `WidgetStyle` fields `fader_w`, `fader_h`, `fader_track_w`, `fader_cap_w`, `fader_cap_h`, `fader_cap_radius`.
- **Graphical Primitive Typographical Metadata (`BUG-DRAW-03`)**:
  - Added `font_family : String` and `font_weight : Int` metadata to `DrawCmd::Text` and `DrawList::add_text`.
  - Enabled bold font weight (700) in `RichText` and explicit monospace typeface in `CodeEditor` line numbers and code text.
  - Updated HTML5 Canvas 2D runners (`gallery_runner.js` and `run.js`) with LRU font string assembly and caching.
- **Test Suite Expansion**: Added comprehensive whitebox tests for `Fader`, bringing total automated test coverage to 221 tests (100% pass rate).
- **Layered Package Restructure (`ARCH-06`)**:
  - Split the former 59-file `src/core` monolith into three physical packages: `src/core` (bare immediate-mode runtime), `src/widgets` (standard controls) and `src/composite` (advanced components), with a strictly unidirectional dependency flow `math -> color -> draw -> core -> widgets -> composite -> src`.
  - `src/core` now contains only the engine runtime (`context`, `id`, `input`, `memory`, `layout_engine`, `focus_manager`, `window_manager`, `layer_manager`, `painter`, `theme`, `response`, `unicode`, `widget`, `text_layout`).
  - Cross-package contract: widgets implement `@core.Widget` and dispatch through `ctx.add(...)`, callers use the `@widgets.*` / `@composite.*` namespace helpers, and read-only structs such as `WidgetStyle` are derived through fluent builders like `WidgetStyle::scaled(factor)` instead of struct update syntax.
  - `src/lib.mbt` acts as the umbrella facade re-exporting every public type and the `Widget` trait via `pub using @core { trait Widget }`.

---

## [0.2.0] - 2026-09-12

### Added
- **Full Self-Hosted "Pure Canvas Studio" (`gallery.html`)**: Complete migration of the component gallery to an in-canvas workbench featuring segmented theme switching (`studio_light`, `slate_dark`, `high_contrast`), 50/50 draggable curtain splitter (`split_horizontal`), line-numbered code viewer (`code_editor`), and full 32-widget code repository.
- **Input Accessibility & Multi-Pointer Overhaul**: Secondary pointer click (right-click) support in `RawInput`, complete Tab focus navigation chain across all widgets, Space/Enter keyboard activation with focus stroke rings, and event consumption (`consume_key`).
- **Typography & Grapheme Traversal Engine**: CJK word-wrapping and line breaking with punctuation avoidance in `rich_text.mbt`, atomic UTF-16 surrogate cluster traversal (`prev_char_boundary`, `next_char_boundary`), LRU typographical measurement caching, and native browser IME `<textarea>` composition bridge.
- **Widget Resiliency Suite**:
  - `CodeEditor`: Binary search character hit-testing, vertical wheel scrolling, auto-scrolling to caret, line culling, and text selection buffers with pointer drag and Shift/Ctrl+A key shortcuts.
  - `ScrollArea`: Interactive vertical scrollbar thumb dragging and post-closure content height clamping.
  - `Dialog`: Dynamic card height computation and Tab focus trapping.
  - `CommandPalette`: Scissor-clipped scrolling and 320px maximum height clamping.
  - `ComboBox`: Boundary collision detection with automatic upward flipping and internal scrolling.
  - `ContextMenu`: Recursive cascading submenus (`children : Array[ContextMenuItem]`, `ContextMenuItem::submenu`) with hover tracking.
  - `Splitter`: Zero-dimension guards and safe minimum padding clamping.
  - `Tooltip` & `Toast`: Viewport boundary clamping and hover occlusion blocking.
- **Rendering & Pipeline Optimizations**:
  - Added `DrawCmd::LinearGradient` primitive and `DrawList::add_linear_gradient`, mapped to `ctx.createLinearGradient` in JS backends.
  - Removed redundant per-cell `push_clip`/`pop_clip` in `Table`, saving 240 canvas state save/restores per frame.
- **Advanced Core Layout & Dynamic Theming**:
  - Auto-wrapping flow layout `UIContext::horizontal_wrapped`.
  - Dynamic runtime theme switching with `Theme` struct (`Theme::studio_light()`, `Theme::slate_dark()`, `Theme::high_contrast()`).
  - Immediate-mode animation tweening state machine (`animate_bool`, `animate_float`).
- **Memory & State Hardening**:
  - Replaced persistent state arrays with generational hash maps (`@hashmap.HashMap[Id, T]`) and frame-counter pruning (`prune_stale_state`).
  - Non-allocating 64-bit integer ID derivation (`Id::from_int`, `Id::with_int`, `IdStack::derive_int`).
- **158 Headless Tests**: 100% test pass rate across unit and whitebox test suites.

---

## [0.1.1] - 2026-09-11

### Added
- **Global Application Menu Bar (`menu_bar`, `menu`, `menu_item`, `menu_separator`)**: Desktop-grade menu strip featuring bistable Hover-to-Switch transitions, outside-click dismissal, deferred foreground layer elevation, and occlusion hover blocking.
- **Milestone 3 Full Delivery**: Completion of Windowing, Advanced Containers, and Scissor Clipping suite (`window`, `menu_bar`, `scroll_area`, `collapsing_header`, `tab_bar`).
- **Interactive Component Gallery Integration**: Added MenuBar showcase with real-time CAD workspace demo in `examples/canvas/gallery.html` and bilingual entries in `examples/canvas/i18n.js`.
- **Studio Light Porcelain Design Unification**: Design token consolidation in `src/color/` and refreshed specifications across design system documentation.
- **Enhanced Tactile Physics**: 1.5px sunken stroke on button press, chiclet keycaps, and micro-grooves.
- **58 Headless Tests**: 100% passing automated test suite covering all interaction states.

---

## [0.1.0-alpha.1] - 2026-09-09

### Added
- **Canvas 2D Interactive Web Playground**: Full working HTML5 Canvas 2D live demo in [`examples/canvas/`](examples/canvas/) running 60 FPS in browser with real-time pointer interaction and telemetry.
- **Core Interactive Widgets**: Ergonomic `label`, `label_colored`, `button`, `button_primary`, `checkbox`, `separator`, and `spacer` methods on `UIContext`.
- **Multi-Tier Architecture**: Modular package organization under `src/` (`src/math`, `src/color`, `src/draw`, `src/core`, `src/lib.mbt`) and blackbox integration suite under `test/`.
- **Mathematical Primitives**: `Vec2` and `Rect` with AABB hit-testing, intersection, margins, and scissor clipping math.
- **Color System & Tokens**: 32-bit RGBA color model, hex parsing, alpha blending, and industrial dark mode design tokens.
- **Render-Agnostic Draw Protocol**: Geometric primitive token enum (`DrawCmd`) and buffer-reusable command queue (`DrawList`).
- **Interaction State Machine**: `RawInput`, `InputState` pointer transition tracking, 64-bit deterministic FNV-1a `Id` hashing, and hierarchical `IdStack`.
- **IMGUI Context Coordinator**: `UIContext` lifecycle manager with linear cursor layout and `allocate_space` core extensibility primitive.
- **Documentation Suite**: Comprehensive bilingual documentation in `docs/` covering architecture, API design, design system, coding style, contributing guide, and engineering roadmap.
- **Automated CI Workflow**: GitHub Actions pipeline verifying formatting (`moon fmt`), unit/integration test suites (`moon test`), and WebAssembly build (`moon build`).
