Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
Research: Piano roll vertical zoom
Findings from reading the current piano roll (src/managed/Nota.App/PianoRollView.cs,
ClipEditorView.cs, MainWindow.Input.cs, MainWindow.Commands.cs,
Nota.Application/Palette/CommandCatalog.cs, PreferencesWindow.cs) and the Avalonia
12.0.3 API.
R1 — Where the row height lives
- Decision: Replace
private const double RowH = 12with an instance propertyRowHbacked by_rowH, plusMinRowH = 6,DefaultRowH = 12,MaxRowH = 36.RangeH,PitchToYandYToPitch(static today) become instance members; the nested controls (KeysColumn,NoteGrid) read_o.RowH. - Rationale: Every row-dependent draw and hit-test already goes through
RowH(~40 uses, all inPianoRollView.cs;PianoRollView.Expression.csuses none), so one source of truth covers FR-008 without touching the drawing logic. - Alternatives considered: A
ScaleTransformon the body — rejected: it would scale note text, pens and the keys column width too, and hit-testing would still be in unscaled rows.
R2 — Anchored zoom math
- Decision: One method
ZoomRowsAt(double factor, double viewportY). Withoff= current vertical offset andh0/h1the old/new row heights, the content position under the pointer isc = off + viewportY; the new offset isc * h1 / h0 - viewportY, clamped to[0, max(0, 88·h1 − viewportHeight)]. The newHeightis set on_keys/_gridControl, and the offset goes through the existing_pendingVOffset→ApplyPendingVOffsetpath, because the ScrollViewer's extent only grows after the next layout pass. - Rationale: The same anchor formula
ZoomAtuses horizontally; reusing the pending offset path avoids a clamp against the stale extent (which would make zoom-in near the bottom jump). - Alternatives considered: Setting
Offsetsynchronously afterUpdateLayout()— works but forces a layout per wheel event; the pending path is already there.
R3 — Wheel gesture
- Decision: In
NoteGrid.OnPointerWheelChanged, test (⌘ or Ctrl) and ⌥ first →ZoomRowsAt(WheelInput.ZoomFactor(e.Delta.Y, 1.2), y-in-viewport); the existing branches (⌘/Ctrl = horizontal zoom, Shift, horizontal swipe) follow unchanged. Add the same ⌘⌥ branch to a newKeysColumn.OnPointerWheelChanged(plain wheel there stays with the ScrollViewer). - Rationale: FR-002/FR-003. Today ⌘⌥+wheel falls into the ⌘ branch (horizontal zoom), so checking ⌥ first is the only change to existing meaning — a combination nobody relies on.
- Note:
ClipEditorView'sRouteWheel(ruler / lane rows) keeps horizontal only — vertical zoom is about rows, which those rows don't show.
R4 — Keys-column drag
- Decision:
KeysColumngetsOnPointerPressed(left button → capture, remember the press Y in_bodyScrollviewport coordinates and the row height at press),OnPointerMovedwhile captured (h = clamp(h0 · exp(dy · 0.01)), applied via aSetRowHeightAt(h, pressViewportY)sibling of R2),OnPointerReleased/OnPointerCaptureLostend it. Down (positive dy) = taller. X is ignored. - Rationale: The keys column has no press handling today (only hover), so there is no conflict and nothing auditions (FR-004). Exponential mapping makes equal drags equal zoom ratios; 0.01/px gives ~2.7× per 100 px, which covers 6→36 px in ~180 px.
- Alternatives considered: Linear px→px mapping — feels sluggish at small heights and jumpy at large ones.
R5 — Trackpad pinch
- Decision:
AddHandler(InputElement.PointerTouchPadGestureMagnifyEvent, …)on the note grid; when ⌥ is held,ZoomRowsAt(1 + e.Delta.X, y)and mark handled. - Rationale: Avalonia 12 exposes
PointerTouchPadGestureMagnify(PointerDeltaEventArgs, "two contact points moving apart on a touchpad"); it is raised by the macOS backend. On platforms that never raise it nothing changes (US4 scenario 2). - Alternatives considered:
Gestures.PinchEvent— that is the touchscreen pinch recogniser, not the touchpad.
R6 — Zoom during a note gesture
- Decision: Ignore vertical-zoom input while
NoteGrid._drag != Mode.None(move, resize, marquee in progress). - Rationale: Simplest way to guarantee SC-004; the drag state stores grab offsets in pixels, and re-deriving them mid-gesture is risk with no user value.
R7 — Fit to notes and ⇧F
- Decision:
PianoRollView.FitToNotes(): empty clip →DefaultRowHand the existingCenterOffsetForNotes()C5 fallback; otherwisespan = maxP − minP + 1 + 2(one margin row each side),h = clamp(viewportHeight / span, MinRowH, MaxRowH), then centre on the notes (the existing centring helper, which now uses the instanceRowH). Uses all notes regardless of selection. - Shortcut: handle
Key.Fwith exactly Shift inNoteGrid.OnKeyDown, setHandled. Because the grid is the focused source, the event never reachesMainWindow.OnKeyDown(a class handler that skips handled events), so the note map's Shift-agnosticF(modexcludes Shift) does not sound a note. Outside the grid, ⇧F is untouched. - Palette:
C("roll.fitNotes", "Fit to notes", "Piano roll", "⇧F", "zoom vertical rows height")inCommandCatalog, bound with the existingRollavailability inMainWindow.Commands. - Header: a "Fit" chip (the header's existing
chipstyle, like "Tools") inClipEditorView's right header group, before the snap chip, tooltip "Fit to notes (⇧F)" — per DESIGN.md, neutral, not accent.
R8 — Persistence
- Decision: Add
RowHto the per-clipViewStaterecord;SaveViewwrites it,SetNotesrestores it (clamped); a clip without saved state getsDefaultRowH(clarification 1 and 2). Not undoable, not saved to the project (FR-009/FR-010). - Rationale: Same scope and lifetime as horizontal zoom and scroll today.
R9 — Key labels at small/large rows
- Decision: Keep labelling only C rows (plus the hovered/held key, as today). The label is centred on its row and may overflow a short row; with C rows ≥ 72 px apart at the 6 px minimum, labels never collide.
- Rationale: FR-011 is already met by the sparse labelling; no thinning logic needed.
R10 — Verification
- Decision: No managed unit-test project exists; the smoke test covers the engine and
is unaffected (no engine change). Verify with the headless Avalonia harness (agent memory
nota-ui-verify): hostPianoRollViewin aWindow, seed notes, drive zoom through synthetic wheel/pointer events and capture frames at 6 / 12 / 36 px and after Fit.