# Changelog

All notable changes to this project 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).

## [Unreleased]

## [2.1.5] - 2026-09-14

### Removed
- Runtime tests from the distributable UPM package; tests remain in the development project.

## [2.1.4] - 2026-08-12

### Removed
- Unused legacy `_ignoreScale` serialized field on `Widget2D` (`Widget2D.cs`)

## [2.1.3] - 2026-08-11

### Added
- `scrollAxisIsZ` property — exposes `useZ` for flat XZ tile layouts (`Widget2D.cs`)

### Fixed
- `RefreshComponentsOnly` now calls `ComputeAllRects` before applying targets (`Widget2D.cs`)

## [2.1.2] - 2026-07-31

### Fixed
- Computed-rect targets with zero `percent`/`delta` preserve full rect size instead of collapsing (`Widget2D.Targets2.cs`)
- `Screen2D` calls `RefreshComponentsOnly` on `Awake` to avoid premature listener notification (`Widget2D.cs`)
- `SpriteFitListener` re-applies fit when sprite reference changes in editor (`SpriteFitListener.cs`)

## [2.1.1] - 2026-07-08

### Added
- `DepthSortGroup` component — stamps `sortingLayerID` / `sortingOrder` on child renderers for 2.5D depth-sort overlap without 3D depth buffer (`DepthSortGroup.cs`)
- `DepthSortEntry` class — flat reorderable list entry; renderer rows or separator rows that split depth groups (`DepthSortGroup.cs`)
- `DepthSortGroup.SetSortIndex(int)` / `SetSortingLayer(int)` — runtime API to change sort values and re-apply (`DepthSortGroup.cs`)
- `DepthSortGroup.GetOrder(int offset)` — helper for untracked renderers (trails, VFX) (`DepthSortGroup.cs`)
- `DepthSortGroup.groupCount` — number of distinct depth groups consumed (`DepthSortGroup.cs`)
- `DepthSortGroupEditor` — custom inspector with `ReorderableList`, sorting layer popup, and inline group labels (`DepthSortGroupEditor.cs`)
- Context menus: "Collect Child Renderers", "Add Separator" (`DepthSortGroup.cs`)
- `SpriteRendererWidget.MergeDuplicateWidgets()` — editor utility to consolidate duplicate widgets on the same GameObject (`SpriteRendererWidget.cs`)

### Changed
- `SpriteRendererWidget.SetFillAmountAll` / `SetFillAmount` no longer auto-enable/disable renderer — fill-only control, visibility managed separately (`SpriteRendererWidget.cs`)

## [2.1.0] - 2026-07-02

### Added
- `ComputedRect` system — named computed rects derived from source Widget2D size (`ComputedRect.cs`)
- Pipeline: Source → Padding → Available → SizeMode → Final Size → Align/Offset → Position
- `PaddingMode` enum: None, Fixed, RatioW, RatioH, RatioMin
- `RectSizeMode` enum: DependentX, DependentY, FitFill, Stretch
- `Widget2D._computedRects` list — flat list of ComputedRect definitions (`Widget2D.ComputedRects.cs`)
- `Widget2D.GetRect(id)` / `GetRectSize(id)` / `GetComputedRect(id)` public API
- `WidgetTarget.rectId` — targets can reference a computed rect by ID instead of raw source
- `AddListener(component, rectId)` — listeners can bind to a computed rect's size
- `ComputedRectDrawer` — custom PropertyDrawer with compact per-mode inspector
- Scene gizmos for computed rects (colored wireframes per rect)
- Unit tests (`Widget2D.Tests` assembly) covering all size modes and padding modes

### Changed
- `Widget2D.Refresh()` now calls `ComputeAllRects()` before `ApplyTargets2()`
- `ApplyTargets2()` resolves `rectId` on each target before computing size
- `NotifyListeners()` checks per-listener rect bindings
- `WidgetTargetDrawer` shows rectId label inline + editable in expanded view

## [2.0.0] - 2026-06-22

### Added
- `WidgetTarget` system — per-target sizing with `Stretch`/`Fit`/`Fill` modes, position percent, and sprite apply options (`WidgetTarget.cs`)
- `Widget2D._targets2` list — new target pipeline supporting `BoxCollider`, `SpriteRenderer`, and child `Widget2D` targets (`Widget2D.Targets2.cs`)
- `WidgetTargetDrawer` — compact single-line Inspector with foldout for target configuration (`WidgetTargetDrawer.cs`)
- `ScaleTransform` mode — applies size as localScale instead of Widget2D size (`Widget2D.cs`)
- `posPercent` field — position as percentage of parent size (`Widget2D.cs`)
- `applySize` / `applyPosition` toggles — selective application control (`Widget2D.cs`)

### Changed
- `SpriteRendererWidget` rewritten — supports `List<SpriteTarget>` for multi-sprite per component (`SpriteRendererWidget.cs`)
- `SpriteFitListener` inlined `UniformScale` logic from removed `ScalerExtension` (`SpriteFitListener.cs`)
- 51% code reduction (2722 → 1332 lines) — dead code removal

### Removed
- **BREAKING**: `WidgetTransform` component — replaced by `_targets2` pipeline (`WidgetTransform.cs`)
- **BREAKING**: `WidgetHandler` base class — inlined into `Widget2D.Targets2` (`WidgetHandler.cs`)
- **BREAKING**: `AlignHandler`, `ScaleHandler`, `SizeHandler` — dead handler classes (`Transform/` folder)
- **BREAKING**: `AxisFilter` enum — no longer used (`AxisFilter.cs`)
- `ScalerExtension` — inlined into `SpriteFitListener` (`ScalerExtension.cs`)
- `Widget2DMigrator`, `SpriteWidgetMigrator` — one-time migration tools removed after use
- `WidgetTransformEditor` — editor for removed component

### Migration Guide
Replace `WidgetTransform` references with `Widget2D._targets2` entries using `WidgetTarget` objects. Each target supports mode selection (Stretch/Fit/Fill), position percent, and delta offsets. Use the migration tool in 1.x before upgrading if prefabs still reference `WidgetTransform`.

## [1.1.2] - 2026-05-25

### Changed
- Updated `README.md` and `Docs/Widget2D-API.md` documentation

## [1.1.1] - 2026-04-03

### Added
- `Widget2D._ignoreScale` field
- `Widget2D.RefreshComponentsOnly()` for early Awake init

### Changed
- `Screen2D.Awake()` auto-initializes size before first frame (eliminates layout pop)
- `Screen2D.Init()` safe to call after `Awake`
- `WidgetHandler.SetComponentSize()` accepts `ignoreScale` parameter

## [1.1.0] - 2026-04-01

### Added
- `Screen2D` — auto-fit to screen aspect ratio with `fitWidthToHeight` blend
- `ISizeListener` interface with `OnResize(Vector2)` callback
- `WidgetHandler.RegisterHandler<T>()` and static size helpers
- `WidgetTransform` — child alignment/scaling relative to `Widget2D` parent
- `SpriteRendererWidget` with optional padding
- `Size2D` struct with `pivot` and `useZ` fields
- `Widget2D.listeners` list with `AddListener()` / `RemoveListener()`
- `ScalerExtension` helpers for BoxCollider and SpriteRenderer
- TextMeshPro handler support (requires `TMPro` define)

### Changed
- `WidgetHandler` caches derived-type lookups
- `Widget2D.Refresh()` calls both `ApplySizeToComponents()` and `NotifyListeners()`

## [1.0.1] - 2026-01-01

### Added
- Initial package scaffold
