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) Pause, show playhead and loop editing on the ruler (#182)

Chris Laupama129312256539
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5dfd50d1..5bb80df7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,22 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
to play it on the track's instrument, ⇧-drag down the keys to glide through them, and
⌘-click (Ctrl-click) a key to select every note of that pitch (⇧ adds to the selection).
Dragging up or down on the keys still zooms the rows.
+- **Pause** (nota-daw/nota#51): ⇧Space (and *Play / pause* in the Transport menu and the
+ command palette) stops with the playhead left where it is, and the next Play carries on from
+ there. Space still stops and goes back to where playback started.
+- **Show playhead** (nota-daw/nota#105): P (and View ▸ Show playhead) scrolls the Arrangement to
+ the playhead without moving it, the zoom or the selection — only when it is off screen, and
+ with what comes next in view. When the playhead is off screen an arrow at that end of the
+ ruler points to it; a click on the arrow does the same. Follow now pauses when you scroll
+ away during playback, instead of snapping back: the Follow button turns to an outline, and
+ P, a click on the button or the next Play picks it up again. Follow no longer scrolls the
+ lanes under a clip drag, trim or selection in progress.
+- **Resize, move and clear the loop region** (nota-daw/nota#125): drag either end of the loop
+ brace in the ruler to move just that end (a sideways cursor and a brighter edge show where
+ to grab), drag the brace itself to move the whole region, with ⌥ to leave the grid. The
+ start, end and length show while you drag. Right-click the ruler to turn the loop on or off,
+ loop the selection or **Clear loop region**, which forgets the region (turning the loop off
+ keeps it). Clips, notes and automation are never touched.
- **The sustain pedal on every built-in instrument** (nota-daw/nota#99): with the pedal down,
released keys keep sounding on Synth, Sampler, Volt, Bass, Flux, Grain, Operator,
Wavetable, Physical, Pentad, Consort, Monolith and Pendulum (and on an Instrument Rack's
diff --git a/FEATURES.md b/FEATURES.md
index a57f7be0..1e194cad 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -70,7 +70,11 @@ JUCE module; the engine core is JUCE-free.
the arrangement can be transposed to it.
- **Transport**: play / stop / record, playhead position.
- **Stop returns to the launch point** (a seek sets the start anchor).
- - **Follow** — the arrangement follows the cursor (playhead stays centred).
+ - **Pause** (⇧Space) — the playhead stays where it stopped and Play carries on from there.
+ - **Follow** — the arrangement follows the cursor (playhead stays centred); scrolling away
+ during playback pauses it until **Show playhead** (P), the button or the next Play.
+ - **Show playhead** (P, View menu, or the arrow the ruler shows when it is off screen) —
+ scrolls the arrangement to the playhead without moving it.
- **Launch quantize** (Q): None … 1/16 … 4 Bars — applied when launching slots and
scenes in Session.
- **Position**: clicking the readout toggles bars ↔ time (mm:ss.ms).
@@ -80,7 +84,8 @@ JUCE module; the engine core is JUCE-free.
power of two), grid and quantization.
- **Tap tempo**: a TAP cell beside the BPM (and *Tap Tempo* in the command palette) sets the
tempo from tapped beats — mean of the last eight gaps, restarts on a pace change or a 3 s pause.
-- **Loop region** (on/off and range; Cmd/Ctrl+L loops the selection). Notes held across the
+- **Loop region** (on/off and range; Cmd/Ctrl+L loops the selection; drag an end of the brace
+ to resize it, the brace to move it; right-click the ruler to clear it). Notes held across the
loop seam keep sounding and release tails ring into the next pass; an arpeggiator keeps its
pattern going across the seam.
- **Metronome** and **count-in** before recording, Session slot takes from stop included (notes played on the count-in are recorded).
diff --git a/specs/025-transport-navigation/spec.md b/specs/025-transport-navigation/spec.md
new file mode 100644
index 00000000..f5cb72f0
--- /dev/null
+++ b/specs/025-transport-navigation/spec.md
@@ -0,0 +1,44 @@
+# Feature Specification: Pause, Show playhead and loop-region editing
+
+**Feature Branch**: `025-transport-navigation`
+
+**Created**: 2026-10-18
+
+**Status**: Implemented
+
+**Input**: User description: three requests about getting around the Arrangement while it plays.
+"Transport: Shift+Space / Ctrl+Space for pause-here and return-to-start-point" (nota-daw/nota#51);
+"Show Playhead and Optional Playback Following" (nota-daw/nota#105); "Clear and Resize the
+Arrangement Loop Region" (nota-daw/nota#125).
+
+## Nota Context
+
+**Feature area**: UI (Avalonia) — transport view model, Arrangement ruler, command catalog.
+No engine change. The engine's Stop already rewinds to the start anchor (where playback
+started, or the last seek), so "return to start point" exists today on Space; what is
+missing is pause. The loop region is transport state: not saved with the project and not in
+the undo history.
+
+## Clarifications
+
+### Session 2026-10-18
+
+- Q: Which keys? → A: ⇧Space = Play / pause. Space keeps Play / Stop (stop returns to where playback started). ⌘Space / Ctrl+Space were not used: they are Spotlight and the input-source switch on macOS. No Preferences option for now; both behaviours are one key apart.
+- Q: How does pause work without an engine change? → A: Stop, then seek to the position it stopped at; a seek moves the start anchor, so the next Play continues from there. A pause during a count-in just stops (nothing moved yet).
+- Q: Show playhead's key? → A: P (free: not part of the computer-keyboard note map, which ends at K). Also View ▸ Show playhead and the command palette.
+- Q: When does Show playhead scroll? → A: Only when the playhead is off screen or within 5 % of an edge; it then lands a quarter of the way in so what comes next is visible. Zoom, vertical position, selection and transport are untouched.
+- Q: Follow suspension? → A: Any user scroll of the lanes during playback with Follow on (wheel, scrollbar, overview strip, edge auto-scroll while dragging a clip) pauses Follow. Show playhead, a click on the Follow button and the next Play pick it up again. While paused the button shows an accent outline instead of the solid key, the tooltip and status bar say how to resume. Follow never scrolls during a clip drag, trim, marquee, time-range or envelope edit.
+- Q: Off-screen indicator? → A: A small accent arrow at that end of the ruler; a press on it (14 px zone) runs Show playhead instead of seeking.
+- Q: Moving vs drawing the loop? → A: A drag that starts on the brace moves it (length kept); a drag on either edge (5 px each side) resizes that edge only; a drag elsewhere draws a new region as before; a click anywhere still seeks; a double-click on the brace still turns it off / on (#59). ⌥ ignores the grid. The other edge is never re-snapped.
+- Q: Clear vs off? → A: Right-click on the ruler: Turn loop on / off, Loop selection, Clear loop region. Clear turns the loop off and forgets the range; the transport cell then shows the range Loop would use (1.1–5.1).
+- Q: Undo for loop edits? → A: Not in this change: the loop region is not part of the project or its history.
+
+## Requirements
+
+- **FR-001**: ⇧Space MUST pause (stop with the playhead in place) while playing, and play while stopped.
+- **FR-002**: Space MUST keep its current behaviour.
+- **FR-003**: Show playhead MUST NOT seek, change zoom, vertical scroll or selection, and MUST NOT scroll when the playhead is already comfortably visible.
+- **FR-004**: A user scroll during playback with Follow on MUST pause Follow; Show playhead, the Follow button and the next Play MUST resume it.
+- **FR-005**: Dragging a loop edge MUST keep the other edge exactly; dragging the brace MUST keep the length.
+- **FR-006**: Clear loop region MUST leave clips, notes and automation untouched.
+- **FR-007**: Settings → Shortcuts, the command palette and the menus MUST list the new commands.
diff --git a/specs/025-transport-navigation/tasks.md b/specs/025-transport-navigation/tasks.md
new file mode 100644
index 00000000..b8c25336
--- /dev/null
+++ b/specs/025-transport-navigation/tasks.md
@@ -0,0 +1,10 @@
+# Tasks: Pause, Show playhead and loop-region editing
+
+**Input**: [spec.md](spec.md)
+
+- [x] T001 `TransportViewModel.PlayPause` (#51); `transport.playPause` in the catalog, Transport menu, ⇧Space in `OnGlobalTransportKey`
+- [x] T002 `ArrangementView.RevealPlayhead`, `PlayheadOffscreen`; `view.showPlayhead` (P) in the catalog, View menu, `MainWindow.ShowPlayhead`
+- [x] T003 Follow suspension: `NoteManualScroll` from wheel / scrollbar / overview / auto-scroll, resume on Play, Show playhead, Follow click; `LaneControl.IsGesturing` guard; `.paused` Follow button style + status text
+- [x] T004 Ruler: off-screen arrow, loop edge hover / resize, brace move, drag readout, right-click menu with Clear loop region; transport cell after a clear
+- [x] T005 Settings → Shortcuts rows, CHANGELOG, FEATURES.md, nota-docs EN + RU
+- [x] T006 Verified in the headless app (transport positions, scroll, loop ranges), `scripts/build-linux.sh` green; macOS check on the Mac
diff --git a/src/managed/Nota.App/ArrangementView.Controls.cs b/src/managed/Nota.App/ArrangementView.Controls.cs
index ca32797d..818d1c03 100644
--- a/src/managed/Nota.App/ArrangementView.Controls.cs
+++ b/src/managed/Nota.App/ArrangementView.Controls.cs
@@ -23,38 +23,121 @@ public sealed partial class ArrangementView
private sealed class RulerControl : Control
{
private readonly ArrangementView _o;
- public RulerControl(ArrangementView o) { _o = o; Cursor = new Cursor(StandardCursorType.Hand); }
+ public RulerControl(ArrangementView o) { _o = o; Cursor = HandCursor; }
- private double _pressBeat;
- private bool _dragging; // a click scrubs the playhead; a drag defines a loop region
- private bool _toggled; // this press double-clicked the loop brace: no seek, no drag
+ private static readonly Cursor HandCursor = new(StandardCursorType.Hand);
+ private static readonly Cursor EdgeCursor = new(StandardCursorType.SizeWestEast);
+ private const double EdgeGrab = 5; // px either side of a loop edge that grabs it
+ private const double ArrowZone = 14; // px at the end of the ruler the off-screen arrow owns
+
+ // A click scrubs the playhead; a drag draws a loop region. On the loop brace a drag
+ // moves the region, on either edge it resizes that edge alone (#125).
+ private enum Gesture { None, Pending, Draw, Move, ResizeStart, ResizeEnd, Done }
+ private Gesture _gesture;
+ private Gesture _onRelease; // what this press becomes once it drags
+ private double _pressBeat, _pressX;
+ private double _origS, _origE;
private double BeatAt(PointerEventArgs e) => _o._scrollBeats + e.GetPosition(this).X / _o._pixelsPerBeat;
+ // Which loop edge (−1 start, +1 end, 0 none) is under x; the closer one on a short loop.
+ private int EdgeAt(double x)
+ {
+ if (!(_o._loopE > _o._loopS)) return 0;
+ double ds = Math.Abs(x - _o.BeatToX(_o._loopS)), de = Math.Abs(x - _o.BeatToX(_o._loopE));
+ if (Math.Min(ds, de) > EdgeGrab) return 0;
+ return ds <= de ? -1 : 1;
+ }
+ private bool OnBrace(double beat) => _o._loopE > _o._loopS && beat > _o._loopS && beat < _o._loopE;
+ private bool OnArrow(double x)
+ {
+ int side = _o.PlayheadOffscreen();
+ return side < 0 ? x < ArrowZone : side > 0 && x > Bounds.Width - ArrowZone;
+ }
+
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
- if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
- _pressBeat = BeatAt(e);
- _dragging = false;
+ var pt = e.GetCurrentPoint(this);
+ if (pt.Properties.IsRightButtonPressed) { ShowMenu(); e.Handled = true; return; }
+ if (!pt.Properties.IsLeftButtonPressed) return;
+ double x = e.GetPosition(this).X;
+ _pressBeat = BeatAt(e); _pressX = x;
+ _origS = _o._loopS; _origE = _o._loopE;
+ _gesture = Gesture.Pending;
+ int edge = EdgeAt(x);
+ if (OnArrow(x)) { _o.RevealPlayhead(); _gesture = Gesture.Done; } // the off-screen arrow (#105)
// Double-click on the loop brace turns the loop off / on; the region stays (#59).
- _toggled = e.ClickCount == 2 && _o.ToggleLoopAt(_pressBeat);
+ else if (e.ClickCount == 2 && _o.ToggleLoopAt(_pressBeat)) _gesture = Gesture.Done;
+ // A click still seeks; only a drag past a few pixels becomes one of these.
+ _onRelease = edge < 0 ? Gesture.ResizeStart : edge > 0 ? Gesture.ResizeEnd
+ : OnBrace(_pressBeat) ? Gesture.Move : Gesture.Draw;
e.Pointer.Capture(this); e.Handled = true;
}
protected override void OnPointerMoved(PointerEventArgs e)
{
- if (_toggled || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ double x = e.GetPosition(this).X;
+ if (_gesture == Gesture.None)
+ {
+ // Hover: a sideways arrow over a loop edge says it can be dragged.
+ int edge = EdgeAt(x);
+ var want = edge != 0 ? EdgeCursor : HandCursor;
+ if (Cursor != want) Cursor = want;
+ if (edge != _hotEdge) { _hotEdge = edge; InvalidateVisual(); }
+ return;
+ }
+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed || _gesture == Gesture.Done) return;
double cur = BeatAt(e);
- if (!_dragging && Math.Abs(cur - _pressBeat) * _o._pixelsPerBeat > 4) _dragging = true;
- if (_dragging) _o.SetLoopPreview(_pressBeat, cur);
+ if (_gesture == Gesture.Pending && Math.Abs(x - _pressX) > 4) _gesture = _onRelease;
+ bool free = (e.KeyModifiers & KeyModifiers.Alt) != 0; // ⌥ = off the grid
+ switch (_gesture)
+ {
+ case Gesture.Draw: _o.SetLoopPreview(_pressBeat, cur); break;
+ case Gesture.Move: _o.SetLoopMovePreview(_origS, _origE, cur - _pressBeat, free); break;
+ case Gesture.ResizeStart: _o.SetLoopEdgePreview(start: true, cur, free); break;
+ case Gesture.ResizeEnd: _o.SetLoopEdgePreview(start: false, cur, free); break;
+ }
}
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
- if (_toggled) { } // the double-click already toggled the loop
- else if (_dragging) _o.CommitLoopPreview(); // drag → loop region
- else _o.SeekTo(_pressBeat); // plain click → scrub playhead
- _dragging = false; _toggled = false;
+ switch (_gesture)
+ {
+ case Gesture.Pending: _o.SeekTo(_pressBeat); break; // plain click → scrub playhead
+ case Gesture.Draw: _o.CommitLoopPreview(); break; // drag → loop region
+ case Gesture.Move or Gesture.ResizeStart or Gesture.ResizeEnd: _o.CommitLoopEdit(); break;
+ }
+ _gesture = Gesture.None;
+ Cursor = EdgeAt(e.GetPosition(this).X) != 0 ? EdgeCursor : HandCursor;
e.Pointer.Capture(null);
}
+ protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e)
+ {
+ if (_gesture is Gesture.Draw or Gesture.Move or Gesture.ResizeStart or Gesture.ResizeEnd) _o.CancelLoopPreview();
+ _gesture = Gesture.None;
+ }
+ protected override void OnPointerExited(PointerEventArgs e)
+ {
+ if (_hotEdge != 0) { _hotEdge = 0; InvalidateVisual(); }
+ }
+ private int _hotEdge; // the loop edge under the pointer, drawn brighter
+
+ // Right-click: the loop region's commands (#125). Clearing forgets the region — unlike
+ // turning the loop off, which keeps it for a double-click to bring back.
+ private void ShowMenu()
+ {
+ var flyout = new MenuFlyout();
+ bool has = _o._loopE > _o._loopS;
+ var toggle = new MenuItem { Header = _o._loopActive ? "Turn loop off" : "Turn loop on", Icon = MenuKit.Icon(GlyphKind.Cycle), InputGesture = MenuKit.LoopKey };
+ toggle.Click += (_, _) => _o.SetLoopOn(!_o._loopActive);
+ var sel = new MenuItem { Header = "Loop selection", Icon = MenuKit.Icon(GlyphKind.Select), IsEnabled = _o.SelectionLoopRange() is not null };
+ sel.Click += (_, _) => { if (_o.SelectionLoopRange() is { } r) _o.SetLoopRegion(r.Start, r.End); };
+ var clear = new MenuItem { Header = "Clear loop region", Icon = MenuKit.Icon(GlyphKind.Trash), IsEnabled = has };
+ clear.Click += (_, _) => _o.ClearLoopRegion();
+ flyout.Items.Add(toggle);
+ flyout.Items.Add(sel);
+ flyout.Items.Add(new Separator());
+ flyout.Items.Add(clear);
+ flyout.ShowAt(this, showAtPointer: true);
+ }
public override void Render(DrawingContext ctx)
{
@@ -73,6 +156,13 @@ public sealed partial class ArrangementView
ctx.FillRectangle(fill, new Rect(cx0, 0, cx1 - cx0, h));
if (lx0 >= 0) ctx.DrawLine(edge, new Point(lx0, 0), new Point(lx0, h));
if (lx1 <= w) ctx.DrawLine(edge, new Point(lx1, 0), new Point(lx1, h));
+ // The edge under the pointer (or being dragged) brightens: it can be grabbed.
+ int hot = _gesture == Gesture.ResizeStart ? -1 : _gesture == Gesture.ResizeEnd ? 1 : _gesture is Gesture.None or Gesture.Pending ? _hotEdge : 0;
+ if (hot != 0)
+ {
+ double hx = hot < 0 ? lx0 : lx1;
+ if (hx >= 0 && hx <= w) ctx.DrawLine(LoopEdgeHot, new Point(hx, 0), new Point(hx, h));
+ }
}
}
@@ -108,6 +198,35 @@ public sealed partial class ArrangementView
}
ctx.DrawGeometry(PlayheadBrush, null, tri);
}
+
+ // Playhead off screen (#105): a small arrow at that end of the ruler; a click on
+ // it brings the playhead into view.
+ int side = _o.PlayheadOffscreen();
+ if (side != 0)
+ {
+ double ax = side < 0 ? 4 : w - 4, cy = h / 2, d = side < 0 ? 1 : -1;
+ ctx.FillRectangle(ChromeBg, new Rect(side < 0 ? 0 : w - ArrowZone, 0, ArrowZone, h)); // over a bar label
+ var arrow = new StreamGeometry();
+ using (var g = arrow.Open())
+ {
+ g.BeginFigure(new Point(ax, cy), true);
+ g.LineTo(new Point(ax + d * 6, cy - 4.5));
+ g.LineTo(new Point(ax + d * 6, cy + 4.5));
+ g.EndFigure(true);
+ }
+ ctx.DrawGeometry(PlayheadBrush, null, arrow);
+ }
+
+ // While a loop region is drawn, moved or resized: its start, end and length.
+ if (_o._loopDragging && _o._loopE > _o._loopS)
+ {
+ var ft = new FormattedText(_o.LoopReadout(), CultureInfo.InvariantCulture,
+ FlowDirection.LeftToRight, NotaFonts.Mono, NotaType.Axis, ReadoutText);
+ double tx = Math.Clamp(_o.BeatToX(_o._loopE) + 6, 2, Math.Max(2, w - ft.Width - 6));
+ var box = new Rect(tx - 3, 2, ft.Width + 6, h - 4);
+ ctx.FillRectangle(ChromeBg, box);
+ ctx.DrawText(ft, new Point(tx, (h - ft.Height) / 2));
+ }
}
}
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index f72c9d6f..19ff5530 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -140,6 +140,9 @@ public sealed partial class ArrangementView
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;
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.
diff --git a/src/managed/Nota.App/ArrangementView.Overview.cs b/src/managed/Nota.App/ArrangementView.Overview.cs
index 0cb665a7..9a1c83c9 100644
--- a/src/managed/Nota.App/ArrangementView.Overview.cs
+++ b/src/managed/Nota.App/ArrangementView.Overview.cs
@@ -93,6 +93,7 @@ public sealed partial class ArrangementView
internal void ApplyOverviewView(double pixelsPerBeat, double startBeat)
{
_pixelsPerBeat = Math.Clamp(pixelsPerBeat, 4, 240);
+ if (Math.Abs(Math.Max(0, startBeat) - _scrollBeats) > 1e-9) NoteManualScroll();
_scrollBeats = Math.Max(0, startBeat);
SyncScroll(_lanes.Bounds.Width); // clamps the scroll to range + syncs the scrollbar
Redraw();
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index de075fec..d5d9a1db 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -296,7 +296,7 @@ public sealed partial class ArrangementView : UserControl
_headerColumnParts.Add(_headerDropRing);
_headerColumnParts.Add(_footerDropRing);
_hScroll = new ThinScrollBar();
- _hScroll.Scroll += (_, _) => { _scrollBeats = _hScroll.Value; Redraw(); };
+ _hScroll.Scroll += (_, _) => { _scrollBeats = _hScroll.Value; NoteManualScroll(); Redraw(); };
// Keep the scroll range in sync with the visible width — outside the
// render pass (mutating controls during Render() is illegal / crashes).
_lanes.SizeChanged += (_, _) => SyncScroll(_lanes.Bounds.Width);
@@ -530,8 +530,66 @@ public sealed partial class ArrangementView : UserControl
internal IReadOnlyList<TrackVM> Tracks => _tracks;
/// <summary>When on, the grid scrolls to keep the playhead centred during playback
- /// ("Follow"); the transport-bar Follow toggle drives this.</summary>
- public bool FollowPlayhead { get; set; }
+ /// ("Follow"); the transport-bar Follow toggle drives this. Setting it (either way)
+ /// clears a suspension.</summary>
+ public bool FollowPlayhead
+ {
+ get => _followPlayhead;
+ set { _followPlayhead = value; SetFollowSuspended(false); }
+ }
+ private bool _followPlayhead;
+
+ /// <summary>Follow is on but paused because the user scrolled the lanes away during
+ /// playback (#105): the view stays where they took it until Show playhead, the Follow
+ /// toggle or the next Play picks it up again.</summary>
+ public bool FollowSuspended { get; private set; }
+ /// <summary>Raised when <see cref="FollowSuspended"/> flips, for the transport button and status.</summary>
+ public event Action? FollowSuspendedChanged;
+ private void SetFollowSuspended(bool on)
+ {
+ if (FollowSuspended == on) return;
+ FollowSuspended = on;
+ FollowSuspendedChanged?.Invoke();
+ }
+ private bool _wasPlaying;
+
+ // A scroll the user asked for (wheel, scrollbar, overview strip, drag auto-scroll):
+ // while Follow is driving the view during playback, it pauses Follow instead of being
+ // undone on the next tick.
+ private void NoteManualScroll()
+ {
+ if (!_followPlayhead || _engine is not { IsPlaying: true }) return;
+ _wasPlaying = true; // this run is under way: the next tick must not read it as a new Play
+ SetFollowSuspended(true);
+ }
+
+ /// <summary>Show playhead (#105): bring the playhead into view without moving it, the
+ /// zoom, the tracks' vertical position or the selection. Does nothing when it is already
+ /// comfortably on screen; otherwise it lands a quarter of the way in, with what comes
+ /// next in view. Also resumes a suspended Follow. False when there was nothing to do.</summary>
+ public bool RevealPlayhead()
+ {
+ SetFollowSuspended(false);
+ double laneWidth = _lanes.Bounds.Width;
+ if (laneWidth <= 0 || _pixelsPerBeat <= 0) return false;
+ double viewportBeats = laneWidth / _pixelsPerBeat;
+ double rel = _playheadBeats - _scrollBeats, margin = viewportBeats * 0.05;
+ if (rel >= margin && rel <= viewportBeats - margin) return false;
+ double target = Math.Clamp(_playheadBeats - viewportBeats * 0.25, 0, Math.Max(0, _hScroll.Maximum));
+ if (Math.Abs(target - _scrollBeats) < 1e-6) return false;
+ _scrollBeats = target;
+ _hScroll.Value = target;
+ Redraw();
+ return true;
+ }
+
+ /// <summary>Where the playhead sits relative to the lanes: −1 left of the view, +1 right
+ /// of it, 0 on screen (the ruler draws an arrow at that edge, #105).</summary>
+ internal int PlayheadOffscreen()
+ {
+ double x = BeatToX(_playheadBeats), w = _lanes.Bounds.Width;
+ return w <= 0 ? 0 : x < 0 ? -1 : x > w ? 1 : 0;
+ }
/// <summary>Snap the view to the playhead now (called when Follow is switched on so the
/// grid jumps to the cursor immediately, without waiting for the next playback tick).</summary>
@@ -570,7 +628,11 @@ public sealed partial class ArrangementView : UserControl
_playheadBeats = beats;
// While following, the view scrolls under the playhead — the lane surface (clips /
// waveforms) must repaint along with the ruler+overlay, not just the overlay.
- bool scrolled = FollowPlayhead && _engine is { IsPlaying: true } && CenterOnPlayhead();
+ // Every Play starts Follow afresh, even when the last run left it paused.
+ bool playing = _engine is { IsPlaying: true };
+ if (playing && !_wasPlaying) SetFollowSuspended(false);
+ _wasPlaying = playing;
+ bool scrolled = _followPlayhead && !FollowSuspended && playing && !_lanes.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.
@@ -631,7 +693,81 @@ public sealed partial class ArrangementView : UserControl
SetLoopRegion(_loopS, _loopE);
}
- private void CancelLoopPreview() { _loopDragging = false; }
+ private void CancelLoopPreview() { _loopDragging = false; Redraw(); }
+
+ /// <summary>Live preview of one loop edge dragged on the ruler (#125): the other edge
+ /// stays exactly where it was; the dragged one snaps (unless <paramref name="free"/>)
+ /// and stops a grid step short of the other.</summary>
+ private void SetLoopEdgePreview(bool start, double beat, bool free)
+ {
+ _loopDragging = true;
+ double b = Math.Max(0, free ? beat : Snap(beat));
+ double min = free ? 1.0 / 64 : SnapStepBeats;
+ if (start) _loopS = Math.Min(b, _loopE - min);
+ else _loopE = Math.Max(b, _loopS + min);
+ _loopS = Math.Max(0, _loopS);
+ Redraw();
+ }
+
+ /// <summary>Live preview of the loop region dragged by its brace (#125): same length,
+ /// start moved by <paramref name="delta"/> beats, snapped unless free, never before 0.</summary>
+ private void SetLoopMovePreview(double origStart, double origEnd, double delta, bool free)
+ {
+ _loopDragging = true;
+ double len = origEnd - origStart;
+ double s = Math.Max(0, free ? origStart + delta : origStart + Snap(delta));
+ _loopS = s; _loopE = s + len;
+ Redraw();
+ }
+
+ /// <summary>Commit a moved / resized region as previewed (no re-snap: the edge that was
+ /// not dragged keeps its exact position). Keeps the loop's on/off state.</summary>
+ private void CommitLoopEdit()
+ {
+ _loopDragging = false;
+ if (_engine is null || !(_loopE > _loopS)) return;
+ _engine.SetLoop(_loopActive, _loopS, _loopE);
+ Redraw();
+ LoopChanged?.Invoke();
+ }
+
+ /// <summary>"5.1 – 9.1 · 4 bars": the loop region while it is dragged on the ruler.</summary>
+ private string LoopReadout()
+ {
+ string Pos(double b) // bar.beat, as the transport's loop cell writes it
+ {
+ int bar = (int)Math.Floor(b / _beatsPerBar + 1e-9);
+ int beat = (int)Math.Floor(b - bar * _beatsPerBar + 1e-9);
+ return $"{bar + 1}.{beat + 1}";
+ }
+ double len = _loopE - _loopS, bars = len / _beatsPerBar;
+ string l = Math.Abs(bars - Math.Round(bars)) < 1e-6
+ ? (Math.Round(bars) == 1 ? "1 bar" : $"{Math.Round(bars)} bars")
+ : $"{len:0.##} beats";
+ return $"{Pos(_loopS)} – {Pos(_loopE)} · {l}";
+ }
+
+ /// <summary>Turn looping on / off over the current region (the ruler's menu).</summary>
+ private void SetLoopOn(bool on)
+ {
+ if (_engine is null) return;
+ if (on && !(_loopE > _loopS)) { _loopS = 0; _loopE = 4 * _beatsPerBar; } // as the transport's Loop does
+ _loopActive = on;
+ _engine.SetLoop(on, _loopS, _loopE);
+ Redraw();
+ LoopChanged?.Invoke();
+ }
+
+ /// <summary>Clear loop region (#125): loop off and the region forgotten, where turning
+ /// the loop off keeps it. Clips, notes and automation are not touched.</summary>
+ internal void ClearLoopRegion()
+ {
+ if (_engine is null) return;
+ _engine.SetLoop(false, 0, 0);
+ _loopActive = false; _loopS = 0; _loopE = 0; _loopDragging = false;
+ Redraw();
+ LoopChanged?.Invoke();
+ }
/// <summary>Enable looping over [start,end] (snapped). Notifies the transport bar.</summary>
internal void SetLoopRegion(double startBeat, double endBeat)
@@ -945,6 +1081,7 @@ public sealed partial class ArrangementView : UserControl
internal void ScrollByBeats(double delta)
{
+ NoteManualScroll();
_scrollBeats = Math.Clamp(_scrollBeats + delta, 0, _hScroll.Maximum);
_hScroll.Value = _scrollBeats;
Redraw();
@@ -2739,6 +2876,8 @@ public sealed partial class ArrangementView : UserControl
private static readonly IBrush LoopBrace = NotaPalette.Wash(NotaPalette.AccentBright, 0x66);
private static readonly IBrush LoopBand = NotaPalette.Wash(NotaPalette.AccentBright, 0x14);
private static readonly IPen LoopEdge = new Pen(NotaPalette.Wash(NotaPalette.AccentBright, 0xA0), 1);
+ private static readonly IPen LoopEdgeHot = new Pen(NotaPalette.AccentBright, 2);
+ private static readonly IBrush ReadoutText = NotaPalette.TextPrimary;
// A switched-off loop keeps its brace on the ruler, in neutral grey (the accent is for what's live).
private static readonly IBrush LoopBraceOff = NotaPalette.Wash(NotaPalette.TextTertiary, 0x38);
private static readonly IPen LoopEdgeOff = new Pen(NotaPalette.Wash(NotaPalette.TextTertiary, 0x80), 1);
diff --git a/src/managed/Nota.App/MainWindow.Commands.cs b/src/managed/Nota.App/MainWindow.Commands.cs
index 8f01f5e3..d1c92adf 100644
--- a/src/managed/Nota.App/MainWindow.Commands.cs
+++ b/src/managed/Nota.App/MainWindow.Commands.cs
@@ -77,6 +77,7 @@ public partial class MainWindow
B("view.toggleOverview", () => OnMenuToggleOverview(this, e));
B("view.toggleSections", () => OnMenuToggleSections(this, e));
B("view.follow", () => OnMenuToggleFollow(this, e));
+ B("view.showPlayhead", ShowPlayhead);
B("view.clipNames", () => OnMenuCycleClipNames(this, e));
B("view.automation", () =>
{
@@ -90,6 +91,7 @@ public partial class MainWindow
// ---- Transport
B("transport.playStop", () => _vm?.Transport.PlayStopCommand.Execute(null));
+ B("transport.playPause", () => _vm?.Transport.PlayPauseCommand.Execute(null));
B("transport.stop", () => _vm?.Transport.StopCommand.Execute(null));
B("transport.record", () => OnMenuRecord(this, e));
B("transport.loop", () => OnMenuLoop(this, e));
diff --git a/src/managed/Nota.App/MainWindow.Input.cs b/src/managed/Nota.App/MainWindow.Input.cs
index 32096398..652ab0df 100644
--- a/src/managed/Nota.App/MainWindow.Input.cs
+++ b/src/managed/Nota.App/MainWindow.Input.cs
@@ -58,7 +58,8 @@ public partial class MainWindow
if (e.Key == Key.Space)
{
- _commands.Run("transport.playStop");
+ // ⇧Space pauses instead: the playhead stays where it stopped (#51).
+ _commands.Run((e.KeyModifiers & KeyModifiers.Shift) != 0 ? "transport.playPause" : "transport.playStop");
e.Handled = true;
}
else if (e.Key == Key.Return)
@@ -314,6 +315,14 @@ public partial class MainWindow
return;
}
+ // P: Show playhead (#105) — scroll the arrangement to it, without moving it.
+ if (!mod && e.Key == Key.P && (e.KeyModifiers & KeyModifiers.Shift) == 0 && _heldKeys.Add(e.Key))
+ {
+ _commands.Run("view.showPlayhead");
+ e.Handled = true;
+ return;
+ }
+
// Z / X: shift the typing-keyboard octave; C / V: nudge the typing velocity.
// De-duped against auto-repeat so one press = one step; skipped in the piano-roll grid.
if (!mod && _editorRoll is not { GridFocused: true }
diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axaml
index 297ec9b5..84c7d4c5 100644
--- a/src/managed/Nota.App/MainWindow.axaml
+++ b/src/managed/Nota.App/MainWindow.axaml
@@ -87,6 +87,7 @@
<!-- Header text is matched from code to keep this checkmark in step with the
transport bar's Follow button — see MainWindow.SetFollowPlayhead. -->
<NativeMenuItem Header="Follow playhead" app:Commands.Id="view.follow" ToggleType="CheckBox"/>
+ <NativeMenuItem Header="Show playhead" app:Commands.Id="view.showPlayhead"/>
<NativeMenuItemSeparator/>
<NativeMenuItem Header="Clip names" app:Commands.Id="view.clipNames"/>
</NativeMenu>
@@ -96,6 +97,7 @@
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem Header="Play / stop" app:Commands.Id="transport.playStop"/>
+ <NativeMenuItem Header="Play / pause" app:Commands.Id="transport.playPause"/>
<NativeMenuItem Header="Record" app:Commands.Id="transport.record"/>
<NativeMenuItem Header="Loop" app:Commands.Id="transport.loop"/>
<NativeMenuItem Header="Loop record: overdub / replace" app:Commands.Id="transport.loopRecordMode"/>
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index f7f456bf..5b47609e 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -353,6 +353,8 @@ public partial class MainWindow : Window
vm.Transport.RecordArmTarget = () => Timeline.RecordArmTarget();
vm.Transport.SelectionLoopRange = () => Timeline.SelectionLoopRange();
vm.Transport.TracksChanged += () => { Timeline.Refresh(); ReloadEditorNotes(); };
+ Timeline.FollowSuspendedChanged -= OnFollowSuspendedChanged;
+ Timeline.FollowSuspendedChanged += OnFollowSuspendedChanged;
Timeline.LoopChanged += () => vm.Transport.SyncLoop(); // ruler drag / "Loop selection" → transport bar
Browser.CollapsedChanged += OnBrowserCollapsedChanged;
@@ -799,7 +801,12 @@ public partial class MainWindow : Window
// Follow: keep the arrangement scrolling with the playhead during playback. The bar
// button and View ▸ Follow playhead are two faces of one state, so both land here.
- private void OnToggleFollow(object? sender, RoutedEventArgs e) => SetFollowPlayhead(FollowBtn.IsChecked == true);
+ // A click on a paused Follow picks it up again rather than turning it off.
+ private void OnToggleFollow(object? sender, RoutedEventArgs e)
+ {
+ if (Timeline.FollowSuspended && FollowBtn.IsChecked != true) FollowBtn.IsChecked = true;
+ SetFollowPlayhead(FollowBtn.IsChecked == true);
+ }
internal void SetFollowPlayhead(bool on)
{
@@ -823,6 +830,27 @@ public partial class MainWindow : Window
_vm.StatusText = PianoRollView.AuditionEnabled ? "Note audition on" : "Note audition off";
}
+ // Show playhead (#105, P / View menu / the ruler's off-screen arrow): a one-shot scroll
+ // to the playhead that also picks up a paused Follow.
+ private void ShowPlayhead()
+ {
+ bool resumed = Timeline.FollowPlayhead && Timeline.FollowSuspended;
+ Timeline.RevealPlayhead();
+ if (_vm is not null && resumed) _vm.StatusText = "Following the playhead";
+ }
+
+ // Follow pauses when the lanes are scrolled away during playback (#105); the Follow
+ // button dims to say so and the status bar says how to pick it up again.
+ private void OnFollowSuspendedChanged()
+ {
+ bool paused = Timeline.FollowSuspended;
+ FollowBtn.Classes.Set("paused", paused);
+ ToolTip.SetTip(FollowBtn, paused
+ ? "Follow is paused while you look elsewhere · P or a click here picks it up again"
+ : "Scroll the arrangement to keep the playhead in view");
+ if (paused && _vm is not null) _vm.StatusText = "Follow paused · press P to go back to the playhead";
+ }
+
private static NativeMenuItem? FindMenuItem(NativeMenu? menu, string header)
{
if (menu is null) return null;
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index f32003a6..709f7fd1 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -1095,12 +1095,16 @@ public sealed partial class PreferencesWindow : NotaWindow
}),
("Transport", new[]
{
- ("Space", "Play / Stop"),
+ ("Space", "Play / Stop · Stop goes back to where playback started"),
+ ("⇧Space", "Play / pause · the playhead stays put and Play carries on from there"),
("Return", "Stop (again → back to the start) · in the Session grid it launches the selection"),
("⌘R", "Record"),
("⌘M", "Metronome"),
("⌘L", "Loop on / off · loop the selected clips or time range"),
("Double-click loop brace", "Loop on / off in the ruler · the region stays, greyed out while off"),
+ ("Drag loop edge · drag loop brace", "Resize that end of the loop region · move the whole region · ⌥ off the grid"),
+ ("Right-click ruler", "Loop on / off · loop the selection · clear the loop region"),
+ ("P", "Show playhead · scroll the Arrangement to it without moving it · picks up a paused Follow"),
("⌘⇧R", "Loop recording: Overdub (every pass adds) / Replace (keep the latest pass)"),
}),
("Arrangement & editing", new[]
@@ -1275,7 +1279,7 @@ public sealed partial class PreferencesWindow : NotaWindow
return new StackPanel { Spacing = 18, Children = { SearchField(filter, 320), groups } };
}
- private static readonly HashSet<string> NamedKeys = new(StringComparer.Ordinal) { "Space", "Return", "Delete", "Tab", "Esc", "PgUp", "PgDn", "⌘Return", "⌥Return", "⇧Return", "⇧Tab" };
+ private static readonly HashSet<string> NamedKeys = new(StringComparer.Ordinal) { "Space", "Return", "Delete", "Tab", "Esc", "PgUp", "PgDn", "⌘Return", "⌥Return", "⇧Return", "⇧Tab", "⇧Space" };
// A token that names a key: no lower-case letters (⌘⇧Z, ←, A, 0), or a named key.
private static bool IsKeyToken(string t) => NamedKeys.Contains(t) || !t.Any(char.IsLower);
diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axaml
index 704db2af..cd878636 100644
--- a/src/managed/Nota.App/Theme/NotaTheme.axaml
+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml
@@ -280,6 +280,13 @@
<Style Selector="ToggleButton.tp-icon.rec:checked">
<Setter Property="Foreground" Value="{DynamicResource Brush.RecordInk}"/>
</Style>
+ <!-- Follow, paused because the view was scrolled away (#105): still on, no longer live —
+ an accent outline and glyph on the resting key instead of the solid accent key. -->
+ <Style Selector="ToggleButton.tp-icon.paused:checked /template/ ContentPresenter#PART_ContentPresenter">
+ <Setter Property="Background" Value="{DynamicResource Brush.SurfaceRaised}"/>
+ <Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
+ <Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.Accent}"/>
+ </Style>
<!-- Play: a raised key like its neighbours at rest, wider; while the transport runs it is
a solid accent key (live). -->
<Style Selector="Button.tp-play">
diff --git a/src/managed/Nota.Application/Palette/CommandCatalog.cs b/src/managed/Nota.Application/Palette/CommandCatalog.cs
index 0764e861..53d6f2f6 100644
--- a/src/managed/Nota.Application/Palette/CommandCatalog.cs
+++ b/src/managed/Nota.Application/Palette/CommandCatalog.cs
@@ -60,6 +60,7 @@ public static class CommandCatalog
C("view.toggleOverview", "Toggle overview", "View", "", "minimap", view: "Arrangement"),
C("view.toggleSections", "Toggle sections", "View", "", "markers locators", view: "Arrangement"),
C("view.follow", "Follow playhead", "View", "", "scroll"),
+ C("view.showPlayhead", "Show playhead", "View", Shortcut.None('P'), "find locate scroll reveal cursor position", view: "Arrangement"),
C("view.clipNames", "Cycle clip names", "View", "", "labels", view: "Arrangement"),
C("view.automation", "Toggle automation mode", "View", Shortcut.CmdShift('A'), "envelopes lanes", view: "Arrangement"),
C("view.history", "Show version history", "View", "", "undo history versions snapshots"),
@@ -69,6 +70,7 @@ public static class CommandCatalog
// ---- Transport --------------------------------------------------------------------
C("transport.playStop", "Play / stop", "Transport", Shortcut.None("Space"), "start pause"),
+ C("transport.playPause", "Play / pause", "Transport", Shortcut.Shift("Space"), "resume continue hold"),
C("transport.stop", "Stop", "Transport", Shortcut.None("Return"), "halt"),
C("transport.record", "Record", "Transport", Shortcut.Cmd('R'), "arm capture"),
C("transport.loop", "Toggle loop", "Transport", Shortcut.Cmd('L'), "cycle repeat"),
diff --git a/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs b/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
index 434f3c0c..9b8513b9 100644
--- a/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
@@ -115,7 +115,9 @@ public partial class TransportViewModel(IAudioEngine engine) : ObservableObject
_syncingLoop = true;
LoopOn = _engine.LoopEnabled;
_syncingLoop = false;
- LoopRangeText = FormatRange(_engine.LoopStart, _engine.LoopEnd);
+ double s = _engine.LoopStart, e = _engine.LoopEnd;
+ if (e <= s) { s = 0; e = 4 * BeatsPerBar; } // a cleared region: what Loop would use (#125)
+ LoopRangeText = FormatRange(s, e);
}
private static string FormatRange(double startBeat, double endBeat) => $"{BarBeat(startBeat)}–{BarBeat(endBeat)}"; // closed: plain numbers
@@ -165,6 +167,23 @@ public partial class TransportViewModel(IAudioEngine engine) : ObservableObject
[RelayCommand]
private void Play() => _engine.PlayWithCountIn();
+ /// <summary>⇧Space (#51): Play / pause. Stop rewinds to where playback started (the
+ /// engine's start anchor); pause leaves the playhead where it is, and the next Play
+ /// carries on from there. Seeking there is what moves the anchor.</summary>
+ [RelayCommand]
+ private void PlayPause()
+ {
+ if (_engine.IsPlaying || _engine.CountInBeats > 0 || RecordOn)
+ {
+ bool counting = !_engine.IsPlaying;
+ double here = _engine.PositionBeats;
+ StopAll();
+ if (!counting) _engine.Seek(here); // a count-in hasn't moved anything yet
+ Message?.Invoke("Paused · Play carries on from here");
+ }
+ else _engine.PlayWithCountIn();
+ }
+
[RelayCommand]
private void Stop()
{