Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(feat) Automation on return tracks; resizable return and master rows (#361)

Egor Khindikaynen6bf8fbe02801
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11dbe137..24c2e5cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,17 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Automation on return tracks**: in automation mode each return row in the arrangement
+ footer has a lane like a track's — pick Volume, Pan or a parameter of a device on the
+ return's chain from its pill, then draw, drag, bend, select, copy and paste points. The
+ return plays its automation back, its fader and pan follow, and the lanes are saved with
+ the project and undo like track automation.
+- **Resizable return and master rows**: drag a return's or the master's bottom edge, or pick
+ Compact, Standard or Large under **Height** in its context menu; a double-click on the edge
+ goes back to Compact; ⌘- or ⇧-click returns to select several and size them together.
+ Their headers adapt like a track's (a return gains a mute button at Standard and its pan at
+ Large), the heights are saved with the project, and past about half the arrangement the
+ footer scrolls instead of crowding out the tracks.
- **Select several devices and group them into a rack** (#328): in the Devices panel ⇧-click
selects a range across MIDI effects, the instrument and audio effects, ⌘-click adds or
removes one, Esc clears. Copy, cut, paste, duplicate, delete, Move to track ▸ and dragging a
@@ -115,6 +126,8 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
before keep the stereo pair. Saved with the project; MCP `set_input_channels`.
### Changed
+- **Return and master rows start compact**: new projects, new returns and projects saved
+ before this version show them at the Compact height, so the tracks get the room.
- **One click arms one track** (nota-daw/nota#332): a click on a track's arm button arms that
track and disarms the others, so picking which instrument the keyboard plays is one click.
⌘-click (Ctrl-click on Windows / Linux) arms several. While recording, a click never
diff --git a/FEATURES.md b/FEATURES.md
index cb7e6de4..e4af6e06 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -141,7 +141,12 @@ track count and closes with Escape.
group's hue, shaded per sibling.
- **Return and Master rows stay pinned** under the tracks, each with a level meter, a
volume fader and its dB value (the Master fader is the same master volume as the
- transport's and the Mixer's).
+ transport's and the Mixer's). They start Compact and resize like tracks — drag the
+ bottom edge, or **Height** (Compact · Standard · Large) in their context menu,
+ double-click the edge to go back to Compact; ⌘- or ⇧-click selects several returns to
+ size together. A return shows its mute at Standard and its pan at Large. Past about half
+ the arrangement the footer scrolls. Heights are saved with the project; ⌥-drag and the
+ all-tracks Height leave them alone.
- **Clip names appear where a run begins** — a clip is a colour band over its waveform,
and the name prints only at the head of each run so a repeated pattern reads as one
block. View ▸ Clip names cycles every clip / first of a run / none; a clip named by
@@ -496,8 +501,9 @@ track count and closes with Escape.
## Automation
-- **Automation lanes** on tracks, with curved segments (Alt+drag) and points (double-click
- to add, double-click a point to remove).
+- **Automation lanes** on tracks and returns, with curved segments (Alt+drag) and points
+ (double-click to add, double-click a point to remove). A return's lane (Volume, Pan or a
+ device on its chain) is edited in its footer row, the master's volume in the Master row.
- **Automation mode** (⌘⇧A): the first time it opens, each track that already has automation
shows its first automated parameter.
- **Draw mode** (the `A` key): drawn automation changes the device parameter in real time,
diff --git a/specs/045-return-master-lanes/checklists/requirements.md b/specs/045-return-master-lanes/checklists/requirements.md
new file mode 100644
index 00000000..8db6a45e
--- /dev/null
+++ b/specs/045-return-master-lanes/checklists/requirements.md
@@ -0,0 +1,35 @@
+# Specification Quality Checklist: Automation and resizable height for return and master rows
+
+**Purpose**: Validate specification completeness and quality before proceeding to planning
+**Created**: 2026-10-28
+**Feature**: [spec.md](../spec.md)
+
+## Content Quality
+
+- [x] No implementation details (languages, frameworks, APIs)
+- [x] Focused on user value and business needs
+- [x] Written for non-technical stakeholders
+- [x] All mandatory sections completed
+
+## Requirement Completeness
+
+- [x] No [NEEDS CLARIFICATION] markers remain
+- [x] Requirements are testable and unambiguous
+- [x] Success criteria are measurable
+- [x] Success criteria are technology-agnostic (no implementation details)
+- [x] All acceptance scenarios are defined
+- [x] Edge cases are identified
+- [x] Scope is clearly bounded
+- [x] Dependencies and assumptions identified
+
+## Feature Readiness
+
+- [x] All functional requirements have clear acceptance criteria
+- [x] User scenarios cover primary flows
+- [x] Feature meets measurable outcomes defined in Success Criteria
+- [x] No implementation details leak into specification
+
+## Notes
+
+- Both open questions resolved in Clarifications (2026-10-28): footer capped at ~half height and scrolls; "all tracks" gestures leave returns/master alone.
+- The Nota Context section names current files on purpose (project template asks for it); the requirements themselves stay behaviour-level.
diff --git a/specs/045-return-master-lanes/contracts/track-view-sidecar.md b/specs/045-return-master-lanes/contracts/track-view-sidecar.md
new file mode 100644
index 00000000..d905a0d5
--- /dev/null
+++ b/specs/045-return-master-lanes/contracts/track-view-sidecar.md
@@ -0,0 +1,32 @@
+# Contract delta: `track-view.json` (return and master heights)
+
+Extends [specs/015's sidecar contract](../../015-track-list-sizing/contracts/track-view-sidecar.md).
+The format stays `version: 1`; the change is additive.
+
+```json
+{
+ "version": 1,
+ "headerWidth": 260,
+ "trackHeights": [
+ { "index": 0, "height": 128 },
+ { "index": 7, "height": 64 }
+ ],
+ "masterHeight": 128
+}
+```
+
+Here index 7 is a return track.
+
+| Key | Type | Meaning |
+|-----|------|---------|
+| `trackHeights[].index` | int | engine track index; may now point at a **return** |
+| `trackHeights[].height` | number | px, clamped to [30, 256] on read |
+| `masterHeight` | number | master row height in px, clamped on read; omitted → 30 |
+
+Rules (in addition to specs/015):
+
+- A return is listed only when its height ≠ 30 (its default). A track is listed only when its height ≠ 64.
+- `masterHeight` is written only when ≠ 30.
+- The file is deleted when header width, every track, every return and the master are at their defaults.
+- Reading: a return entry sets that return's height; a missing return entry or a missing `masterHeight` means Compact (30). This also covers projects saved before this feature.
+- Older builds skip return entries (their loader filters returns) and ignore `masterHeight`, so files open both ways.
diff --git a/specs/045-return-master-lanes/contracts/ui-gestures.md b/specs/045-return-master-lanes/contracts/ui-gestures.md
new file mode 100644
index 00000000..a741d220
--- /dev/null
+++ b/specs/045-return-master-lanes/contracts/ui-gestures.md
@@ -0,0 +1,14 @@
+# Contract: footer (return / master) gestures and menu
+
+| Where | Gesture | Result |
+|-------|---------|--------|
+| Bottom edge of a return / master row (header or lane, ±3 px band) | hover | vertical-resize cursor; the seam line lights with `Brush.BorderStrong` |
+| same | drag | that row's height follows the pointer within [30, 256], snapping to 30 / 64 / 128; if the dragged return is selected along with other returns, they all take the height |
+| same | Alt/Option + drag | same as a plain drag; footer rows never resize "all tracks" |
+| same | double-click | back to Compact (30) |
+| Return / master header | right-click | context menu adds a **Height** segmented row: Compact · Standard · Large, current one marked, no all-tracks variant |
+| Track row edge | Alt + drag / "all tracks" preset | regular tracks only; footer heights unchanged |
+| Return lane, automation mode | target pill | opens the same target menu as a track: Volume, Pan, devices on the return's chain (built-in, plugin, nested) |
+| Return lane, automation mode | double-click / drag / right-click / Alt-drag / Shift-drag | add / move / remove or menu / bend / range select, exactly as on a track lane |
+| Master lane, automation mode | click / drag / right-click / double-click | master-volume points as today, mapped to the row's current height |
+| Footer, content taller than its cap | wheel / scrollbar | footer scrolls vertically; track list unaffected |
diff --git a/specs/045-return-master-lanes/data-model.md b/specs/045-return-master-lanes/data-model.md
new file mode 100644
index 00000000..2394aae0
--- /dev/null
+++ b/specs/045-return-master-lanes/data-model.md
@@ -0,0 +1,38 @@
+# Data Model: Automation and resizable height for return and master rows
+
+All of this is managed view state in `ArrangementView`, except return automation lanes,
+which are existing engine track data.
+
+## Row height (per return)
+
+- **Key**: return track id (session-scoped), stored in `_trackHeights` with track heights.
+- **Value**: px, clamped to [30, 256], snapped to 30 / 64 / 128 within 4 px while dragging.
+- **Default**: 30 (Compact). Track rows keep 64. An entry equal to its row's default is not stored.
+- **Lifecycle**: created by a seam drag or menu pick; removed when its return is deleted
+ (`PruneTrackHeights` covers returns too); reset by a seam double-click.
+- **Persisted**: `track-view.json` → `trackHeights[]` by engine track index.
+
+## Master row height
+
+- **Field**: `_masterHeight`, px, same clamp/snap, default 30.
+- **Persisted**: `track-view.json` → `masterHeight` (omitted at default).
+- **Reset**: New project / `ResetTrackView()` → 30.
+
+## Footer geometry (derived, not stored)
+
+- `_footerRowTops[0..returns+1]`: cumulative tops; the last entry is the footer content height.
+- **Footer viewport**: `min(content height, cap)`, where cap ≈ half the vertical space
+ shared by the track scroller and the footer. Past the cap, the footer scrolls vertically.
+- **Header tier** per footer row: `TierFor(height)`.
+
+## Return automation lane (existing)
+
+- Same entity as a track lane: target (Volume / Pan / DeviceParam / PluginParam / nested)
+ plus points (beat, value, curve). Owned by the return track in the engine graph and
+ saved in the project document `tracks[].automation`.
+- UI selection per return: `_autoTargets[returnId]`, as for tracks; the first automated
+ lane is shown on the first visit in automation mode.
+
+## Master volume automation (existing, unchanged)
+
+- `_masterAuto` points, value range 0..2, committed with `SetMasterVolumeAutomation`.
diff --git a/specs/045-return-master-lanes/plan.md b/specs/045-return-master-lanes/plan.md
new file mode 100644
index 00000000..04cb31a7
--- /dev/null
+++ b/specs/045-return-master-lanes/plan.md
@@ -0,0 +1,118 @@
+# Implementation Plan: Automation and resizable height for return and master rows
+
+**Branch**: `045-return-master-lanes` | **Date**: 2026-10-28 | **Spec**: [spec.md](spec.md)
+
+**Input**: Feature specification from `specs/045-return-master-lanes/spec.md`
+
+## Summary
+
+Return rows get the automation lane editing regular tracks have (target pill + menu,
+points, curves, range select / clipboard), and return and master rows become resizable
+(seam drag, Compact / Standard / Large in the context menu), Compact by default. The
+pinned footer is capped at about half the arrangement height and scrolls past it. The
+engine and the project file already handle automation lanes on return tracks, so the
+change is in `Nota.App`: the arrangement's automation editor is pulled out of
+`LaneControl` into a row-agnostic editor that both the track lanes and the footer lanes
+use; the footer gets per-row geometry, seam grips and a vertical scroller; the
+`track-view.json` sidecar gains return and master heights. See [research.md](research.md).
+
+## Nota: Read Before Planning
+
+Consult the matching source of truth before designing:
+
+- **Engine work** → [`ARCHITECTURE.md`](../../ARCHITECTURE.md): the AR rules table is binding (AR-4 lock-free queue, AR-5 immutable snapshots, AR-6 audio-thread restrictions, AR-7 pure C ABI, AR-9 `Transport` is the only source of musical time).
+- **UI work** → [`DESIGN.md`](../../DESIGN.md) (Studio design language) and the `nota-design` skill.
+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md): licensing, dependency policy, PR expectations.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10 (managed app only). No C++ change expected; see R1.
+
+**Primary Dependencies**: Avalonia (existing). No new dependency.
+
+**Storage**: `.nota` bundle. Return automation lanes are already saved in the project
+document (`ProjectService` writes `t.Automation` for every track, returns included, and
+reloads them after `AddReturnTrack`). Return and master heights go into the existing
+`track-view.json` sidecar ([contract](contracts/track-view-sidecar.md)).
+
+**Audio-Thread Impact**: None new. Return lanes use the existing automation ABI
+(`AddAutomationLane` / `SetAutomationPoints[Live]` → new graph snapshot, AR-5), and the
+block-rate `applyAutomation` pass already visits return tracks. Heights are view state.
+
+**Testing**: `tests/Nota.SmokeTest` gets a return-automation round trip (add lane on a
+return, set points, render, check level follows; save/load keeps the lane). UI behaviour is
+checked with the [quickstart](quickstart.md) scenarios and headless screenshots (agent
+memory `nota-ui-verify`).
+
+**Target Platform**: macOS, Windows, Linux desktop (Avalonia).
+
+**Project Type**: desktop app.
+
+**Performance Goals**: footer seam drag follows the pointer with no visible lag; at most
+5 footer rows (4 returns + master, `kMaxReturns = 4`), so rebuilding footer headers per
+frame is acceptable.
+
+**Constraints**: track-row automation, resizing and gestures must not regress (the
+editor refactor touches `LaneControl`).
+
+**Scale/Scope**: ~5 files in `src/managed/Nota.App`, one smoke test, one sidecar extension.
+
+## Constitution Check
+
+*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
+
+| Principle | Status | Note |
+|-----------|--------|------|
+| I. Real-time audio safety | Pass | No audio-thread code; existing automation path reused |
+| II. Boundary discipline | Pass | Existing C ABI calls only; no JUCE outside `pluginhost/` |
+| III. Licensing hygiene | Pass | No dependency; the new `ArrangementView.AutoEditor.cs` carries the SPDX header |
+| IV. Verification gate | Pass | `scripts/build.sh` + new smoke check for return automation |
+| V. One logical change | Pass | One PR: return/master rows in the arrangement footer |
+| VI. Docs in sync | Planned | CHANGELOG `[Unreleased]`, nota-features, nota-docs (arrangement / automation / mixing pages), nota-shortcuts wording check |
+| VII. Spec first | Pass | spec → plan → tasks |
+| VIII. Rules not weakened | Pass | — |
+
+Post-design re-check: unchanged, all pass.
+
+## Project Structure
+
+### Documentation (this feature)
+
+```text
+specs/045-return-master-lanes/
+├── plan.md
+├── research.md
+├── data-model.md
+├── quickstart.md
+├── contracts/
+│ ├── track-view-sidecar.md # delta on specs/015's sidecar
+│ └── ui-gestures.md # footer gestures and menu
+└── tasks.md # /speckit-tasks
+```
+
+### Source Code (repository root)
+
+```text
+src/managed/Nota.App/
+├── ArrangementView.AutoEditor.cs # NEW: row-agnostic automation editor (press/move/release,
+│ # hover, bend, range select, draw) extracted from LaneControl
+├── ArrangementView.LaneControl.cs # track lanes delegate automation mode to the editor
+├── ArrangementView.Controls.cs # FooterLaneControl: per-row geometry, return rows via the editor,
+│ # master-volume row kept, lane-side seam band
+├── ArrangementView.Sizing.cs # per-kind default height, footer heights, master height,
+│ # footer resize, sidecar returns + masterHeight
+├── ArrangementView.cs # footer layout: ScrollViewer + cap, row tops, BuildSlimRow tiers,
+│ # ShowFooterMenu "Height" row, drop-row hit test by geometry
+└── ArrangementView.Tracks.cs # TrackHeightRow variant without the all-tracks modifier
+
+tests/Nota.SmokeTest/
+└── ReturnAutomationTests.cs # NEW: return lane render + save/load round trip
+```
+
+**Structure Decision**: UI-only change in `Nota.App` (the arrangement lives there, not in
+`Nota.Presentation`), plus one smoke test. The automation editor is extracted into its own
+partial file so the footer can reuse it instead of duplicating ~400 lines (R2).
+
+## Complexity Tracking
+
+No constitution violations.
diff --git a/specs/045-return-master-lanes/quickstart.md b/specs/045-return-master-lanes/quickstart.md
new file mode 100644
index 00000000..e3d3b884
--- /dev/null
+++ b/specs/045-return-master-lanes/quickstart.md
@@ -0,0 +1,36 @@
+# Quickstart: validating return / master automation and heights
+
+## Prerequisites
+
+- `scripts/build.sh` passes, including the new return-automation smoke check
+ (`tests/Nota.SmokeTest/ReturnAutomationTests.cs`).
+- Isolate app data with `NOTA_DATA_DIR=<tmp dir>` (HOME does not isolate JUCE).
+- A test project: 6+ tracks sending to two returns; return A has a reverb device.
+
+## Scenarios
+
+| # | Steps | Expected |
+|---|-------|----------|
+| 1 | New project | Master row is 30 px (Compact); add a return → it is 30 px too (FR-012) |
+| 2 | Open a project saved before this feature | Returns and master Compact; no errors |
+| 3 | Automation mode → return A pill → Volume; double-click to add a ramp; play | Return level follows; header fader and mixer move (FR-001–003) |
+| 4 | Return A pill → reverb decay; draw points, Alt-bend a segment, Shift-select a range, copy/paste | Same as on a track lane (FR-002) |
+| 5 | Undo / redo a return point edit | Steps like on a track (FR-004) |
+| 6 | Save, close, reopen | Return lanes and points restored |
+| 7 | Master lane in automation mode at 30 / 64 / 128 px | Master-volume points editable at every height (FR-005) |
+| 8 | Drag a return's bottom edge (header, then lane) | Row resizes, snaps to 64 / 128; rows below move ([gestures](contracts/ui-gestures.md)) |
+| 9 | Right-click return / master → Height → each preset | Row takes 30 / 64 / 128; current preset marked (FR-007) |
+| 10 | Select both returns, drag one edge | Both take the height |
+| 11 | Double-click a footer seam | Back to 30 (FR-008) |
+| 12 | Alt-drag a track edge; track menu "all tracks" Large | Tracks change; returns and master don't (FR-016) |
+| 13 | Make every footer row Large in a short window | Footer stops at ~half the height and scrolls; tracks stay visible (FR-015) |
+| 14 | Screenshot return / master headers at 30 / 61 / 62 / 111 / 112 / 256 px × widths 160 / 228 / 480 | Compact / standard / large layouts; nothing clipped (SC-005) |
+| 15 | Drop an effect from the browser onto each footer row at mixed heights | Lands on the highlighted bus (FR-013) |
+| 16 | Save with resized returns / master; inspect `track-view.json` | Matches [the sidecar delta](contracts/track-view-sidecar.md); reopen restores the heights |
+| 17 | Regression: track automation, track resizing, clip edits on track lanes | Unchanged (editor refactor) |
+
+## Screenshot harness
+
+Recipe in agent memory `nota-ui-verify`: an env-guarded in-app hook that sets heights and
+then `screencapture`, or an Avalonia.Headless offscreen render of `ArrangementView` with
+a seeded project.
diff --git a/specs/045-return-master-lanes/research.md b/specs/045-return-master-lanes/research.md
new file mode 100644
index 00000000..f952c6dc
--- /dev/null
+++ b/specs/045-return-master-lanes/research.md
@@ -0,0 +1,103 @@
+# Research: Automation and resizable height for return and master rows
+
+## R1. Does the engine already support automation on returns?
+
+- **Decision**: Yes; no engine change. Add a smoke check to lock it in.
+- **Rationale**: A return is a `Track` of type `Return` (`Engine::addReturnTrack`), so
+ `addAutomationLane` / `setAutomationPoints` find it through `findTrackAuthoring`.
+ `Engine::applyAutomation` walks every track in the graph before the mix, including
+ returns, and the return render pass (pass 2 in `Engine_Render.cpp`) reads `t.volume()`,
+ `t.pan()` and runs `t.devices`, so automated values take effect. `ProjectService` saves
+ and reloads `Automation` for every track, and returns go through the same loop after
+ `AddReturnTrack()`. On the managed side, `Refresh()` already fills return `TrackVM`s
+ with their automation target and points, and `OnAutomationTouched` already searches
+ `_returns`. What's missing is a footer UI that shows and edits them.
+- **Alternatives considered**: a send-level workaround (automating every send) was
+ rejected by the spec.
+
+## R2. How should the footer edit return automation?
+
+- **Decision**: Extract the automation editor from `LaneControl` into a row-agnostic
+ `AutoEditor` (new partial file). It holds the drag / bend / hover / range state and the
+ press / move / release / draw logic, and reads rows through a small host interface:
+ `Count`, `TrackAt(i)`, `Top(i)`, `Height(i)`, `RowAtY(y)`, plus the owning control
+ (pointer capture, invalidate, menu anchor). `LaneControl` maps it to `_tracks` /
+ `_rowTops`; `FooterLaneControl` maps it to `_returns` / footer row tops.
+- **Rationale**: FR-002 asks for identical editing (snap, curves with Alt-bend, Shift
+ range select, copy/paste, right-click menu, double-click add, fine drag). Duplicating the
+ ~400 lines in `LaneControl` would drift; the code already works on a `TrackVM` plus row
+ geometry, so the extraction is mostly mechanical (replace `_o._tracks[i]`, `RowTop(i)`,
+ `RowH(i)`, `_o.RowAtY` with host calls).
+- **Alternatives considered**:
+ - Move returns into the scrolling track list: contradicts the spec's assumption that
+ they stay pinned.
+ - A cut-down footer editor (points only): fails FR-002.
+ - Modelling master-volume as a pseudo `TrackVM`: its points live in `_masterAuto` with
+ their own commit path (`SetMasterVolumeAutomation`) and range. The master row keeps
+ its own handler, adapted to variable height (FR-005). Unifying it is optional later.
+
+## R3. Where do return and master heights live?
+
+- **Decision**: Return heights go in the existing `_trackHeights` (track id → height),
+ with the default resolved per row kind: `DefaultHeightFor(id)` = Compact (30) for
+ returns, Standard (64) for tracks. `StoreRowHeight` drops an entry when it equals that
+ row's default. The master gets its own `_masterHeight` field (default 30), since its
+ reserved id is not an engine track index.
+- **Rationale**: Reuses clamp/snap and the prune logic. `AllTrackRowIds()` already
+ excludes returns, so Alt-drag and "all tracks" leave the footer alone (FR-016) with no
+ extra work.
+- **Persistence**: the sidecar stays `version: 1`; return heights are written as
+ `trackHeights` entries by engine index (as tracks are) and a new `masterHeight` key is
+ added. Older builds skip return entries (their loader filters `IsReturn`) and ignore
+ unknown keys, so files stay compatible both ways. A project without these entries
+ opens with Compact returns and master (FR-012). See
+ [contracts/track-view-sidecar.md](contracts/track-view-sidecar.md).
+
+## R4. Footer cap and scrolling
+
+- **Decision**: Wrap the footer grid (header canvas + `FooterLaneControl`) in a vertical
+ `ScrollViewer` docked at the bottom. Its `MaxHeight` is half the height left for
+ footer + track scroller, recomputed when the view resizes. The horizontal position
+ still follows the lanes' shared `_scrollBeats` (the footer lanes draw in beat space, as
+ they do today), so only vertical scrolling is new. The vertical scrollbar uses the
+ same thin style as the track scroller.
+- **Rationale**: FR-015. With at most 5 rows the footer rarely passes the cap, so a plain
+ scroller is enough.
+- **Alternatives considered**: stopping growth at the cap (rejected in Clarifications);
+ making the footer split resizable (more UI than asked for).
+
+## R5. Header layout per tier for return / master rows
+
+- **Decision**: `BuildSlimRow` picks the tier with `TierFor(height)` (same thresholds as
+ tracks: compact < 62 ≤ standard < 112 ≤ large):
+ - **Compact** (30 px default): one line with spine, name, mini fader, dB readout and meter.
+ When the column is narrow the fader shrinks first, then the dB readout goes.
+ - **Standard**: today's 40 px layout (name + dB over a full-width fader), vertically
+ centred, plus a Mute chip for returns on the name line (the engine already honours a
+ return's mute).
+ - **Large**: standard plus a pan control row for returns (pan is now automatable on
+ returns, so it should be visible). The master has no pan, so it keeps standard
+ content with a taller fader area.
+- **Rationale**: FR-009 asks for the same tier rules with nothing clipped. Mute and pan
+ are the controls a return lacks today that its new automation targets need.
+- **Alternatives considered**: keeping a single layout and clipping it (fails FR-009);
+ adding solo/arm (returns are exempt from solo, can't record).
+
+## R6. Resizing gestures in the footer
+
+- **Decision**: Footer rows get header-side seam grips (like `RowSeamGrip`) on
+ `_footerHeaders` and a lane-side seam band in `FooterLaneControl`. Both go through a
+ footer resize path that shares `SnapRowHeight` / `ClampRowHeight`, ignores Alt (FR-016),
+ resizes the selected returns together when the dragged one is selected (US2-3), and
+ rebuilds footer headers per frame (5 rows max). Double-click resets to Compact. The
+ footer context menu gets the "Height" segmented row (`TrackHeightRow` with the
+ all-tracks modifier turned off).
+- **Rationale**: Same gestures as specs/015, so `nota-shortcuts` needs only a wording
+ check ("track or return/master").
+
+## R7. Hit testing and drop targets
+
+- **Decision**: `FooterRowAt(y)`, `SetFooterDropRow`, `MasterRowTop` and
+ `FooterLaneControl.Render` switch from `row * FooterRowH` to a `_footerRowTops` array
+ rebuilt with the heights. `FooterRowH` goes away.
+- **Rationale**: FR-010 and FR-013 (browser drops still land on the right bus).
diff --git a/specs/045-return-master-lanes/spec.md b/specs/045-return-master-lanes/spec.md
new file mode 100644
index 00000000..55ae0fa6
--- /dev/null
+++ b/specs/045-return-master-lanes/spec.md
@@ -0,0 +1,184 @@
+# Feature Specification: Automation and resizable height for return and master rows
+
+**Feature Branch**: `045-return-master-lanes`
+
+**Created**: 2026-10-28
+
+**Status**: Draft
+
+**Input**: User description: "Return tracks and the Master track: (1) Return tracks currently cannot have automation — add automation lanes for return tracks (like regular tracks). (2) Return and Master tracks cannot change their track height — allow resizing their height, including the context-menu Compact / Standard / Large height modes that regular tracks have. (3) By default, Return and Master tracks should be in Compact mode."
+
+## Nota Context *(fill in — drives plan and tasks)*
+
+**Feature area** *(pick the main one)*:
+
+- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table
+- [ ] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation
+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)
+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed
+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`
+- [ ] Docs only
+
+Today the return and master rows live in the arrangement's pinned footer
+(`FooterLaneControl` in `src/managed/Nota.App/ArrangementView.Controls.cs`) at a fixed
+40 px (`FooterRowH`). The master row edits only master-volume automation; return rows
+show no automation at all. Track rows already have per-track heights with
+Compact 30 / Standard 64 / Large 128 presets and size-adaptive headers (specs/015,
+`ArrangementView.Sizing.cs`), and full automation lanes (`ArrangementView.Automation.cs`).
+In the engine a return is an ordinary track of type Return and the block-rate automation
+pass already walks every track, so return automation is expected to need no engine
+change — the plan confirms this and adds a smoke check.
+
+**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:
+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),
+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR
+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),
+[`FEATURES.md`](../../FEATURES.md), [`specs/015-track-list-sizing`](../015-track-list-sizing/spec.md).
+
+## Clarifications
+
+### Session 2026-10-28
+
+- Q: When the footer grows too tall, cap it and scroll, or just stop growing? → A: Cap at about half the arrangement height and scroll the footer internally.
+- Q: Do the "all tracks" height gestures also resize return and master rows? → A: No — regular tracks only; returns and master are resized on their own.
+
+## User Scenarios & Testing *(mandatory)*
+
+### User Story 1 - Automate a return track (Priority: P1)
+
+A producer sends several tracks to a reverb return and wants the reverb to swell in the
+chorus and duck in the verse. In automation mode they pick a parameter on the return row
+— its volume, its pan, or a parameter of a device on the return's chain (e.g. the
+reverb's decay) — draw points into the return's lane, and on playback the return follows
+them exactly as a regular track's automation would.
+
+**Why this priority**: This is a missing capability, not a layout preference — today the
+only workaround is automating every send on every source track.
+
+**Independent Test**: Add a return with a device, enter automation mode, draw a volume
+ramp and a device-parameter ramp on the return, play, and confirm the return's level and
+the device parameter follow the drawn curves; save, reopen, and confirm the lanes are
+still there.
+
+**Acceptance Scenarios**:
+
+1. **Given** a project with a return track, **When** the user enters automation mode, **Then** the return's row offers the same automation-target choice as a regular track: volume, pan, and the parameters of the devices on its chain.
+2. **Given** a chosen return target, **When** the user clicks, drags and removes points in the return's row, **Then** the points behave as on a regular track (add, move, snap, remove with right-click / double-click, curve editing where tracks have it).
+3. **Given** return automation exists, **When** the song plays, **Then** the return's volume / pan / device parameter follow the curve, and the return's controls (header, mixer, device card) move with it.
+4. **Given** return automation exists, **When** the project is saved and reopened, **Then** every return lane and point is restored.
+5. **Given** return automation exists, **When** the user undoes / redoes an automation edit, **Then** it undoes / redoes as on a regular track.
+6. **Given** the master row, **When** in automation mode, **Then** master-volume automation keeps working as today.
+
+---
+
+### User Story 2 - Resize return and master rows (Priority: P1)
+
+A user mixing with three returns wants the reverb return tall to see its automation
+clearly and the others short. They drag the bottom edge of a return or the master row,
+or right-click it and pick Compact / Standard / Large under "Track height", exactly as on
+a regular track.
+
+**Why this priority**: Return automation (US1) is hard to edit in a fixed 40 px row; the
+footer also takes space the user may want for tracks.
+
+**Independent Test**: Resize one return and the master by edge drag and by each context
+menu preset, confirm only that row changes, its header adapts like a track header, and
+the sizes survive save/reopen.
+
+**Acceptance Scenarios**:
+
+1. **Given** a return or master row, **When** the user drags its bottom edge, **Then** that row's height follows the pointer within the track height limits, snapping to the presets as track rows do, and the rest of the footer moves accordingly.
+2. **Given** a return or master row, **When** the user right-clicks its header, **Then** the context menu offers "Track height" with Compact / Standard / Large, the current one marked, and picking one sets that row's height.
+3. **Given** several returns are selected, **When** the user picks a preset or drags one of their edges, **Then** every selected return takes the same height.
+4. **Given** a resized return or master, **When** the user double-clicks its bottom edge, **Then** the row returns to its default height (Compact).
+5. **Given** a return or master row at any height, **Then** its header uses the same compact / standard / large layout rules as a track header, with no control clipped or overlapping.
+6. **Given** resized returns and master, **When** the project is saved and reopened, **Then** they have the heights they had when saved.
+
+---
+
+### User Story 3 - Compact by default (Priority: P2)
+
+A user opens a new project or adds a return: the return and master rows start compact,
+so the footer takes as little room as possible and the tracks get the space.
+
+**Why this priority**: A small default that only makes sense once rows are resizable.
+
+**Independent Test**: Create a new project and add a return; confirm the master and the
+return are at the Compact height. Open an old project saved before this feature; confirm
+its returns and master are Compact too.
+
+**Acceptance Scenarios**:
+
+1. **Given** a new project, **Then** the master row is at the Compact height.
+2. **Given** any project, **When** the user adds a return, **Then** the new return row is at the Compact height.
+3. **Given** a project saved before this feature (no stored return/master heights), **When** it opens, **Then** returns and master are at the Compact height.
+4. **Given** a regular track, **Then** its default stays Standard (unchanged).
+
+---
+
+### Edge Cases
+
+- **Footer taller than the view**: the footer is pinned, so tall returns could crowd out the tracks. The footer is capped at about half the arrangement height; past the cap it scrolls vertically on its own, and its rows keep their heights (see FR-015).
+- **"All tracks" resize** (Alt-drag on a track edge, the "all tracks" preset) resizes regular tracks only; return and master rows keep their own heights and are resized only through their own edges and context menu (see FR-016).
+- **Return removed**: its stored height and automation go with it; the remaining returns keep theirs.
+- **Device on a return removed or moved**: return lanes on that device follow the same fix-up rules as track lanes (removed with the device, re-pointed when moved).
+- **Return lanes during automation write / record**: if regular tracks support writing automation from moving controls, returns do too; if a mode is track-only today, it stays out of scope here and is noted in the plan.
+- **Compact master with automation**: master-volume points remain editable at 30 px (value axis compressed, hit targets unchanged).
+- **Resizing is a view change**: not in undo history, does not change audio (consistent with specs/015); it may mark the project unsaved.
+- **Older Nota builds** opening a project saved with return/master heights or return lanes ignore the extra data without error (return lanes are already engine track data, so an older build may play them).
+- **Session view, mixer and Nota Remote** are not changed.
+
+## Requirements *(mandatory)*
+
+### Functional Requirements
+
+- **FR-001**: In automation mode, each return row MUST offer the automation-target choice regular tracks offer — volume, pan, and the parameters of devices (built-in and hosted plugins) on its chain.
+- **FR-002**: Return automation lanes MUST support the same point editing as regular track lanes (add, move, snap, remove, curves, copy/paste of selected points where tracks support it).
+- **FR-003**: During playback, return automation MUST drive the return's volume, pan and device parameters, and the related controls MUST reflect the automated value.
+- **FR-004**: Return automation MUST be saved with the project, restored on open, and its edits MUST be undoable like track automation edits.
+- **FR-005**: Master-volume automation MUST keep working unchanged at every master row height.
+- **FR-006**: Users MUST be able to resize each return row and the master row by dragging its bottom edge, within the track height limits (30–256 px) and with the same preset snapping as track rows.
+- **FR-007**: The context menu of a return or master row MUST offer "Track height" → Compact / Standard / Large (30 / 64 / 128 px), marking the current one, applying to the selected returns when several are selected.
+- **FR-008**: Double-clicking a return's or the master's bottom edge MUST reset it to Compact.
+- **FR-009**: Return and master headers MUST pick their layout from their height with the same compact / standard / large rules as track headers; no control may be clipped or overlap at any height or track-list width within the limits.
+- **FR-010**: The footer lanes (automation, grid, loop wash, playhead, browser drop highlight) MUST draw at each row's own height.
+- **FR-011**: Return and master heights MUST be saved with the project and restored on open.
+- **FR-012**: New projects, newly added returns, and projects without stored return/master heights MUST show returns and master at the Compact height (30 px). Regular tracks keep Standard as their default.
+- **FR-013**: Existing footer interactions (selecting a return/master, its context menu, browser drag-and-drop onto a return or master, the track-list width seam) MUST keep working; the resize zone is limited to a thin band at the row seam.
+- **FR-014**: The new handles and layouts MUST follow `DESIGN.md` (Studio): neutral seams, no new accent use.
+- **FR-015**: The pinned footer MUST NOT grow beyond about half the arrangement's visible height; when its rows add up to more, the footer MUST scroll vertically (headers and lanes together), leaving the track list its space.
+- **FR-016**: The "all tracks" height gestures (Alt-drag on a track edge, the "all tracks" preset) MUST resize regular tracks only and leave return and master heights unchanged.
+
+### Key Entities
+
+- **Return / master row height**: per return and one for the master; Compact when absent. Stored with the project like track heights.
+- **Return automation lane**: the same kind of lane a regular track has (target + points), owned by the return.
+- **Master volume automation**: unchanged graph-level lane edited in the master row.
+
+## Success Criteria *(mandatory)*
+
+### Measurable Outcomes
+
+- **SC-001**: A user can draw a return volume ramp and a return device-parameter ramp and hear both on playback, with no per-send workaround.
+- **SC-002**: Every return and the master can be set to each of the three presets with one context-menu pick, and to any height in the limits with one drag.
+- **SC-003**: With default settings, a project with two returns uses less footer height than today (2 × 30 + 30 = 90 px instead of 120 px).
+- **SC-004**: Return lanes and return/master heights survive save/reopen in 100% of cases; projects from previous versions open with returns and master at Compact and no data loss.
+- **SC-005**: At every height and track-list width within the limits, no return or master header control is clipped or overlaps another (verified by screenshots at Compact, Standard, Large).
+
+## Assumptions
+
+- The engine already stores and applies automation lanes on return tracks (a return is a track of type Return and the automation pass visits all tracks); the work is the managed UI plus a smoke check. If the plan finds an engine gap, it is fixed within this feature.
+- The master row keeps only master-volume automation; master device-parameter or pan automation is out of scope.
+- "Compact by default" applies to returns and master only; regular track defaults are unchanged.
+- The return and master rows stay in the pinned footer (they do not move into the scrolling track list).
+- The new mouse gestures on footer rows are the same as on track rows, so Preferences → Shortcuts only needs a wording check (nota-shortcuts skill).
+
+## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*
+
+- [ ] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md)
+- [x] No new dependency — or: license checked, AGPL-compatible, `LICENSES/third-party.md` row planned
+- [x] Audio-thread impact considered: no alloc / lock / I/O on the audio thread (AR-6), command queue for data in (AR-4), immutable snapshots for structural edits (AR-5) — reuses the existing automation path; no new audio-thread work expected
+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/` — existing automation ABI is reused
+- [ ] Smoke-test impact assessed: engine behaviour change → extend `tests/Nota.SmokeTest` (add a return-automation check)
+- [ ] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned (and FEATURES.md / user docs via the nota-features / nota-docs skills when working with an agent that has them)
+- [ ] UI change → follows `DESIGN.md` (Studio design language)
diff --git a/specs/045-return-master-lanes/tasks.md b/specs/045-return-master-lanes/tasks.md
new file mode 100644
index 00000000..ea9487fe
--- /dev/null
+++ b/specs/045-return-master-lanes/tasks.md
@@ -0,0 +1,243 @@
+---
+
+description: "Tasks: automation and resizable height for return and master rows"
+---
+
+# Tasks: Automation and resizable height for return and master rows
+
+**Input**: Design documents from `specs/045-return-master-lanes/`
+
+**Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md), [data-model.md](data-model.md), [contracts/](contracts/), [quickstart.md](quickstart.md)
+
+**Tests**: One smoke check (plan § Testing, constitution IV) locks in the engine's existing
+return-automation behaviour. UI behaviour is verified with [quickstart.md](quickstart.md)
+scenarios and headless screenshots.
+
+**Organization**: Tasks are grouped by user story so each story can be implemented and tested on its own.
+
+## Format: `[ID] [P?] [Story] Description`
+
+- **[P]**: Can run in parallel (different files, no dependencies)
+- **[Story]**: Which user story this task belongs to (US1, US2, US3)
+
+All app paths are under `src/managed/Nota.App/`. Nearly every task edits one of the
+`ArrangementView.*.cs` partials, so few tasks are parallel.
+
+---
+
+## Phase 1: Setup
+
+- [X] T001 Create branch `045-return-master-lanes` off `develop` (the plan setup did not switch branches)
+
+---
+
+## Phase 2: Foundational (Blocking Prerequisites)
+
+**Purpose**: Footer rows get real per-row geometry instead of `row * FooterRowH`. Both the return lane editor (US1) and resizing (US2) depend on it.
+
+- [X] T002 In `src/managed/Nota.App/ArrangementView.Sizing.cs` add the per-kind default: `internal const double DefaultFooterRowHeight = CompactRowHeight;` and `DefaultHeightFor(int trackId)`, which returns 30 for a return (look up in `_returns`) and 64 otherwise. Make `StoredRowHeight` and `StoreRowHeight` use it: an entry equal to its row's default is removed. Add `private double _masterHeight = DefaultFooterRowHeight;`. Keep `AllTrackRowIds()` excluding returns (FR-016). Prune heights of returns that no longer exist: `PruneTrackHeights` must keep live return ids too, so build `alive` from every engine track, returns included.
+- [X] T003 In `src/managed/Nota.App/ArrangementView.cs` replace `FooterRowH` with footer geometry:
+ - add `double[] _footerRowTops` (length `_returns.Count + 2`), rebuilt by a `RebuildFooterGeometry()`;
+ - add helpers `FooterRowTop(i)`, `FooterRowHeight(i)` (returns: `StoredRowHeight(id)`; master, i == `_returns.Count`: `_masterHeight`) and `FooterContentHeight`;
+ - call `RebuildFooterGeometry()` from `Refresh()` before `RebuildFooterHeaders()`, and set `_footer.Height` / `_footerHeaders.Height` from `FooterContentHeight` (replacing `(_returns.Count + 1) * FooterRowH`);
+ - rewrite `FooterRowAt(y)` to search `_footerRowTops`;
+ - `SetFooterDropRow` positions `_footerDropRing` with `FooterRowTop(row)` / `FooterRowHeight(row)`;
+ - `BuildSlimRow` takes the row height instead of `FooterRowH`, and `RebuildFooterHeaders` advances `y` by `FooterRowHeight(i)`.
+- [X] T004 In `src/managed/Nota.App/ArrangementView.Controls.cs` make `FooterLaneControl` use the geometry: `MasterRowTop` → `_o.FooterRowTop(_o._returns.Count)`; `MasterValueToY` / `MasterYToValue` use the master row height; `Render` fills and draws the seam lines per row from `_footerRowTops`, as do the master hint text, the master curve and the drop highlight. Remove the `FooterRowH` constant once nothing references it.
+
+**Checkpoint**: Footer renders exactly as before (each row now 30 px by default, see US3). Browser drops onto returns and master still land on the right row.
+
+---
+
+## Phase 3: User Story 1 - Automate a return track (Priority: P1) 🎯 MVP
+
+**Goal**: Return rows in automation mode show a target pill and an editable lane identical to a track lane; playback follows; lanes save and undo.
+
+**Independent Test**: [quickstart.md](quickstart.md) scenarios 3–7 and 17.
+
+### Test for User Story 1
+
+- [X] T005 [P] [US1] Add `tests/Nota.SmokeTest/ReturnAutomationTests.cs` (SPDX header) and register it where the other smoke test classes are invoked. The test should:
+ - add an audio/instrument source with a send to a new return;
+ - `AddAutomationLane(returnId, AutomationTarget.Volume, -1, -1)` and set points ramping 0 → 1 over 4 beats;
+ - render a block near beat 0 and one near beat 4 and assert the return's meter / master level is lower at the start (use a deterministic WAV clip, not a synth note, per agent memory `smoke-level-tests`);
+ - save the project to a temp bundle, reload it, and assert `AutomationLaneCount(returnId) == 1` with the same points;
+ - repeat with a `DeviceParam` lane on a device on the return.
+
+### Implementation for User Story 1
+
+- [X] T006 [US1] Create `src/managed/Nota.App/ArrangementView.AutoEditor.cs` (SPDX header plus a comment on why it exists: one automation editor shared by the track lanes and the footer return lanes). Define a nested `IAutoRows` host interface:
+ - `int Count`, `TrackVM TrackAt(int i)`, `double Top(int i)`, `double Height(int i)`, `int RowAtY(double y)`;
+ - `bool Editable(int i)` (false for slim group bars);
+ - `Control Owner`, `(int lo, int hi) VisibleRange`.
+
+ Then define `sealed class AutoEditor`, holding the state and logic now inside `LaneControl`:
+ - state: `_autoDrag`, `_autoDragTrack`, `_autoDragLo/Hi`, `_autoDragStartVal`, `_bendLeft/_bendRight/_bendTrack`, `_rangeTrack/_rangeAnchor`, `_autoLiveStarted`, `_hoverPoint/_hoverSegLeft/_hoverTrack`;
+ - logic: `PillWidth`, `PillRect`, `ValueToY`, `YToValue`, `AutoPointerPressed`, `HitSegment`, `AutoBendMoved`, `AutoPointerMoved`, `CommitAutoDuringDrag`, `AutoPointerReleased`, `ShowAutoMenu`, hover handling and `DrawAutomation`.
+
+ Every `_o._tracks[i]`, `RowTop(i)`, `RowH(i)`, `_o.RowAtY`, `_o.VisibleRowRange()`, `_o.IsSlimRowAt(i)` becomes a host call. Move the code; don't change behaviour.
+- [X] T007 [US1] In `src/managed/Nota.App/ArrangementView.LaneControl.cs` implement `IAutoRows` over `_tracks` / `_rowTops`, hold one `AutoEditor`, and delegate the automation-mode branches of `OnPointerPressed` / `OnPointerMoved` / `OnPointerReleased` / `OnPointerExited` / `Render`, plus `IsEditingPoint`, to it. Delete the moved members. Build, then run quickstart scenario 17 (track automation unchanged) before going on.
+- [X] T008 [US1] In `src/managed/Nota.App/ArrangementView.Controls.cs` give `FooterLaneControl` an `IAutoRows` over `_returns`: `Top` / `Height` come from the T003 geometry, `RowAtY` returns only return rows (the master is excluded), `Editable` is always true. Add an `AutoEditor` instance, and in automation mode:
+ - route pointer events to the editor for return rows and keep the existing master-volume handler for the master row;
+ - draw the return lanes with `AutoEditor.DrawAutomation` (scrim, curve, points, range band, target pill) on top of the row backgrounds and grid, below loop wash and playhead.
+
+ Outside automation mode, draw a quiet label on return rows, as the master row does today.
+- [X] T009 [US1] In `src/managed/Nota.App/ArrangementView.Automation.cs` make sure every path that looks up a `TrackVM` by id also searches `_returns`. Today only `OnAutomationTouched` does. Check `ShowAutoTargetMenu`, the range clipboard (`CopyAutoSelection` / paste / delete targets via `_autoSelTrack`), `RemapAutoTargets` callers and `Redraw()`, so the footer is invalidated (`_footerLanes.InvalidateVisual()`) whenever track lanes are. The target menu for a return lists Volume, Pan and the return's device chain (built-in, plugin, nested). Nothing is offered for MIDI-FX or the instrument, since returns have neither.
+- [X] T010 [US1] Live sync: in `src/managed/Nota.App/ArrangementView.cs` the footer return fader / dB readout (`_footerFaders`, `_footerDb`) must follow automated volume during playback the way track header faders do. Find the meter/fader poll that updates track headers and extend it to return rows, so the related controls reflect the automated value (FR-003).
+- [X] T011 [US1] Verify FR-004: a return point edit makes one undo step, like a track edit (`CommitAuto` → `SetAutomationPoints`). Undo / redo, then `Refresh()`, must reload return `AutoPoints` (`Refresh` already calls `LoadAutoPoints` for returns; confirm the footer redraws). Fix any gap in `src/managed/Nota.App/ArrangementView.cs`.
+
+**Checkpoint**: Return automation works end to end; track automation unchanged; smoke test green.
+
+---
+
+## Phase 4: User Story 2 - Resize return and master rows (Priority: P1)
+
+**Goal**: Return and master rows resize by seam drag and through the context menu; headers adapt; the footer caps at about half the height and scrolls; heights persist.
+
+**Independent Test**: [quickstart.md](quickstart.md) scenarios 8–16.
+
+- [X] T012 [US2] In `src/managed/Nota.App/ArrangementView.Sizing.cs` add the footer resize path: `BeginFooterResize(int footerRow, double y)`, `UpdateFooterResize(double y)` and `EndFooterResize()`. Targets: the dragged return, or the selected returns when it is one of several selected (`SelectedTrackIds()` ∩ returns), or the master alone. Alt is ignored (FR-016). Height = `SnapRowHeight(start + dy)`, written with `StoreRowHeight` or to `_masterHeight`. Each frame does `RebuildFooterGeometry()` + `RebuildFooterHeaders()` + `_footerLanes.InvalidateVisual()` (5 rows max). Add `ResetFooterRowHeight(int footerRow)`, which sets the targets back to 30, and `SetFooterHeights(IEnumerable<int> returnIds, bool master, double h)`.
+- [X] T013 [US2] In `src/managed/Nota.App/ArrangementView.cs` / `ArrangementView.Sizing.cs` add header-side seam grips on `_footerHeaders`, one per footer row at its bottom edge, built like `RowSeamGrip`:
+ - 6 px band, `SizeNorthSouth` cursor, `Brush.BorderStrong` line on hover;
+ - wired to the T012 methods, with double-click resetting the row;
+ - added at the end of `RebuildFooterHeaders()` above the cards.
+- [X] T014 [US2] In `src/managed/Nota.App/ArrangementView.Controls.cs` add the lane-side seam band to `FooterLaneControl`: within ±3 px of a row bottom, set the `SizeNorthSouth` cursor on hover, start the T012 resize on press (before the automation / master handlers), and reset on double-click.
+- [X] T015 [US2] In `src/managed/Nota.App/ArrangementView.Tracks.cs` add a `TrackHeightRow` overload / flag with no all-tracks modifier. Its handler ignores `all` and calls `SetFooterHeights`, and it marks the current preset from the footer heights. In `src/managed/Nota.App/ArrangementView.cs` `ShowFooterMenu`, add this "Height" row as its own group: for a return, it targets the selected returns when the clicked one is selected, else that return; for the master, the master.
+- [X] T016 [US2] In `src/managed/Nota.App/ArrangementView.cs` make `BuildSlimRow` tier-aware, using `TierFor(height)` per [research.md R5](research.md):
+ - **Compact**: one line with spine, name, mini fader, dB and meter. When the column is narrow, the fader shrinks first, then the dB readout is dropped.
+ - **Standard**: today's two-line layout, vertically centred, plus an "M" `ChipToggle` for returns (`SetTrackMute`).
+ - **Large**: standard plus a pan control row for returns, with the same pan control as track headers (one undo step per gesture via `MixGesture` with `MixTarget.Pan(id)`). The master keeps standard content.
+
+ No control may be clipped or overlap at widths 160–480 px.
+- [X] T017 [US2] In `src/managed/Nota.App/ArrangementView.cs` wrap `_footer` in a vertical `ScrollViewer` (`_footerScroller`, horizontal scrolling disabled, thin scrollbar matching the track scroller) docked at the bottom in place of `_footer`. Set its `MaxHeight` to `Math.Floor(0.5 * (footer area + centerArea height))` and recompute it in `OnViewSizeChanged` and after footer geometry changes. The footer seam and drag-drop handlers stay on `_footer`. Wheel over footer lanes scrolls the footer vertically when it overflows (FR-015).
+- [X] T018 [US2] In `src/managed/Nota.App/ArrangementView.Sizing.cs` extend the sidecar per [contracts/track-view-sidecar.md](contracts/track-view-sidecar.md):
+ - `TrackViewDto` gets `[JsonPropertyName("masterHeight")] double? MasterHeight`;
+ - `SaveTrackView` writes return heights via the existing loop (entries are only present when they differ from the 30 default) and writes `MasterHeight` when `_masterHeight` ≠ 30. The file is deleted when everything is at its default;
+ - `LoadTrackView` accepts return entries (drop the `!ti.IsReturn` filter) and reads `MasterHeight` clamped to [30, 256];
+ - `ResetTrackView` sets `_masterHeight = 30`;
+ - keep `version: 1`.
+
+**Checkpoint**: Footer rows resize by drag and menu, headers adapt, the footer scrolls past the cap, and the layout survives save/reopen.
+
+---
+
+## Phase 5: User Story 3 - Compact by default (Priority: P2)
+
+**Goal**: New projects, new returns and old projects show returns and master at 30 px.
+
+**Independent Test**: [quickstart.md](quickstart.md) scenarios 1–2.
+
+- [X] T019 [US3] Confirm that the T002/T018 defaults give Compact everywhere:
+ - a new project (`ResetTrackView`);
+ - `AddReturnTrack` from the UI (no stored entry → 30);
+ - an old bundle without return entries or `masterHeight`;
+ - undo of a return delete brings the return back at 30 (ids change, so no stale entry).
+
+ Regular tracks still default to 64. Fix any path in `src/managed/Nota.App/ArrangementView.Sizing.cs` that assumes `DefaultRowHeight` for every row.
+
+**Checkpoint**: All three stories work.
+
+---
+
+## Phase 6: Polish & Cross-Cutting Concerns
+
+- [X] T020 Run every [quickstart.md](quickstart.md) scenario and take headless screenshots of return / master headers at 30 / 61 / 62 / 111 / 112 / 256 px × widths 160 / 228 / 480 (agent memory `nota-ui-verify`); fix clipping or overlaps
+- [X] T021 Check the new handles and layouts against `DESIGN.md` with the `nota-design` skill: neutral seams, no new accent use, sentence-case labels
+
+### Nota closing tasks *(always include — these are the PR gates)*
+
+- [X] T022 Run `scripts/build.sh` until native + managed + smoke test (including `ReturnAutomationTests`) are green
+- [X] T023 AGPL-3.0-only SPDX two-line header on `src/managed/Nota.App/ArrangementView.AutoEditor.cs` and `tests/Nota.SmokeTest/ReturnAutomationTests.cs`
+- [X] T024 New dependency: N/A
+- [X] T025 `CHANGELOG.md` `[Unreleased]` → Added: automation lanes on return tracks; resizable return / master rows with Compact / Standard / Large; Changed: return and master rows are compact by default
+- [X] T026 `FEATURES.md` via the `nota-features` skill; user docs (arrangement, automation, mixing / returns pages, EN + RU) via `nota-docs`; Preferences → Shortcuts wording for the row-seam gestures ("track, return or master") via `nota-shortcuts`
+- [X] T027 Smoke test extended for return automation (T005). No other engine behaviour changed.
+
+---
+
+## Dependencies & Execution Order
+
+### Phase Dependencies
+
+- **Setup (T001)** → **Foundational (T002–T004)** → user stories.
+- **US1** (T005–T011) and **US2** (T012–T018) both depend on Foundational. Within US1, T006 → T007 → T008 → T009–T011. Within US2, T012 → T013/T014 → T015–T018.
+- **US3** (T019) depends on T002 and T018.
+- **Polish** (T020–T027) after the stories.
+
+### User Story Dependencies
+
+- US1 and US2 are independent of each other; both touch `ArrangementView.Controls.cs` and `ArrangementView.cs`, so run them one after the other, not in parallel.
+- US3 is a verification pass on US2's defaults.
+
+### Parallel Opportunities
+
+- T005 (smoke test, `tests/`) can run alongside T006–T011 (app).
+- T021, T025 and T026 can run in parallel once the code is done.
+
+---
+
+## Parallel Example: User Story 1
+
+```bash
+Task: "Add tests/Nota.SmokeTest/ReturnAutomationTests.cs (return lane render + save/load)"
+Task: "Extract AutoEditor into src/managed/Nota.App/ArrangementView.AutoEditor.cs"
+```
+
+---
+
+## Implementation Strategy
+
+### MVP First (User Story 1)
+
+1. T001–T004: footer geometry (no visible change except the 30 px default).
+2. T005–T011: return automation. **Stop and validate** quickstart 3–7 and 17.
+
+### Incremental Delivery
+
+1. Foundational → US1 (return automation) → validate.
+2. US2 (resizing, scroll, persistence) → validate 8–16.
+3. US3 defaults → validate 1–2.
+4. Polish and PR gates.
+
+---
+
+## Notes
+
+- The T006/T007 extraction is a pure move; check track automation (quickstart 17) before building on it.
+- Heights are view state: never in undo history, never sent to the engine.
+- Commit after each logical group (repo style `(feat) …`); per agent memory, leave commits to the user unless asked.
+
+## Implementation notes (2026-10-28)
+
+- T008: return rows outside automation mode draw no label (the master keeps its "master
+ volume" hint); a per-return hint added noise without telling the user anything new.
+- T012/T014: footer seam drags read the pointer in `ArrangementView` coordinates. The footer
+ is docked to the bottom and grows upwards, so its own coordinates move under the pointer
+ while a row grows; footer-local coordinates made the drag run away. Until the footer hits
+ its cap, the dragged row grows upwards and its bottom edge stays put.
+- T012/T015: returns can't be multi-selected in the footer today (a click selects one), so
+ "the selected returns" is the one selected return in practice. The code takes every
+ multi-selected return, should footer multi-selection arrive.
+- T013: a live footer drag moves the existing cards and grips (a rebuild would drop the grip
+ holding the pointer) and rebuilds a card only when it crosses a layout tier.
+- T020: verified with a headless harness (`/tmp/footerharness`): compact defaults (30/30/30),
+ return lane drawing in automation mode, mixed heights, widths 160/480, the cap (content 768
+ px in a 211 px scroller), a synthetic lane-side seam drag, and the sidecar round trip
+ (`masterHeight` + a return entry). A stale-frame artifact after resizing the headless
+ window disappears on a full redraw — not a layout issue (bounds checked).
+- T026: docs edited in `../nota-docs` (arrangement + automation, EN + RU); the site build was
+ not run here (node is not on PATH). No new screenshots.
+
+## Phase 7: Convergence
+
+- [X] T028 Let return rows join a multi-selection in the footer (⇧-click / ⌘-click on a return header in `src/managed/Nota.App/ArrangementView.cs` `BuildSlimRow`, adding to `_selTracks` as track headers do), so a seam drag or a Height preset on one selected return resizes every selected return per US2/AC3 and FR-007 (partial)
+- [X] T029 Finish the header screenshot matrix for return and master rows at 30 / 61 / 62 / 111 / 112 / 256 px × widths 160 / 228 / 480 with `/tmp/footerharness`, and fix any clipped or overlapping control per SC-005 and FR-009 (partial)
+
+### Convergence notes (2026-10-28)
+
+- T028: ⌘/Ctrl-click a return header adds or removes it, ⇧-click takes the range from the
+ selected return; a return selection never mixes with tracks (track commands stay
+ track-only). Verified in `/tmp/footerharness matrix`: two selected returns resize together
+ from one preset.
+- T029: headers shot at 30 / 61 / 62 / 111 / 112 / 256 px × 160 / 228 / 480 px with an
+ automated bounds check of every text, fader and pan inside its card — nothing clipped.
diff --git a/src/managed/Nota.App/ArrangementView.AutoEditor.cs b/src/managed/Nota.App/ArrangementView.AutoEditor.cs
new file mode 100644
index 00000000..47062575
--- /dev/null
+++ b/src/managed/Nota.App/ArrangementView.AutoEditor.cs
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Arrangement · automation lane editor (specs/045-return-master-lanes). One editor for every
+// row that shows an automation lane — the scrolling track lanes and the pinned return rows in
+// the footer — so a return's lane edits exactly like a track's: target pill, points, snap,
+// fine drag, curve bends, range selection and its clipboard. The editor owns the gesture state
+// and drawing; the control hosting it supplies the rows through IAutoRows.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Media;
+using Nota.Presentation;
+
+namespace Nota.App;
+
+public sealed partial class ArrangementView
+{
+ /// <summary>The rows an <see cref="AutoEditor"/> edits, in its owner's coordinates.</summary>
+ private interface IAutoRows
+ {
+ Control Owner { get; }
+ int RowAtY(double y); // row under y, or -1
+ TrackVM TrackAt(int i);
+ int IndexOf(TrackVM t); // -1 when the track is no longer a row here
+ double Top(int i);
+ double Height(int i);
+ bool Editable(int i); // false for a row with no room for an envelope
+ (int lo, int hi) VisibleRange { get; }
+ }
+
+ private sealed class AutoEditor
+ {
+ private readonly ArrangementView _o;
+ private readonly IAutoRows _rows;
+ private readonly Control _owner;
+ public AutoEditor(ArrangementView o, IAutoRows rows) { _o = o; _rows = rows; _owner = rows.Owner; }
+
+ /// <summary>A point drag, curve bend or range selection is live.</summary>
+ internal bool IsActive => _autoDrag is not null || _bendLeft is not null || _rangeTrack is not null;
+
+ /// <summary>Drop a live gesture (capture lost / cancel). False when nothing was live.</summary>
+ internal bool Cancel()
+ {
+ if (!IsActive) return false;
+ _autoDrag = null; _autoDragTrack = null; _bendLeft = _bendRight = null; _bendTrack = null;
+ _rangeTrack = null;
+ _autoLiveStarted = false; // the next drag checkpoints undo again
+ return true;
+ }
+
+ // Automation editing (M9-A3).
+ private AutoPt? _autoDrag;
+ private TrackVM? _autoDragTrack;
+ private double _autoDragLo, _autoDragHi; // neighbour beats — a point can't be dragged past them (req 8.2.3)
+ private float _autoDragStartVal; // value at grab (for Shift fine-mode, req 8.2.2)
+ private AutoPt? _bendLeft, _bendRight; // segment being bent (M9-D)
+ private TrackVM? _bendTrack;
+ // While dragging/bending, the engine lane is updated live (no undo) so the device
+ // follows in real time; the first update checkpoints undo once, the rest are raw.
+ private bool _autoLiveStarted;
+ private AutoPt? _hoverPoint; // point / segment-left under the cursor (hover feedback)
+ private AutoPt? _hoverSegLeft;
+ private TrackVM? _hoverTrack;
+ private TrackVM? _rangeTrack; // Shift-drag time-range selection in progress (Phase 2)
+ private double _rangeAnchor;
+ internal bool IsEditingPoint => _autoDrag != null || _bendLeft != null; // M9-C/D: don't clobber a hand-edit
+
+ // Target-selector pill: width fits its label so nothing clips.
+ private const double PillH = 16;
+ private static double PillWidth(string label)
+ {
+ var ft = new FormattedText(label, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
+ Typeface.Default, 9, NotaPalette.TextPrimary);
+ return Math.Clamp(Math.Ceiling(ft.Width) + 12, 34, 180);
+ }
+ private Rect PillRect(int i, double w) => new(4, _rows.Top(i) + 3, w, PillH);
+ private double ValueToY(TrackVM t, int row, float v)
+ {
+ var (min, max) = _o.AutoRange(t);
+ double top = _rows.Top(row) + 8, bot = _rows.Top(row) + _rows.Height(row) - 8;
+ double frac = max > min ? Math.Clamp((v - min) / (max - min), 0, 1) : 0.5;
+ return bot - frac * (bot - top);
+ }
+ private float YToValue(TrackVM t, int row, double py)
+ {
+ var (min, max) = _o.AutoRange(t);
+ double top = _rows.Top(row) + 8, bot = _rows.Top(row) + _rows.Height(row) - 8;
+ double frac = Math.Clamp((bot - py) / (bot - top), 0, 1);
+ return (float)(min + frac * (max - min));
+ }
+
+ // --- automation editing (M9-A3) ------------------------------------
+ internal void AutoPointerPressed(PointerPressedEventArgs e)
+ {
+ var pt = e.GetCurrentPoint(_owner);
+ var pos = pt.Position;
+ int i = _rows.RowAtY(pos.Y);
+ if (i < 0) return;
+ var t = _rows.TrackAt(i);
+
+ double pillW = PillWidth(t.AutoLabel);
+ if (PillRect(i, pillW).Contains(pos)) { _o.ShowAutoTargetMenu(_owner, t); return; }
+
+ double curBeat = Math.Max(0, _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers));
+
+ // Point under the cursor? (7px grab radius). Detected first so Shift can mean
+ // "fine-drag this point" (req 8.2.2) rather than always starting a range select.
+ AutoPt? hit = null;
+ foreach (var p in t.AutoPoints)
+ {
+ double dx = _o.BeatToX(p.Beat) - pos.X;
+ double dy = ValueToY(t, i, p.Value) - pos.Y;
+ if (dx * dx + dy * dy <= 49) { hit = p; break; }
+ }
+
+ bool right = pt.Properties.IsRightButtonPressed;
+ bool dbl = e.ClickCount == 2;
+
+ // Shift + left-drag authors a time-range selection (Phase 2) — including when the
+ // drag starts on a point, so a range bounded by points is selectable. Fine-drag of a
+ // point is still available by holding Shift *during* an already-started drag.
+ if ((e.KeyModifiers & KeyModifiers.Shift) != 0 && !right)
+ {
+ _rangeTrack = t; _rangeAnchor = curBeat;
+ _o.SetAutoSelection(t, curBeat, curBeat);
+ e.Pointer.Capture(_owner);
+ return;
+ }
+
+ if (hit is not null)
+ {
+ // On a point: right-click or double-click removes it; a single press grabs it to drag.
+ if (right || dbl) { t.AutoPoints.Remove(hit); _o.CommitAuto(t); _owner.InvalidateVisual(); return; }
+ // else: grab the existing point (drag logic below).
+ }
+ else
+ {
+ var seg = HitSegment(t, i, pos);
+ // Right-click resets a segment's curve, else opens the range menu.
+ if (right)
+ {
+ if (seg is { } sr) { sr.left.Curve = 0f; _o.CommitAuto(t); _owner.InvalidateVisual(); }
+ else ShowAutoMenu(t, curBeat);
+ return;
+ }
+ // Alt+drag on a segment bends it (M9-D).
+ if (seg is { } sg && (e.KeyModifiers & KeyModifiers.Alt) != 0)
+ {
+ _bendLeft = sg.left; _bendRight = sg.right; _bendTrack = t;
+ e.Pointer.Capture(_owner);
+ return;
+ }
+ if (dbl)
+ {
+ // Double-click adds a breakpoint at the cursor, then grabs it for immediate drag.
+ _o.ClearAutoSelection();
+ hit = new AutoPt { Beat = curBeat, Value = YToValue(t, i, pos.Y) };
+ t.AutoPoints.Add(hit);
+ }
+ else
+ {
+ // Single click: behave like the arrangement — move the playhead when stopped, do
+ // nothing while playing. Points come from double-clicking, never a single click.
+ _o.ClearAutoSelection();
+ if (_o._engine is not { IsPlaying: true })
+ _o.SeekTo(_o._scrollBeats + pos.X / _o._pixelsPerBeat);
+ return;
+ }
+ }
+
+ // Grab the point (existing on a single press, or the one just double-click-added) to drag.
+ _autoDrag = hit;
+ _autoDragTrack = t;
+ _autoDragStartVal = hit!.Value;
+ // Neighbour bounds: the point can't be dragged past its neighbours in time (req 8.2.3).
+ _autoDragLo = 0; _autoDragHi = double.MaxValue;
+ foreach (var p in t.AutoPoints)
+ {
+ if (ReferenceEquals(p, hit)) continue;
+ if (p.Beat <= hit.Beat) _autoDragLo = Math.Max(_autoDragLo, p.Beat);
+ else _autoDragHi = Math.Min(_autoDragHi, p.Beat);
+ }
+ e.Pointer.Capture(_owner);
+ _owner.InvalidateVisual();
+ }
+
+ // The (left,right) points of the segment whose curve line is under `pos`, or null.
+ private (AutoPt left, AutoPt right)? HitSegment(TrackVM t, int row, Point pos)
+ {
+ var ordered = t.AutoPoints.OrderBy(p => p.Beat).ToList();
+ double beat = _o._scrollBeats + pos.X / _o._pixelsPerBeat;
+ for (int k = 1; k < ordered.Count; k++)
+ {
+ var a = ordered[k - 1]; var b = ordered[k];
+ if (beat < a.Beat || beat > b.Beat) continue;
+ double span = b.Beat - a.Beat;
+ if (span <= 0) return null;
+ double tt = (beat - a.Beat) / span;
+ double vy = a.Value + (b.Value - a.Value) * Shape(tt, a.Curve);
+ double cy = ValueToY(t, row, (float)vy);
+ return Math.Abs(cy - pos.Y) <= 6 ? (a, b) : null;
+ }
+ return null;
+ }
+
+ private void AutoBendMoved(Point pos)
+ {
+ if (_bendLeft is null || _bendRight is null || _bendTrack is null) return;
+ int i = _rows.IndexOf(_bendTrack);
+ if (i < 0) return;
+ float v0 = _bendLeft.Value, v1 = _bendRight.Value;
+ if (Math.Abs(v1 - v0) < 1e-4f) { _bendLeft.Curve = 0f; _owner.InvalidateVisual(); return; }
+ double val = YToValue(_bendTrack, i, pos.Y);
+ double frac = Math.Clamp((val - v0) / (v1 - v0), 0.02, 0.98);
+ // Solve Shape(0.5, curve) == frac -> 0.5^e = frac -> e = ln(frac)/ln(0.5).
+ double e = Math.Log(frac) / Math.Log(0.5);
+ _bendLeft.Curve = (float)Math.Clamp(-Math.Log2(e) / 4.0, -1.0, 1.0);
+ CommitAutoDuringDrag(_bendTrack); // engine follows the curve bend live
+ _owner.InvalidateVisual();
+ }
+
+ // Hover feedback (M9-D): highlight the point or segment under the cursor.
+ internal void UpdateHover(Point pos)
+ {
+ AutoPt? pt = null, seg = null; TrackVM? tr = null;
+ int i = _rows.RowAtY(pos.Y);
+ if (i >= 0)
+ {
+ var t = _rows.TrackAt(i);
+ foreach (var p in t.AutoPoints)
+ {
+ double dx = _o.BeatToX(p.Beat) - pos.X, dy = ValueToY(t, i, p.Value) - pos.Y;
+ if (dx * dx + dy * dy <= 49) { pt = p; break; } // 7px, matches grab radius
+ }
+ if (pt is null && HitSegment(t, i, pos) is { } sg) seg = sg.left;
+ if (pt is not null || seg is not null) tr = t;
+ }
+ if (!ReferenceEquals(pt, _hoverPoint) || !ReferenceEquals(seg, _hoverSegLeft) || !ReferenceEquals(tr, _hoverTrack))
+ {
+ _hoverPoint = pt; _hoverSegLeft = seg; _hoverTrack = tr;
+ _owner.InvalidateVisual();
+ }
+ }
+
+ internal void ClearHover()
+ {
+ if (_hoverPoint is null && _hoverSegLeft is null) return;
+ _hoverPoint = null; _hoverSegLeft = null; _hoverTrack = null;
+ _owner.InvalidateVisual();
+ }
+
+ internal void AutoPointerMoved(PointerEventArgs e)
+ {
+ if (_rangeTrack is not null)
+ {
+ double beat = Math.Max(0, _o.Snap(_o._scrollBeats + e.GetPosition(_owner).X / _o._pixelsPerBeat));
+ _o.SetAutoSelection(_rangeTrack, _rangeAnchor, beat);
+ return;
+ }
+ if (_bendLeft is not null) { AutoBendMoved(e.GetPosition(_owner)); return; }
+ if (_autoDrag is null || _autoDragTrack is null) { UpdateHover(e.GetPosition(_owner)); return; }
+ int i = _rows.IndexOf(_autoDragTrack);
+ if (i < 0) return;
+ var pos = e.GetPosition(_owner);
+ // Time: snapped (Alt bypasses), clamped between neighbour points — no reordering (8.2.3).
+ double cand = Math.Max(0, _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers));
+ _autoDrag.Beat = Math.Clamp(cand, _autoDragLo, _autoDragHi);
+ // Value: free, but Shift = fine-mode (quarter sensitivity, anchored at the grab value, 8.2.2).
+ float full = YToValue(_autoDragTrack, i, pos.Y);
+ _autoDrag.Value = (e.KeyModifiers & KeyModifiers.Shift) != 0
+ ? _autoDragStartVal + (full - _autoDragStartVal) * 0.25f
+ : full;
+ CommitAutoDuringDrag(_autoDragTrack); // engine follows live (device updates at the playhead)
+ _owner.InvalidateVisual();
+ }
+
+ // First push of a drag checkpoints undo (CommitAuto); the rest are raw (CommitAutoLive),
+ // so a whole drag is one undo step while the device follows in real time.
+ private void CommitAutoDuringDrag(TrackVM t)
+ {
+ if (!_autoLiveStarted) { _o.CommitAuto(t); _autoLiveStarted = true; }
+ else _o.CommitAutoLive(t);
+ }
+
+ internal void AutoPointerReleased(PointerReleasedEventArgs e)
+ {
+ if (_rangeTrack is not null)
+ {
+ // A zero-width drag (Shift-click, no move) is a deselect, not a selection.
+ if (_o._autoSelEnd - _o._autoSelStart <= 1e-6) _o.ClearAutoSelection();
+ _rangeTrack = null;
+ e.Pointer.Capture(null);
+ return;
+ }
+ if (_bendLeft is not null && _bendTrack is not null)
+ {
+ // Final state: a live drag already checkpointed at its start, so commit raw;
+ // a no-move press (shouldn't happen for bend) still gets a normal undo commit.
+ if (_autoLiveStarted) _o.CommitAutoLive(_bendTrack); else _o.CommitAuto(_bendTrack);
+ _autoLiveStarted = false;
+ _bendLeft = _bendRight = null; _bendTrack = null;
+ e.Pointer.Capture(null);
+ _owner.InvalidateVisual();
+ return;
+ }
+ if (_autoDrag is null || _autoDragTrack is null) return;
+ if (_autoLiveStarted) _o.CommitAutoLive(_autoDragTrack); else _o.CommitAuto(_autoDragTrack);
+ _autoLiveStarted = false;
+ _autoDrag = null;
+ _autoDragTrack = null;
+ e.Pointer.Capture(null);
+ _owner.InvalidateVisual();
+ }
+
+ // Automation-mode right-click: copy/cut/delete the selected time range and paste the
+ // range clipboard at the cursor (Phase 2). Copy/Cut/Delete need a selection on this
+ // track; Paste needs a filled clipboard.
+ private void ShowAutoMenu(TrackVM t, double beat)
+ {
+ bool hasSel = _o.HasAutoSelection && ReferenceEquals(_o._autoSelTrack, t);
+ var flyout = new MenuFlyout();
+ var copy = MenuKit.Item("Copy automation", GlyphKind.Copy, () => _o.CopyAutoSelection(), MenuKit.CopyKey, hasSel);
+ var cut = MenuKit.Item("Cut automation", GlyphKind.Cut, () => _o.CutAutoSelection(), MenuKit.CutKey, hasSel);
+ var paste = MenuKit.Item("Paste automation", GlyphKind.Paste, () => _o.PasteAutoAt(t, _o.Snap(beat)), MenuKit.PasteKey, _o.HasAutoClip);
+ var del = MenuKit.Danger("Delete automation", GlyphKind.Trash, () => _o.DeleteAutoSelection(), MenuKit.DeleteKey, hasSel);
+ MenuKit.AddGroups(flyout.Items, new Control[] { copy, cut, paste }, new Control[] { del });
+ flyout.ShowAt(_owner, showAtPointer: true);
+ }
+
+ private static readonly IPen AutoCurvePen = new Pen(NotaPalette.VizInk, 1.6);
+
+ internal void DrawAutomation(DrawingContext ctx, double w)
+ {
+ var (rLo, rHi) = _rows.VisibleRange;
+ for (int i = rLo; i <= rHi; i++)
+ {
+ var t = _rows.TrackAt(i);
+ double y = _rows.Top(i);
+ ctx.FillRectangle(AutoScrim, new Rect(0, y, w, _rows.Height(i)));
+ if (!_rows.Editable(i)) continue; // a slim group bar has no room for an envelope
+
+ // Automation: the curve and its points in neutral viz ink; only the
+ // point or segment under the pointer takes the accent.
+ var content = NotaPalette.VizInk;
+ var pen = AutoCurvePen;
+
+ var ordered = t.AutoPoints.OrderBy(p => p.Beat).ToList();
+ if (ordered.Count == 0)
+ {
+ // Empty lane: dashed baseline at the current value (grab to start).
+ double by = ValueToY(t, i, _o.AutoCurrent(t));
+ ctx.DrawLine(AutoBasePen, new Point(0, by), new Point(w, by));
+ }
+ else
+ {
+ double firstX = _o.BeatToX(ordered[0].Beat), firstY = ValueToY(t, i, ordered[0].Value);
+ ctx.DrawLine(pen, new Point(0, firstY), new Point(firstX, firstY)); // left end-hold
+ for (int k = 1; k < ordered.Count; k++)
+ {
+ var a = ordered[k - 1]; var b = ordered[k];
+ var segPen = ReferenceEquals(t, _hoverTrack) && ReferenceEquals(a, _hoverSegLeft) ? AutoHoverPen : pen;
+ double ax = _o.BeatToX(a.Beat), ay = ValueToY(t, i, a.Value);
+ double bx = _o.BeatToX(b.Beat), by2 = ValueToY(t, i, b.Value);
+ if (a.Curve == 0f) { ctx.DrawLine(segPen, new Point(ax, ay), new Point(bx, by2)); continue; }
+ // Curved segment: polyline of shaped sub-samples (M9-D).
+ const int steps = 16;
+ var prev = new Point(ax, ay);
+ for (int s = 1; s <= steps; s++)
+ {
+ double tt = s / (double)steps;
+ double vy = a.Value + (b.Value - a.Value) * Shape(tt, a.Curve);
+ var cur = new Point(ax + (bx - ax) * tt, ValueToY(t, i, (float)vy));
+ ctx.DrawLine(segPen, prev, cur);
+ prev = cur;
+ }
+ }
+ double lastX = _o.BeatToX(ordered[^1].Beat), lastY = ValueToY(t, i, ordered[^1].Value);
+ ctx.DrawLine(pen, new Point(lastX, lastY), new Point(w, lastY)); // right end-hold
+ foreach (var p in ordered)
+ {
+ double dx = _o.BeatToX(p.Beat), dy = ValueToY(t, i, p.Value);
+ if (dx < -4 || dx > w + 4) continue;
+ bool ptHover = ReferenceEquals(t, _hoverTrack) && ReferenceEquals(p, _hoverPoint);
+ ctx.DrawEllipse(ptHover ? PlayheadBrush : content, null, new Point(dx, dy), ptHover ? 4.5 : 3.5, ptHover ? 4.5 : 3.5);
+ if (ptHover) ctx.DrawEllipse(null, AutoHoverRing, new Point(dx, dy), 7, 7);
+ }
+ }
+
+ // Range selection band (Phase 2): teal wash + edges over the picked span.
+ if (ReferenceEquals(_o._autoSelTrack, t) && _o._autoSelEnd - _o._autoSelStart > 1e-6)
+ {
+ double sx = _o.BeatToX(_o._autoSelStart), ex = _o.BeatToX(_o._autoSelEnd);
+ double cx0 = Math.Max(0, sx), cx1 = Math.Min(w, ex);
+ if (cx1 > cx0)
+ {
+ double arh = _rows.Height(i);
+ ctx.FillRectangle(AutoSelBand, new Rect(cx0, y, cx1 - cx0, arh));
+ if (sx >= 0) ctx.DrawLine(AutoSelEdge, new Point(sx, y), new Point(sx, y + arh));
+ if (ex <= w) ctx.DrawLine(AutoSelEdge, new Point(ex, y), new Point(ex, y + arh));
+ }
+ }
+
+ // Target-selector pill (top-left) — width fits the label, text centred.
+ double pillW = PillWidth(t.AutoLabel);
+ var pill = PillRect(i, pillW);
+ ctx.DrawRectangle(NotaPalette.SurfaceRaised, null, pill, NotaRadius.ControlValue, NotaRadius.ControlValue);
+ var ft = new FormattedText(t.AutoLabel, CultureInfo.InvariantCulture,
+ FlowDirection.LeftToRight, NotaFonts.SansMedium, 9, NotaPalette.TextPrimary);
+ using (ctx.PushClip(pill))
+ ctx.DrawText(ft, new Point(pill.X + 6, pill.Y + (PillH - ft.Height) / 2));
+ }
+ }
+ }
+}
diff --git a/src/managed/Nota.App/ArrangementView.Controls.cs b/src/managed/Nota.App/ArrangementView.Controls.cs
index d9f8da52..124d6e4f 100644
--- a/src/managed/Nota.App/ArrangementView.Controls.cs
+++ b/src/managed/Nota.App/ArrangementView.Controls.cs
@@ -281,33 +281,72 @@ public sealed partial class ArrangementView
}
// ---- pinned return/master lanes --------------------------------------
- private sealed class FooterLaneControl : Control
+ private sealed class FooterLaneControl : Control, IAutoRows
{
private static readonly IBrush AutomationText = NotaPalette.TextDisabled; // Brush.TextDisabled
private readonly ArrangementView _o;
- public FooterLaneControl(ArrangementView o) { _o = o; ClipToBounds = true; }
+ private readonly AutoEditor _auto; // return rows edit their lanes like tracks (specs/045)
+ public FooterLaneControl(ArrangementView o) { _o = o; ClipToBounds = true; _auto = new AutoEditor(o, this); }
+
+ // The return rows, as the automation editor sees them; the master row below them keeps
+ // its own master-volume editing.
+ Control IAutoRows.Owner => this;
+ int IAutoRows.RowAtY(double y) { int r = _o.FooterRowAt(y); return r < _o._returns.Count ? r : -1; }
+ TrackVM IAutoRows.TrackAt(int i) => _o._returns[i];
+ int IAutoRows.IndexOf(TrackVM t) => _o._returns.IndexOf(t);
+ double IAutoRows.Top(int i) => _o.FooterRowTop(i);
+ double IAutoRows.Height(int i) => _o.FooterRowHeight(i);
+ bool IAutoRows.Editable(int i) => true;
+ (int lo, int hi) IAutoRows.VisibleRange => (0, _o._returns.Count - 1);
+
+ public bool IsEditingPoint => _auto.IsEditingPoint || _mDrag is not null;
private AutoPt? _mDrag; // master-automation point being dragged
- private double MasterRowTop => _o._returns.Count * FooterRowH;
+ private int MasterRow => _o._returns.Count;
+ private double MasterRowTop => _o.FooterRowTop(MasterRow);
+ private double MasterRowH => _o.FooterRowHeight(MasterRow);
+ private double MasterInset => Math.Min(6, MasterRowH * 0.15); // a compact row keeps most of its height for the curve
private double MasterValueToY(float v)
{
- double top = MasterRowTop + 6, bot = MasterRowTop + FooterRowH - 6;
+ double top = MasterRowTop + MasterInset, bot = MasterRowTop + MasterRowH - MasterInset;
double t = (v - ArrangementView.MasterAutoMin) / (ArrangementView.MasterAutoMax - ArrangementView.MasterAutoMin);
return bot - Math.Clamp(t, 0, 1) * (bot - top);
}
private float MasterYToValue(double py)
{
- double top = MasterRowTop + 6, bot = MasterRowTop + FooterRowH - 6;
+ double top = MasterRowTop + MasterInset, bot = MasterRowTop + MasterRowH - MasterInset;
double t = (bot - py) / Math.Max(1, bot - top);
return ArrangementView.MasterAutoMin + (float)Math.Clamp(t, 0, 1) * (ArrangementView.MasterAutoMax - ArrangementView.MasterAutoMin);
}
+ // Lane side of a footer row's bottom seam (specs/045): a thin band that resizes the row,
+ // checked before automation editing so the edge never adds a point.
+ private static readonly Cursor SeamCursor = new(StandardCursorType.SizeNorthSouth);
+ private bool _seamHover;
+
+ private void SetSeamHover(bool on)
+ {
+ if (on == _seamHover) return;
+ _seamHover = on;
+ Cursor = on ? SeamCursor : Cursor.Default;
+ }
+
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
+ var pt = e.GetCurrentPoint(this);
+ int seam = _o.FooterSeamAtY(pt.Position.Y);
+ if (seam >= 0 && pt.Properties.IsLeftButtonPressed)
+ {
+ e.Handled = true;
+ if (e.ClickCount == 2) { _o.ResetFooterRowHeight(seam); return; }
+ _o.BeginFooterResize(seam, e.GetPosition(_o).Y);
+ e.Pointer.Capture(this);
+ return;
+ }
if (!_o._automationMode) return;
var pos = e.GetPosition(this);
- if (pos.Y < MasterRowTop) return; // only the master row is editable
+ if (pos.Y < MasterRowTop) { _auto.AutoPointerPressed(e); return; } // a return row
bool right = e.GetCurrentPoint(this).Properties.IsRightButtonPressed;
double beat = Math.Max(0, _o.Snap(_o._scrollBeats + pos.X / _o._pixelsPerBeat));
@@ -334,7 +373,14 @@ public sealed partial class ArrangementView
protected override void OnPointerMoved(PointerEventArgs e)
{
- if (_mDrag is null) return;
+ if (_o.IsFooterResizing) { _o.UpdateFooterResize(e.GetPosition(_o).Y); return; }
+ if (_mDrag is null && _auto is { IsActive: false })
+ {
+ bool onSeam = _o.FooterSeamAtY(e.GetPosition(this).Y) >= 0;
+ SetSeamHover(onSeam);
+ if (onSeam) { _auto.ClearHover(); return; }
+ }
+ if (_mDrag is null) { if (_o._automationMode) _auto.AutoPointerMoved(e); return; }
var pos = e.GetPosition(this);
_mDrag.Beat = Math.Max(0, _o.Snap(_o._scrollBeats + pos.X / _o._pixelsPerBeat));
_mDrag.Value = MasterYToValue(pos.Y);
@@ -343,12 +389,38 @@ public sealed partial class ArrangementView
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
- if (_mDrag is null) return;
+ if (_o.IsFooterResizing) { e.Pointer.Capture(null); _o.EndFooterResize(); return; }
+ if (_mDrag is null) { if (_o._automationMode) _auto.AutoPointerReleased(e); return; }
_mDrag = null;
e.Pointer.Capture(null);
_o.CommitMasterAuto();
}
+ protected override void OnPointerExited(PointerEventArgs e) { _auto.ClearHover(); SetSeamHover(false); base.OnPointerExited(e); }
+
+ // Like the track lanes, a lost capture never cancels an edit: on macOS it fires before
+ // the button-up that commits it. Esc and a lost window focus cancel through CancelGesture.
+ protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e)
+ {
+ _o.EndFooterResize();
+ base.OnPointerCaptureLost(e);
+ }
+
+ /// <summary>A return-lane edit, a master-volume point drag or a row resize is live.</summary>
+ public bool IsGesturing => _auto.IsActive || _mDrag is not null || _o.IsFooterResizing;
+
+ // Esc / lost window focus: drop a live edit with no model change and reload the lanes
+ // from the engine (a resize keeps the height it reached — heights are view state).
+ internal bool CancelGesture()
+ {
+ if (!IsGesturing) return false;
+ _auto.Cancel();
+ _mDrag = null;
+ _o.EndFooterResize();
+ _o.Refresh();
+ return true;
+ }
+
public override void Render(DrawingContext ctx)
{
double w = Bounds.Width, h = Bounds.Height;
@@ -356,26 +428,29 @@ public sealed partial class ArrangementView
for (int i = 0; i < rows; i++)
{
- double y = i * FooterRowH;
- ctx.FillRectangle(LaneBgB, new Rect(0, y, w, FooterRowH));
- ctx.DrawLine(BeatPen, new Point(0, y + FooterRowH), new Point(w, y + FooterRowH));
+ double y = _o.FooterRowTop(i), rh = _o.FooterRowHeight(i);
+ ctx.FillRectangle(LaneBgB, new Rect(0, y, w, rh));
+ ctx.DrawLine(BeatPen, new Point(0, y + rh), new Point(w, y + rh));
}
// Vertical grid: the snap grid's lines at this zoom — what you see is what you snap to.
_o.DrawGrid(ctx, w, h);
+ // Return rows: their lanes, edited like a track's (specs/045).
+ if (_o._automationMode) _auto.DrawAutomation(ctx, w);
+
// Master row: master-volume automation (M9 follow-up) in automation mode,
// else a quiet hint. Value axis 0..2 across the row.
- double my = _o._returns.Count * FooterRowH;
+ double my = MasterRowTop, mh = MasterRowH;
if (_o._automationMode)
{
- ctx.FillRectangle(AutoScrim, new Rect(0, my, w, FooterRowH));
+ ctx.FillRectangle(AutoScrim, new Rect(0, my, w, mh));
var pts = _o._masterAuto;
if (pts.Count == 0)
{
var hint = new FormattedText("click to add master volume points", CultureInfo.InvariantCulture,
FlowDirection.LeftToRight, Typeface.Default, 9, AutomationText);
- ctx.DrawText(hint, new Point(12, my + (FooterRowH - hint.Height) / 2));
+ ctx.DrawText(hint, new Point(12, my + (mh - hint.Height) / 2));
}
else
{
@@ -401,13 +476,13 @@ public sealed partial class ArrangementView
{
var ft = new FormattedText("master volume", CultureInfo.InvariantCulture,
FlowDirection.LeftToRight, Typeface.Default, 9, AutomationText);
- ctx.DrawText(ft, new Point(12, my + (FooterRowH - ft.Height) / 2));
+ ctx.DrawText(ft, new Point(12, my + (mh - ft.Height) / 2));
}
// Browser drag-over: the return / master the drop would land on.
if (_o.FooterDropRow >= 0)
{
- var r = new Rect(0, _o.FooterDropRow * FooterRowH, w, FooterRowH);
+ var r = new Rect(0, _o.FooterRowTop(_o.FooterDropRow), w, _o.FooterRowHeight(_o.FooterDropRow));
ctx.FillRectangle(DropWash, r);
ctx.DrawRectangle(null, DropEdgePen, r.Deflate(1));
}
diff --git a/src/managed/Nota.App/ArrangementView.Groups.cs b/src/managed/Nota.App/ArrangementView.Groups.cs
index d8c45c7a..f48ca91a 100644
--- a/src/managed/Nota.App/ArrangementView.Groups.cs
+++ b/src/managed/Nota.App/ArrangementView.Groups.cs
@@ -7,6 +7,7 @@
// selection (grouping + the track commands in ArrangementView.Tracks.cs), and the
// create/ungroup commands.
+using System;
using System.Collections.Generic;
using System.Linq;
using Nota.Application.Editing;
@@ -105,6 +106,8 @@ public sealed partial class ArrangementView
private void ToggleTrackInSelection(int trackId)
{
+ // A track selection never carries returns (they select among themselves in the footer).
+ _selTracks.RemoveWhere(id => _returns.Any(r => r.Id == id));
// Seed the set with the current primary so the click extends rather than replaces.
if (_selTracks.Count == 0 && _tracks.Any(t => t.Id == SelTrackId)) _selTracks.Add(SelTrackId);
if (_selTracks.Add(trackId)) { Select(trackId, -1, keepTrackSet: true); return; } // make it primary + show its devices
@@ -118,6 +121,32 @@ public sealed partial class ArrangementView
private void ClearTrackMultiSelection() => _selTracks.Clear();
+ // Returns select among themselves in the footer (specs/045): ⌘/Ctrl-click adds or removes
+ // one, ⇧-click takes the range from the selected return. A selection never mixes returns
+ // with tracks, so track commands (group, duplicate, delete …) never reach a return; the
+ // selected returns resize together.
+ private void ToggleReturnInSelection(int returnId)
+ {
+ bool IsReturn(int id) => _returns.Any(r => r.Id == id);
+ _selTracks.RemoveWhere(id => !IsReturn(id));
+ if (_selTracks.Count == 0 && IsReturn(SelTrackId)) _selTracks.Add(SelTrackId);
+ if (_selTracks.Add(returnId)) { Select(returnId, -1, keepTrackSet: true); return; }
+ _selTracks.Remove(returnId);
+ int next = _returns.FirstOrDefault(r => _selTracks.Contains(r.Id))?.Id ?? -1;
+ if (next > 0) Select(next, -1, keepTrackSet: true);
+ else Select(-1, -1);
+ }
+
+ private void SelectReturnRange(int returnId)
+ {
+ int from = _returns.FindIndex(r => r.Id == SelTrackId), to = _returns.FindIndex(r => r.Id == returnId);
+ if (to < 0) return;
+ if (from < 0) from = to;
+ _selTracks.Clear();
+ for (int i = Math.Min(from, to); i <= Math.Max(from, to); i++) _selTracks.Add(_returns[i].Id);
+ Select(returnId, -1, keepTrackSet: true);
+ }
+
// Where a Shift-click range starts: the last plain- or Ctrl/Cmd-clicked header (#249).
private int _trackAnchorId = -1;
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index 8ce54cc2..33f8f969 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -20,15 +20,29 @@ namespace Nota.App;
public sealed partial class ArrangementView
{
// ---- lanes ------------------------------------------------------------
- private sealed class LaneControl : Control
+ private sealed class LaneControl : Control, IAutoRows
{
private readonly ArrangementView _o;
+ private readonly AutoEditor _auto; // automation mode (M9-A3), shared with the footer's return rows
public LaneControl(ArrangementView o)
{
_o = o;
ClipToBounds = true;
+ _auto = new AutoEditor(o, this);
}
+ // The scrolling track rows, as the automation editor sees them.
+ Control IAutoRows.Owner => this;
+ int IAutoRows.RowAtY(double y) => _o.RowAtY(y);
+ TrackVM IAutoRows.TrackAt(int i) => _o._tracks[i];
+ int IAutoRows.IndexOf(TrackVM t) => _o._tracks.IndexOf(t);
+ double IAutoRows.Top(int i) => _o.RowTop(i);
+ double IAutoRows.Height(int i) => _o.RowHeightAt(i);
+ bool IAutoRows.Editable(int i) => !_o.IsSlimRowAt(i); // a slim group bar has no room for an envelope
+ (int lo, int hi) IAutoRows.VisibleRange => _o.VisibleRowRange();
+
+ public bool IsEditingPoint => _auto.IsEditingPoint; // M9-C/D: don't clobber a hand-edit
+
private enum Drag { None, Move, TrimL, TrimR }
private Drag _drag;
private int _dragTrackId, _dragClipIndex;
@@ -132,51 +146,11 @@ public sealed partial class ArrangementView
private int _shiftClipTrack = -1, _shiftClipIndex = -1; // Shift-armed over a clip → click falls back to rectangular clip-select
private const double DragThreshold = 4;
- // Automation editing (M9-A3).
- private AutoPt? _autoDrag;
- private TrackVM? _autoDragTrack;
- private double _autoDragLo, _autoDragHi; // neighbour beats — a point can't be dragged past them (req 8.2.3)
- private float _autoDragStartVal; // value at grab (for Shift fine-mode, req 8.2.2)
- private AutoPt? _bendLeft, _bendRight; // segment being bent (M9-D)
- private TrackVM? _bendTrack;
- // While dragging/bending, the engine lane is updated live (no undo) so the device
- // follows in real time; the first update checkpoints undo once, the rest are raw.
- private bool _autoLiveStarted;
- private AutoPt? _hoverPoint; // point / segment-left under the cursor (hover feedback)
- private AutoPt? _hoverSegLeft;
- private TrackVM? _hoverTrack;
- private TrackVM? _rangeTrack; // Shift-drag time-range selection in progress (Phase 2)
- private double _rangeAnchor;
- public bool IsEditingPoint => _autoDrag != null || _bendLeft != null; // M9-C/D: don't clobber a hand-edit
/// <summary>A clip drag / trim, marquee, time-range or envelope edit is in progress:
/// Follow must not scroll the lanes out from under it (#105).</summary>
- public bool IsGesturing => _drag != Drag.None || _marquee is not null || _rangeTrack is not null || IsEditingPoint;
+ public bool IsGesturing => _drag != Drag.None || _marquee is not null || _auto.IsActive;
private double RowTop(int i) => _o.RowTop(i);
private double RowH(int i) => _o.RowHeightAt(i);
- // Target-selector pill: width fits its label so nothing clips.
- private const double PillH = 16;
- private static double PillWidth(string label)
- {
- var ft = new FormattedText(label, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
- Typeface.Default, 9, NotaPalette.TextPrimary);
- return Math.Clamp(Math.Ceiling(ft.Width) + 12, 34, 180);
- }
- private Rect PillRect(int i, double w) => new(4, RowTop(i) + 3, w, PillH);
- private double ValueToY(TrackVM t, int row, float v)
- {
- var (min, max) = _o.AutoRange(t);
- double top = RowTop(row) + 8, bot = RowTop(row) + RowH(row) - 8;
- double frac = max > min ? Math.Clamp((v - min) / (max - min), 0, 1) : 0.5;
- return bot - frac * (bot - top);
- }
- private float YToValue(TrackVM t, int row, double py)
- {
- var (min, max) = _o.AutoRange(t);
- double top = RowTop(row) + 8, bot = RowTop(row) + RowH(row) - 8;
- double frac = Math.Clamp((bot - py) / (bot - top), 0, 1);
- return (float)(min + frac * (max - min));
- }
-
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
=> _o.HandleLaneWheel(e, e.GetPosition(this).X);
@@ -225,7 +199,7 @@ public sealed partial class ArrangementView
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
if (RowSeamPressed(e)) return;
- if (_o._automationMode) { AutoPointerPressed(e); return; }
+ if (_o._automationMode) { _auto.AutoPointerPressed(e); return; }
var pt = e.GetCurrentPoint(this);
var hit = HitTest(pt.Position, out double beat);
@@ -376,7 +350,7 @@ public sealed partial class ArrangementView
if (_o.IsRowResizing) { _o.UpdateRowResize(e.GetPosition(this).Y); return; }
if (e.GetCurrentPoint(this).Properties is { IsLeftButtonPressed: false, IsRightButtonPressed: false }
&& RowSeamHover(e.GetPosition(this))) return;
- if (_o._automationMode) { AutoPointerMoved(e); return; }
+ if (_o._automationMode) { _auto.AutoPointerMoved(e); return; }
var pos = e.GetPosition(this);
_lastPos = pos;
_lastMods = e.KeyModifiers;
@@ -544,7 +518,7 @@ public sealed partial class ArrangementView
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
if (_o.IsRowResizing) { e.Pointer.Capture(null); _o.EndRowResize(); return; }
- if (_o._automationMode) { AutoPointerReleased(e); return; }
+ if (_o._automationMode) { _auto.AutoPointerReleased(e); return; }
var eng = _o._engine;
if (_adsrDrag != AdsrHandle.None)
@@ -703,13 +677,12 @@ public sealed partial class ArrangementView
// that a PointerCaptureLost fired around button-up doesn't wipe the latch before
// OnPointerReleased turns it into a selection.
bool active = _drag != Drag.None || _groupMove is not null || _rangeActive
- || _autoDrag is not null || _bendLeft is not null || _rangeTrack is not null
+ || _auto.IsActive
|| _adsrDrag != AdsrHandle.None;
if (!active) return false;
_pending = false; _drag = Drag.None; _groupMove = null; _moveRowDelta = 0; _dragClip = null; _rpPeaks = null;
_marqueeArmed = false; _rangeActive = false; _marquee = null; _shiftClipTrack = -1; _shiftClipIndex = -1;
- _autoDrag = null; _autoDragTrack = null; _bendLeft = _bendRight = null; _bendTrack = null;
- _rangeTrack = null;
+ _auto.Cancel();
_adsrDrag = AdsrHandle.None; _adsrClip = null;
SetLoadRow(-1);
SetNewTrackRows(false);
@@ -779,167 +752,7 @@ public sealed partial class ArrangementView
_o.SetSelection(hits);
}
- // --- automation editing (M9-A3) ------------------------------------
- private void AutoPointerPressed(PointerPressedEventArgs e)
- {
- var pt = e.GetCurrentPoint(this);
- var pos = pt.Position;
- int i = _o.RowAtY(pos.Y);
- if (i < 0) return;
- var t = _o._tracks[i];
-
- double pillW = PillWidth(t.AutoLabel);
- if (PillRect(i, pillW).Contains(pos)) { _o.ShowAutoTargetMenu(this, t); return; }
-
- double curBeat = Math.Max(0, _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers));
-
- // Point under the cursor? (7px grab radius). Detected first so Shift can mean
- // "fine-drag this point" (req 8.2.2) rather than always starting a range select.
- AutoPt? hit = null;
- foreach (var p in t.AutoPoints)
- {
- double dx = _o.BeatToX(p.Beat) - pos.X;
- double dy = ValueToY(t, i, p.Value) - pos.Y;
- if (dx * dx + dy * dy <= 49) { hit = p; break; }
- }
-
- bool right = pt.Properties.IsRightButtonPressed;
- bool dbl = e.ClickCount == 2;
-
- // Shift + left-drag authors a time-range selection (Phase 2) — including when the
- // drag starts on a point, so a range bounded by points is selectable. Fine-drag of a
- // point is still available by holding Shift *during* an already-started drag.
- if ((e.KeyModifiers & KeyModifiers.Shift) != 0 && !right)
- {
- _rangeTrack = t; _rangeAnchor = curBeat;
- _o.SetAutoSelection(t, curBeat, curBeat);
- e.Pointer.Capture(this);
- return;
- }
-
- if (hit is not null)
- {
- // On a point: right-click or double-click removes it; a single press grabs it to drag.
- if (right || dbl) { t.AutoPoints.Remove(hit); _o.CommitAuto(t); InvalidateVisual(); return; }
- // else: grab the existing point (drag logic below).
- }
- else
- {
- var seg = HitSegment(t, i, pos);
- // Right-click resets a segment's curve, else opens the range menu.
- if (right)
- {
- if (seg is { } sr) { sr.left.Curve = 0f; _o.CommitAuto(t); InvalidateVisual(); }
- else ShowAutoMenu(t, curBeat);
- return;
- }
- // Alt+drag on a segment bends it (M9-D).
- if (seg is { } sg && (e.KeyModifiers & KeyModifiers.Alt) != 0)
- {
- _bendLeft = sg.left; _bendRight = sg.right; _bendTrack = t;
- e.Pointer.Capture(this);
- return;
- }
- if (dbl)
- {
- // Double-click adds a breakpoint at the cursor, then grabs it for immediate drag.
- _o.ClearAutoSelection();
- hit = new AutoPt { Beat = curBeat, Value = YToValue(t, i, pos.Y) };
- t.AutoPoints.Add(hit);
- }
- else
- {
- // Single click: behave like the arrangement — move the playhead when stopped, do
- // nothing while playing. Points come from double-clicking, never a single click.
- _o.ClearAutoSelection();
- if (_o._engine is not { IsPlaying: true })
- _o.SeekTo(_o._scrollBeats + pos.X / _o._pixelsPerBeat);
- return;
- }
- }
-
- // Grab the point (existing on a single press, or the one just double-click-added) to drag.
- _autoDrag = hit;
- _autoDragTrack = t;
- _autoDragStartVal = hit!.Value;
- // Neighbour bounds: the point can't be dragged past its neighbours in time (req 8.2.3).
- _autoDragLo = 0; _autoDragHi = double.MaxValue;
- foreach (var p in t.AutoPoints)
- {
- if (ReferenceEquals(p, hit)) continue;
- if (p.Beat <= hit.Beat) _autoDragLo = Math.Max(_autoDragLo, p.Beat);
- else _autoDragHi = Math.Min(_autoDragHi, p.Beat);
- }
- e.Pointer.Capture(this);
- InvalidateVisual();
- }
-
- // The (left,right) points of the segment whose curve line is under `pos`, or null.
- private (AutoPt left, AutoPt right)? HitSegment(TrackVM t, int row, Point pos)
- {
- var ordered = t.AutoPoints.OrderBy(p => p.Beat).ToList();
- double beat = _o._scrollBeats + pos.X / _o._pixelsPerBeat;
- for (int k = 1; k < ordered.Count; k++)
- {
- var a = ordered[k - 1]; var b = ordered[k];
- if (beat < a.Beat || beat > b.Beat) continue;
- double span = b.Beat - a.Beat;
- if (span <= 0) return null;
- double tt = (beat - a.Beat) / span;
- double vy = a.Value + (b.Value - a.Value) * Shape(tt, a.Curve);
- double cy = ValueToY(t, row, (float)vy);
- return Math.Abs(cy - pos.Y) <= 6 ? (a, b) : null;
- }
- return null;
- }
-
- private void AutoBendMoved(Point pos)
- {
- if (_bendLeft is null || _bendRight is null || _bendTrack is null) return;
- int i = _o._tracks.IndexOf(_bendTrack);
- if (i < 0) return;
- float v0 = _bendLeft.Value, v1 = _bendRight.Value;
- if (Math.Abs(v1 - v0) < 1e-4f) { _bendLeft.Curve = 0f; InvalidateVisual(); return; }
- double val = YToValue(_bendTrack, i, pos.Y);
- double frac = Math.Clamp((val - v0) / (v1 - v0), 0.02, 0.98);
- // Solve Shape(0.5, curve) == frac -> 0.5^e = frac -> e = ln(frac)/ln(0.5).
- double e = Math.Log(frac) / Math.Log(0.5);
- _bendLeft.Curve = (float)Math.Clamp(-Math.Log2(e) / 4.0, -1.0, 1.0);
- CommitAutoDuringDrag(_bendTrack); // engine follows the curve bend live
- InvalidateVisual();
- }
-
- // Hover feedback (M9-D): highlight the point or segment under the cursor.
- private void UpdateHover(Point pos)
- {
- AutoPt? pt = null, seg = null; TrackVM? tr = null;
- int i = _o.RowAtY(pos.Y);
- if (i >= 0)
- {
- var t = _o._tracks[i];
- foreach (var p in t.AutoPoints)
- {
- double dx = _o.BeatToX(p.Beat) - pos.X, dy = ValueToY(t, i, p.Value) - pos.Y;
- if (dx * dx + dy * dy <= 49) { pt = p; break; } // 7px, matches grab radius
- }
- if (pt is null && HitSegment(t, i, pos) is { } sg) seg = sg.left;
- if (pt is not null || seg is not null) tr = t;
- }
- if (!ReferenceEquals(pt, _hoverPoint) || !ReferenceEquals(seg, _hoverSegLeft) || !ReferenceEquals(tr, _hoverTrack))
- {
- _hoverPoint = pt; _hoverSegLeft = seg; _hoverTrack = tr;
- InvalidateVisual();
- }
- }
-
- private void ClearHover()
- {
- if (_hoverPoint is null && _hoverSegLeft is null) return;
- _hoverPoint = null; _hoverSegLeft = null; _hoverTrack = null;
- InvalidateVisual();
- }
-
- protected override void OnPointerExited(PointerEventArgs e) { ClearHover(); ClearEdgeHover(); ClearAdsrHover(); base.OnPointerExited(e); }
+ protected override void OnPointerExited(PointerEventArgs e) { _auto.ClearHover(); ClearEdgeHover(); ClearAdsrHover(); base.OnPointerExited(e); }
// One engine edit (one undo step); an open clip editor re-reads it, the lane reloads.
private void CommitAdsr(int trackId, ClipVM clip, ClipAdsr adsr)
@@ -1015,69 +828,6 @@ public sealed partial class ArrangementView
Cursor = on ? ResizeCursor : ArrowCursor;
}
- private void AutoPointerMoved(PointerEventArgs e)
- {
- if (_rangeTrack is not null)
- {
- double beat = Math.Max(0, _o.Snap(_o._scrollBeats + e.GetPosition(this).X / _o._pixelsPerBeat));
- _o.SetAutoSelection(_rangeTrack, _rangeAnchor, beat);
- return;
- }
- if (_bendLeft is not null) { AutoBendMoved(e.GetPosition(this)); return; }
- if (_autoDrag is null || _autoDragTrack is null) { UpdateHover(e.GetPosition(this)); return; }
- int i = _o._tracks.IndexOf(_autoDragTrack);
- if (i < 0) return;
- var pos = e.GetPosition(this);
- // Time: snapped (Alt bypasses), clamped between neighbour points — no reordering (8.2.3).
- double cand = Math.Max(0, _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers));
- _autoDrag.Beat = Math.Clamp(cand, _autoDragLo, _autoDragHi);
- // Value: free, but Shift = fine-mode (quarter sensitivity, anchored at the grab value, 8.2.2).
- float full = YToValue(_autoDragTrack, i, pos.Y);
- _autoDrag.Value = (e.KeyModifiers & KeyModifiers.Shift) != 0
- ? _autoDragStartVal + (full - _autoDragStartVal) * 0.25f
- : full;
- CommitAutoDuringDrag(_autoDragTrack); // engine follows live (device updates at the playhead)
- InvalidateVisual();
- }
-
- // First push of a drag checkpoints undo (CommitAuto); the rest are raw (CommitAutoLive),
- // so a whole drag is one undo step while the device follows in real time.
- private void CommitAutoDuringDrag(TrackVM t)
- {
- if (!_autoLiveStarted) { _o.CommitAuto(t); _autoLiveStarted = true; }
- else _o.CommitAutoLive(t);
- }
-
- private void AutoPointerReleased(PointerReleasedEventArgs e)
- {
- if (_rangeTrack is not null)
- {
- // A zero-width drag (Shift-click, no move) is a deselect, not a selection.
- if (_o._autoSelEnd - _o._autoSelStart <= 1e-6) _o.ClearAutoSelection();
- _rangeTrack = null;
- e.Pointer.Capture(null);
- return;
- }
- if (_bendLeft is not null && _bendTrack is not null)
- {
- // Final state: a live drag already checkpointed at its start, so commit raw;
- // a no-move press (shouldn't happen for bend) still gets a normal undo commit.
- if (_autoLiveStarted) _o.CommitAutoLive(_bendTrack); else _o.CommitAuto(_bendTrack);
- _autoLiveStarted = false;
- _bendLeft = _bendRight = null; _bendTrack = null;
- e.Pointer.Capture(null);
- InvalidateVisual();
- return;
- }
- if (_autoDrag is null || _autoDragTrack is null) return;
- if (_autoLiveStarted) _o.CommitAutoLive(_autoDragTrack); else _o.CommitAuto(_autoDragTrack);
- _autoLiveStarted = false;
- _autoDrag = null;
- _autoDragTrack = null;
- e.Pointer.Capture(null);
- InvalidateVisual();
- }
-
// A small inline rename popup (Enter commits, Esc cancels) anchored at the pointer.
private void PromptRename(string current, Action<string> commit)
{
@@ -1092,21 +842,6 @@ public sealed partial class ArrangementView
Dispatcher.UIThread.Post(() => { box.SelectAll(); box.Focus(); }, DispatcherPriority.Input);
}
- // Automation-mode right-click: copy/cut/delete the selected time range and paste the
- // range clipboard at the cursor (Phase 2). Copy/Cut/Delete need a selection on this
- // track; Paste needs a filled clipboard.
- private void ShowAutoMenu(TrackVM t, double beat)
- {
- bool hasSel = _o.HasAutoSelection && ReferenceEquals(_o._autoSelTrack, t);
- var flyout = new MenuFlyout();
- var copy = MenuKit.Item("Copy automation", GlyphKind.Copy, () => _o.CopyAutoSelection(), MenuKit.CopyKey, hasSel);
- var cut = MenuKit.Item("Cut automation", GlyphKind.Cut, () => _o.CutAutoSelection(), MenuKit.CutKey, hasSel);
- var paste = MenuKit.Item("Paste automation", GlyphKind.Paste, () => _o.PasteAutoAt(t, _o.Snap(beat)), MenuKit.PasteKey, _o.HasAutoClip);
- var del = MenuKit.Danger("Delete automation", GlyphKind.Trash, () => _o.DeleteAutoSelection(), MenuKit.DeleteKey, hasSel);
- MenuKit.AddGroups(flyout.Items, new Control[] { copy, cut, paste }, new Control[] { del });
- flyout.ShowAt(this, showAtPointer: true);
- }
-
// "Paste bounced audio" onto this track at `at`, or null when there's nothing to paste
// or the track can't take it (only audio tracks can).
private MenuItem? PasteBouncedItem(int trackId, double at)
@@ -1397,7 +1132,7 @@ public sealed partial class ArrangementView
}
// Automation overlay (M9-A3): scrim + envelope + target pill per row.
- if (_o._automationMode) DrawAutomation(ctx, w);
+ if (_o._automationMode) _auto.DrawAutomation(ctx, w);
// Cross-track drag: the dragged clips are hidden on their source lanes
// (above) and previewed translucently on the destination lane here.
@@ -1983,89 +1718,6 @@ public sealed partial class ArrangementView
return true;
}
- private static readonly IPen AutoCurvePen = new Pen(NotaPalette.VizInk, 1.6);
-
- private void DrawAutomation(DrawingContext ctx, double w)
- {
- var (rLo, rHi) = _o.VisibleRowRange();
- for (int i = rLo; i <= rHi; i++)
- {
- var t = _o._tracks[i];
- double y = RowTop(i);
- ctx.FillRectangle(AutoScrim, new Rect(0, y, w, RowH(i)));
- if (_o.IsSlimRowAt(i)) continue; // a slim group bar has no room for an envelope
-
- // Automation: the curve and its points in neutral viz ink; only the
- // point or segment under the pointer takes the accent.
- var content = NotaPalette.VizInk;
- var pen = AutoCurvePen;
-
- var ordered = t.AutoPoints.OrderBy(p => p.Beat).ToList();
- if (ordered.Count == 0)
- {
- // Empty lane: dashed baseline at the current value (grab to start).
- double by = ValueToY(t, i, _o.AutoCurrent(t));
- ctx.DrawLine(AutoBasePen, new Point(0, by), new Point(w, by));
- }
- else
- {
- double firstX = _o.BeatToX(ordered[0].Beat), firstY = ValueToY(t, i, ordered[0].Value);
- ctx.DrawLine(pen, new Point(0, firstY), new Point(firstX, firstY)); // left end-hold
- for (int k = 1; k < ordered.Count; k++)
- {
- var a = ordered[k - 1]; var b = ordered[k];
- var segPen = ReferenceEquals(t, _hoverTrack) && ReferenceEquals(a, _hoverSegLeft) ? AutoHoverPen : pen;
- double ax = _o.BeatToX(a.Beat), ay = ValueToY(t, i, a.Value);
- double bx = _o.BeatToX(b.Beat), by2 = ValueToY(t, i, b.Value);
- if (a.Curve == 0f) { ctx.DrawLine(segPen, new Point(ax, ay), new Point(bx, by2)); continue; }
- // Curved segment: polyline of shaped sub-samples (M9-D).
- const int steps = 16;
- var prev = new Point(ax, ay);
- for (int s = 1; s <= steps; s++)
- {
- double tt = s / (double)steps;
- double vy = a.Value + (b.Value - a.Value) * Shape(tt, a.Curve);
- var cur = new Point(ax + (bx - ax) * tt, ValueToY(t, i, (float)vy));
- ctx.DrawLine(segPen, prev, cur);
- prev = cur;
- }
- }
- double lastX = _o.BeatToX(ordered[^1].Beat), lastY = ValueToY(t, i, ordered[^1].Value);
- ctx.DrawLine(pen, new Point(lastX, lastY), new Point(w, lastY)); // right end-hold
- foreach (var p in ordered)
- {
- double dx = _o.BeatToX(p.Beat), dy = ValueToY(t, i, p.Value);
- if (dx < -4 || dx > w + 4) continue;
- bool ptHover = ReferenceEquals(t, _hoverTrack) && ReferenceEquals(p, _hoverPoint);
- ctx.DrawEllipse(ptHover ? PlayheadBrush : content, null, new Point(dx, dy), ptHover ? 4.5 : 3.5, ptHover ? 4.5 : 3.5);
- if (ptHover) ctx.DrawEllipse(null, AutoHoverRing, new Point(dx, dy), 7, 7);
- }
- }
-
- // Range selection band (Phase 2): teal wash + edges over the picked span.
- if (ReferenceEquals(_o._autoSelTrack, t) && _o._autoSelEnd - _o._autoSelStart > 1e-6)
- {
- double sx = _o.BeatToX(_o._autoSelStart), ex = _o.BeatToX(_o._autoSelEnd);
- double cx0 = Math.Max(0, sx), cx1 = Math.Min(w, ex);
- if (cx1 > cx0)
- {
- double arh = RowH(i);
- ctx.FillRectangle(AutoSelBand, new Rect(cx0, y, cx1 - cx0, arh));
- if (sx >= 0) ctx.DrawLine(AutoSelEdge, new Point(sx, y), new Point(sx, y + arh));
- if (ex <= w) ctx.DrawLine(AutoSelEdge, new Point(ex, y), new Point(ex, y + arh));
- }
- }
-
- // Target-selector pill (top-left) — width fits the label, text centred.
- double pillW = PillWidth(t.AutoLabel);
- var pill = PillRect(i, pillW);
- ctx.DrawRectangle(NotaPalette.SurfaceRaised, null, pill, NotaRadius.ControlValue, NotaRadius.ControlValue);
- var ft = new FormattedText(t.AutoLabel, CultureInfo.InvariantCulture,
- FlowDirection.LeftToRight, NotaFonts.SansMedium, 9, NotaPalette.TextPrimary);
- using (ctx.PushClip(pill))
- ctx.DrawText(ft, new Point(pill.X + 6, pill.Y + (PillH - ft.Height) / 2));
- }
- }
}
// ---- playhead + loop overlay -----------------------------------------
diff --git a/src/managed/Nota.App/ArrangementView.Sizing.cs b/src/managed/Nota.App/ArrangementView.Sizing.cs
index 5ef5932d..7226955e 100644
--- a/src/managed/Nota.App/ArrangementView.Sizing.cs
+++ b/src/managed/Nota.App/ArrangementView.Sizing.cs
@@ -75,13 +75,23 @@ public sealed partial class ArrangementView
private double TrackRowHeight(TrackVM t) => StoredRowHeight(t.Id);
+ // Return and master rows sit in the pinned footer, so they start compact (specs/045):
+ // the tracks get the room. A track row starts at the standard height.
+ internal const double DefaultFooterRowHeight = CompactRowHeight;
+ private double _masterHeight = DefaultFooterRowHeight;
+
+ // Asks the engine rather than _returns: a project load stores heights before Refresh
+ // rebuilds the VMs.
+ private double DefaultHeightFor(int trackId)
+ => _engine is { } e && e.TrackReturnIndex(trackId) >= 0 ? DefaultFooterRowHeight : DefaultRowHeight;
+
private double StoredRowHeight(int trackId)
- => _trackHeights.TryGetValue(trackId, out var h) ? h : DefaultRowHeight;
+ => _trackHeights.TryGetValue(trackId, out var h) ? h : DefaultHeightFor(trackId);
private void StoreRowHeight(int trackId, double h)
{
h = ClampRowHeight(h);
- if (Math.Abs(h - DefaultRowHeight) < 0.5) _trackHeights.Remove(trackId);
+ if (Math.Abs(h - DefaultHeightFor(trackId)) < 0.5) _trackHeights.Remove(trackId);
else _trackHeights[trackId] = h;
}
@@ -96,11 +106,11 @@ public sealed partial class ArrangementView
return ids;
}
- /// <summary>Drop heights of tracks that no longer exist (deleted, or undone away).</summary>
+ /// <summary>Drop heights of tracks and returns that no longer exist (deleted, or undone away).</summary>
private void PruneTrackHeights()
{
if (_engine is null || _trackHeights.Count == 0) return;
- var alive = new HashSet<int>(AllTrackRowIds());
+ var alive = new HashSet<int>(AllTrackRowIds().Concat(_returns.Select(r => r.Id)));
foreach (var id in _trackHeights.Keys.Where(id => !alive.Contains(id)).ToList())
_trackHeights.Remove(id);
}
@@ -303,6 +313,141 @@ public sealed partial class ArrangementView
return grip;
}
+ // ---- footer row resize (return / master rows, specs/045) -----------------
+ // The same snap and limits as a track row, but never "all tracks": Alt is ignored, and a
+ // track-row gesture never reaches the footer. Five rows at most, so a drag simply rebuilds
+ // the footer headers each frame.
+
+ private bool _footerResizing, _footerResizeChanged;
+ private int[] _footerResizeReturns = Array.Empty<int>();
+ private bool _footerResizeMaster;
+ private double _footerResizeStartH, _footerResizeStartY;
+ private int _footerResizeRowsAbove;
+
+ internal bool IsFooterResizing => _footerResizing;
+
+ /// <summary>Footer row whose bottom edge is within the grab band of <paramref name="y"/>, or -1.</summary>
+ internal int FooterSeamAtY(double y)
+ {
+ for (int i = 0; i + 1 < _footerRowTops.Length; i++)
+ if (Math.Abs(y - _footerRowTops[i + 1]) <= SeamGrabPx / 2) return i;
+ return -1;
+ }
+
+ // A return inside the selection takes the selected returns with it; the master goes alone.
+ private (int[] returns, bool master) FooterResizeTargets(int footerRow)
+ {
+ if (footerRow >= _returns.Count) return (Array.Empty<int>(), true);
+ int id = _returns[footerRow].Id;
+ var sel = _returns.Where(r => IsTrackMultiSelected(r.Id)).Select(r => r.Id).ToArray();
+ return (sel.Length > 1 && sel.Contains(id) ? sel : new[] { id }, false);
+ }
+
+ // pointerY is in ArrangementView coordinates: the footer is docked to the bottom and grows
+ // upwards, so its own coordinates shift under the pointer while a row grows.
+ internal void BeginFooterResize(int footerRow, double pointerY)
+ {
+ if (footerRow < 0 || footerRow > _returns.Count) return;
+ (_footerResizeReturns, _footerResizeMaster) = FooterResizeTargets(footerRow);
+ _footerResizing = true;
+ _footerResizeChanged = false;
+ _footerResizeStartH = FooterRowHeight(footerRow);
+ _footerResizeStartY = pointerY;
+ var targets = new HashSet<int>(_footerResizeReturns);
+ _footerResizeRowsAbove = 0;
+ for (int i = 0; i < footerRow && i < _returns.Count; i++)
+ if (targets.Contains(_returns[i].Id)) _footerResizeRowsAbove++;
+ }
+
+ internal void UpdateFooterResize(double pointerY)
+ {
+ if (!_footerResizing) return;
+ double h = SnapRowHeight(_footerResizeStartH + (pointerY - _footerResizeStartY) / (_footerResizeRowsAbove + 1));
+ if (SetFooterHeightsRaw(_footerResizeReturns, _footerResizeMaster, h))
+ {
+ _footerResizeChanged = true;
+ RelayoutFooterLive();
+ }
+ }
+
+ internal void EndFooterResize()
+ {
+ if (!_footerResizing) return;
+ _footerResizing = false;
+ _footerResizeReturns = Array.Empty<int>();
+ // After a drag, one full rebuild settles the cards (posted: the grip still holds the pointer).
+ if (_footerResizeChanged) Dispatcher.UIThread.Post(RelayoutFooter, DispatcherPriority.Render);
+ }
+
+ /// <summary>Double-click on a footer seam: the row (or the selected returns) back to compact.</summary>
+ internal void ResetFooterRowHeight(int footerRow)
+ {
+ _footerResizing = false;
+ var (returns, master) = FooterResizeTargets(footerRow);
+ SetFooterHeights(returns, master, DefaultFooterRowHeight);
+ }
+
+ internal void SetFooterHeights(IEnumerable<int> returnIds, bool master, double h)
+ {
+ if (SetFooterHeightsRaw(returnIds, master, h)) RelayoutFooter();
+ }
+
+ private bool SetFooterHeightsRaw(IEnumerable<int> returnIds, bool master, double h)
+ {
+ bool changed = false;
+ foreach (var id in returnIds)
+ {
+ if (Math.Abs(StoredRowHeight(id) - h) < 0.5) continue;
+ StoreRowHeight(id, h);
+ changed = true;
+ }
+ if (master && Math.Abs(_masterHeight - ClampRowHeight(h)) >= 0.5)
+ {
+ _masterHeight = ClampRowHeight(h);
+ changed = true;
+ }
+ return changed;
+ }
+
+ private void RelayoutFooter()
+ {
+ RebuildFooterGeometry();
+ RebuildFooterHeaders();
+ ApplyFooterHeight();
+ }
+
+ // Header side of a footer row's bottom seam, like a track row's grip.
+ private Border FooterSeamGrip(int footerRow)
+ {
+ var line = new Border { Height = 1, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Transparent };
+ var grip = new Border
+ {
+ Height = SeamGrabPx, Background = Brushes.Transparent, Child = line,
+ Cursor = new Cursor(StandardCursorType.SizeNorthSouth),
+ };
+ grip.PointerEntered += (_, _) => line.Background = Brush("Brush.BorderStrong");
+ grip.PointerExited += (_, _) => { if (!_footerResizing) line.Background = Brushes.Transparent; };
+ grip.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(grip).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ if (e.ClickCount == 2) { ResetFooterRowHeight(footerRow); return; }
+ BeginFooterResize(footerRow, e.GetPosition(this).Y);
+ e.Pointer.Capture(grip);
+ };
+ grip.PointerMoved += (_, e) => { if (_footerResizing) { UpdateFooterResize(e.GetPosition(this).Y); e.Handled = true; } };
+ grip.PointerReleased += (_, e) =>
+ {
+ if (!_footerResizing) return;
+ e.Handled = true;
+ e.Pointer.Capture(null);
+ line.Background = Brushes.Transparent;
+ EndFooterResize();
+ };
+ grip.PointerCaptureLost += (_, _) => { line.Background = Brushes.Transparent; EndFooterResize(); };
+ return grip;
+ }
+
// ---- column resize (drag the seam between headers and lanes) -------------
private bool _colResizing;
@@ -418,6 +563,8 @@ public sealed partial class ArrangementView
[JsonPropertyName("version")] public int Version { get; set; } = 1;
[JsonPropertyName("headerWidth")] public double? HeaderWidth { get; set; }
[JsonPropertyName("trackHeights")] public List<TrackHeightDto> TrackHeights { get; set; } = new();
+ // specs/045: return rows ride in trackHeights by index; the master has no index.
+ [JsonPropertyName("masterHeight")] public double? MasterHeight { get; set; }
}
private sealed class TrackHeightDto
@@ -426,7 +573,7 @@ public sealed partial class ArrangementView
[JsonPropertyName("height")] public double Height { get; set; }
}
- /// <summary>Write the track heights and header width into a .nota bundle, keyed by track
+ /// <summary>Write the track, return and master heights and the header width into a .nota bundle, keyed by track
/// index (ids only last a session). Cosmetic — a failure here never fails the save.</summary>
public void SaveTrackView(string bundleDir)
{
@@ -439,7 +586,8 @@ public sealed partial class ArrangementView
for (int i = 0; i < _engine.TrackCount; i++)
if (_engine.TryGetTrackInfo(i, out var ti) && _trackHeights.TryGetValue(ti.Id, out var h))
dto.TrackHeights.Add(new TrackHeightDto { Index = i, Height = h });
- if (dto.HeaderWidth is null && dto.TrackHeights.Count == 0)
+ if (Math.Abs(_masterHeight - DefaultFooterRowHeight) >= 0.5) dto.MasterHeight = _masterHeight;
+ if (dto.HeaderWidth is null && dto.TrackHeights.Count == 0 && dto.MasterHeight is null)
{
if (System.IO.File.Exists(path)) System.IO.File.Delete(path);
return;
@@ -461,9 +609,10 @@ public sealed partial class ArrangementView
var dto = JsonSerializer.Deserialize<TrackViewDto>(System.IO.File.ReadAllText(path));
if (dto is null || dto.Version > 1) return;
if (dto.HeaderWidth is { } w) _userHeaderW = Math.Round(Math.Clamp(w, MinHeaderW, MaxHeaderW));
- foreach (var th in dto.TrackHeights)
- if (th.Index >= 0 && _engine.TryGetTrackInfo(th.Index, out var ti) && !ti.IsReturn)
+ foreach (var th in dto.TrackHeights) // tracks and returns alike (specs/045)
+ if (th.Index >= 0 && _engine.TryGetTrackInfo(th.Index, out var ti))
StoreRowHeight(ti.Id, th.Height);
+ if (dto.MasterHeight is { } mh) _masterHeight = ClampRowHeight(mh);
}
catch { /* a corrupt sidecar just means the default layout */ }
finally { ApplyHeaderWidth(final: false); }
@@ -473,6 +622,7 @@ public sealed partial class ArrangementView
public void ResetTrackView()
{
_trackHeights.Clear();
+ _masterHeight = DefaultFooterRowHeight;
_clipboardHeights = null;
_userHeaderW = DefaultHeaderW;
ApplyHeaderWidth(final: false);
diff --git a/src/managed/Nota.App/ArrangementView.Tracks.cs b/src/managed/Nota.App/ArrangementView.Tracks.cs
index 68919ed9..8674f1f0 100644
--- a/src/managed/Nota.App/ArrangementView.Tracks.cs
+++ b/src/managed/Nota.App/ArrangementView.Tracks.cs
@@ -254,6 +254,19 @@ public sealed partial class ArrangementView
});
}
+ // Compact / Standard / Large for a footer row (specs/045): the right-clicked return — or the
+ // selected returns it belongs to — or the master. Never "all tracks", so Alt/Option is ignored.
+ private MenuItem FooterHeightRow(int footerRow)
+ {
+ (string, double)[] presets = { ("Compact", CompactRowHeight), ("Standard", StandardRowHeight), ("Large", LargeRowHeight) };
+ var (returns, master) = FooterResizeTargets(footerRow);
+ var current = returns.Select(StoredRowHeight).Concat(master ? new[] { _masterHeight } : Array.Empty<double>()).ToList();
+ double? chosen = presets.Select(p => p.Item2)
+ .Where(h => current.Count > 0 && current.All(c => Math.Abs(c - h) < 0.5))
+ .Select(h => (double?)h).FirstOrDefault();
+ return MenuKit.Segments("Height", presets, chosen, (h, _) => SetFooterHeights(returns, master, h));
+ }
+
// "Recent" instruments under Add track (spec 034 US5): the host (MainWindow) builds the
// items from the recent-instruments list; each adds a track after the anchor.
public Func<int, IReadOnlyList<MenuItem>>? RecentInstrumentItems;
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index 0de843c1..1660e5f3 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -92,7 +92,6 @@ public sealed partial class ArrangementView : UserControl
private const double GroupRowHeight = 26; // a group row: a slim titled bar, no controls
private const double RulerH = 24;
private const double SectionsH = 22; // song-structure lane above the ruler
- private const double FooterRowH = 40; // slim return/master rows
// Row geometry. Rows are no longer a fixed pitch — a group weighs a fraction of a track
// (design 1a), so every y↔row conversion goes through the prefix table below instead of
@@ -171,6 +170,33 @@ public sealed partial class ArrangementView : UserControl
return r >= 0 ? r : (y < 0 ? 0 : _tracks.Count - 1);
}
+ // Footer geometry (specs/045): the pinned return/master rows each have their own height —
+ // returns first, the master last. Rebuilt with the track rows on every Refresh and live
+ // while a footer seam is dragged.
+ private double[] _footerRowTops = { 0, DefaultFooterRowHeight };
+
+ private void RebuildFooterGeometry()
+ {
+ int n = _returns.Count + 1;
+ var tops = new double[n + 1];
+ for (int i = 0; i < n; i++) tops[i + 1] = tops[i] + FooterRowHeightRaw(i);
+ _footerRowTops = tops;
+ }
+
+ private double FooterRowHeightRaw(int i)
+ => i < _returns.Count ? StoredRowHeight(_returns[i].Id) : _masterHeight;
+
+ /// <summary>Height of footer row <paramref name="i"/> (returns, then the master).</summary>
+ internal double FooterRowHeight(int i)
+ => i >= 0 && i + 1 < _footerRowTops.Length ? _footerRowTops[i + 1] - _footerRowTops[i] : DefaultFooterRowHeight;
+
+ /// <summary>Top of footer row <paramref name="i"/>; past the last row, the content bottom.</summary>
+ internal double FooterRowTop(int i)
+ => _footerRowTops[Math.Clamp(i, 0, _footerRowTops.Length - 1)];
+
+ /// <summary>Combined height of the return and master rows.</summary>
+ internal double FooterContentHeight => _footerRowTops[^1];
+
/// <summary>Insertion gap nearest <paramref name="y"/> (0.._tracks.Count) — where a
/// header-reorder drop would land.</summary>
internal int RowGapAtY(double y)
@@ -225,6 +251,8 @@ public sealed partial class ArrangementView : UserControl
private readonly Canvas _footerHeaders;
private readonly FooterLaneControl _footerLanes;
private readonly Grid _footer;
+ private readonly ScrollViewer _footerScroller;
+ private Grid _centerArea = null!;
/// <summary>Raised when a MIDI clip is double-clicked (trackId, clipIndex).</summary>
public event Action<int, int>? MidiClipActivated;
@@ -413,7 +441,7 @@ public sealed partial class ArrangementView : UserControl
_headerColumnParts.Add(leftBackdrop);
leftBackdrop.BindResource(Border.BackgroundProperty, "Brush.SurfaceCard");
leftBackdrop.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
- var centerArea = new Grid();
+ var centerArea = _centerArea = new Grid();
centerArea.Children.Add(leftBackdrop);
centerArea.Children.Add(scroller);
@@ -435,6 +463,15 @@ public sealed partial class ArrangementView : UserControl
DragDrop.AddDragOverHandler(_footer, OnFooterDragOver);
DragDrop.AddDragLeaveHandler(_footer, (_, _) => SetFooterDropRow(-1));
DragDrop.AddDropHandler(_footer, OnFooterDrop);
+ // Tall returns must not crowd out the tracks: past about half the arrangement the
+ // footer stops growing and scrolls (specs/045).
+ _footerScroller = new ScrollViewer
+ {
+ Content = _footer,
+ Background = Brushes.Transparent,
+ HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
+ VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
+ };
// Bottom: a thin horizontal scrollbar under the lanes, on the well, past a hairline.
var bottomGrid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
@@ -457,13 +494,13 @@ public sealed partial class ArrangementView : UserControl
DockPanel.SetDock(_sectionsRow, Dock.Top);
DockPanel.SetDock(top, Dock.Top);
DockPanel.SetDock(bottom, Dock.Bottom);
- DockPanel.SetDock(_footer, Dock.Bottom);
+ DockPanel.SetDock(_footerScroller, Dock.Bottom);
DockPanel.SetDock(footerSeam, Dock.Bottom);
root.Children.Add(_overviewRow); // Overview sits above the ruler
root.Children.Add(_sectionsRow); // …then the named song sections
root.Children.Add(top);
root.Children.Add(bottom);
- root.Children.Add(_footer);
+ root.Children.Add(_footerScroller);
root.Children.Add(footerSeam); // docked after the footer → sits on top of it
root.Children.Add(centerArea);
@@ -473,7 +510,7 @@ public sealed partial class ArrangementView : UserControl
// The header/lane seam is draggable along the view's full height (overview to footer).
_columnSeam = BuildColumnSeam();
var layered = new Grid { Children = { root, _columnSeam } };
- SizeChanged += (_, _) => OnViewSizeChanged();
+ SizeChanged += (_, _) => { OnViewSizeChanged(); CapFooterHeight(); };
var island = new Border
{
@@ -545,9 +582,11 @@ public sealed partial class ArrangementView : UserControl
if (!_automationMode) return;
var eng = _engine;
if (eng is not { IsPlaying: true } || !eng.AutomationRecording) return;
- if (_lanes.IsEditingPoint) return;
+ if (_lanes.IsEditingPoint || _footerLanes.IsEditingPoint) return;
foreach (var t in _tracks) LoadAutoPoints(t);
+ foreach (var t in _returns) LoadAutoPoints(t);
_lanes.InvalidateVisual();
+ _footerLanes.InvalidateVisual();
}
internal IReadOnlyList<TrackVM> Tracks => _tracks;
@@ -654,7 +693,7 @@ public sealed partial class ArrangementView : UserControl
bool playing = _engine is { IsPlaying: true };
if (playing && !_wasPlaying) SetFollowSuspended(false);
_wasPlaying = playing;
- bool scrolled = _followPlayhead && !FollowSuspended && playing && !_lanes.IsGesturing && CenterOnPlayhead();
+ bool scrolled = _followPlayhead && !FollowSuspended && playing && !_lanes.IsGesturing && !_footerLanes.IsGesturing && CenterOnPlayhead();
if (scrolled) _lanes.InvalidateVisual();
// Converge the loop highlight with the engine (~30 Hz) so transport-bar
// toggles/changes reflect here too — except mid-drag, where we show a preview.
@@ -693,7 +732,13 @@ public sealed partial class ArrangementView : UserControl
if (t.AutoPoints.Count != 0) continue; // only empty lanes show a baseline
sig = sig * 31.0 + (AutoCurrent(t) + 3.0) * (i * 7 + 1);
}
- if (sig != _autoBaselineSig) { _autoBaselineSig = sig; _lanes.InvalidateVisual(); }
+ for (int i = 0; i < _returns.Count; i++) // the footer's return lanes (specs/045)
+ {
+ var t = _returns[i];
+ if (t.AutoPoints.Count != 0) continue;
+ sig = sig * 31.0 + (AutoCurrent(t) + 3.0) * (i * 13 + 5);
+ }
+ if (sig != _autoBaselineSig) { _autoBaselineSig = sig; _lanes.InvalidateVisual(); _footerLanes.InvalidateVisual(); }
}
// ---- loop region authoring -------------------------------------------
@@ -881,6 +926,8 @@ public sealed partial class ArrangementView : UserControl
p.Pan = ti.Pan;
if (_footerFaders.TryGetValue(ti.Id, out var rf))
FollowVolume(rf, _footerDb.GetValueOrDefault(ti.Id), ti.Volume);
+ if (_footerPans.TryGetValue(ti.Id, out var rp) && !rp.Dragging && Math.Abs(rp.Pan - ti.Pan) > 1e-3)
+ rp.Pan = ti.Pan;
}
}
@@ -1056,6 +1103,7 @@ public sealed partial class ArrangementView : UserControl
RebuildRowGeometry(); // row tops depend on which rows are groups → after the reorder
RecomputeTotalBeats();
LoadMasterAuto(); // master-volume automation for the footer row (M9 follow-up)
+ RebuildFooterGeometry(); // footer rows follow the returns just rebuilt
if (rebuildHeaders)
{
RebuildHeaders();
@@ -1063,10 +1111,7 @@ public sealed partial class ArrangementView : UserControl
}
_lanes.Height = Math.Max(DefaultRowHeight, RowsHeight);
_overlay.Height = _lanes.Height; // keep the playhead/loop overlay the same span
- double footerH = (_returns.Count + 1) * FooterRowH; // returns + master
- _footer.Height = footerH;
- _footerHeaders.Height = footerH;
- _footerLanes.InvalidateVisual();
+ ApplyFooterHeight();
SyncScroll(_lanes.Bounds.Width);
Redraw();
}
@@ -1451,8 +1496,10 @@ public sealed partial class ArrangementView : UserControl
// The return/master footer row at y: returns first, master last; -1 outside.
private int FooterRowAt(double y)
{
- int row = (int)Math.Floor(y / FooterRowH);
- return y >= 0 && row <= _returns.Count ? row : -1;
+ if (y < 0) return -1;
+ for (int i = 0; i + 1 < _footerRowTops.Length; i++)
+ if (y < _footerRowTops[i + 1]) return i;
+ return -1;
}
private int FooterRowTrackId(int row)
=> row < 0 ? -1 : row < _returns.Count ? _returns[row].Id : _engine?.MasterTrackId ?? -1;
@@ -1502,8 +1549,8 @@ public sealed partial class ArrangementView : UserControl
_footerLanes.InvalidateVisual();
_footerDropRing.IsVisible = row >= 0;
if (row < 0) return;
- Canvas.SetTop(_footerDropRing, row * FooterRowH);
- _footerDropRing.Height = FooterRowH;
+ Canvas.SetTop(_footerDropRing, FooterRowTop(row));
+ _footerDropRing.Height = FooterRowHeight(row);
}
// A device card dragged out of the Devices panel (specs/043): the row it is over lights when
@@ -1637,11 +1684,11 @@ public sealed partial class ArrangementView : UserControl
/// <summary>Esc: cancel an in-progress lane gesture if one is active (no model change),
/// otherwise clear any selection (req 1.2.6 / 2.11). Returns true if it did something.</summary>
/// <summary>Abort any in-progress lane gesture with no model change (window focus loss).</summary>
- public void CancelActiveGesture() => _lanes.CancelGesture();
+ public void CancelActiveGesture() { _lanes.CancelGesture(); _footerLanes.CancelGesture(); }
internal bool EscapePressed()
{
- if (_lanes.CancelGesture()) return true;
+ if (_lanes.CancelGesture() | _footerLanes.CancelGesture()) return true;
bool had = _sel.Count > 0 || SelTrackId > 0 || HasAutoSelection || HasTimeSelection;
if (HasAutoSelection) ClearAutoSelection();
if (HasTimeSelection) ClearTimeSelection();
@@ -2792,44 +2839,126 @@ public sealed partial class ArrangementView : UserControl
if (undo is null) set(value); else undo.Change(value, set);
}
+ // The footer's rows changed height (Refresh, a footer seam drag, a menu preset).
+ private void ApplyFooterHeight()
+ {
+ double h = FooterContentHeight;
+ _footer.Height = h;
+ _footerHeaders.Height = h;
+ _footerLanes.InvalidateVisual();
+ CapFooterHeight();
+ }
+
+ // The footer may take at most half of the space it shares with the track list.
+ private void CapFooterHeight()
+ {
+ double shared = _centerArea.Bounds.Height + _footerScroller.Bounds.Height;
+ _footerScroller.MaxHeight = shared > 0 ? Math.Max(DefaultFooterRowHeight, Math.Floor(shared / 2)) : double.PositiveInfinity;
+ }
+
+ // Footer header cards (one per return, then the master) and their seam grips. A seam drag
+ // moves the existing cards and grips instead of rebuilding them — rebuilding would drop the
+ // grip that holds the pointer — and swaps in a fresh card only when a row crosses a tier.
+ private readonly List<(Control card, HeaderTier tier)> _footerCards = new();
+ private readonly List<Border> _footerGrips = new();
+ private readonly Dictionary<int, PanBar> _footerPans = new();
+
private void RebuildFooterHeaders()
{
_footerHeaders.Children.Clear();
_footerMeters.Clear();
_footerFaders.Clear();
_footerDb.Clear();
- double y = 0;
- foreach (var r in _returns)
+ _footerPans.Clear();
+ _footerCards.Clear();
+ _footerGrips.Clear();
+ int rows = _returns.Count + 1;
+ for (int i = 0; i < rows; i++)
+ {
+ var card = BuildFooterCard(i);
+ _footerCards.Add((card, TierFor(FooterRowHeight(i))));
+ Canvas.SetLeft(card, 0);
+ Canvas.SetTop(card, FooterRowTop(i));
+ _footerHeaders.Children.Add(card);
+ }
+ for (int i = 0; i < rows; i++)
{
+ var grip = FooterSeamGrip(i);
+ _footerGrips.Add(grip);
+ _footerHeaders.Children.Add(grip);
+ }
+ PlaceFooterGrips();
+ _footerHeaders.Children.Add(_footerDropRing); // browser drop target (kept invisible until a drag)
+ }
+
+ // Footer row i: a return (its bus volume) or, last, the master (the transport's master volume).
+ private Control BuildFooterCard(int i)
+ {
+ double h = FooterRowHeight(i);
+ if (i < _returns.Count)
+ {
+ var r = _returns[i];
int id = r.Id;
- var row = BuildSlimRow(r.Name, r.ColorIndex, id, "Brush.SurfaceCard", r.Volume,
- v => _engine?.SetTrackVolume(id, (float)v), out var meter, out var fader, out var db);
+ var card = BuildSlimRow(r.Name, r.ColorIndex, id, "Brush.SurfaceCard", r.Volume, h,
+ v => _engine?.SetTrackVolume(id, (float)v), out var meter, out var fader, out var db, ret: r);
_footerMeters[id] = meter;
_footerFaders[id] = fader;
_footerDb[id] = db;
- Canvas.SetLeft(row, 0);
- Canvas.SetTop(row, y);
- _footerHeaders.Children.Add(row);
- y += FooterRowH;
+ return card;
}
// Master row: selectable (opens the master effect chain) via the reserved id.
int masterId = _engine?.MasterTrackId ?? -1;
string masterName = _engine is { } me2 && me2.GetTrackName(masterId) is { Length: > 0 } mn ? mn : "Master";
- var master = BuildSlimRow(masterName, -1, masterId, "Brush.SurfaceRaised", GetMasterVolume?.Invoke() ?? 1f,
+ return BuildSlimRow(masterName, -1, masterId, "Brush.SurfaceRaised", GetMasterVolume?.Invoke() ?? 1f, h,
v => SetMasterVolume?.Invoke((float)v), out _masterRowMeter, out _masterRowFader, out _masterRowDb,
masterSpine: true);
- Canvas.SetLeft(master, 0);
- Canvas.SetTop(master, y);
- _footerHeaders.Children.Add(master);
- _footerHeaders.Children.Add(_footerDropRing); // browser drop target (kept invisible until a drag)
}
- // A slim footer row: name and volume read-out over a mini fader, with the same vertical
- // level meter as a track header on the right. No pan, and the fader writes no automation —
- // returns have no visible lane down here.
- private Control BuildSlimRow(string title, int colorIndex, int trackId, string bgKey, double volume,
- Action<double> setVolume, out MeterBar meter, out MiniFader fader, out TextBlock db, bool masterSpine = false)
+ private void PlaceFooterGrips()
{
+ for (int i = 0; i < _footerGrips.Count; i++)
+ {
+ _footerGrips[i].Width = _headerW;
+ Canvas.SetLeft(_footerGrips[i], 0);
+ Canvas.SetTop(_footerGrips[i], FooterRowTop(i + 1) - SeamGrabPx / 2);
+ }
+ }
+
+ // During a footer seam drag: move and resize the cards in place; a card whose height
+ // crossed a layout tier is rebuilt on its own.
+ private void RelayoutFooterLive()
+ {
+ RebuildFooterGeometry();
+ var children = _footerHeaders.Children;
+ for (int i = 0; i < _footerCards.Count; i++)
+ {
+ var (card, built) = _footerCards[i];
+ double h = FooterRowHeight(i);
+ if (built != TierFor(h))
+ {
+ int at = children.IndexOf(card);
+ var fresh = BuildFooterCard(i);
+ if (at >= 0) children[at] = fresh; else children.Insert(0, fresh);
+ Canvas.SetLeft(fresh, 0);
+ _footerCards[i] = (fresh, TierFor(h));
+ card = fresh;
+ }
+ Canvas.SetTop(card, FooterRowTop(i));
+ card.Height = h;
+ }
+ PlaceFooterGrips();
+ ApplyFooterHeight();
+ }
+
+ // A footer row: name and volume read-out with the same vertical level meter as a track
+ // header on the right, laid out by the row's height (specs/045) — compact puts name, fader
+ // and read-out on one line; standard stacks the fader under the name (a return adds its mute);
+ // large adds a return's pan. A return's fader and pan write automation like a track's.
+ private Control BuildSlimRow(string title, int colorIndex, int trackId, string bgKey, double volume, double height,
+ Action<double> setVolume, out MeterBar meter, out MiniFader fader, out TextBlock db, bool masterSpine = false,
+ TrackVM? ret = null)
+ {
+ var tier = TierFor(height);
var spineBrush = masterSpine ? NotaPalette.Master : ClipColors(colorIndex).content;
var name = new TextBlock
{
@@ -2847,25 +2976,82 @@ public sealed partial class ArrangementView : UserControl
// One undo step per drag / reset (specs/009): the master row targets the master volume.
var undo = _engine is { } ue ? new MixGesture(ue, masterSpine ? MixTarget.Master : MixTarget.Volume(trackId)) : null;
fader.GestureBegin += () => undo?.Begin();
+ if (ret is not null)
+ {
+ fader.GestureBegin += () => _engine?.BeginAutomationWrite(trackId, AutomationTarget.Volume, -1, -1, "");
+ fader.GestureEnd += () => _engine?.EndAutomationWrite(trackId, AutomationTarget.Volume, -1, -1, "");
+ }
fader.GestureEnd += () => undo?.End();
fader.ValueChanged += v => { Change(undo, v, setVolume); dbText.Text = VolumeDbText(v); };
ValueEntry.Attach(fader, fader.EntryField("Volume", VolumeDbText), dbText);
- var row = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), RowDefinitions = new RowDefinitions("*,*") };
- Grid.SetColumn(name, 0);
- Grid.SetColumn(dbText, 1);
- Grid.SetRow(fader, 1);
- Grid.SetColumnSpan(fader, 2);
- row.Children.Add(name);
- row.Children.Add(dbText);
- row.Children.Add(fader);
+ Control? mute = ret is null ? null
+ : ChipToggle("M", ret.Muted, NotaPalette.Mute, v => { ret.Muted = v; _engine?.SetTrackMute(trackId, v); });
- meter = new MeterBar { VerticalAlignment = VerticalAlignment.Stretch, Width = 8, Margin = new Thickness(0, 6, 3, 6) };
+ // Room for the controls beside the name: card minus spine, padding and meter.
+ double contentW = HeaderW - 3 - 16 - 11;
+ Control rowContent;
+ if (tier == HeaderTier.Compact)
+ {
+ // One line: name · fader · dB. A narrow column shrinks the fader, then drops it.
+ double faderW = Math.Clamp(contentW - 56 - 36, 0, 96);
+ var line = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto,Auto") };
+ Grid.SetColumn(name, 0);
+ line.Children.Add(name);
+ if (faderW >= 28)
+ {
+ fader.Width = faderW;
+ fader.Margin = new Thickness(6, 0, 0, 0);
+ Grid.SetColumn(fader, 1);
+ line.Children.Add(fader);
+ }
+ Grid.SetColumn(dbText, 2);
+ line.Children.Add(dbText);
+ rowContent = line;
+ }
+ else
+ {
+ var nameRow = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto,Auto") };
+ Grid.SetColumn(name, 0);
+ nameRow.Children.Add(name);
+ if (mute is not null)
+ {
+ mute.Margin = new Thickness(6, 0, 0, 0);
+ Grid.SetColumn(mute, 1);
+ nameRow.Children.Add(mute);
+ }
+ Grid.SetColumn(dbText, 2);
+ nameRow.Children.Add(dbText);
+ var stack = new StackPanel { VerticalAlignment = VerticalAlignment.Center, Spacing = 6 };
+ stack.Children.Add(nameRow);
+ stack.Children.Add(fader);
+ if (tier == HeaderTier.Large && ret is not null)
+ {
+ var pan = new PanBar(ret.Pan) { VerticalAlignment = VerticalAlignment.Center };
+ var panUndo = _engine is { } pe ? new MixGesture(pe, MixTarget.Pan(trackId)) : null;
+ pan.GestureBegin += () => panUndo?.Begin();
+ Action<double> setPan = p => _engine?.SetTrackPan(trackId, (float)p);
+ pan.PanChanged += p => Change(panUndo, p, setPan);
+ pan.GestureBegin += () => _engine?.BeginAutomationWrite(trackId, AutomationTarget.Pan, -1, -1, "");
+ pan.GestureEnd += () => _engine?.EndAutomationWrite(trackId, AutomationTarget.Pan, -1, -1, "");
+ pan.GestureEnd += () => panUndo?.End();
+ ValueEntry.Attach(pan, pan.EntryField("Pan"));
+ _footerPans[trackId] = pan;
+ stack.Children.Add(pan);
+ }
+ rowContent = stack;
+ }
+
+ meter = new MeterBar
+ {
+ VerticalAlignment = VerticalAlignment.Stretch, Width = 8,
+ Margin = tier == HeaderTier.Compact ? new Thickness(0, 4, 3, 4) : new Thickness(0, 6, 3, 6),
+ };
DockPanel.SetDock(meter, Dock.Right);
var body = new DockPanel
{
LastChildFill = true,
- Children = { meter, new Border { Padding = new Thickness(8, 4), Child = row } },
+ Children = { meter, new Border { Padding = tier == HeaderTier.Compact ? new Thickness(8, 0) : new Thickness(8, 4), Child = rowContent } },
};
var spine = new Border { Width = 3, Background = spineBrush };
@@ -2875,11 +3061,11 @@ public sealed partial class ArrangementView : UserControl
grid.Children.Add(spine);
grid.Children.Add(body);
- bool sel = trackId > 0 && trackId == SelTrackId;
+ bool sel = trackId > 0 && (trackId == SelTrackId || (ret is not null && _selTracks.Contains(trackId)));
if (sel) spine.Background = NotaPalette.Accent; // selected: accent stripe, name stays primary
var card = new Border
{
- Width = HeaderW, Height = FooterRowH, ClipToBounds = true,
+ Width = HeaderW, Height = height, ClipToBounds = true,
Background = sel ? SelHeaderBg : Brush(bgKey),
BorderBrush = Brush("Brush.BorderDefault"),
BorderThickness = new Thickness(0, 0, 1, 1),
@@ -2889,14 +3075,19 @@ public sealed partial class ArrangementView : UserControl
card.PointerPressed += (_, e) =>
{
if (e.GetCurrentPoint(card).Properties.IsRightButtonPressed) { ShowFooterMenu(card, trackId); return; }
+ if (ret is not null && (e.KeyModifiers & KeyModifiers.Shift) != 0) { SelectReturnRange(trackId); e.Handled = true; return; }
+ if (ret is not null && (e.KeyModifiers & (KeyModifiers.Control | KeyModifiers.Meta)) != 0)
+ {
+ ToggleReturnInSelection(trackId); e.Handled = true; return;
+ }
Select(trackId, -1);
};
return card;
}
- // Context menu for a send/return or the master row: rename + colour (the same edits
- // regular tracks get; returns/master have no clips to copy/duplicate), and Delete for a
- // return (the master stays).
+ // Context menu for a send/return or the master row: rename, colour and height (the same
+ // edits regular tracks get; returns/master have no clips to copy/duplicate), and Delete for
+ // a return (the master stays).
private void ShowFooterMenu(Control anchor, int trackId)
{
if (_engine is null) return;
@@ -2908,6 +3099,7 @@ public sealed partial class ArrangementView : UserControl
new Control[] { MenuKit.Header(name.Length > 0 ? name : isReturn ? "Return" : "Master",
TrackBrush(EffectiveColorIndex(_engine, trackId)), isReturn ? "Return" : "Master") },
new Control[] { TrackColourRow(new[] { trackId }) },
+ new Control[] { FooterHeightRow(isReturn ? _returns.FindIndex(r => r.Id == trackId) : _returns.Count) },
new Control[] { MenuKit.Item("Rename…", GlyphKind.Edit, () => PromptRenameTrack(anchor, trackId)) },
isReturn ? new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => DeleteTracks(new[] { trackId }), MenuKit.DeleteKey) } : null);
flyout.ShowAt(anchor, showAtPointer: true);
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 7c6b328f..3c7e539f 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -1318,6 +1318,8 @@ public sealed partial class PreferencesWindow : NotaWindow
("Drag a track's bottom edge", "Resize the track (header or lane) · snaps to compact / standard / large · a multi-selection resizes together"),
("Drag a track's bottom edge + ⌥", "Resize every track at once"),
("Double-click a track's bottom edge", "Back to the standard height"),
+ ("Drag a return's or the master's bottom edge", "Resize that row (header or lane) · same snaps · double-click goes back to compact"),
+ ("⌘-click / ⇧-click return headers", "Select several returns · they resize together"),
("⌥-click a height key in the track menu", "Set every track to Compact · Standard · Large"),
("Drag the track-list edge", "Widen or narrow the track headers · double-click resets"),
("Drag sections lane", "Mark a new section over the dragged bars"),
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 95f2e6bc..32301d8e 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -355,6 +355,14 @@ if (args.Length >= 1 && args[0] == "--linux-desktop")
return failures == 0 ? 0 : 1;
}
+// Return-track automation alone: `--return-automation`. Also part of the full run.
+if (args.Length >= 1 && args[0] == "--return-automation")
+{
+ Console.WriteLine("-- return automation --");
+ foreach (var (ok, label) in ReturnAutomationTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "RETURN AUTOMATION PASSED" : $"RETURN AUTOMATION FAILED ({failures})");
+ return failures == 0 ? 0 : 1;
+}
// Deleting a return track alone: `--returns`. Also part of the full run.
if (args.Length >= 1 && args[0] == "--returns")
{
@@ -15135,6 +15143,9 @@ foreach (var (ok, label) in ProjectTemplateTests.Run()) Check(ok, label);
Console.WriteLine("-- return delete --");
foreach (var (ok, label) in ReturnDeleteTests.Run()) Check(ok, label);
+Console.WriteLine("-- return automation --");
+foreach (var (ok, label) in ReturnAutomationTests.Run()) Check(ok, label);
+
Console.WriteLine("-- arrangement moves --");
foreach (var (ok, label) in ArrangementMovesTests.Run()) Check(ok, label);
diff --git a/tests/Nota.SmokeTest/ReturnAutomationTests.cs b/tests/Nota.SmokeTest/ReturnAutomationTests.cs
new file mode 100644
index 00000000..367e0481
--- /dev/null
+++ b/tests/Nota.SmokeTest/ReturnAutomationTests.cs
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Automation on a return track (specs/045-return-master-lanes): a return is a track to the
+// engine, so its volume and device-parameter lanes play back and survive save/load like a
+// track's. The arrangement footer edits them; this locks in the engine side it relies on.
+// Also runnable alone: `dotnet run --project tests/Nota.SmokeTest -- --return-automation`.
+
+using Nota.Application;
+using Nota.Infrastructure;
+
+namespace Nota.SmokeTest;
+
+internal static class ReturnAutomationTests
+{
+ private const int Utility = 4; // unity gain, no tail: the bus level is the send level
+
+ public static IEnumerable<(bool ok, string label)> Run()
+ {
+ using var eng = new NotaEngine();
+ int src = eng.AddInstrumentTrack();
+ int clip = eng.AddMidiClip(src, 0.0, 16.0);
+ eng.SetClipNotes(src, clip, new[] { new NotaNote(60, 0.0, 16.0, 0.9f) });
+ int ret = eng.AddReturnTrack();
+ eng.AddBuiltinDevice(ret, Utility);
+ eng.SetTrackSend(src, 0, 0.8f);
+
+ // Volume lane: silent for the first bar, full from beat 8 on.
+ int vol = eng.AddAutomationLane(ret, AutomationTarget.Volume, -1, -1);
+ yield return (vol >= 0, $"return automation: a volume lane on a return (lane {vol})");
+ eng.SetAutomationPoints(ret, vol, new[]
+ {
+ new AutomationPoint(0.0, 0f), new AutomationPoint(4.0, 0f), new AutomationPoint(8.0, 1f),
+ });
+ float quiet = PeakAt(eng, ret, 1.0), loud = PeakAt(eng, ret, 10.0);
+ yield return (quiet < 0.0005f && loud > 0.001f,
+ $"return automation: the return follows its volume lane (beat 1 peak={quiet:F4}, beat 10 peak={loud:F4})");
+
+ // Device-parameter lane on the return's chain: the device takes the lane's value.
+ float lo = eng.DeviceParamMin(ret, 0, 0), hi = eng.DeviceParamMax(ret, 0, 0);
+ float target = lo + (hi - lo) * 0.25f;
+ int dev = eng.AddAutomationLane(ret, AutomationTarget.DeviceParam, 0, 0);
+ eng.SetAutomationPoints(ret, dev, new[] { new AutomationPoint(0.0, target), new AutomationPoint(16.0, target) });
+ PeakAt(eng, ret, 2.0);
+ float got = eng.DeviceGetParam(ret, 0, 0);
+ yield return (dev >= 0 && Math.Abs(got - target) < 1e-3f * Math.Max(1f, hi - lo),
+ $"return automation: a device lane drives the return's device (want {target:F3}, got {got:F3})");
+
+ // Undo takes the last point edit back.
+ yield return (eng.Undo() && eng.GetAutomationPoints(ret, dev).Length == 0,
+ "return automation: undo reverts a return lane edit");
+ yield return (eng.Redo() && eng.GetAutomationPoints(ret, dev).Length == 2,
+ "return automation: redo re-applies it");
+
+ // Save/load keeps both lanes and their points on the return.
+ string dir = Path.Combine(Path.GetTempPath(), "nota-return-auto-" + Guid.NewGuid().ToString("N"));
+ try
+ {
+ var doc = ProjectService.Capture(eng, new TransportState(120, 1, false, false), new List<string>());
+ ProjectService.Save(doc, dir, eng);
+ using var eng2 = new NotaEngine();
+ ProjectService.Apply(ProjectService.Load(dir), eng2, dir);
+ int ret2 = -1;
+ for (int i = 0; i < eng2.TrackCount; i++)
+ if (eng2.TryGetTrackInfo(i, out var t) && t.IsReturn) ret2 = t.Id;
+ int lanes = ret2 > 0 ? eng2.AutomationLaneCount(ret2) : 0;
+ bool volOk = false, devOk = false;
+ for (int l = 0; l < lanes; l++)
+ {
+ var info = eng2.AutomationLaneInfo(ret2, l);
+ var pts = eng2.GetAutomationPoints(ret2, l);
+ if (info.Target == AutomationTarget.Volume) volOk = pts.Length == 3 && Math.Abs(pts[2].Value - 1f) < 1e-6f;
+ if (info.Target == AutomationTarget.DeviceParam) devOk = pts.Length == 2 && Math.Abs(pts[0].Value - target) < 1e-4f;
+ }
+ yield return (lanes == 2 && volOk && devOk,
+ $"return automation: save/load keeps the return's lanes ({lanes} lanes, volume {volOk}, device {devOk})");
+ }
+ finally
+ {
+ try { if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); } catch (IOException) { }
+ }
+ }
+
+ // Peak of the return's meter over one block rendered from `beat`.
+ private static float PeakAt(NotaEngine eng, int trackId, double beat)
+ {
+ var buf = new float[4096 * 2];
+ eng.Seek(beat);
+ eng.Play();
+ eng.RenderOffline(buf, 4096);
+ eng.StopTransport();
+ eng.TryGetTrackMeter(trackId, out var m);
+ return m.Peak;
+ }
+}