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.

Rework the arrangement as an island, structure first

Egor Khindikaynen1e7c222f8c98
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aec34a4c..fe5a4500 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,14 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Song sections.** A lane over the ruler holds named spans — Intro, Verse, Drop — so the
+ timeline says where you are in the song rather than only which bar you are on. Drag on
+ the empty lane to mark one, click it to jump the playhead there, double-click to rename,
+ drag its body or edges to move and resize it (always on whole bars). Its menu loops the
+ section, selects it as a time range across every track, duplicates it or deletes it.
+ Sections travel with the project and can be hidden from View ▸ Toggle sections.
+- **View ▸ Clip names** cycles how much of the arrangement prints clip names: every clip,
+ the first clip of each run (the default), or none. A clip named by hand always shows it.
- **A gamepad can be mapped like a MIDI controller** (macOS). Arm MIDI Learn, click a
control, then press a button or move a stick — that control is now driven by the pad.
A mapped button stops playing its note while every unmapped one keeps the built-in
@@ -38,6 +46,19 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
restart — and the choice is remembered.
### Changed
+- **The arrangement and the modular canvas are islands, and groups stop weighing as much as
+ their tracks.** Both now float on the app ground as rounded panels, matching the browser —
+ the modular view keeps its toolbar, track rail and status line inside those corners. A group
+ row collapses to a 26px titled bar carrying its disclosure, mute/solo and level, and
+ opens to the full control set when you select it — so a session of ten tracks under
+ three groups reads as three families instead of thirteen equal rows.
+- **One hue per group.** A track that has not been given a colour of its own takes its
+ group's, varied by shade so siblings stay apart inside the family. An explicitly coloured
+ track keeps its colour, and every view — arrangement, mixer, clip editor — agrees.
+- **Clips carry a colour band, not a name strip.** The 14px title strip is gone: a clip is
+ a 2px band in the track colour over the full-height waveform, and the name appears only
+ where a run of clips begins, so a repeated pattern reads as one block rather than the
+ same word printed twenty times.
- **The browser is a compact index.** It is now an island panel — rounded, floating on the
app ground — and its rows are single-line: sectioned into **BUILT-IN** and **PLUG-INS**
with counts, the repeated "Nota" prefix dropped to tertiary ink so names scan on their
diff --git a/DESIGN.html b/DESIGN.html
index e1739ef1..8b394e00 100644
--- a/DESIGN.html
+++ b/DESIGN.html
@@ -952,7 +952,7 @@ footer {
<section id="tracks">
<p class="eyebrow">07 — Track palette</p>
<h2>Eight tracks, then it wraps</h2>
- <p>Track colours are assigned round-robin from <code>Brush.Track1..8</code>. They are muted and equal-weight on purpose: no track should look more important than another, and none competes with the brass accent.</p>
+ <p>Track colours are assigned round-robin from <code>Brush.Track1..8</code>. They are muted and equal-weight on purpose: no track should look more important than another, and none competes with the brass accent. A track inside a group takes its group's hue instead, varied across the three shades so siblings stay apart inside one family; an explicitly coloured track keeps its own colour.</p>
<div class="tracks">
<div class="track"><div class="track__bar" style="background:var(--track-1)"></div><div class="track__body"><div class="track__name">Track 1 · rust</div><div class="track__hex">#C4756A</div></div></div>
@@ -1266,7 +1266,8 @@ footer {
<div class="rules">
<div class="rule rule--do">
<h4><span class="rule__glyph">+</span> Layout skeleton</h4>
- <p>Transport bar → toolbar → track area (scrolls, on <code>Brush.BgApp</code>) → 26px status bar. Panels are <code>Brush.SurfaceCard</code> with a 1px bottom border. Track rows are cards: radius 10, 1px border, 10px pad.</p>
+ <p>Transport bar → toolbar → body (on <code>Brush.BgApp</code>) → 26px status bar. Panels are <code>Brush.SurfaceCard</code> with a 1px bottom border. The body holds <strong>islands</strong>: the browser, the arrangement and the modular canvas are <code>Radius.Md</code> cards with a 1px <code>Brush.BorderDefault</code> edge, clipped to their bounds, floating on the app ground with an 8px gutter; the splitter between two islands is a 2px transparent grab strip inside that gutter and carries no line of its own.</p>
+ <p>Arrangement rows are not one pitch. A <strong>track</strong> row is 64px and its header carries every control (name + kind · mute/solo/arm + input · fader + dB + pan, with a level rail on the right edge). A <strong>group</strong> row is a 26px titled bar — disclosure, name, mute/solo, a 4px level rail, kind tag — and opens to a full 64px row only while it is the selected track. Header column 228px. A <strong>clip</strong> is a tinted body (<code>Radius.Clip</code>) under a 2px band in the track colour, with the waveform or notes across its full height; the name is drawn over the body, only where a run of clips begins.</p>
</div>
<div class="rule rule--do">
<h4><span class="rule__glyph">+</span> Scrollbars recede</h4>
diff --git a/DESIGN.md b/DESIGN.md
index 8843b353..4c21a79b 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -152,7 +152,9 @@ controls match instead of shipping default blue.
### Track palette
-Assigned round-robin, muted and equal-weight so no track outranks another. Paper keeps
+Assigned round-robin, muted and equal-weight so no track outranks another. A track inside
+a group takes its group's hue instead, varied across the three shades so siblings stay
+apart inside one family; an explicitly coloured track keeps its own colour. Paper keeps
the eight hues and darkens them, so a clip's full-strength content still reads over a 16%
fill of itself:
@@ -272,9 +274,24 @@ takes — not a drawing that resembles one.
## Layout skeleton
-`Transport bar → toolbar → track area (scrolls, on Brush.BgApp) → 26px status bar.`
-Panels are `Brush.SurfaceCard` with a 1px bottom border. Track rows are cards: radius 10,
-1px border, 10px pad.
+`Transport bar → toolbar → body (on Brush.BgApp) → 26px status bar.`
+Panels are `Brush.SurfaceCard` with a 1px bottom border.
+
+The body holds **islands**: the browser, the arrangement and the modular canvas are
+`Radius.Md` cards with a 1px `Brush.BorderDefault` edge, clipped to their bounds, floating
+on `Brush.BgApp` with an 8px gutter. The splitter between two islands carries no line of
+its own — it is a 2px transparent grab strip inside that gutter.
+
+Arrangement rows are not one pitch. A **track** row is 64px and its header carries every
+control (name + kind · mute/solo/arm + input · fader + dB + pan, with a level rail on the
+right edge). A **group** row is a 26px titled bar — disclosure, name, mute/solo, a 4px
+level rail, kind tag — and opens to a full 64px row only while it is the selected track.
+Header column 228px. Every y↔row conversion goes through `ArrangementView.RowTop` /
+`RowAtY`; nothing multiplies by a row constant.
+
+A **clip** is a tinted body (`Radius.Clip`) under a 2px band in the track colour, with the
+waveform or notes across its full height. The name is drawn over the body — not in a strip
+of its own — and only where a run of clips begins.
Transport buttons set `IsTabStop` and `Focusable` to false, so global hotkeys (Space, R,
L, Return) always reach the window instead of a focused control.
diff --git a/FEATURES.md b/FEATURES.md
index e2b8c577..194ee8a7 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -63,16 +63,30 @@ JUCE module; the engine core is JUCE-free.
Three top-level views, switched from the toolbar (**Arrangement · Session · Modular**);
the mixer opens as a separate floating window (**View → Mixer**, ⌘M).
-- **Arrangement View** — a linear timeline: place, move, trim and duplicate clips; grid
- and snap to bars/beats; scroll and zoom; recording into the arrangement (audio and
- MIDI); split at the cursor or across a selection (Cmd/Ctrl+E cuts every track in the
- selection); clip scrubbing on the ruler. An **Overview** strip above the ruler shows
- the whole project in miniature with the visible span as a window over it — drag it to
- scroll, drag its edges (or drag vertically) to zoom, double-click to fit the project.
+- **Arrangement View** — a linear timeline, floating on the app ground as its own island:
+ place, move, trim and duplicate clips; grid and snap to bars/beats; scroll and zoom;
+ recording into the arrangement (audio and MIDI); split at the cursor or across a
+ selection (Cmd/Ctrl+E cuts every track in the selection); clip scrubbing on the ruler.
+ An **Overview** strip above the ruler shows the whole project in miniature with the
+ visible span as a window over it — drag it to scroll, drag its edges (or drag vertically)
+ to zoom, double-click to fit the project.
+ - **Sections** — a lane between the Overview and the ruler names spans of the song
+ (Intro, Verse, Drop). Drag the empty lane to mark one, click it to jump the playhead
+ there, double-click to rename, drag its body or edges to move and resize it (always on
+ whole bars). Its menu loops the section, selects it as a time range across every track,
+ duplicates it or deletes it. Saved with the project; View ▸ Toggle sections hides it.
+ - **Group rows are slim** — a group collapses to a titled bar with its disclosure,
+ mute/solo and level, and opens to the full control set when selected, so groups read as
+ families rather than as more tracks. A track without a colour of its own takes its
+ group's hue, shaded per sibling.
+ - **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
+ hand always shows its name.
- **Session View** — a clip grid (tracks × scenes): launch and stop a clip, launch a whole
scene, launch quantization, recording into a clip slot (MIDI or audio), loop clips with
a configurable length, and moving material between Session and Arrangement.
-- **Modular View** — a signal-graph editor for the track's chain: MIDI FX → instrument →
+- **Modular View** — a signal-graph editor for the track's chain, on its own island: MIDI FX → instrument →
effects shown as nodes you can expand, bypass, duplicate, delete and reorder right on the
canvas (node positions are saved with the project), plus a **Global view** that shows
tracks as islands with cross-track connections. Its centrepiece is **CV modulation** —
diff --git a/src/managed/Nota.App/ArrangementView.Groups.cs b/src/managed/Nota.App/ArrangementView.Groups.cs
index 1bf76072..cfeee778 100644
--- a/src/managed/Nota.App/ArrangementView.Groups.cs
+++ b/src/managed/Nota.App/ArrangementView.Groups.cs
@@ -159,7 +159,8 @@ public sealed partial class ArrangementView
private void HandleHeaderDrop(int id, double y)
{
if (_engine is null || _tracks.Count == 0) { Select(id, -1); return; }
- int row = System.Math.Clamp((int)System.Math.Floor(y / RowHeight), 0, _tracks.Count - 1);
+ int row = RowAtYClamped(y);
+ if (row < 0) { Select(id, -1); return; }
var target = _tracks[row];
var dragged = _tracks.FirstOrDefault(t => t.Id == id);
if (dragged is null || target.Id == id) { Select(id, -1); return; }
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index f3a4c349..4d97c0e6 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -96,7 +96,8 @@ 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
- private static double RowTop(int i) => i * ArrangementView.RowHeight;
+ 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)
@@ -105,18 +106,18 @@ public sealed partial class ArrangementView
Typeface.Default, 9, Brushes.White);
return Math.Clamp(Math.Ceiling(ft.Width) + 12, 34, 180);
}
- private static Rect PillRect(int i, double w) => new(4, RowTop(i) + 3, w, PillH);
+ 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) + ArrangementView.RowHeight - 8;
+ 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) + ArrangementView.RowHeight - 8;
+ 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));
}
@@ -127,8 +128,8 @@ public sealed partial class ArrangementView
private (TrackVM track, ClipVM clip)? HitTest(Point p, out double beat)
{
beat = _o._scrollBeats + p.X / _o._pixelsPerBeat;
- int ti = (int)(p.Y / ArrangementView.RowHeight);
- if (ti < 0 || ti >= _o._tracks.Count) return null;
+ int ti = _o.RowAtY(p.Y);
+ if (ti < 0) return null;
var t = _o._tracks[ti];
foreach (var c in t.Clips)
if (beat >= c.StartBeat && beat <= c.StartBeat + c.LengthBeats)
@@ -154,8 +155,8 @@ public sealed partial class ArrangementView
// Double-click empty space on an instrument track's lane → new MIDI clip there.
if (e.ClickCount == 2)
{
- int ti = (int)(pt.Position.Y / ArrangementView.RowHeight);
- if (ti >= 0 && ti < _o._tracks.Count && _o._tracks[ti].IsInstrument)
+ int ti = _o.RowAtY(pt.Position.Y);
+ if (ti >= 0 && _o._tracks[ti].IsInstrument)
{
_o.AddMidiClipAt(_o._tracks[ti].Id, beat);
return;
@@ -278,8 +279,8 @@ public sealed partial class ArrangementView
// extend across rows vertically (req 1.2.1/1.2.2).
double a = _o.SnapMaybe(_o._scrollBeats + _marqueePress.X / _o._pixelsPerBeat, e.KeyModifiers);
double b = _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers);
- int rowA = Math.Clamp((int)(_marqueePress.Y / ArrangementView.RowHeight), 0, Math.Max(0, _o._tracks.Count - 1));
- int rowB = Math.Clamp((int)(pos.Y / ArrangementView.RowHeight), 0, Math.Max(0, _o._tracks.Count - 1));
+ int rowA = Math.Max(0, _o.RowAtYClamped(_marqueePress.Y));
+ int rowB = Math.Max(0, _o.RowAtYClamped(pos.Y));
_o.SetTimeSelection(a, b, rowA, rowB);
}
else
@@ -339,7 +340,7 @@ public sealed partial class ArrangementView
double delta = snappedStart - _grabOrigStart;
foreach (var m in _groupMove) m.vm.StartBeat = Math.Max(0, m.origStart + delta);
// Vertical: how many rows to shift (instrument→instrument only).
- int targetRow = Math.Clamp((int)(pos.Y / ArrangementView.RowHeight), 0, _o._tracks.Count - 1);
+ int targetRow = Math.Max(0, _o.RowAtYClamped(pos.Y));
_moveRowDelta = ClampRowDelta(targetRow - _grabRow);
InvalidateVisual();
return;
@@ -529,13 +530,13 @@ public sealed partial class ArrangementView
var hits = new List<(int, int)>();
for (int i = 0; i < _o._tracks.Count; i++)
{
- double y = i * ArrangementView.RowHeight;
- if (!r.Intersects(new Rect(0, y, double.MaxValue, ArrangementView.RowHeight))) continue;
+ double y = RowTop(i);
+ if (!r.Intersects(new Rect(0, y, double.MaxValue, RowH(i)))) continue;
foreach (var c in _o._tracks[i].Clips)
{
double cx0 = _o.BeatToX(c.StartBeat);
double cx1 = _o.BeatToX(c.StartBeat + c.LengthBeats);
- var clipRect = new Rect(cx0, y, Math.Max(1, cx1 - cx0), ArrangementView.RowHeight);
+ var clipRect = new Rect(cx0, y, Math.Max(1, cx1 - cx0), RowH(i));
if (r.Intersects(clipRect)) hits.Add((_o._tracks[i].Id, c.ClipIndex));
}
}
@@ -547,8 +548,8 @@ public sealed partial class ArrangementView
{
var pt = e.GetCurrentPoint(this);
var pos = pt.Position;
- int i = (int)(pos.Y / ArrangementView.RowHeight);
- if (i < 0 || i >= _o._tracks.Count) return;
+ int i = _o.RowAtY(pos.Y);
+ if (i < 0) return;
var t = _o._tracks[i];
double pillW = PillWidth(t.AutoLabel);
@@ -676,8 +677,8 @@ public sealed partial class ArrangementView
private void UpdateHover(Point pos)
{
AutoPt? pt = null, seg = null; TrackVM? tr = null;
- int i = (int)(pos.Y / ArrangementView.RowHeight);
- if (i >= 0 && i < _o._tracks.Count)
+ int i = _o.RowAtY(pos.Y);
+ if (i >= 0)
{
var t = _o._tracks[i];
foreach (var p in t.AutoPoints)
@@ -847,8 +848,8 @@ public sealed partial class ArrangementView
// consolidate the time selection when the click lands inside it.
private void ShowLaneMenu(Point pos, double beat)
{
- int ti = (int)(pos.Y / ArrangementView.RowHeight);
- if (ti < 0 || ti >= _o._tracks.Count) return;
+ int ti = _o.RowAtY(pos.Y);
+ if (ti < 0) return;
int trackId = _o._tracks[ti].Id;
bool inRange = _o.TimeSelectionCovers(trackId, beat);
if (!_o.HasClipClipboard && !inRange) return;
@@ -1001,9 +1002,11 @@ public sealed partial class ArrangementView
// Lane backgrounds + separators.
for (int i = rLo; i <= rHi; i++)
{
- double y = i * ArrangementView.RowHeight;
- ctx.FillRectangle((i & 1) == 0 ? LaneBgA : LaneBgB, new Rect(0, y, w, ArrangementView.RowHeight));
- ctx.DrawLine(BeatPen, new Point(0, y + ArrangementView.RowHeight), new Point(w, y + ArrangementView.RowHeight));
+ double y = RowTop(i), rh = RowH(i);
+ // A group row reads as chrome between its children, not as another lane.
+ ctx.FillRectangle(_o.IsSlimRowAt(i) ? GroupLaneBg : (i & 1) == 0 ? LaneBgA : LaneBgB,
+ new Rect(0, y, w, rh));
+ ctx.DrawLine(BeatPen, new Point(0, y + rh), new Point(w, y + rh));
}
if (_o._tracks.Count == 0)
ctx.FillRectangle(LaneBgA, new Rect(0, 0, w, h));
@@ -1013,15 +1016,15 @@ public sealed partial class ArrangementView
for (int i = rLo; i <= rHi; i++)
{
if (_o._tracks[i].Id != _o.SelTrackId) continue;
- double sy = i * ArrangementView.RowHeight;
- ctx.FillRectangle(SelWash, new Rect(0, sy, w, ArrangementView.RowHeight));
+ double sy = RowTop(i);
+ ctx.FillRectangle(SelWash, new Rect(0, sy, w, RowH(i)));
}
// Browser drag-over: glow the lane the drop would land on (future state).
if (_o.DropTrackIndex >= 0 && _o.DropTrackIndex < _o._tracks.Count)
{
- double dy = _o.DropTrackIndex * ArrangementView.RowHeight;
- var r = new Rect(0, dy, w, ArrangementView.RowHeight);
+ double dy = RowTop(_o.DropTrackIndex);
+ var r = new Rect(0, dy, w, RowH(_o.DropTrackIndex));
ctx.FillRectangle(DropWash, r);
ctx.DrawRectangle(null, new Pen(DropEdge, 1.5), r);
}
@@ -1039,18 +1042,19 @@ public sealed partial class ArrangementView
else if (showBeats) ctx.DrawLine(BeatPen, new Point(x, 0), new Point(x, h));
}
- // Clips (fill + border + 14px name strip, all in the track colour). A clip
- // being dragged to another track is hidden here and shown as a translucent
- // preview on the destination lane (below).
+ // Clips: a tinted body under a 2px colour band, with the name drawn only where a
+ // run of clips starts (design 1a) so a repeating pattern reads as one block instead
+ // of the same word printed twenty times. A clip being dragged to another track is
+ // hidden here and shown as a translucent preview on the destination lane (below).
for (int i = rLo; i <= rHi; i++)
{
- double y = i * ArrangementView.RowHeight;
+ double y = RowTop(i), rh = RowH(i);
int tid = _o._tracks[i].Id;
// Group rows carry no clips of their own: preview their descendants instead
// (stacked mini-clips collapsed, a thin colour strip expanded).
if (_o._tracks[i].IsGroup)
{
- DrawGroupLane(ctx, _o._tracks[i], y, w, _o.IsGroupCollapsed(tid));
+ DrawGroupLane(ctx, _o._tracks[i], y, rh, w, _o.IsGroupCollapsed(tid));
continue;
}
foreach (var c in _o._tracks[i].Clips)
@@ -1060,7 +1064,7 @@ public sealed partial class ArrangementView
var edgeHi = Drag.None;
if (_hoverEdge != Drag.None && _hoverEdgeTrack == tid && _hoverEdgeClip == c.ClipIndex) edgeHi = _hoverEdge;
else if ((_drag == Drag.TrimL || _drag == Drag.TrimR) && _dragTrackId == tid && _dragClipIndex == c.ClipIndex) edgeHi = _drag;
- DrawClipBody(ctx, _o._tracks[i].ColorIndex, _o._tracks[i].Name, c, y, _o.IsSelected(tid, c.ClipIndex), edgeHi);
+ DrawClipBody(ctx, _o._tracks[i].ColorIndex, _o._tracks[i].Name, c, y, rh, _o.IsSelected(tid, c.ClipIndex), edgeHi);
}
}
@@ -1074,7 +1078,7 @@ public sealed partial class ArrangementView
for (int i = rLo; i <= rHi; i++)
{
if (_o._tracks[i].Id != rt) continue;
- double ry = i * ArrangementView.RowHeight;
+ double ry = RowTop(i), rh = RowH(i);
// Loop recording punches the loop region → draw a stable box over it.
// Otherwise the box grows by the actual captured length (monotonic),
// not the playhead.
@@ -1089,7 +1093,7 @@ public sealed partial class ArrangementView
rx0 = _o.BeatToX(re.AudioRecordStartBeat);
rx1 = Math.Max(rx0, _o.BeatToX(re.AudioRecordStartBeat + re.AudioRecordLengthBeats));
}
- var rr = new Rect(rx0, ry + 2, Math.Max(2, rx1 - rx0), ArrangementView.RowHeight - 4);
+ var rr = new Rect(rx0, ry + 2, Math.Max(2, rx1 - rx0), rh - 4);
ctx.DrawRectangle(RecFill, RecBorder, rr, 4, 4);
// Live waveform of what's being captured, so the take shows real
// signal rather than an empty box (clips only materialise on stop).
@@ -1116,7 +1120,7 @@ public sealed partial class ArrangementView
int destRow = m.origRow + _moveRowDelta;
if (destRow < 0 || destRow >= _o._tracks.Count) continue;
var dest = _o._tracks[destRow];
- DrawClipBody(ctx, dest.ColorIndex, dest.Name, m.vm, destRow * ArrangementView.RowHeight, true);
+ DrawClipBody(ctx, dest.ColorIndex, dest.Name, m.vm, RowTop(destRow), RowH(destRow), true);
}
// Clip marquee (plain drag on empty space).
@@ -1126,8 +1130,8 @@ public sealed partial class ArrangementView
if (_o.HasTimeSelection)
{
double sx = _o.BeatToX(_o._timeSelStart), ex = _o.BeatToX(_o._timeSelEnd);
- double ty = _o._timeSelRowLo * ArrangementView.RowHeight;
- double th = (_o._timeSelRowHi - _o._timeSelRowLo + 1) * ArrangementView.RowHeight;
+ double ty = RowTop(_o._timeSelRowLo);
+ double th = RowTop(_o._timeSelRowHi + 1) - ty;
double cx0 = Math.Max(0, sx), cx1 = Math.Min(w, ex);
if (cx1 > cx0) ctx.FillRectangle(MarqueeFill, new Rect(cx0, ty, cx1 - cx0, th));
if (sx >= 0 && sx <= w) ctx.DrawLine(MarqueePen, new Point(sx, ty), new Point(sx, ty + th));
@@ -1235,23 +1239,37 @@ public sealed partial class ArrangementView
// Group lane preview: collapsed → each descendant clip as a mini-clip stacked into its
// own sub-lane (child colour), so starts/ends read at a glance; expanded → a thin strip
// in the group colour over each descendant clip's span, marking content boundaries.
- private void DrawGroupLane(DrawingContext ctx, ArrangementView.TrackVM g, double y, double w, bool collapsed)
+ private void DrawGroupLane(DrawingContext ctx, ArrangementView.TrackVM g, double y, double rowH, double w, bool collapsed)
{
if (g.GroupMini.Count == 0) return;
if (collapsed)
{
+ // Collapsed: the hidden children still have to read, so each takes a sub-lane
+ // of the (slim) row. Below ~3px a sub-lane stops being legible — past that the
+ // stack degrades to one merged span strip.
int slots = Math.Max(1, g.GroupSlotCount);
- const double padTop = 7, padBot = 7;
- double innerH = ArrangementView.RowHeight - padTop - padBot;
+ const double padTop = 5, padBot = 5;
+ double innerH = rowH - padTop - padBot;
double laneH = innerH / slots;
- double barH = Math.Max(3, laneH - 2);
+ if (laneH >= 2.5)
+ {
+ double barH = Math.Max(2, laneH - 1);
+ foreach (var m in g.GroupMini)
+ {
+ double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
+ if (x1 < 0 || x0 > w || m.Length <= 0) continue;
+ var (fill, border, _, _) = ClipColors(m.ColorIndex);
+ var r = new Rect(x0, y + padTop + m.Slot * laneH, Math.Max(2, x1 - x0), barH);
+ ctx.DrawRectangle(fill, border, r, 1.5, 1.5);
+ }
+ return;
+ }
foreach (var m in g.GroupMini)
{
double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
if (x1 < 0 || x0 > w || m.Length <= 0) continue;
var (fill, border, _, _) = ClipColors(m.ColorIndex);
- var r = new Rect(x0, y + padTop + m.Slot * laneH, Math.Max(2, x1 - x0), barH);
- ctx.DrawRectangle(fill, border, r, 2, 2);
+ ctx.DrawRectangle(fill, border, new Rect(x0, y + padTop, Math.Max(2, x1 - x0), innerH), 1.5, 1.5);
}
}
else
@@ -1259,8 +1277,8 @@ public sealed partial class ArrangementView
var col = TrackColorForIndex(g.ColorIndex);
var fill = Alpha(col, 0.55);
var border = new Pen(Alpha(col, 0.85), 1);
- const double stripH = 6;
- double sy = y + (ArrangementView.RowHeight - stripH) / 2;
+ double stripH = Math.Min(6, Math.Max(3, rowH - 12));
+ double sy = y + (rowH - stripH) / 2;
foreach (var m in g.GroupMini)
{
double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
@@ -1271,14 +1289,15 @@ public sealed partial class ArrangementView
}
}
- private void DrawClipBody(DrawingContext ctx, int colorIndex, string label, ClipVM c, double y, bool selected, Drag edgeHi = Drag.None)
+ private void DrawClipBody(DrawingContext ctx, int colorIndex, string label, ClipVM c, double y,
+ double rowH, bool selected, Drag edgeHi = Drag.None)
{
double w = Bounds.Width;
double x0 = _o.BeatToX(c.StartBeat);
double x1 = _o.BeatToX(c.StartBeat + c.LengthBeats);
if (x1 < 0 || x0 > w || c.LengthBeats <= 0) return;
- var (fill, border, strip, content) = ClipColors(colorIndex);
- var rect = new Rect(x0, y + 2, Math.Max(2, x1 - x0), ArrangementView.RowHeight - 4);
+ var (fill, border, _, content) = ClipColors(colorIndex);
+ var rect = new Rect(x0, y + 2, Math.Max(2, x1 - x0), rowH - 4);
ctx.DrawRectangle(fill, selected ? ClipSelBorder : border, rect, 4, 4);
// Resize-edge affordance: a bright bar on the edge a drag would trim.
@@ -1288,31 +1307,50 @@ public sealed partial class ArrangementView
ctx.FillRectangle(EdgeHighlight, new Rect(ex, rect.Y, 2.5, rect.Height));
}
- double stripH = Math.Min(14, rect.Height);
+ // The name is a label on the clip, not a strip that eats a fifth of the row's
+ // height. Content first, then the band and the name over it. Both DrawNotes and
+ // DrawWaveform already clip themselves to the rect they are handed.
+ var contentRect = new Rect(rect.X, rect.Y + BandH, rect.Width, Math.Max(0, rect.Height - BandH));
+ if (c.IsMidi) DrawNotes(ctx, c, contentRect, content);
+ else DrawWaveform(ctx, c, contentRect, content);
+
+ // 2px band in the track colour along the top edge: the clip's family marker.
if (rect.Width > 3)
+ ctx.FillRectangle(content, new Rect(rect.X + 1, rect.Y + 1, rect.Width - 2, BandH));
+
+ if (rect.Width > 24 && rect.Height > 14 && ShowsLabel(c))
{
- var stripRect = new Rect(rect.X + 1, rect.Y + 1, rect.Width - 2, stripH);
- ctx.FillRectangle(strip, stripRect);
- if (rect.Width > 16)
- {
- // The clip's own name (set via its menu) wins; otherwise the track name.
- var ft = new FormattedText(string.IsNullOrEmpty(c.Name) ? label : c.Name, CultureInfo.InvariantCulture,
- FlowDirection.LeftToRight, Typeface.Default, 9, content);
- using (ctx.PushClip(stripRect))
- ctx.DrawText(ft, new Point(rect.X + 5, rect.Y + 2));
- }
+ // The clip's own name (set via its menu) wins; otherwise the track name.
+ string text = string.IsNullOrEmpty(c.Name) ? label : c.Name;
+ var ft = new FormattedText(text, CultureInfo.InvariantCulture,
+ FlowDirection.LeftToRight, Typeface.Default, 9, content)
+ { MaxTextWidth = Math.Max(8, rect.Width - 10), Trimming = TextTrimming.CharacterEllipsis };
+ var plate = new Rect(rect.X + 1, rect.Y + BandH + 1,
+ Math.Min(rect.Width - 2, ft.Width + 8), ft.Height + 2);
+ using var _ = ctx.PushClip(rect);
+ // A soft plate keeps the name readable over a dense waveform without
+ // reintroducing a full-width strip.
+ ctx.FillRectangle(LabelPlate, plate);
+ ctx.DrawText(ft, new Point(rect.X + 5, rect.Y + BandH + 2));
}
- var contentRect = new Rect(rect.X, rect.Y + stripH, rect.Width, Math.Max(0, rect.Height - stripH));
- if (c.IsMidi) DrawNotes(ctx, c, contentRect, content);
- else DrawWaveform(ctx, c, contentRect, content);
-
// Deactivated clip (key 0): grey it out with a dark scrim so it reads as "off"
// while still showing its content/geometry. Inset so the (selection) border stays.
if (!c.Active)
ctx.DrawRectangle(InactiveVeil, null, rect.Deflate(1), 3, 3);
}
+ private const double BandH = 2; // clip colour band along the top edge
+
+ // Which clips carry their name (design 1a's "labels" choice). A clip that was named by
+ // hand always shows it — that name was authored to be read.
+ private bool ShowsLabel(ClipVM c) => _o.ClipLabels switch
+ {
+ ClipLabelMode.Every => true,
+ ClipLabelMode.None => !string.IsNullOrEmpty(c.Name),
+ _ => c.RunStart || !string.IsNullOrEmpty(c.Name),
+ };
+
// Capture full-material peaks + the committed play window for a live resize preview
// (point 2). Unwarped: peaks over the whole sample, window = source frames. Warped:
// peaks over the whole warp, window = played beats. Cleared on release/cancel.
@@ -1409,7 +1447,8 @@ public sealed partial class ArrangementView
{
var t = _o._tracks[i];
double y = RowTop(i);
- ctx.FillRectangle(AutoScrim, new Rect(0, y, w, ArrangementView.RowHeight));
+ 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
var (fill, _, strip, content) = ClipColors(t.ColorIndex);
var pen = new Pen(content, 1.6);
@@ -1463,9 +1502,10 @@ public sealed partial class ArrangementView
double cx0 = Math.Max(0, sx), cx1 = Math.Min(w, ex);
if (cx1 > cx0)
{
- ctx.FillRectangle(AutoSelBand, new Rect(cx0, y, cx1 - cx0, ArrangementView.RowHeight));
- if (sx >= 0) ctx.DrawLine(AutoSelEdge, new Point(sx, y), new Point(sx, y + ArrangementView.RowHeight));
- if (ex <= w) ctx.DrawLine(AutoSelEdge, new Point(ex, y), new Point(ex, y + ArrangementView.RowHeight));
+ 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));
}
}
diff --git a/src/managed/Nota.App/ArrangementView.Sections.cs b/src/managed/Nota.App/ArrangementView.Sections.cs
new file mode 100644
index 00000000..1d8c564a
--- /dev/null
+++ b/src/managed/Nota.App/ArrangementView.Sections.cs
@@ -0,0 +1,456 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Arrangement · Sections — the song-structure lane between the Overview and the ruler
+// (design 1a, "structure first"). A bar of numbers says nothing about a song; a row of named
+// spans — Intro, Verse, Drop — says where you are. Sections are authoring metadata, not
+// audio: they live in the view and ride in the bundle as a sidecar, so a project written by
+// an older build still opens and simply has none.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Input;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Threading;
+
+namespace Nota.App;
+
+/// <summary>A named span of arrangement time (Intro / Verse A / Drop …).</summary>
+public sealed class ArrangementSection
+{
+ public double StartBeat { get; set; }
+ public double LengthBeats { get; set; }
+ public string Name { get; set; } = "";
+}
+
+public sealed partial class ArrangementView
+{
+ private readonly List<ArrangementSection> _sections = new();
+ private readonly SectionsControl _sectionsLane;
+ private Border _sectionsRow = null!;
+
+ /// <summary>Show/hide the Sections lane (View ▸ Toggle sections).</summary>
+ public bool ShowSections
+ {
+ get => _sectionsRow.IsVisible;
+ set
+ {
+ if (_sectionsRow.IsVisible == value) return;
+ _sectionsRow.IsVisible = value;
+ if (value) _sectionsLane.InvalidateVisual();
+ }
+ }
+
+ /// <summary>Raised whenever the section list changes, so the host can mark the project dirty.</summary>
+ public event Action? SectionsChanged;
+
+ // The lane row: the same header-column chrome as the ruler, then the spans themselves.
+ private Border BuildSectionsRow()
+ {
+ var label = new TextBlock
+ {
+ Text = "SECTIONS", Classes = { "SectionLabel" },
+ HorizontalAlignment = HorizontalAlignment.Left,
+ VerticalAlignment = VerticalAlignment.Center,
+ Margin = new Thickness(8, 0, 0, 0),
+ };
+ var grid = new Grid { Height = SectionsH, ColumnDefinitions = new ColumnDefinitions("Auto,*") };
+ grid.Children.Add(HeaderPanel(label));
+ Grid.SetColumn(_sectionsLane, 1);
+ grid.Children.Add(_sectionsLane);
+
+ var row = new Border { BorderThickness = new Thickness(0, 0, 0, 1), Child = grid };
+ row.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ return row;
+ }
+
+ // ---- model ------------------------------------------------------------
+
+ /// <summary>The sections, in start order (what the bundle sidecar persists).</summary>
+ public IReadOnlyList<ArrangementSection> SectionList
+ {
+ get { _sections.Sort((a, b) => a.StartBeat.CompareTo(b.StartBeat)); return _sections; }
+ }
+
+ /// <summary>Replace the whole list (project load).</summary>
+ public void SetSections(IEnumerable<ArrangementSection> sections)
+ {
+ _sections.Clear();
+ foreach (var s in sections)
+ if (s.LengthBeats > 0) _sections.Add(new ArrangementSection { StartBeat = Math.Max(0, s.StartBeat), LengthBeats = s.LengthBeats, Name = s.Name });
+ _sections.Sort((a, b) => a.StartBeat.CompareTo(b.StartBeat));
+ _sectionsLane.InvalidateVisual();
+ }
+
+ /// <summary>Drop every section (File ▸ New).</summary>
+ public void ClearSections()
+ {
+ if (_sections.Count == 0) return;
+ _sections.Clear();
+ _sectionsLane.InvalidateVisual();
+ }
+
+ private void SectionsEdited()
+ {
+ _sections.Sort((a, b) => a.StartBeat.CompareTo(b.StartBeat));
+ _sectionsLane.InvalidateVisual();
+ SectionsChanged?.Invoke();
+ }
+
+ // A new section is named for the slot it lands in, so a session gets Section 1..n without
+ // a dialog in the way; renaming is one double-click.
+ private string NextSectionName()
+ {
+ for (int i = 1; ; i++)
+ {
+ string candidate = "Section " + i.ToString(CultureInfo.InvariantCulture);
+ if (!_sections.Any(s => string.Equals(s.Name, candidate, StringComparison.Ordinal))) return candidate;
+ }
+ }
+
+ private ArrangementSection AddSection(double startBeat, double lengthBeats)
+ {
+ var s = new ArrangementSection
+ {
+ StartBeat = Math.Max(0, startBeat),
+ LengthBeats = Math.Max(_beatsPerBar, lengthBeats),
+ Name = NextSectionName(),
+ };
+ _sections.Add(s);
+ SectionsEdited();
+ return s;
+ }
+
+ private void RemoveSection(ArrangementSection s)
+ {
+ if (!_sections.Remove(s)) return;
+ SectionsEdited();
+ }
+
+ // Snap a section edge to whole bars — song structure is bar-aligned, always, so this
+ // ignores the clip snap grid (which is often finer than a bar).
+ private double SnapBar(double beat)
+ {
+ double bar = Math.Max(1, _beatsPerBar);
+ return Math.Max(0, Math.Round(beat / bar) * bar);
+ }
+
+ private void RenameSection(Control anchor, ArrangementSection s)
+ {
+ var box = new TextBox { Text = s.Name, Width = 160, FontSize = 12 };
+ var flyout = new Flyout { Content = box, Placement = PlacementMode.Bottom };
+ box.KeyDown += (_, ke) =>
+ {
+ if (ke.Key == Key.Enter) { s.Name = box.Text ?? ""; SectionsEdited(); flyout.Hide(); ke.Handled = true; }
+ else if (ke.Key == Key.Escape) { flyout.Hide(); ke.Handled = true; }
+ };
+ flyout.ShowAt(anchor);
+ Dispatcher.UIThread.Post(() => { box.SelectAll(); box.Focus(); }, DispatcherPriority.Input);
+ }
+
+ // ---- the lane ---------------------------------------------------------
+
+ private sealed class SectionsControl : Control
+ {
+ private static readonly IBrush LaneBg = NotaPalette.Wash(NotaPalette.BgSunken, 0xFF);
+ // Spans alternate between a brass-marked and a neutral treatment, so a long song
+ // reads as a rhythm of blocks rather than one continuous ribbon of labels.
+ private static readonly IBrush WarmFill = NotaPalette.Wash(NotaPalette.Accent, 0x33);
+ private static readonly IBrush ColdFill = NotaPalette.Wash(NotaPalette.SurfaceRaised, 0xFF);
+ private static readonly IBrush WarmEdge = NotaPalette.AccentBright;
+ private static readonly IBrush ColdEdge = NotaPalette.BorderStrong;
+ private static readonly IBrush WarmInk = NotaPalette.AccentBright;
+ private static readonly IBrush ColdInk = NotaPalette.TextSecondary;
+ private static readonly IBrush HintInk = NotaPalette.TextDisabled;
+ private static readonly IBrush DraftFill = NotaPalette.Wash(NotaPalette.AccentBright, 0x28);
+ private static readonly IPen DraftPen = new Pen(NotaPalette.Wash(NotaPalette.AccentBright, 0xC0), 1);
+ private static readonly Cursor HandCursor = new(StandardCursorType.Hand);
+ private static readonly Cursor EdgeCursor = new(StandardCursorType.SizeWestEast);
+
+ private const double EdgeGrab = 4; // px around a span edge that grabs it
+
+ private enum Mode { None, Draft, Move, EdgeLeft, EdgeRight }
+
+ private readonly ArrangementView _o;
+ private Mode _mode;
+ private ArrangementSection? _active;
+ private double _pressBeat, _grabOffset, _fixedBeat;
+ private bool _moved;
+
+ public SectionsControl(ArrangementView o)
+ {
+ _o = o;
+ ClipToBounds = true;
+ Cursor = HandCursor;
+ }
+
+ private double BeatAt(double x) => _o._scrollBeats + x / _o._pixelsPerBeat;
+
+ private ArrangementSection? HitTest(double x, out bool onLeft, out bool onRight)
+ {
+ onLeft = onRight = false;
+ foreach (var s in _o._sections)
+ {
+ double x0 = _o.BeatToX(s.StartBeat), x1 = _o.BeatToX(s.StartBeat + s.LengthBeats);
+ if (x < x0 - EdgeGrab || x > x1 + EdgeGrab) continue;
+ bool wide = x1 - x0 > 3 * EdgeGrab;
+ onLeft = wide && Math.Abs(x - x0) <= EdgeGrab;
+ onRight = wide && Math.Abs(x - x1) <= EdgeGrab;
+ return s;
+ }
+ return null;
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ var pt = e.GetCurrentPoint(this);
+ double x = pt.Position.X;
+ var hit = HitTest(x, out bool onLeft, out bool onRight);
+
+ if (pt.Properties.IsRightButtonPressed)
+ {
+ ShowMenu(hit, BeatAt(x));
+ e.Handled = true;
+ return;
+ }
+ if (!pt.Properties.IsLeftButtonPressed) return;
+
+ if (hit is not null && e.ClickCount == 2) { _o.RenameSection(this, hit); e.Handled = true; return; }
+
+ _pressBeat = BeatAt(x);
+ _moved = false;
+ _active = hit;
+ if (hit is null) _mode = Mode.Draft;
+ else if (onLeft) { _mode = Mode.EdgeLeft; _fixedBeat = hit.StartBeat + hit.LengthBeats; }
+ else if (onRight) { _mode = Mode.EdgeRight; _fixedBeat = hit.StartBeat; }
+ else { _mode = Mode.Move; _grabOffset = _pressBeat - hit.StartBeat; }
+ e.Pointer.Capture(this);
+ e.Handled = true;
+ }
+
+ protected override void OnPointerMoved(PointerEventArgs e)
+ {
+ var pos = e.GetPosition(this);
+ if (_mode == Mode.None)
+ {
+ HitTest(pos.X, out bool l, out bool r);
+ Cursor = l || r ? EdgeCursor : HandCursor;
+ return;
+ }
+
+ double beat = BeatAt(pos.X);
+ if (!_moved && Math.Abs(beat - _pressBeat) * _o._pixelsPerBeat > 3) _moved = true;
+ if (!_moved) return;
+
+ switch (_mode)
+ {
+ case Mode.Draft:
+ _draftEnd = beat; // the draft band is drawn from _pressBeat to here
+ InvalidateVisual();
+ break;
+ case Mode.Move when _active is not null:
+ _active.StartBeat = _o.SnapBar(beat - _grabOffset);
+ InvalidateVisual();
+ break;
+ case Mode.EdgeLeft when _active is not null:
+ {
+ double start = Math.Min(_o.SnapBar(beat), _fixedBeat - _o._beatsPerBar);
+ _active.LengthBeats = _fixedBeat - start;
+ _active.StartBeat = start;
+ InvalidateVisual();
+ break;
+ }
+ case Mode.EdgeRight when _active is not null:
+ _active.LengthBeats = Math.Max(_o._beatsPerBar, _o.SnapBar(beat) - _fixedBeat);
+ InvalidateVisual();
+ break;
+ }
+ }
+
+ private double _draftEnd;
+
+ protected override void OnPointerReleased(PointerReleasedEventArgs e)
+ {
+ var mode = _mode;
+ var active = _active;
+ bool moved = _moved;
+ _mode = Mode.None; _active = null; _moved = false;
+ e.Pointer.Capture(null);
+
+ if (mode == Mode.Draft)
+ {
+ if (moved)
+ {
+ double a = _o.SnapBar(Math.Min(_pressBeat, _draftEnd));
+ double b = _o.SnapBar(Math.Max(_pressBeat, _draftEnd));
+ _o.AddSection(a, Math.Max(_o._beatsPerBar, b - a));
+ }
+ else _o.SeekTo(_o.SnapBar(_pressBeat)); // a plain click on empty lane scrubs
+ InvalidateVisual();
+ return;
+ }
+ if (active is null) return;
+ // A click (no drag) on a span jumps the playhead to its start — the gesture the
+ // lane exists for. A drag committed geometry instead.
+ if (!moved) _o.SeekTo(active.StartBeat);
+ else _o.SectionsEdited();
+ InvalidateVisual();
+ }
+
+ // Wheel over the lane drives the timeline exactly as it does over the ruler and lanes.
+ protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
+ {
+ _o.HandleLaneWheel(e, e.GetPosition(this).X);
+ if (!e.Handled) { _o.ScrollByBeats(-WheelInput.Pixels(e.Delta.Y) / _o._pixelsPerBeat); e.Handled = true; }
+ }
+
+ private void ShowMenu(ArrangementSection? s, double beat)
+ {
+ var flyout = new MenuFlyout();
+ if (s is not null)
+ {
+ var rename = new MenuItem { Header = "Rename…" };
+ rename.Click += (_, _) => _o.RenameSection(this, s);
+ var loop = new MenuItem { Header = "Loop section" };
+ loop.Click += (_, _) => _o.SetLoopRegion(s.StartBeat, s.StartBeat + s.LengthBeats); // raises LoopChanged itself
+ var select = new MenuItem { Header = "Select section" };
+ select.Click += (_, _) => _o.SelectSectionRange(s);
+ var dup = new MenuItem { Header = "Duplicate" };
+ dup.Click += (_, _) =>
+ {
+ var copy = _o.AddSection(s.StartBeat + s.LengthBeats, s.LengthBeats);
+ copy.Name = s.Name;
+ _o.SectionsEdited();
+ };
+ var del = new MenuItem { Header = "Delete" };
+ del.Click += (_, _) => _o.RemoveSection(s);
+ flyout.Items.Add(rename);
+ flyout.Items.Add(loop);
+ flyout.Items.Add(select);
+ flyout.Items.Add(new Separator());
+ flyout.Items.Add(dup);
+ flyout.Items.Add(del);
+ }
+ else
+ {
+ var add = new MenuItem { Header = "Add section here" };
+ add.Click += (_, _) => _o.AddSection(_o.SnapBar(beat), _o._beatsPerBar * 8);
+ flyout.Items.Add(add);
+ if (_o._sections.Count > 0)
+ {
+ var clear = new MenuItem { Header = "Delete all sections" };
+ clear.Click += (_, _) => { _o.ClearSections(); _o.SectionsChangedRaise(); };
+ flyout.Items.Add(clear);
+ }
+ }
+ flyout.ShowAt(this, showAtPointer: true);
+ }
+
+ public override void Render(DrawingContext ctx)
+ {
+ double w = Bounds.Width, h = Bounds.Height;
+ if (w <= 0 || h <= 0) return;
+ ctx.FillRectangle(LaneBg, new Rect(0, 0, w, h));
+
+ var list = _o._sections;
+ if (list.Count == 0 && _mode != Mode.Draft)
+ {
+ var hint = new FormattedText("drag here to mark a section", CultureInfo.InvariantCulture,
+ FlowDirection.LeftToRight, Typeface.Default, 9, HintInk);
+ ctx.DrawText(hint, new Point(8, (h - hint.Height) / 2));
+ }
+
+ for (int i = 0; i < list.Count; i++)
+ {
+ var s = list[i];
+ double x0 = _o.BeatToX(s.StartBeat), x1 = _o.BeatToX(s.StartBeat + s.LengthBeats);
+ if (x1 < 0 || x0 > w) continue;
+ bool warm = (i & 1) == 0;
+ var r = new Rect(x0, 2, Math.Max(2, x1 - x0), h - 4);
+ using (ctx.PushClip(new Rect(0, 0, w, h)))
+ {
+ ctx.DrawRectangle(warm ? WarmFill : ColdFill, null, r, 3, 3);
+ ctx.FillRectangle(warm ? WarmEdge : ColdEdge, new Rect(r.X, r.Y, 2, r.Height));
+ if (r.Width > 22)
+ {
+ var ft = new FormattedText(s.Name, CultureInfo.InvariantCulture,
+ FlowDirection.LeftToRight, Typeface.Default, 9, warm ? WarmInk : ColdInk)
+ { MaxTextWidth = Math.Max(8, r.Width - 10), Trimming = TextTrimming.CharacterEllipsis };
+ ctx.DrawText(ft, new Point(r.X + 7, r.Y + (r.Height - ft.Height) / 2));
+ }
+ }
+ }
+
+ // The span being drawn right now (drag on empty lane).
+ if (_mode == Mode.Draft && _moved)
+ {
+ double a = _o.BeatToX(_o.SnapBar(Math.Min(_pressBeat, _draftEnd)));
+ double b = _o.BeatToX(_o.SnapBar(Math.Max(_pressBeat, _draftEnd)));
+ var r = new Rect(a, 2, Math.Max(2, b - a), h - 4);
+ ctx.DrawRectangle(DraftFill, DraftPen, r, 3, 3);
+ }
+
+ // Playhead tick, so the lane and the ruler read as one instrument.
+ double px = _o.BeatToX(_o._playheadBeats);
+ if (px >= 0 && px <= w) ctx.DrawLine(PlayheadPen, new Point(px, 0), new Point(px, h));
+ }
+ }
+
+ // ---- commands the lane's menu reaches ---------------------------------
+
+ internal void SectionsChangedRaise() => SectionsChanged?.Invoke();
+
+ /// <summary>Make a section's span the arrangement's time selection, across every row —
+ /// so Delete / Duplicate / Consolidate act on the whole section.</summary>
+ internal void SelectSectionRange(ArrangementSection s)
+ {
+ if (_tracks.Count == 0) return;
+ SetTimeSelection(s.StartBeat, s.StartBeat + s.LengthBeats, 0, _tracks.Count - 1);
+ }
+
+ // ---- sidecar persistence ---------------------------------------------
+
+ private const string SectionsSidecar = "sections.json";
+
+ private sealed class SectionDto
+ {
+ public double Start { get; set; }
+ public double Length { get; set; }
+ public string Name { get; set; } = "";
+ }
+
+ /// <summary>Write the sections into a .nota bundle. Cosmetic metadata — a failure here
+ /// must never fail the save.</summary>
+ public void SaveSections(string bundleDir)
+ {
+ var path = System.IO.Path.Combine(bundleDir, SectionsSidecar);
+ try
+ {
+ if (_sections.Count == 0) { if (System.IO.File.Exists(path)) System.IO.File.Delete(path); return; }
+ var dto = SectionList.Select(s => new SectionDto { Start = s.StartBeat, Length = s.LengthBeats, Name = s.Name }).ToList();
+ System.IO.File.WriteAllText(path, System.Text.Json.JsonSerializer.Serialize(dto));
+ }
+ catch { /* sections are cosmetic — never block a save */ }
+ }
+
+ /// <summary>Read the sections back out of a bundle (absent / corrupt → none).</summary>
+ public void LoadSections(string bundleDir)
+ {
+ ClearSections();
+ var path = System.IO.Path.Combine(bundleDir, SectionsSidecar);
+ if (!System.IO.File.Exists(path)) return;
+ try
+ {
+ var dto = System.Text.Json.JsonSerializer.Deserialize<List<SectionDto>>(System.IO.File.ReadAllText(path));
+ if (dto is null) return;
+ SetSections(dto.Select(d => new ArrangementSection { StartBeat = d.Start, LengthBeats = d.Length, Name = d.Name }));
+ }
+ catch { /* a corrupt sidecar just means no sections */ }
+ }
+}
diff --git a/src/managed/Nota.App/ArrangementView.Vms.cs b/src/managed/Nota.App/ArrangementView.Vms.cs
index b63ce3b5..6481b038 100644
--- a/src/managed/Nota.App/ArrangementView.Vms.cs
+++ b/src/managed/Nota.App/ArrangementView.Vms.cs
@@ -77,5 +77,9 @@ public sealed partial class ArrangementView
public int PeakCount;
public NotaNote[]? Notes;
public string Name = "";
+ /// <summary>True when no clip on the same track ends where this one begins — the head
+ /// of a run. Only these carry a name on the lane (design 1a), so a repeated pattern
+ /// reads as one block. Computed in <c>Refresh</c>.</summary>
+ public bool RunStart = true;
}
}
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index d63f7bc4..b6ea4080 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -24,6 +24,9 @@ public enum ClipConvertMode { Drums, Slice, Melody, Harmony }
/// <summary>Which kind of track an arrangement context menu asked for.</summary>
public enum NewTrackKind { Instrument, Audio, Return }
+/// <summary>How much of the arrangement names its clips (View ▸ Clip names).</summary>
+public enum ClipLabelMode { Every, RunStart, None }
+
public sealed partial class ArrangementView : UserControl
{
// --- coordinate model / shared state ---
@@ -67,11 +70,86 @@ public sealed partial class ArrangementView : UserControl
// Per-track chosen automation target, kept across Refresh (which rebuilds VMs).
private readonly Dictionary<int, (AutomationTarget target, int dev, int param, string paramId)> _autoTargets = new();
- private const double HeaderW = 224;
- private const double RowHeight = 64;
+ private const double HeaderW = 228;
+ private const double RowHeight = 64; // a track row: header carries every control
+ 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
+ // multiplying/dividing by one constant. Rebuilt on every Refresh, after ApplyHierarchy.
+ private double[] _rowTops = { 0 };
+
+ private void RebuildRowGeometry()
+ {
+ var tops = new double[_tracks.Count + 1];
+ double y = 0;
+ for (int i = 0; i < _tracks.Count; i++)
+ {
+ tops[i] = y;
+ y += IsSlimRow(_tracks[i]) ? GroupRowHeight : RowHeight;
+ }
+ tops[_tracks.Count] = y;
+ _rowTops = tops;
+ }
+
+ /// <summary>Height of arrangement row <paramref name="i"/> — a slim bar for a group.</summary>
+ internal double RowHeightAt(int i)
+ => i >= 0 && i < _tracks.Count && IsSlimRow(_tracks[i]) ? GroupRowHeight : RowHeight;
+
+ /// <summary>A group is a slim titled bar (1a: "groups weigh the same as their children"
+ /// was the problem) — until it is the selected track, where it opens to a full row so its
+ /// own mute/solo, fader, pan and meter stay reachable.</summary>
+ private bool IsSlimRow(TrackVM t) => t.IsGroup && t.Id != SelTrackId;
+ internal bool IsSlimRowAt(int i) => i >= 0 && i < _tracks.Count && IsSlimRow(_tracks[i]);
+
+ /// <summary>Top edge of row <paramref name="i"/> in lane coordinates. Indices past the
+ /// last row extrapolate by a full track row, so "the gap after the end" still has a y.</summary>
+ internal double RowTop(int i)
+ {
+ if (i <= 0) return 0;
+ int n = _tracks.Count;
+ return i <= n ? _rowTops[i] : _rowTops[n] + (i - n) * RowHeight;
+ }
+
+ /// <summary>Combined height of every visible row.</summary>
+ internal double RowsHeight => _rowTops[_tracks.Count];
+
+ /// <summary>Row containing <paramref name="y"/>, or -1 when it falls outside the rows.</summary>
+ internal int RowAtY(double y)
+ {
+ if (y < 0 || _tracks.Count == 0 || y >= _rowTops[_tracks.Count]) return -1;
+ for (int i = 0; i < _tracks.Count; i++)
+ if (y < _rowTops[i + 1]) return i;
+ return -1;
+ }
+
+ /// <summary>Like <see cref="RowAtY"/> but clamped to the first/last row (-1 only when
+ /// there are no rows at all) — for gestures that must always land somewhere.</summary>
+ internal int RowAtYClamped(double y)
+ {
+ if (_tracks.Count == 0) return -1;
+ int r = RowAtY(y);
+ return r >= 0 ? r : (y < 0 ? 0 : _tracks.Count - 1);
+ }
+
+ /// <summary>Insertion gap nearest <paramref name="y"/> (0.._tracks.Count) — where a
+ /// header-reorder drop would land.</summary>
+ internal int RowGapAtY(double y)
+ {
+ int n = _tracks.Count;
+ if (n == 0) return 0;
+ for (int i = 0; i < n; i++)
+ {
+ double top = _rowTops[i], bot = _rowTops[i + 1];
+ if (y < (top + bot) / 2) return i;
+ if (y < bot) return i + 1;
+ }
+ return n;
+ }
+
private IAudioEngine? _engine;
private readonly RulerControl _ruler;
@@ -141,6 +219,7 @@ public sealed partial class ArrangementView : UserControl
{
_ruler = new RulerControl(this) { Height = RulerH };
_overview = new OverviewControl(this);
+ _sectionsLane = new SectionsControl(this);
_lanes = new LaneControl(this) { VerticalAlignment = VerticalAlignment.Top };
// Sits in the same grid cell as _lanes, on top; hit-transparent so all pointer
// gestures pass through to the lanes beneath.
@@ -186,8 +265,10 @@ public sealed partial class ArrangementView : UserControl
Grid.SetColumn(_ruler, 1);
top.Children.Add(_ruler);
- // Above the ruler: the Overview strip (whole project + a draggable viewport window).
+ // Above the ruler: the Overview strip (whole project + a draggable viewport window),
+ // then the Sections lane — song structure sits directly over the bar numbers it names.
_overviewRow = BuildOverviewRow();
+ _sectionsRow = BuildSectionsRow();
// Center: vertical scroll over [headers | lanes].
// Top-anchored: the ScrollViewer would otherwise stretch the short
@@ -229,7 +310,7 @@ public sealed partial class ArrangementView : UserControl
{
if (!e.GetCurrentPoint(scroller).Properties.IsRightButtonPressed) return;
double y = e.GetPosition(_headers).Y; // shared vertical (scrolls with content)
- if (y >= 0 && y < _tracks.Count * RowHeight) return; // on a track → it shows its own menu
+ if (y >= 0 && y < RowsHeight) return; // on a track → it shows its own menu
ShowEmptyAreaMenu(scroller);
};
// Wheel over the empty area below the tracks (top-anchored lanes leave a gap when few
@@ -270,15 +351,30 @@ public sealed partial class ArrangementView : UserControl
var root = new DockPanel();
DockPanel.SetDock(_overviewRow, Dock.Top);
+ DockPanel.SetDock(_sectionsRow, Dock.Top);
DockPanel.SetDock(top, Dock.Top);
DockPanel.SetDock(bottom, Dock.Bottom);
DockPanel.SetDock(_footer, 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(centerArea);
- Content = root;
+
+ // The island: like the browser, the arrangement is a rounded card floating on the app
+ // ground rather than a full-bleed region. ClipToBounds keeps the ruler, the header
+ // column and the pinned footer inside the rounded corners.
+ var island = new Border
+ {
+ BorderThickness = new Thickness(1),
+ ClipToBounds = true,
+ Child = root,
+ };
+ island.BindResource(Border.CornerRadiusProperty, "Radius.Md");
+ island.BindResource(Border.BackgroundProperty, "Brush.SurfaceCard");
+ island.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ Content = island;
}
public IAudioEngine? Engine
@@ -299,6 +395,15 @@ public sealed partial class ArrangementView : UserControl
public int BeatsPerBar { get => _beatsPerBar; set { _beatsPerBar = value; Redraw(); } }
/// <summary>Clip-drag snap grid in beats (toolbar Snap chip, 1b).</summary>
public double SnapBeats { get => _snapBeats; set { _snapBeats = Math.Max(1.0 / 32, value); Redraw(); } }
+
+ /// <summary>How many clips print their name on the lane (View ▸ Clip names). The default
+ /// names only the head of each run, so a repeating pattern reads as one block.</summary>
+ public ClipLabelMode ClipLabels
+ {
+ get => _clipLabels;
+ set { if (_clipLabels == value) return; _clipLabels = value; _lanes.InvalidateVisual(); }
+ }
+ private ClipLabelMode _clipLabels = ClipLabelMode.RunStart;
/// <summary>Show/edit parameter-automation envelopes over the lanes (M9-A3).</summary>
public bool AutomationMode
{
@@ -318,7 +423,6 @@ public sealed partial class ArrangementView : UserControl
_lanes.InvalidateVisual();
}
internal IReadOnlyList<TrackVM> Tracks => _tracks;
- internal double RowH => RowHeight;
/// <summary>When on, the grid scrolls to keep the playhead centred during playback
/// ("Follow"); the transport-bar Follow toggle drives this.</summary>
@@ -330,6 +434,7 @@ public sealed partial class ArrangementView : UserControl
{
CenterOnPlayhead();
_ruler.InvalidateVisual();
+ _sectionsLane.InvalidateVisual();
_lanes.InvalidateVisual();
_overlay.InvalidateVisual();
_footerLanes.InvalidateVisual();
@@ -372,6 +477,7 @@ public sealed partial class ArrangementView : UserControl
// Only the overlay (playhead + loop band) moves each tick — the lane surface
// beneath is unchanged, so leave it be to avoid a full clip/waveform repaint.
_ruler.InvalidateVisual();
+ if (_sectionsRow.IsVisible) _sectionsLane.InvalidateVisual();
_overlay.InvalidateVisual();
_footerLanes.InvalidateVisual();
TickOverviewPlayhead(); // only when the marker crossed a pixel of the strip
@@ -508,14 +614,15 @@ public sealed partial class ArrangementView : UserControl
if (_tracks.Count == 0) return (0, -1);
double offY = _scroller?.Offset.Y ?? 0;
double vpH = _scroller is { } s && s.Viewport.Height > 0 ? s.Viewport.Height : _lanes.Bounds.Height;
- int lo = Math.Max(0, (int)(offY / RowHeight) - 1);
- int hi = Math.Min(_tracks.Count - 1, (int)((offY + vpH) / RowHeight) + 1);
+ int lo = Math.Max(0, (RowAtYClamped(offY)) - 1);
+ int hi = Math.Min(_tracks.Count - 1, RowAtYClamped(offY + vpH) + 1);
return (lo, hi);
}
private void Redraw()
{
_ruler.InvalidateVisual();
+ _sectionsLane.InvalidateVisual(); // spans follow scroll + zoom
_lanes.InvalidateVisual();
_overlay.InvalidateVisual(); // playhead/loop band track scroll+zoom+loop edits
_footerLanes.InvalidateVisual();
@@ -617,11 +724,13 @@ public sealed partial class ArrangementView : UserControl
}
tvm.Clips.Add(cvm);
}
+ MarkClipRuns(tvm);
(tvm.IsReturn ? _returns : _tracks).Add(tvm);
}
}
ApplyHierarchy(); // reorder _tracks into group DFS order (depth + collapse-filtered)
+ RebuildRowGeometry(); // row tops depend on which rows are groups → after the reorder
RecomputeTotalBeats();
LoadMasterAuto(); // master-volume automation for the footer row (M9 follow-up)
if (rebuildHeaders)
@@ -629,7 +738,7 @@ public sealed partial class ArrangementView : UserControl
RebuildHeaders();
RebuildFooterHeaders();
}
- _lanes.Height = Math.Max(RowHeight, _tracks.Count * RowHeight);
+ _lanes.Height = Math.Max(RowHeight, RowsHeight);
_overlay.Height = _lanes.Height; // keep the playhead/loop overlay the same span
double footerH = (_returns.Count + 1) * FooterRowH; // returns + master
_footer.Height = footerH;
@@ -639,6 +748,21 @@ public sealed partial class ArrangementView : UserControl
Redraw();
}
+ // A clip heads a run when nothing on the track ends where it begins. Engine clip order
+ // is not sorted by time, so this walks a start-ordered view and leaves the VM order alone
+ // (clip indices there address the engine).
+ private static void MarkClipRuns(TrackVM t)
+ {
+ if (t.Clips.Count == 0) return;
+ var byStart = t.Clips.OrderBy(c => c.StartBeat).ToList();
+ double runEnd = double.NegativeInfinity;
+ foreach (var c in byStart)
+ {
+ c.RunStart = c.StartBeat > runEnd + 1e-6;
+ runEnd = Math.Max(runEnd, c.StartBeat + c.LengthBeats);
+ }
+ }
+
private void RecomputeTotalBeats()
{
double end = 0;
@@ -873,7 +997,7 @@ public sealed partial class ArrangementView : UserControl
{
bool ok = BrowserView.IsAcceptableDrag(e);
e.DragEffects = ok ? DragDropEffects.Copy : DragDropEffects.None;
- int ti = ok ? (int)(e.GetPosition(_lanes).Y / RowHeight) : -1;
+ int ti = ok ? RowAtY(e.GetPosition(_lanes).Y) : -1;
if (ti != DropTrackIndex) { DropTrackIndex = ti; _lanes.InvalidateVisual(); }
}
@@ -883,8 +1007,8 @@ public sealed partial class ArrangementView : UserControl
var items = BrowserView.DroppedItems(e);
if (items.Count == 0) return;
var p = e.GetPosition(_lanes);
- int ti = (int)(p.Y / RowHeight);
- int trackId = (ti >= 0 && ti < _tracks.Count) ? _tracks[ti].Id : -1;
+ int ti = RowAtY(p.Y);
+ int trackId = ti >= 0 ? _tracks[ti].Id : -1;
double beat = Math.Max(0.0, Snap(_scrollBeats + p.X / _pixelsPerBeat));
// One internal item drops as-is; multiple external files land the first on the
// target track and each of the rest on its own new track (trackId -1), so they
@@ -896,16 +1020,37 @@ public sealed partial class ArrangementView : UserControl
internal void Select(int trackId, int clipIndex)
{
if (HasTimeSelection) ClearTimeSelection(); // clip- and time-selection are exclusive (1.2.5)
+ int prev = SelTrackId;
SelTrackId = trackId;
SelClipIndex = clipIndex;
_sel.Clear();
if (trackId > 0 && clipIndex >= 0) _sel.Add((trackId, clipIndex));
+ // Selecting into or out of a group changes that row's height, so the rows below it
+ // move: re-lay them before the headers repaint their selection.
+ if (prev != trackId && (IsGroupTrack(prev) || IsGroupTrack(trackId))) RelayoutRows();
UpdateHeaderSelection();
RebuildFooterHeaders(); // returns/master carry the selection highlight too (1e)
Redraw();
if (trackId > 0) TrackSelected?.Invoke(trackId);
}
+ private bool IsGroupTrack(int id)
+ {
+ if (id <= 0) return false;
+ foreach (var t in _tracks) if (t.Id == id) return t.IsGroup;
+ return false;
+ }
+
+ // Re-measure the rows and rebuild the header cards against the new heights. Cheaper than a
+ // full Refresh (no engine read, no peak fetch) and enough for a pure layout change.
+ private void RelayoutRows()
+ {
+ RebuildRowGeometry();
+ RebuildHeaders();
+ _lanes.Height = Math.Max(RowHeight, RowsHeight);
+ _overlay.Height = _lanes.Height;
+ }
+
/// <summary>True if the clip is part of the current multi-selection.</summary>
internal bool IsSelected(int trackId, int clipIndex) => _sel.Contains((trackId, clipIndex));
@@ -1240,14 +1385,97 @@ public sealed partial class ArrangementView : UserControl
{
var card = BuildHeaderCard(_tracks[i]);
Canvas.SetLeft(card, 0);
- Canvas.SetTop(card, i * RowHeight); // pin to the same Y as the lane row
+ Canvas.SetTop(card, RowTop(i)); // pin to the same Y as the lane row
_headers.Children.Add(card);
}
_headers.Children.Add(_trackDropLine); // insertion marker (kept invisible until a drag)
- _headers.Height = Math.Max(RowHeight, _tracks.Count * RowHeight);
+ _headers.Height = Math.Max(RowHeight, RowsHeight);
}
private Control BuildHeaderCard(TrackVM t)
+ {
+ if (IsSlimRow(t)) return BuildGroupBar(t);
+ return BuildTrackCard(t);
+ }
+
+ // A group's row, collapsed to a title bar: disclosure, name, its own mute/solo, kind tag.
+ // The fader, pan and meter live on the same card when the group is selected (BuildTrackCard),
+ // so nothing is lost — it just stops costing a full row while you work on its children.
+ private Control BuildGroupBar(TrackVM t)
+ {
+ bool selected = IsTrackMultiSelected(t.Id);
+ var (_, _, _, spineBrush) = ClipColors(t.ColorIndex);
+
+ var tri = new TextBlock
+ {
+ Text = _collapsed.Contains(t.Id) ? "▸" : "▾", FontSize = 9,
+ Foreground = Brush("Brush.TextSecondary"), VerticalAlignment = VerticalAlignment.Center,
+ Cursor = new Cursor(StandardCursorType.Hand),
+ Background = Brushes.Transparent, Padding = new Thickness(2, 0),
+ };
+ tri.PointerPressed += (_, e) => { e.Handled = true; ToggleCollapse(t.Id); };
+
+ var name = new TextBlock
+ {
+ Text = t.Name, FontSize = 11, FontWeight = FontWeight.SemiBold,
+ Foreground = Brush(selected ? "Brush.AccentBright" : "Brush.TextPrimary"),
+ VerticalAlignment = VerticalAlignment.Center,
+ TextTrimming = TextTrimming.CharacterEllipsis,
+ Margin = new Thickness(4, 0, 0, 0),
+ };
+
+ var chips = new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 3,
+ VerticalAlignment = VerticalAlignment.Center,
+ Children =
+ {
+ ChipToggle("M", t.Muted, danger: false, v => _engine?.SetTrackMute(t.Id, v)),
+ ChipToggle("S", t.Soloed, danger: false, v => _engine?.SetTrackSolo(t.Id, v)),
+ },
+ };
+
+ var row = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto,Auto") };
+ Grid.SetColumn(tri, 0);
+ Grid.SetColumn(name, 1);
+ Grid.SetColumn(chips, 2);
+ var kind = TypeTag("GROUP");
+ Grid.SetColumn(kind, 3);
+ row.Children.Add(tri);
+ row.Children.Add(name);
+ row.Children.Add(chips);
+ row.Children.Add(kind);
+
+ // A group keeps its level readable at 26px as a 2px rail under the title.
+ var meter = new MeterBar(horizontal: true) { Height = 4, MinWidth = 0 };
+ _meters[t.Id] = meter;
+ var body = new DockPanel { LastChildFill = true, Margin = new Thickness(8 + t.Depth * 14, 0, 8, 0) };
+ DockPanel.SetDock(meter, Dock.Bottom);
+ meter.Margin = new Thickness(0, 0, 0, 3);
+ body.Children.Add(meter);
+ body.Children.Add(row);
+
+ var spine = new Border { Width = 3, Background = spineBrush };
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("3,*") };
+ Grid.SetColumn(spine, 0);
+ Grid.SetColumn(body, 1);
+ grid.Children.Add(spine);
+ grid.Children.Add(body);
+
+ var card = new Border
+ {
+ Width = HeaderW, Height = GroupRowHeight, ClipToBounds = true,
+ Background = selected ? SelHeaderBg : Brush("Brush.SurfaceRaised"),
+ BorderBrush = Brush("Brush.BorderDefault"),
+ BorderThickness = new Thickness(0, 0, 1, 1),
+ Child = grid,
+ };
+ _headerCards[t.Id] = (card, name, true);
+ AttachHeaderGestures(card, t);
+ return card;
+ }
+
+ private Control BuildTrackCard(TrackVM t)
{
bool selected = IsTrackMultiSelected(t.Id);
var (_, _, _, spineBrush) = ClipColors(t.ColorIndex);
@@ -1336,7 +1564,8 @@ public sealed partial class ArrangementView : UserControl
VerticalAlignment = VerticalAlignment.Center, Width = 30, TextAlignment = TextAlignment.Right,
Margin = new Thickness(6, 0, 0, 0),
};
- void ShowDb(double v) => db.Text = v <= 0.0011 ? "-∞" : AudioMath.LinToDb(v).ToString("0.0");
+ void ShowDb(double v) => db.Text = v <= 0.0011 ? "-∞"
+ : AudioMath.LinToDb(v).ToString("0.0", CultureInfo.InvariantCulture);
ShowDb(t.Volume);
fader.ValueChanged += v => { _engine?.SetTrackVolume(volTrackId, (float)v); ShowDb(v); };
fader.GestureBegin += () => _engine?.BeginAutomationWrite(volTrackId, AutomationTarget.Volume, -1, -1, "");
@@ -1388,6 +1617,13 @@ public sealed partial class ArrangementView : UserControl
Child = grid,
};
_headerCards[t.Id] = (card, name, t.IsGroup); // for in-place selection repaint
+ AttachHeaderGestures(card, t);
+ return card;
+ }
+
+ // Select / reorder / context-menu gestures shared by a full track card and a slim group bar.
+ private void AttachHeaderGestures(Border card, TrackVM t)
+ {
card.PointerPressed += (_, e) =>
{
// A click inside the input ComboBox must reach it (and not reselect the track,
@@ -1430,9 +1666,9 @@ public sealed partial class ArrangementView : UserControl
_hdrDragging = true;
card.Cursor = new Cursor(StandardCursorType.SizeAll);
card.Opacity = 0.55;
- int gap = Math.Clamp((int)Math.Round(p.Y / RowHeight), 0, _tracks.Count);
+ int gap = RowGapAtY(p.Y);
_hdrDropGap = gap;
- Canvas.SetTop(_trackDropLine, gap * RowHeight - 1);
+ Canvas.SetTop(_trackDropLine, RowTop(gap) - 1);
_trackDropLine.IsVisible = true;
};
card.PointerReleased += (_, e) =>
@@ -1450,7 +1686,6 @@ public sealed partial class ArrangementView : UserControl
if (!dragged) { Select(id, -1); return; } // never crossed the threshold → plain select
HandleHeaderDrop(id, dropY);
};
- return card;
}
// Track context menu (Duplicate / Delete). Both go through the engine's
@@ -1644,6 +1879,11 @@ public sealed partial class ArrangementView : UserControl
{
var inTb = new TextBlock { Text = "In", FontSize = 9, Foreground = Brush("Brush.TextTertiary"), Opacity = 0.7, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(6, 0) };
var valTb = new TextBlock { Text = value, FontSize = 9, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right, TextTrimming = TextTrimming.CharacterEllipsis, Margin = new Thickness(6, 0) };
+ // The closed box hoists this content out of its item, where it stops following the
+ // theme foreground and keeps whatever it was built with — so on the paper variant
+ // the name rendered near-white. A NotaPalette brush re-points on a variant change,
+ // so setting it locally holds in both.
+ valTb.Foreground = Brush("Brush.TextPrimary");
DockPanel.SetDock(inTb, Dock.Left);
// MinWidth so the closed selection box (which doesn't stretch its content in
// Avalonia) still spreads In to the left edge and the name to the right.
@@ -1683,6 +1923,11 @@ public sealed partial class ArrangementView : UserControl
{
var inTb = new TextBlock { Text = "In", FontSize = 9, Foreground = Brush("Brush.TextTertiary"), Opacity = 0.7, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(6, 0) };
var valTb = new TextBlock { Text = value, FontSize = 9, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right, TextTrimming = TextTrimming.CharacterEllipsis, Margin = new Thickness(6, 0) };
+ // The closed box hoists this content out of its item, where it stops following the
+ // theme foreground and keeps whatever it was built with — so on the paper variant
+ // the name rendered near-white. A NotaPalette brush re-points on a variant change,
+ // so setting it locally holds in both.
+ valTb.Foreground = Brush("Brush.TextPrimary");
DockPanel.SetDock(inTb, Dock.Left);
var content = new DockPanel { LastChildFill = true, MinWidth = 84, Children = { inTb, valTb } };
cb.Items.Add(new ComboBoxItem { Content = content, Padding = new Thickness(6, 2), MinHeight = 0, HorizontalContentAlignment = HorizontalAlignment.Stretch });
@@ -1745,21 +1990,17 @@ public sealed partial class ArrangementView : UserControl
Dispatcher.UIThread.Post(() => { box.SelectAll(); box.Focus(); }, DispatcherPriority.Input);
}
- // Bordered MIDI/AUDIO type-tag chip.
+ // MIDI/AUDIO/GROUP kind tag: a quiet mono label, not a chip. It names the row's kind,
+ // which is reference information — a border would give it the weight of a control (1a).
private Control TypeTag(string text)
{
var tb = new TextBlock
{
- Text = text, FontSize = 8, FontWeight = FontWeight.Bold,
- Foreground = Brush("Brush.TextTertiary"), VerticalAlignment = VerticalAlignment.Center,
- };
- var b = new Border
- {
- BorderThickness = new Thickness(1), BorderBrush = Brush("Brush.BorderDefault"),
- CornerRadius = new CornerRadius(3), Padding = new Thickness(3, 0),
- VerticalAlignment = VerticalAlignment.Center, Child = tb,
+ Text = text, FontSize = 8, FontWeight = FontWeight.Medium, Classes = { "Mono" },
+ Foreground = Brush("Brush.TextDisabled"), VerticalAlignment = VerticalAlignment.Center,
+ Margin = new Thickness(6, 0, 0, 0),
};
- return b;
+ return tb;
}
// A small 18×16 stateful chip toggle (M/S/●). Danger variant reds when active.
@@ -1913,6 +2154,10 @@ public sealed partial class ArrangementView : UserControl
// Selected-track highlight: just a soft brass wash on the lane row — no edge
// lines, so it never fights the grid. Header uses a warm tinted background.
private static readonly IBrush SelWash = NotaPalette.Wash(NotaPalette.Accent, 0x20); // Accent @ ~12%
+ // A group's lane is chrome between its children, not another lane to scan.
+ internal static readonly IBrush GroupLaneBg = NotaPalette.Wash(NotaPalette.BgSunken, 0xE0);
+ // Plate behind a clip's name so it survives a dense waveform without a full-width strip.
+ internal static readonly IBrush LabelPlate = NotaPalette.Wash(NotaPalette.BgSunken, 0x99);
// Browser drag-over: the lane the drop would land on glows (bright accent wash + edge).
private static readonly IBrush DropWash = NotaPalette.Wash(NotaPalette.AccentBright, 0x28);
private static readonly IBrush DropEdge = NotaPalette.Wash(NotaPalette.AccentBright, 0xC0);
@@ -1963,13 +2208,19 @@ public sealed partial class ArrangementView : UserControl
/// <summary>Colour index for a return bus (0/1).</summary>
internal static int ReturnColorIndex(int returnIdx) => ReturnColorBase + (Math.Max(0, returnIdx) % NotaPalette.ReturnColors.Length);
- /// <summary>The effective palette index for a track: its stored colour if set,
- /// otherwise the automatic colour for its position. Shared by every view so a
- /// user-picked colour shows consistently in the arrangement, mixer and detail.</summary>
+ /// <summary>The effective palette index for a track: its stored colour if set, else its
+ /// group's hue (shaded per sibling), else the automatic colour for its position. Shared by
+ /// every view so a user-picked colour shows consistently in the arrangement, mixer and
+ /// detail — and so a grouped session reads as a handful of families rather than one
+ /// unrelated hue per track (design 1a).</summary>
public static int EffectiveColorIndex(IAudioEngine eng, int trackId)
+ => EffectiveColorIndex(eng, trackId, 0);
+
+ private static int EffectiveColorIndex(IAudioEngine eng, int trackId, int depth)
{
int stored = eng.GetTrackColorIndex(trackId);
if (stored >= 0) return stored;
+ if (depth < 8 && GroupShadeFor(eng, trackId, depth) is { } inherited) return inherited;
int nth = 0;
for (int i = 0; i < eng.TrackCount; i++)
{
@@ -1981,6 +2232,32 @@ public sealed partial class ArrangementView : UserControl
return 0;
}
+ // An uncoloured member of a group takes the group's base hue; siblings walk the three
+ // shades of that base so they stay apart without leaving the family. Nested groups inherit
+ // the same way (depth-guarded — a malformed parent chain must not hang the paint).
+ private static int? GroupShadeFor(IAudioEngine eng, int trackId, int depth)
+ {
+ int groupId = -1;
+ for (int i = 0; i < eng.TrackCount; i++)
+ {
+ if (!eng.TryGetTrackInfo(i, out var ti) || ti.Id != trackId) continue;
+ if (ti.IsReturn) return null;
+ groupId = ti.GroupId;
+ break;
+ }
+ if (groupId < 0) return null;
+ int parent = EffectiveColorIndex(eng, groupId, depth + 1);
+ if (parent >= ReturnColorBase) return null;
+ int nth = 0;
+ for (int i = 0; i < eng.TrackCount; i++)
+ {
+ if (!eng.TryGetTrackInfo(i, out var ti) || ti.GroupId != groupId) continue;
+ if (ti.Id == trackId) break;
+ nth++;
+ }
+ return (parent / PaletteShades) * PaletteShades + nth % PaletteShades;
+ }
+
private static Color Mix(Color a, Color b, double t) => Color.FromRgb(
(byte)(a.R + (b.R - a.R) * t), (byte)(a.G + (b.G - a.G) * t), (byte)(a.B + (b.B - a.B) * t));
/// <summary>The track colour for a palette index (shared with the clip editor, 1e).</summary>
diff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.cs
index 6216847f..b5c91056 100644
--- a/src/managed/Nota.App/MainWindow.Files.cs
+++ b/src/managed/Nota.App/MainWindow.Files.cs
@@ -203,6 +203,7 @@ public partial class MainWindow
_vm.Transport.TimeSigDenominator = 4;
_projectPath = null;
_learn?.Clear(); // start with a clean MIDI-map for the new project
+ Timeline.ClearSections(); // …and a clean song structure
RefreshAfterLoad();
UpdateWindowTitle();
_vm.StatusText = "New project.";
@@ -256,6 +257,7 @@ public partial class MainWindow
_projectPath = dir;
_learn?.LoadMappings(dir); // MIDI-learn mappings ride in the bundle sidecar
_modular?.LoadLayout(dir); // modular-editor node/island positions (sidecar)
+ Timeline.LoadSections(dir); // arrangement song sections (sidecar)
LoadFreezeLinks(dir); // live-freeze links (v1.1) — re-sleep linked sources
RecordRecentProject(dir); // surface it on the welcome screen next launch
RefreshAfterLoad();
@@ -331,6 +333,7 @@ public partial class MainWindow
var warnings = _projects.Save(Engine, TransportSnapshot(), dir);
_learn?.SaveMappings(dir); // MIDI-learn mappings ride in the bundle sidecar
_modular?.SaveLayout(dir); // modular-editor node/island positions (sidecar)
+ Timeline.SaveSections(dir); // arrangement song sections (sidecar)
SaveFreezeLinks(dir); // live-freeze links (v1.1) ride in the bundle sidecar
_projectPath = dir;
RecordRecentProject(dir); // surface it on the welcome screen next launch
diff --git a/src/managed/Nota.App/MainWindow.Menu.cs b/src/managed/Nota.App/MainWindow.Menu.cs
index de7fee5d..a7559383 100644
--- a/src/managed/Nota.App/MainWindow.Menu.cs
+++ b/src/managed/Nota.App/MainWindow.Menu.cs
@@ -149,6 +149,37 @@ public partial class MainWindow
Timeline.ShowOverview = !Timeline.ShowOverview;
if (_vm is not null) _vm.StatusText = Timeline.ShowOverview ? "Overview strip shown" : "Overview strip hidden";
}
+ private void OnMenuToggleSections(object? sender, EventArgs e)
+ {
+ Timeline.ShowSections = !Timeline.ShowSections;
+ if (_vm is null) return;
+ _vm.Settings.Current.ArrangementShowSections = Timeline.ShowSections;
+ _vm.Settings.Save();
+ _vm.StatusText = Timeline.ShowSections ? "Sections lane shown" : "Sections lane hidden";
+ }
+ // Cycles how much of the arrangement prints clip names: every clip → the head of each run
+ // (the default, so a repeated pattern reads as one block) → none.
+ private void OnMenuCycleClipNames(object? sender, EventArgs e)
+ {
+ Timeline.ClipLabels = Timeline.ClipLabels switch
+ {
+ ClipLabelMode.Every => ClipLabelMode.RunStart,
+ ClipLabelMode.RunStart => ClipLabelMode.None,
+ _ => ClipLabelMode.Every,
+ };
+ if (_vm is not null)
+ {
+ _vm.Settings.Current.ArrangementClipLabels = (int)Timeline.ClipLabels;
+ _vm.Settings.Save();
+ }
+ if (_vm is not null)
+ _vm.StatusText = Timeline.ClipLabels switch
+ {
+ ClipLabelMode.Every => "Clip names: every clip",
+ ClipLabelMode.RunStart => "Clip names: first of a run",
+ _ => "Clip names: none",
+ };
+ }
private void OnMenuPlayStop(object? sender, EventArgs e) => _vm?.Transport.PlayStopCommand.Execute(null);
private void OnMenuRecord(object? sender, EventArgs e) { if (_vm is not null) _vm.Transport.RecordOn = !_vm.Transport.RecordOn; }
private void OnMenuLoop(object? sender, EventArgs e)
diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axaml
index 8241b81c..3317dac4 100644
--- a/src/managed/Nota.App/MainWindow.axaml
+++ b/src/managed/Nota.App/MainWindow.axaml
@@ -60,6 +60,9 @@
<NativeMenuItem Header="Toggle browser" Click="OnMenuToggleBrowser"/>
<NativeMenuItem Header="Toggle detail panel" Click="OnMenuToggleClip"/>
<NativeMenuItem Header="Toggle overview" Click="OnMenuToggleOverview"/>
+ <NativeMenuItem Header="Toggle sections" Click="OnMenuToggleSections"/>
+ <NativeMenuItemSeparator/>
+ <NativeMenuItem Header="Clip names" Click="OnMenuCycleClipNames"/>
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
@@ -287,9 +290,9 @@
<RowDefinition Height="0"/>
</Grid.RowDefinitions>
- <!-- Left browser (240) + main area (fills). The browser is an island: it floats on
- the app ground with an even gutter, so the splitter beside it carries no line of
- its own — it is a 2px transparent grab strip inside that gutter. -->
+ <!-- Left browser (240) + main area (fills). Browser and arrangement are both islands:
+ they float on the app ground with an even gutter, so the splitter between them
+ carries no line of its own — it is a 2px transparent grab strip inside that gutter. -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="288" MinWidth="160" MaxWidth="480"/>
@@ -300,7 +303,7 @@
<GridSplitter Grid.Column="1" Width="2" Background="Transparent"
ResizeDirection="Columns"/>
<Panel x:Name="MainContent" Grid.Column="2">
- <app:ArrangementView x:Name="Timeline"/>
+ <app:ArrangementView x:Name="Timeline" Margin="0,8,8,8"/>
</Panel>
</Grid>
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index 6b452041..560ee112 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -232,6 +232,9 @@ public partial class MainWindow : Window
Timeline.LoopChanged += () => vm.Transport.SyncLoop(); // ruler drag / "Loop selection" → transport bar
Browser.SetSettings(vm.Settings); // the ⋮ view options persist
+ // Arrangement view options (View menu) persist the same way.
+ Timeline.ClipLabels = (ClipLabelMode)Math.Clamp(vm.Settings.Current.ArrangementClipLabels, 0, 2);
+ Timeline.ShowSections = vm.Settings.Current.ArrangementShowSections;
Browser.SetViewModel(vm.Browser);
Browser.ItemActivated += OnBrowserItemActivated;
Browser.PreviewRequested += OnBrowserPreview;
@@ -261,7 +264,8 @@ public partial class MainWindow : Window
// Modular: signal-graph view of the selected track (mockup 1a). Follows track
// selection like the Detail device chain does.
- _modular = new ModularView(vm.Engine) { IsVisible = false };
+ // Same island gutter as the arrangement it replaces in MainContent.
+ _modular = new ModularView(vm.Engine) { IsVisible = false, Margin = new Thickness(0, 8, 8, 8) };
_modular.Changed += () => { Timeline.Refresh(); if (_deviceChain is { } dc && dc.TrackId > 0) dc.Refresh(); };
_modular.TrackActivated += OnTrackSelected; // Global-view island → select that track
_modular.ItemDropped += OnModularDrop; // browser drag onto the modular canvas
diff --git a/src/managed/Nota.App/ModularView.cs b/src/managed/Nota.App/ModularView.cs
index aab5b445..2063dd92 100644
--- a/src/managed/Nota.App/ModularView.cs
+++ b/src/managed/Nota.App/ModularView.cs
@@ -164,12 +164,26 @@ public sealed class ModularView : UserControl
Grid.SetColumn(_viewport, 1);
body.Children.Add(_viewport);
- Content = new Grid
+ var root = new Grid
{
RowDefinitions = new RowDefinitions("34,*,22"),
Children = { Toolbar(), Row(body, 1), StatusBar() },
};
+ // The island: like the browser and the arrangement, the modular canvas is a rounded
+ // card floating on the app ground. ClipToBounds keeps the toolbar, the track rail and
+ // the status line inside the rounded corners.
+ var island = new Border
+ {
+ BorderThickness = new Thickness(1),
+ ClipToBounds = true,
+ Child = root,
+ };
+ island.BindResource(Border.CornerRadiusProperty, "Radius.Md");
+ island.BindResource(Border.BackgroundProperty, "Brush.SurfaceCard");
+ island.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ Content = island;
+
_zoomLabel.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");
_statusRight.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 098a1ce2..c9e7f9a0 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -614,6 +614,10 @@ public sealed class PreferencesWindow : NotaWindow
("MOUSE", new[]
{
("Double-click clip", "Open in the clip editor"),
+ ("Drag sections lane", "Mark a new section over the dragged bars"),
+ ("Click section", "Jump the playhead to its start"),
+ ("Double-click section", "Rename it"),
+ ("Drag section · its edge", "Move / resize it, snapped to bars"),
("Drag overview strip", "Drag sideways to scroll · up / down to zoom out / in"),
("Drag overview edge", "Zoom by resizing the viewport window"),
("Double-click overview", "Fit the whole project on screen"),
diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.cs
index f2b88c8e..c3b8554c 100644
--- a/src/managed/Nota.Application/Settings.cs
+++ b/src/managed/Nota.Application/Settings.cs
@@ -54,6 +54,13 @@ public sealed class Settings
public bool BrowserGroupBySource { get; set; } = true;
/// <summary>Float favorited devices to the top of their section.</summary>
public bool BrowserFavoritesFirst { get; set; } = true;
+
+ // --- arrangement view options (View menu) --------------------------------
+ /// <summary>How many clips print their name on the lane: 0 every clip, 1 the head of each
+ /// run (default — a repeated pattern then reads as one block), 2 none.</summary>
+ public int ArrangementClipLabels { get; set; } = 1;
+ /// <summary>Show the song-structure (sections) lane over the ruler.</summary>
+ public bool ArrangementShowSections { get; set; } = true;
}
public interface ISettingsService