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) Clip inspector and MIDI tools in two columns when one would scroll (#276) (#391)

Chris Laupamad209445a720a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc6c6677..bbe4d995 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
it on the next launch.
### Changed
+- **Clip inspector and MIDI tools in two columns** (#276): in a short clip editor the
+ inspector (MIDI and audio) and the Tools rail lay their sections out in two columns instead
+ of one scrolling column, so Clip, Quantize, Transpose and Selection (or Clip, Playback and
+ Warp) are all in view. They stay one column while that fits or the editor is narrow, and
+ scroll only when even two columns don't fit.
- **Track header buttons stay in one place at every track height** (#387): M / S / arm — and,
on audio tracks, the headphone monitor button — now sit on the right of the header in
compact, standard and large rows alike. The input selector moves to their left on a
diff --git a/DESIGN.md b/DESIGN.md
index e209fbe7..ffa010dc 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -701,7 +701,10 @@ Every region is **docked**: radius 0, no gutter, separated by 1 px seams (the wi
- **Clip editor** (MIDI and audio share one frame, `ClipEditorKit`): header 38 whose first
232 is the clip cell (3 px track-colour bar, name, mono kind badge), modes as shell
segments after it; inspector 232 on the left, sections split by rules and ending in one
- Ink 5 hint line; the canvas sits in the well. MIDI: keys 48, rows 12, a beats-only
+ Ink 5 hint line; the canvas sits in the well. The inspector and the tools panel take a
+ second column of the same width (464 / 544 in all) when one column would scroll and the
+ canvas keeps 480; sections stay whole and in order, the clip cell follows the inspector's
+ width, and only past two columns does a panel scroll. MIDI: keys 48, rows 12, a beats-only
ruler 24 with the loop as a 3 px accent strip, notes in the track colour quieter by
velocity, selected notes accent, scale rows a neutral lift; the tools panel is 272 and
Apply is its primary action. Audio: a ruler 24, a 22 px warp-marker strip, and
diff --git a/FEATURES.md b/FEATURES.md
index 1695063f..06dd0a7c 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -363,6 +363,10 @@ docks as a panel under any of the three, or floats in its own window — see
- Everything is **seeded**, so a result is repeatable and "New seed" re-rolls it.
- Tools that think in pitch follow the roll's **Set Scale** key, so what they write
stays in key.
+- **Clip editor side panels**: the clip inspector (MIDI and audio) and the Tools rail show
+ their sections in one column while they fit the editor's height and in two side by side when
+ they don't and the editor is wide enough, so the controls stay in view; only past that do
+ they scroll. Sections keep their order and are never split between columns.
- **Pattern (step sequencer)**: on a Drum Rack track the detail panel gains a **Pattern**
tab between Devices and Clip — a drum-machine grid with one row per loaded pad. Click a
step to place a hit, shift-click for an accent, drag across the grid to paint, and use
diff --git a/specs/055-clip-panel-columns/plan.md b/specs/055-clip-panel-columns/plan.md
new file mode 100644
index 00000000..6f412f62
--- /dev/null
+++ b/specs/055-clip-panel-columns/plan.md
@@ -0,0 +1,60 @@
+# Implementation Plan: Two-column clip inspector and MIDI tools
+
+**Branch**: `cursor/clip-panels-two-columns-edc4` | **Spec**: [spec.md](spec.md) | **Issue**: nota-daw/nota#276
+
+## Summary
+
+UI only (`src/managed/Nota.App`); no engine, model or project-file change. The side panels keep
+their sections as separate controls and a new host picks one or two columns at measure time from
+the height it is given and the width it is offered.
+
+## Pieces
+
+- **`ClipEditor/PanelColumns.cs`** (no Avalonia, linked into the smoke test): `Stack` (sections
+ plus gaps), `BestSplit` (the leading run that minimises the taller column, ties to the first
+ column), `Choose` (one column if it fits / no width / a single section, else two).
+- **`ClipPanelColumns.cs`**:
+ - `SectionColumns`: the sections in one or two equal columns, a 1 px `GraphBorder` hairline
+ centred in the gap between neighbours of a column (replaces the `StackPanel` + `Rule()`
+ children `ClipEditorKit.Sections` built).
+ - `ColumnFlow`: a vertical `ScrollViewer` around the sections with an optional foot pinned
+ below. Measure: foot at one-column width, each section at the column's inner width, then
+ `PanelColumns.Choose`; two columns are `2 × ColumnWidth + border` wide (the panel, border
+ included, doubles) and the column gap is the side padding plus the border, so a section has
+ the same width in either layout and never reflows. `Reserve`
+ is the width the editor canvas keeps.
+- **`ClipEditorKit`**: `Sections` returns `SectionColumns`; `Inspector` builds a `ColumnFlow`
+ (column 231 px + 1 px border = 232 px; two columns 464 px, padding 14/16/14/8, hint as the foot) and hands it back;
+ `Header` takes the inspector and keeps the clip cell at its width (`SizeChanged`);
+ it also gives the inspector's `ColumnFlow` a `Beside` width (the rest of the header) that
+ `PanelColumns.RoomForTwo` weighs against the canvas reserve;
+ `MinCanvasW = 480`; `Rule()` goes (unused).
+- **`MidiToolsView`**: sections = [Generate / Transform + tool list], parameters, Output, spacing
+ 10; foot = result line, Apply, Revert / Defaults; column 271 px + 1 px border = 272 px (544 px
+ in two columns).
+- **Editors**: the body `Grid` (`Auto,*,Auto` / `Auto,*`) becomes a `DockPanel` (inspector left,
+ tools right, canvas fill), so the panels are measured with the real width (a Grid `Auto` column
+ measures with infinite width) and in order: inspector first, tools from what is left.
+ `ClipEditorView.SetTools` sets the inspector's `Reserve` to `MinCanvasW + ToolsW` while Tools
+ is open.
+- **Re-layout**: a section growing or shrinking changes the scroller's desired size whenever the
+ choice could flip, which re-measures the host; no extra hook.
+
+## Audio-thread impact and architecture rules
+
+None. Every change is in the Avalonia layout pass on the UI thread (`Nota.App`); nothing
+touches the engine, the C ABI, the graph or the transport.
+
+- AR-6 (no allocation, locks or I/O on the audio thread): the audio thread runs no new code.
+- AR-5 (graph snapshots): no structural edit; the graph is not touched.
+- AR-7 (pure C ABI): no new or changed `nota_engine.h` call.
+- No JUCE outside `pluginhost/`: no native code changes.
+- AR-9 (`Transport` is the only source of musical time): nothing reads or keeps time.
+- No new dependency.
+
+## Testing
+
+- Smoke test `--clipeditor`: `PanelColumns` cases (fits → one, overflow → two with the expected
+ split, narrow → one, still too tall → two and scroll, lone section, best split, tie rule).
+- Full `scripts/build-linux.sh` smoke run.
+- Screenshots of a short editor before / after (MIDI with Tools, audio).
diff --git a/specs/055-clip-panel-columns/spec.md b/specs/055-clip-panel-columns/spec.md
new file mode 100644
index 00000000..c0e03bc7
--- /dev/null
+++ b/specs/055-clip-panel-columns/spec.md
@@ -0,0 +1,99 @@
+# Feature Specification: Two-column clip inspector and MIDI tools
+
+**Feature Branch**: `cursor/clip-panels-two-columns-edc4`
+
+**Created**: 2026-10-30
+
+**Status**: Implemented
+
+**Input**: nota-daw/nota#276: "The clip editor's side panels are a single narrow column that
+scrolls vertically … Lay out the inspector and the MIDI tools panel in two columns, so most or all
+sections fit without scrolling. Make the layout adaptive: two columns when there is room, one
+column when the editor area is narrow, and vertical scrolling only as a last resort when even two
+columns don't fit the height. Sections stay whole, keep a stable order, and the change applies to
+the MIDI clip editor, the audio clip editor and MIDI tools in the same way."
+
+## User Scenarios & Testing *(mandatory)*
+
+### User Story 1 - Reach every inspector control without scrolling (Priority: P1)
+
+A producer opens a MIDI clip in the detail area, which is about 320 px tall. Today Clip and
+Quantize are visible and Transpose and Selection sit below the fold. With this change the
+inspector widens to two columns, Clip and Quantize on the left and Transpose and Selection on
+the right, and nothing scrolls.
+
+**Independent Test**: Open a MIDI clip in a short, wide editor: the inspector shows all four
+sections in two columns and has no scrollbar. Make the editor tall: the inspector goes back to
+one 232 px column.
+
+**Acceptance Scenarios**:
+
+1. **Given** the inspector's sections fit the editor's height in one column, **Then** it stays
+ one 232 px column, as today.
+2. **Given** they don't fit and the editor can give the inspector a second column while the piano
+ roll / waveform keeps at least 480 px, **Then** the inspector shows two columns of the same
+ width side by side (464 px in all).
+3. **Given** they don't fit and the editor is too narrow for a second column, **Then** the
+ inspector stays one column and scrolls.
+4. **Given** two columns and they still don't fit the height, **Then** the inspector scrolls
+ vertically (both columns together).
+5. **Given** any layout, **Then** a section is never split across columns, the first column holds
+ the leading sections and the second the rest in their usual order, and the split is the one
+ that leaves the taller column shortest.
+6. **Given** the inspector's width changes, **Then** the header's clip cell (colour bar, name,
+ kind badge) keeps the inspector's width, so the hairline under it lines up.
+7. **Given** the hint line, **Then** it stays pinned under the sections across the panel's full
+ width.
+
+### User Story 2 - The same for the audio editor and MIDI tools (Priority: P1)
+
+The audio clip editor's inspector (Clip, Playback, Warp; ADSR in ADSR mode) and the MIDI tools
+panel (the Generate / Transform tool list, the tool's parameters, Output) follow the same rules.
+The tools panel's column is 272 px; its result line, Apply and Revert / Defaults stay pinned at
+the foot across the panel's width.
+
+**Acceptance Scenarios**:
+
+1. **Given** the audio editor, **Then** its inspector behaves as in User Story 1. In ADSR mode
+ its single section is one column.
+2. **Given** the MIDI tools panel is open, **Then** it takes a second column under the same rules,
+ after the inspector has chosen its own: the inspector leaves room for a one-column tools panel
+ when it decides, and the tools panel decides from the width that remains.
+3. **Given** a section changes height (the selection card appears, a tool with more parameters is
+ picked), **Then** the layout is re-chosen.
+
+### Edge Cases
+
+- A panel with a single section never takes a second column.
+- Infinite height (a panel measured without a height limit) is always one column.
+- Hidden sections take no part in the split.
+
+## Requirements *(mandatory)*
+
+### Functional Requirements
+
+- **FR-001**: The clip inspector (MIDI and audio) and the MIDI tools panel MUST use one column
+ while their sections fit the available height.
+- **FR-002**: They MUST use two columns of the one-column width when one column would scroll and
+ the width they are offered, less what the editor canvas keeps (480 px, plus a one-column tools
+ panel for the inspector while Tools is open), holds two columns.
+ The inspector also leaves the header the width its mode and right-hand controls need beside the
+ clip cell, which widens with the inspector, so no control runs outside the visible panel.
+- **FR-003**: They MUST scroll vertically only when the chosen layout doesn't fit the height.
+- **FR-004**: Sections MUST stay whole and in order; column one holds a leading run of them.
+- **FR-005**: The split MUST minimise the taller column; on a tie the first column takes more.
+- **FR-006**: The header's clip cell MUST keep the inspector's width.
+
+## Success Criteria *(mandatory)*
+
+- **SC-001**: In a MIDI editor 320 px tall (header included) and 1400 px wide, all four inspector
+ sections are visible without scrolling. (Measured in the headless app: the two-column inspector
+ needs an editor about 310 px tall; 300 px, the figure first written here, was too short.)
+- **SC-002**: In a tall editor the panels are pixel-for-pixel today's single column.
+- **SC-003**: The layout choice is covered by smoke-test cases (`--clipeditor`).
+
+## Assumptions
+
+- Two columns are used only when one would scroll: when everything already fits, the roll keeps
+ the width. The 480 px canvas reserve is a tunable constant (`ClipEditorKit.MinCanvasW`).
+- No persisted setting: the layout follows the editor's size.
diff --git a/specs/055-clip-panel-columns/tasks.md b/specs/055-clip-panel-columns/tasks.md
new file mode 100644
index 00000000..ee754de8
--- /dev/null
+++ b/specs/055-clip-panel-columns/tasks.md
@@ -0,0 +1,17 @@
+# Tasks: Two-column clip inspector and MIDI tools
+
+- [x] T1 `PanelColumns` layout math (stack, best split, choose)
+- [x] T2 `SectionColumns` + `ColumnFlow` (columns, hairlines, pinned foot, reserve)
+- [x] T3 `ClipEditorKit.Inspector` / `Sections` on the new host; header clip cell follows the inspector
+- [x] T4 `MidiToolsView` on the new host
+- [x] T5 MIDI and audio editor bodies as dock panels; inspector reserve follows the Tools toggle
+- [x] T6 Smoke test cases (`--clipeditor`)
+- [x] T7 CHANGELOG
+- [x] T8 Screenshots before / after
+
+## Phase 2: Convergence
+
+- [x] T009 Make two columns exactly twice the one-column panel (464 px inspector, 544 px tools) per US1/AC2 (partial)
+- [x] T010 Correct SC-001 to the measured editor height at which every inspector section fits without scrolling per SC-001 (partial)
+- [x] T011 Update DESIGN.md's clip editor entry (inspector and tools widths) to the adaptive layout per Constitution VI (partial)
+- [x] T012 Verify a tall editor renders as before (before / after pixel diff, Tools open) per SC-002 (partial)
diff --git a/src/managed/Nota.App/AudioClipEditorView.cs b/src/managed/Nota.App/AudioClipEditorView.cs
index 7355ee0f..74fc03b0 100644
--- a/src/managed/Nota.App/AudioClipEditorView.cs
+++ b/src/managed/Nota.App/AudioClipEditorView.cs
@@ -3,8 +3,8 @@
//
// Detail · Clip for AUDIO clips (nota-design "Nota Clip Editor" 1b): the same frame as the
// MIDI editor — a 38px header (clip cell, Sample | Envelope, the envelope target while
-// editing one, the snap-grid chip, the file's format) over the 232px inspector (CLIP,
-// PLAYBACK, WARP) and the waveform canvas: a beat ruler, a 22px warp-marker strip, and
+// editing one, the snap-grid chip, the file's format) over the inspector (CLIP, PLAYBACK,
+// WARP; one column or two, specs/055) and the waveform canvas: a beat ruler, a 22px warp-marker strip, and
// the wave in the track colour, everything past the clip's played region darkened rather
// than hidden. Envelope and ADSR are modes of the canvas, not checkboxes. ADSR edits the
// clip's amplitude shape with the same handles the arrangement shows on the clip
@@ -47,8 +47,8 @@ public sealed class AudioClipEditorView : UserControl
private Action _syncAttack = () => { }, _syncDecay = () => { }, _syncSustain = () => { }, _syncRelease = () => { };
private ClipAdsr _adsr = ClipAdsr.Identity;
private int _mode; // 0 = Sample, 1 = Envelope, 2 = ADSR
- private readonly ContentControl _inspectorBody = new();
- private Control _sampleSections = null!, _adsrSections = null!;
+ private ColumnFlow _inspectorFlow = null!;
+ private SectionColumns _sampleSections = null!, _adsrSections = null!;
private double _startBeat;
private double _lengthBeats = 4;
@@ -177,8 +177,8 @@ public sealed class AudioClipEditorView : UserControl
_sampleSections = Sections(clip, playback, warp);
_adsrSections = Sections(adsr);
- _inspectorBody.Content = _sampleSections;
- var inspector = Inspector(_inspectorBody, _hint);
+ var inspector = Inspector(_sampleSections, _hint, out _inspectorFlow);
+ DockPanel.SetDock(inspector, Dock.Left);
// Column 1: the waveform (row 0), a horizontal zoom scrollbar (row 1), and a
// floating overlay (Canvas with null background → clicks pass through except the
@@ -205,10 +205,7 @@ public sealed class AudioClipEditorView : UserControl
col1.Children.Add(waveHost);
Grid.SetRow(_hScroll, 1); col1.Children.Add(_hScroll);
- var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
- grid.Children.Add(inspector);
- Grid.SetColumn(col1, 1);
- grid.Children.Add(col1);
+ var grid = new DockPanel { Children = { inspector, col1 } };
// Header: Sample | Envelope | ADSR, the target while editing an envelope, Snap, the format.
var tabs = Segments(new[] { "Sample", "Envelope", "ADSR" }, 0, SetMode, out _);
@@ -220,7 +217,7 @@ public sealed class AudioClipEditorView : UserControl
_wave.GridChanged += chip.Refresh;
var right = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12, Children = { snap, HeaderDivider(), _fileText } };
var name = engine.GetClipName(trackId, clipIndex);
- var header = Header(clipColor, string.IsNullOrWhiteSpace(name) ? $"Audio {trackId}" : name, "AUDIO", tabs, _envTargetDrop, right);
+ var header = Header(clipColor, string.IsNullOrWhiteSpace(name) ? $"Audio {trackId}" : name, "AUDIO", tabs, _envTargetDrop, right, inspector, _inspectorFlow);
DockPanel.SetDock(header, Dock.Top);
Content = new DockPanel { Background = NotaPalette.Gutter, Children = { header, grid } };
@@ -608,7 +605,7 @@ public sealed class AudioClipEditorView : UserControl
_envTargetDrop.IsVisible = _envMode;
_wave.SetEnvMode(_envMode);
_wave.SetAdsrMode(mode == 2);
- _inspectorBody.Content = mode == 2 ? _adsrSections : _sampleSections;
+ _inspectorFlow.Body = mode == 2 ? _adsrSections : _sampleSections;
PaintHint();
}
diff --git a/src/managed/Nota.App/ClipEditor/PanelColumns.cs b/src/managed/Nota.App/ClipEditor/PanelColumns.cs
new file mode 100644
index 00000000..0c81ecf9
--- /dev/null
+++ b/src/managed/Nota.App/ClipEditor/PanelColumns.cs
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// How the clip editor's side panels (the clip inspector, the MIDI tools) lay out their
+// sections (specs/055): one column while everything fits the height, two when it doesn't and
+// the editor has the width, and scrolling only past that. Sections are never split, keep
+// their order (the first column takes a leading run, the second the rest), and the split is
+// the one that leaves the taller column shortest. No Avalonia here, so the smoke test links it.
+
+using System;
+
+namespace Nota.App;
+
+public static class PanelColumns
+{
+ /// <summary>The chosen layout: 1 or 2 columns, how many sections the first column holds
+ /// (all of them for one column), and the taller column's height.</summary>
+ public readonly record struct Plan(int Columns, int Split, double Height);
+
+ /// <summary>Height of sections <paramref name="from"/>..<paramref name="to"/> (exclusive)
+ /// stacked with <paramref name="gap"/> between neighbours.</summary>
+ public static double Stack(ReadOnlySpan<double> heights, int from, int to, double gap)
+ {
+ double h = 0;
+ for (int i = from; i < to; i++) h += heights[i] + (i > from ? gap : 0);
+ return h;
+ }
+
+ /// <summary>The first column's section count (1..n-1) that leaves the taller column shortest;
+ /// on a tie the first column takes more, so it reads top-left first.</summary>
+ public static int BestSplit(ReadOnlySpan<double> heights, double gap)
+ {
+ int n = heights.Length, best = n;
+ double bestH = double.PositiveInfinity;
+ for (int k = 1; k < n; k++)
+ {
+ double h = Math.Max(Stack(heights, 0, k, gap), Stack(heights, k, n, gap));
+ if (h <= bestH) { bestH = h; best = k; }
+ }
+ return best;
+ }
+
+ /// <summary>Whether a panel can take its second column: of the <paramref name="available"/>
+ /// width, <paramref name="two"/> goes to the panel and what is left must still hold the
+ /// larger of <paramref name="reserve"/> (the canvas's minimum) and <paramref name="beside"/>
+ /// (what the header needs next to the clip cell, which widens with the panel).</summary>
+ public static bool RoomForTwo(double available, double two, double reserve, double beside)
+ => available - Math.Max(reserve, beside) >= two;
+
+ /// <summary>Picks the layout. <paramref name="room"/> is the height the sections get in one
+ /// column; <paramref name="widthForTwo"/> says the editor can spare a second column.</summary>
+ public static Plan Choose(ReadOnlySpan<double> heights, double gap, double room, bool widthForTwo)
+ {
+ int n = heights.Length;
+ double one = Stack(heights, 0, n, gap);
+ if (n < 2 || one <= room || !widthForTwo) return new Plan(1, n, one);
+ int k = BestSplit(heights, gap);
+ return new Plan(2, k, Math.Max(Stack(heights, 0, k, gap), Stack(heights, k, n, gap)));
+ }
+}
diff --git a/src/managed/Nota.App/ClipEditorKit.cs b/src/managed/Nota.App/ClipEditorKit.cs
index 4fe12fbf..a0795de7 100644
--- a/src/managed/Nota.App/ClipEditorKit.cs
+++ b/src/managed/Nota.App/ClipEditorKit.cs
@@ -4,7 +4,8 @@
// Shared shell pieces of the clip editor (nota-design "Nota Clip Editor"): one frame for
// MIDI and audio — a 38px header whose first 232px is the clip cell (track-colour bar,
// name, kind badge), mode segments after it, and a 232px inspector on the left whose
-// sections are split by hairlines and end in a single hint line. Everything here is the
+// sections are split by hairlines and end in a single hint line. Inspector and MIDI tools
+// take a second column when one would scroll (specs/055); the clip cell follows. Everything here is the
// shell scale (11px words, 10px caps section labels); the theme's Button / .primary /
// ToggleButton.seg carry the states.
@@ -22,16 +23,24 @@ internal static class ClipEditorKit
{
public const double HeaderH = 38, InspectorW = 232, ToolsW = 272, FieldH = 26;
+ /// <summary>Width the piano roll / waveform keeps before a side panel takes a second column.</summary>
+ public const double MinCanvasW = 480;
+
// ---- header -----------------------------------------------------------
/// <summary>The 38px header: clip cell | modes | (flex) | right-hand controls.</summary>
- public static Border Header(IBrush trackColor, string name, string kind, Control modes, Control? afterModes, Control? right)
- => Header(trackColor, name, kind, modes, afterModes, right, out _, out _);
+ public static Border Header(IBrush trackColor, string name, string kind, Control modes, Control? afterModes, Control? right,
+ Control? inspector = null, ColumnFlow? flow = null)
+ => Header(trackColor, name, kind, modes, afterModes, right, out _, out _, inspector, flow);
/// <summary>As above, handing back the name and the colour bar so a header can follow the
- /// clip it names (the multi-clip editor's active clip).</summary>
+ /// clip it names (the multi-clip editor's active clip). The clip cell keeps the width of
+ /// <paramref name="inspector"/>, so it stays over it at one column or two; the rest of the
+ /// header can't shrink, so <paramref name="flow"/> (that inspector's columns) is told how much
+ /// width it needs and takes a second column only when that still fits.</summary>
public static Border Header(IBrush trackColor, string name, string kind, Control modes, Control? afterModes, Control? right,
- out TextBlock nameOut, out Border colorBar)
+ out TextBlock nameOut, out Border colorBar,
+ Control? inspector = null, ColumnFlow? flow = null)
{
var cell = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 9 };
var nameText = new TextBlock
@@ -59,6 +68,7 @@ internal static class ClipEditorKit
},
},
};
+ if (inspector is not null) inspector.SizeChanged += (_, e) => cellHost.Width = e.NewSize.Width;
var row = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,Auto,*,Auto"), ColumnSpacing = 12 };
row.Children.Add(cellHost);
@@ -66,11 +76,17 @@ internal static class ClipEditorKit
Grid.SetColumn(modes, 1); row.Children.Add(modes);
if (afterModes is not null) { afterModes.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(afterModes, 2); row.Children.Add(afterModes); }
if (right is not null) { right.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(right, 4); row.Children.Add(right); }
- return new Border
+ var header = new Border
{
Height = HeaderH, Background = NotaPalette.Panel, BorderBrush = NotaPalette.BorderDefault,
BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(0, 0, 12, 0), Child = row,
};
+ // Everything but the clip cell: the controls at their natural width (hidden ones measure 0),
+ // the column gaps and the right padding.
+ if (flow is not null)
+ flow.Beside = () => modes.DesiredSize.Width + (afterModes?.DesiredSize.Width ?? 0) + (right?.DesiredSize.Width ?? 0)
+ + row.ColumnSpacing * (row.ColumnDefinitions.Count - 1) + header.Padding.Right;
+ return header;
}
/// <summary>A 1×18 hairline between header groups.</summary>
@@ -109,44 +125,24 @@ internal static class ClipEditorKit
// ---- inspector --------------------------------------------------------
- /// <summary>The 232px inspector: scrolling sections with the hint line pinned below.</summary>
- public static Border Inspector(Control sections, TextBlock hint)
+ /// <summary>The inspector: sections in one 232px column, or two side by side when one would
+ /// scroll and the editor has the width (specs/055), with the hint line pinned below.</summary>
+ public static Border Inspector(SectionColumns sections, TextBlock hint) => Inspector(sections, hint, out _);
+
+ public static Border Inspector(SectionColumns sections, TextBlock hint, out ColumnFlow flow)
{
- DockPanel.SetDock(hint, Dock.Bottom);
hint.Margin = new Thickness(14, 6, 14, 12);
+ flow = new ColumnFlow(sections, hint, new Thickness(14, 16, 14, 8), InspectorW - 1) { Reserve = MinCanvasW };
return new Border
{
- Width = InspectorW, Background = NotaPalette.Panel, BorderBrush = NotaPalette.BorderDefault,
- BorderThickness = new Thickness(0, 0, 1, 0),
- Child = new DockPanel
- {
- Children =
- {
- hint,
- new ScrollViewer
- {
- Content = new Border { Padding = new Thickness(14, 16, 14, 8), Child = sections },
- HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
- VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- },
- },
- },
+ Background = NotaPalette.Panel, BorderBrush = NotaPalette.BorderDefault,
+ BorderThickness = new Thickness(0, 0, 1, 0), Child = flow,
};
}
- /// <summary>A vertical run of sections split by hairlines (gap 18 around each rule).</summary>
- public static StackPanel Sections(params Control[] sections)
- {
- var s = new StackPanel { Spacing = 18 };
- for (int i = 0; i < sections.Length; i++)
- {
- if (i > 0) s.Children.Add(Rule());
- s.Children.Add(sections[i]);
- }
- return s;
- }
-
- public static Border Rule() => new() { Height = 1, Background = NotaPalette.GraphBorder };
+ /// <summary>Sections split by hairlines (gap 18 around each rule), laid out in columns by
+ /// the panel that hosts them.</summary>
+ public static SectionColumns Sections(params Control[] sections) => new(18, sections);
/// <summary>A section title (sentence case, muted), with an optional mono read-out on the right.</summary>
public static Grid SectionTitle(string title, TextBlock? right = null)
diff --git a/src/managed/Nota.App/ClipEditorView.cs b/src/managed/Nota.App/ClipEditorView.cs
index 76b4f5c4..1d5b922c 100644
--- a/src/managed/Nota.App/ClipEditorView.cs
+++ b/src/managed/Nota.App/ClipEditorView.cs
@@ -3,8 +3,8 @@
//
// Detail · Clip for MIDI clips (nota-design "Nota Clip Editor" 1a): a 38px header — the clip
// cell, Notes | Envelopes, then the Scale switch with its key, mode and "Remove out of
-// scale", and the Tools toggle — over the 232px inspector (ClipPropsView), the piano roll (PianoRollView) and
-// the 272px clip-tools panel (MidiToolsView). Envelopes is a mode of the same canvas: the
+// scale", and the Tools toggle — over the inspector (ClipPropsView), the piano roll (PianoRollView) and
+// the clip-tools panel (MidiToolsView), each panel one column or two (specs/055). Envelopes is a mode of the same canvas: the
// notes dim under a wash and the clip envelope (Velocity / Volume) is drawn over them in
// brass, on the roll's own beat axis so zoom and scroll carry over. With several clips open
// (specs/029) the header, inspector and envelopes follow the roll's active clip.
@@ -48,14 +48,13 @@ public sealed class ClipEditorView : UserControl
// Inspector | roll | clip-tools panel. The tools panel is a toggle rather than a
// tab because its whole point is watching the roll change while you turn a knob.
- var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto") };
+ // Docked in this order, the inspector picks its columns first, then the tools panel
+ // from what is left, and the roll takes the rest (specs/055).
_props = new ClipPropsView(roll, startBeat);
- grid.Children.Add(_props);
- Grid.SetColumn(roll, 1);
- grid.Children.Add(roll);
+ DockPanel.SetDock(_props, Dock.Left);
_tools = new MidiToolsView(roll) { IsVisible = false };
- Grid.SetColumn(_tools, 2);
- grid.Children.Add(_tools);
+ DockPanel.SetDock(_tools, Dock.Right);
+ var body = new DockPanel { Children = { _props, _tools, roll } };
_toolsToggle = new ToggleButton { Content = "Tools", Padding = new Thickness(12, 0), Classes = { "chip" } };
_toolsToggle.Click += (_, _) => SetTools(_toolsToggle.IsChecked == true);
@@ -67,9 +66,9 @@ public sealed class ClipEditorView : UserControl
Orientation = Orientation.Horizontal, Spacing = 12,
Children = { AuditionControl(), FitControl(roll), SnapControl(roll), HeaderDivider(), ScaleControls(), HeaderDivider(), _toolsToggle },
};
- var header = Header(roll.TrackBrush, HeaderName(clipName), "MIDI", tabs, null, right, out _nameText, out _colorBar);
+ var header = Header(roll.TrackBrush, HeaderName(clipName), "MIDI", tabs, null, right, out _nameText, out _colorBar, _props, _props.Flow);
DockPanel.SetDock(header, Dock.Top);
- Content = new DockPanel { Background = NotaPalette.Gutter, Children = { header, grid } };
+ Content = new DockPanel { Background = NotaPalette.Gutter, Children = { header, body } };
roll.ActiveClipChanged += OnActiveClipChanged;
if (roll.Clips.IsMulti) OnActiveClipChanged(); // envelopes on the active clip's place on the axis
}
@@ -159,6 +158,7 @@ public sealed class ClipEditorView : UserControl
{
if (show && _envMode) { _setTab(0); ShowTab(false); }
_tools.IsVisible = show;
+ _props.Flow.Reserve = MinCanvasW + (show ? ToolsW : 0);
_toolsToggle.IsChecked = show;
_tools.SetActive(show);
}
diff --git a/src/managed/Nota.App/ClipPanelColumns.cs b/src/managed/Nota.App/ClipPanelColumns.cs
new file mode 100644
index 00000000..5139db53
--- /dev/null
+++ b/src/managed/Nota.App/ClipPanelColumns.cs
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The adaptive frame of the clip editor's side panels (specs/055): SectionColumns stacks the
+// sections in one or two columns, split by hairlines, and ColumnFlow decides how many from the
+// height it is given and the width the editor can spare (PanelColumns does the arithmetic),
+// with a foot (the inspector's hint, the tools' Apply row) pinned under the scrolling sections.
+// The second column has exactly the first one's width, so a section never reflows: the panel,
+// border included, just doubles (2 × 232 for the inspector), and the column gap is the side
+// padding plus the border width.
+
+using System;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Media;
+
+namespace Nota.App;
+
+/// <summary>Sections in one or two columns (set by <see cref="ColumnFlow"/>), a hairline
+/// centred in the gap between neighbours of a column.</summary>
+public sealed class SectionColumns : Control
+{
+ private readonly double _spacing;
+ private readonly Control[] _sections;
+ private Rect[] _rules = Array.Empty<Rect>();
+
+ /// <param name="spacing">Space either side of the hairline between two sections.</param>
+ public SectionColumns(double spacing, params Control[] sections)
+ {
+ _spacing = spacing;
+ _sections = sections;
+ foreach (var s in sections) { LogicalChildren.Add(s); VisualChildren.Add(s); }
+ }
+
+ public double Gap => 2 * _spacing + 1;
+ public int Columns { get; private set; } = 1;
+ public int Split { get; private set; } = int.MaxValue;
+ public double ColumnGap { get; set; }
+
+ internal void SetLayout(int columns, int split)
+ {
+ if (columns == Columns && split == Split) return;
+ Columns = columns; Split = split;
+ InvalidateMeasure();
+ }
+
+ private double ColumnWidth(double width) => Columns == 2 ? Math.Max(0, (width - ColumnGap) / 2) : width;
+
+ /// <summary>Each visible section's height at <paramref name="columnWidth"/>.</summary>
+ internal double[] MeasureSections(double columnWidth)
+ {
+ var h = new System.Collections.Generic.List<double>(_sections.Length);
+ foreach (var c in _sections)
+ {
+ if (!c.IsVisible) continue;
+ c.Measure(new Size(columnWidth, double.PositiveInfinity));
+ h.Add(c.DesiredSize.Height);
+ }
+ return h.ToArray();
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ var h = MeasureSections(ColumnWidth(availableSize.Width));
+ int k = Math.Min(Split, h.Length);
+ double height = Math.Max(PanelColumns.Stack(h, 0, k, Gap), PanelColumns.Stack(h, k, h.Length, Gap));
+ double width = double.IsInfinity(availableSize.Width) ? 0 : availableSize.Width;
+ return new Size(width, height);
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ double colW = ColumnWidth(finalSize.Width);
+ var rules = new System.Collections.Generic.List<Rect>();
+ int i = 0;
+ double y = 0, x = 0;
+ foreach (var c in _sections)
+ {
+ if (!c.IsVisible) continue;
+ if (i == Split) { x = colW + ColumnGap; y = 0; }
+ else if (i > 0) { rules.Add(new Rect(x, y + _spacing, colW, 1)); y += Gap; }
+ c.Arrange(new Rect(x, y, colW, c.DesiredSize.Height));
+ y += c.DesiredSize.Height;
+ i++;
+ }
+ _rules = rules.ToArray();
+ InvalidateVisual();
+ return finalSize;
+ }
+
+ public override void Render(DrawingContext context)
+ {
+ base.Render(context);
+ foreach (var r in _rules) context.FillRectangle(NotaPalette.GraphBorder, r);
+ }
+}
+
+/// <summary>A side panel's body: <see cref="SectionColumns"/> in a vertical scroller with an
+/// optional foot pinned below. One column is <see cref="ColumnWidth"/> wide, inside the panel's
+/// border (<c>edge</c> wide); it takes a second only when one column would scroll and the width
+/// it is offered, less <see cref="Reserve"/> (what the editor canvas keeps), still holds two.</summary>
+public sealed class ColumnFlow : Control
+{
+ private readonly ScrollViewer _scroll;
+ private readonly Border _pad;
+ private readonly Control? _foot;
+ private SectionColumns _body = null!;
+
+ private readonly double _edge;
+
+ public ColumnFlow(SectionColumns body, Control? foot, Thickness padding, double columnWidth, double edge = 1)
+ {
+ ColumnWidth = columnWidth;
+ _edge = edge;
+ _pad = new Border { Padding = padding };
+ _scroll = new ScrollViewer
+ {
+ Content = _pad,
+ HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
+ VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
+ };
+ _foot = foot;
+ LogicalChildren.Add(_scroll); VisualChildren.Add(_scroll);
+ if (foot is not null) { LogicalChildren.Add(foot); VisualChildren.Add(foot); }
+ Body = body;
+ }
+
+ public double ColumnWidth { get; }
+
+ /// <summary>Width the editor's header needs beside the clip cell, which follows this panel's
+ /// width, so a second column must leave it. Read at each measure.</summary>
+ public Func<double>? Beside { get; set; }
+
+ private double _reserve;
+ public double Reserve
+ {
+ get => _reserve;
+ set { if (_reserve != value) { _reserve = value; InvalidateMeasure(); } }
+ }
+
+ public SectionColumns Body
+ {
+ get => _body;
+ set
+ {
+ _body = value;
+ _body.ColumnGap = _pad.Padding.Left + _pad.Padding.Right + _edge;
+ _pad.Child = value;
+ InvalidateMeasure();
+ }
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ var pad = _pad.Padding;
+ double one = ColumnWidth, two = 2 * ColumnWidth + _edge;
+ double footH = 0;
+ if (_foot is not null) { _foot.Measure(new Size(one, availableSize.Height)); footH = _foot.DesiredSize.Height; }
+ var heights = _body.MeasureSections(Math.Max(0, one - pad.Left - pad.Right));
+ double room = availableSize.Height - footH - pad.Top - pad.Bottom;
+ bool widthForTwo = PanelColumns.RoomForTwo(availableSize.Width, two, Reserve, Beside?.Invoke() ?? 0);
+ var plan = PanelColumns.Choose(heights, _body.Gap, room, widthForTwo);
+ _body.SetLayout(plan.Columns, plan.Columns == 2 ? plan.Split : int.MaxValue);
+
+ double w = plan.Columns == 2 ? two : one;
+ if (_foot is not null) { _foot.Measure(new Size(w, availableSize.Height)); footH = _foot.DesiredSize.Height; }
+ _scroll.Measure(new Size(w, Math.Max(0, availableSize.Height - footH)));
+ double h = _scroll.DesiredSize.Height + footH;
+ return new Size(w, double.IsInfinity(availableSize.Height) ? h : Math.Min(h, availableSize.Height));
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ double footH = _foot?.DesiredSize.Height ?? 0;
+ double scrollH = Math.Max(0, finalSize.Height - footH);
+ _scroll.Arrange(new Rect(0, 0, finalSize.Width, scrollH));
+ _foot?.Arrange(new Rect(0, scrollH, finalSize.Width, footH));
+ return finalSize;
+ }
+}
diff --git a/src/managed/Nota.App/ClipPropsView.cs b/src/managed/Nota.App/ClipPropsView.cs
index 49535175..66607c1a 100644
--- a/src/managed/Nota.App/ClipPropsView.cs
+++ b/src/managed/Nota.App/ClipPropsView.cs
@@ -40,6 +40,8 @@ public sealed class ClipPropsView : UserControl
private int _transpose;
private double _strength = 0.8;
+ public ColumnFlow Flow { get; }
+
public ClipPropsView(PianoRollView roll, double startBeat)
{
_roll = roll;
@@ -92,7 +94,8 @@ public sealed class ClipPropsView : UserControl
var selection = Section(SectionTitle("Selection", _selCount), 8, _selCard, _selEmpty);
Content = Inspector(Sections(clip, grid, transpose, selection),
- Hint("Double-click — add or delete · edge — length · Shift — add to selection"));
+ Hint("Double-click — add or delete · edge — length · Shift — add to selection"), out var flow);
+ Flow = flow;
PaintTranspose();
OnRollChanged();
diff --git a/src/managed/Nota.App/MidiToolsView.cs b/src/managed/Nota.App/MidiToolsView.cs
index a87911cf..1c76da91 100644
--- a/src/managed/Nota.App/MidiToolsView.cs
+++ b/src/managed/Nota.App/MidiToolsView.cs
@@ -27,9 +27,9 @@ namespace Nota.App;
public sealed class MidiToolsView : UserControl
{
- public const double RailWidth = ToolsW;
-
private readonly PianoRollView _roll;
+
+ public ColumnFlow Flow { get; }
private readonly Dictionary<string, MidiToolSettings> _settings = new(StringComparer.Ordinal);
private readonly StackPanel _toolList = new();
@@ -58,7 +58,6 @@ public sealed class MidiToolsView : UserControl
public MidiToolsView(PianoRollView roll)
{
_roll = roll;
- Width = RailWidth;
Background = NotaPalette.Panel;
BorderBrush = NotaPalette.BorderDefault;
BorderThickness = new Thickness(1, 0, 0, 0);
@@ -109,25 +108,16 @@ public sealed class MidiToolsView : UserControl
Pair(ClipEditorKit.Button("Revert", Revert), ClipEditorKit.Button("Defaults", ResetTool)),
},
};
- DockPanel.SetDock(foot, Dock.Bottom);
- foot.Margin = new Thickness(0, 10, 8, 0);
+ foot.Margin = new Thickness(14, 10, 14, 12);
- // The scroll content keeps 8px clear on the right for the overlay scrollbar.
- var top = new StackPanel { Spacing = 10, Margin = new Thickness(0, 0, 8, 0), Children = { kinds, _toolList, Rule(), parameters, Rule(), output } };
- Content = new DockPanel
+ // The right padding keeps 8px clear of the overlay scrollbar. Like the inspector, the
+ // panel takes a second column when one would scroll (specs/055).
+ var tools = new StackPanel { Spacing = 10, Children = { kinds, _toolList } };
+ Flow = new ColumnFlow(new SectionColumns(10, tools, parameters, output), foot, new Thickness(14, 12, 14, 0), ToolsW - 1)
{
- Margin = new Thickness(14, 12, 6, 12),
- Children =
- {
- foot,
- new ScrollViewer
- {
- Content = top,
- HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
- VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
- },
- },
+ Reserve = MinCanvasW,
};
+ Content = Flow;
RebuildToolList();
RebuildParams();
diff --git a/tests/Nota.SmokeTest/ClipEditorTests.cs b/tests/Nota.SmokeTest/ClipEditorTests.cs
index 51afa40d..2420ea6a 100644
--- a/tests/Nota.SmokeTest/ClipEditorTests.cs
+++ b/tests/Nota.SmokeTest/ClipEditorTests.cs
@@ -101,5 +101,36 @@ internal static class ClipEditorTests
double[] stretched = { 0, 2, 5, 10 }; // the last marker dragged out
yield return (Near(WarpRemap.OldBeatAt(src3, beat3, stretched, 10), 8, 1e-9) && Near(WarpRemap.OldBeatAt(src3, beat3, stretched, 7.5), 6.5, 1e-9),
"remap: dragging the last marker stretches the last segment");
+
+ // ---- PanelColumns (specs/055) ------------------------------------------------
+ // The MIDI inspector's four sections (Clip, Quantize, Transpose, Selection), 37px apart.
+ double[] insp = { 80, 70, 50, 140 };
+ const double g = 37;
+ double one = PanelColumns.Stack(insp, 0, 4, g);
+ yield return (Near(one, 340 + 3 * g), "columns: one column stacks every section and the gaps between");
+ var fits = PanelColumns.Choose(insp, g, one, true);
+ yield return (fits.Columns == 1 && fits.Split == 4, "columns: one column while it fits the height, even with room for two");
+ var tall = PanelColumns.Choose(insp, g, 300, true);
+ yield return (tall.Columns == 2 && tall.Split == 2 && Near(tall.Height, 190 + g),
+ "columns: two columns when one would scroll — Clip · Quantize, then Transpose · Selection");
+ var narrow = PanelColumns.Choose(insp, g, 300, false);
+ yield return (narrow.Columns == 1 && Near(narrow.Height, one), "columns: a narrow editor keeps one column and scrolls");
+ var cramped = PanelColumns.Choose(insp, g, 100, true);
+ yield return (cramped.Columns == 2 && cramped.Height > 100, "columns: two columns still scroll when even they don't fit");
+ yield return (PanelColumns.Choose(new double[] { 400 }, g, 100, true).Columns == 1, "columns: a lone section never takes a second column");
+ // Every split keeps order and wholeness: the chosen one is the shortest taller column.
+ double[] mixed = { 120, 30, 30, 30, 200, 10 };
+ int k = PanelColumns.BestSplit(mixed, g);
+ double best = Math.Max(PanelColumns.Stack(mixed, 0, k, g), PanelColumns.Stack(mixed, k, 6, g));
+ bool shortest = true;
+ for (int s = 1; s < 6; s++) shortest &= best <= Math.Max(PanelColumns.Stack(mixed, 0, s, g), PanelColumns.Stack(mixed, s, 6, g));
+ yield return (shortest && k is > 0 and < 6, "columns: the split leaves the taller column shortest");
+ // Room for a second column leaves the canvas its minimum and the header what it needs beside the cell.
+ yield return (PanelColumns.RoomForTwo(1000, 463, 480, 0) && !PanelColumns.RoomForTwo(900, 463, 480, 0),
+ "columns: a second column leaves the canvas its minimum width");
+ yield return (!PanelColumns.RoomForTwo(1150, 463, 480, 700) && PanelColumns.RoomForTwo(1163, 463, 480, 700),
+ "columns: a second column leaves the header the width of its controls");
+ yield return (PanelColumns.BestSplit(new double[] { 50, 50 }, g) == 1 && PanelColumns.BestSplit(new double[] { 10, 50, 10 }, g) == 2,
+ "columns: on a tie the first column takes more");
}
}