Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) collapsable browser
Egor Khindikaynend59940f9ea29
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex bb913584..811887b9 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -1081,6 +1081,9 @@ public sealed partial class ArrangementViewDrawGroupLane(ctx, _o._tracks[i], y, rh, w, _o.IsGroupCollapsed(tid));continue;}+ // One pitch scale for the whole track, so a clip an octave up reads higher+ // than its neighbour instead of every clip auto-fitting to its own notes.+ var pitches = TrackPitchRange(_o._tracks[i].Clips);// A track still being filled by a background import reads as translucent.using (ctx.PushOpacity(_o.IsProcessingTrack(tid) ? 0.5 : 1.0))foreach (var c in _o._tracks[i].Clips)@@ -1090,12 +1093,12 @@ public sealed partial class ArrangementViewvar 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, rh, _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, pitches);}// Imports still decoding: a translucent placeholder whose waveform fills in.using (ctx.PushOpacity(0.5))foreach (var c in _o.PendingClipsFor(tid))- DrawClipBody(ctx, _o._tracks[i].ColorIndex, _o._tracks[i].Name, c, y, rh, false);+ DrawClipBody(ctx, _o._tracks[i].ColorIndex, _o._tracks[i].Name, c, y, rh, false, pitches: pitches);}// In-progress audio take (M-fix): audio clips only materialise on stop,@@ -1151,7 +1154,8 @@ public sealed partial class ArrangementViewint 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, RowTop(destRow), RowH(destRow), true);+ var pitches = TrackPitchRange(dest.Clips.Append(m.vm));+ DrawClipBody(ctx, dest.ColorIndex, dest.Name, m.vm, RowTop(destRow), RowH(destRow), true, pitches: pitches);}// Clip marquee (plain drag on empty space).@@ -1212,16 +1216,28 @@ public sealed partial class ArrangementViewg.EndFigure(true);}- private void DrawNotes(DrawingContext ctx, ClipVM c, Rect r, IBrush brush)+ // Lowest/highest pitch across a track's MIDI clips, or null when there are no notes.+ private static (int lo, int hi)? TrackPitchRange(IEnumerable<ClipVM> clips)+ {+ int lo = int.MaxValue, hi = int.MinValue;+ foreach (var c in clips)+ if (c.IsMidi && c.Notes is { } notes)+ foreach (var n in notes) { lo = Math.Min(lo, n.Pitch); hi = Math.Max(hi, n.Pitch); }+ return lo <= hi ? (lo, hi) : null;+ }++ private void DrawNotes(DrawingContext ctx, ClipVM c, Rect r, IBrush brush, (int lo, int hi)? pitches = null){if (c.Notes is null || c.Notes.Length == 0 || c.LengthBeats <= 0 || r.Height <= 0) return;- // Auto-range to the pitches actually present: a fixed 5-octave range+ // Auto-range to the pitches actually present on the track (all its clips share+ // one scale, so relative register reads across clips): a fixed 5-octave range// needs far more height than one lane row, so mapping it with a min// bar height pushes high notes above the clip and into the row above.- int lo = int.MaxValue, hi = int.MinValue;- foreach (var n in c.Notes) { lo = Math.Min(lo, n.Pitch); hi = Math.Max(hi, n.Pitch); }+ var (lo, hi) = pitches ?? TrackPitchRange(new[] { c })!.Value;int span = Math.Max(1, hi - lo + 1);- double noteH = Math.Clamp(r.Height / span, 1, 4);+ // Row step may drop below a pixel on a wide track range; the bar keeps 1px so+ // it stays visible, and the top note still lands inside the clip.+ double step = Math.Min(r.Height / span, 4), noteH = Math.Max(1, step);using var _ = ctx.PushClip(r); // never bleed into adjacent lanesvar geo = new StreamGeometry();using (var g = geo.Open())@@ -1229,7 +1245,7 @@ public sealed partial class ArrangementView{double nx = r.X + (n.StartBeat / c.LengthBeats) * r.Width;double nw = Math.Max(2, (n.LengthBeats / c.LengthBeats) * r.Width);- double ny = r.Bottom - (n.Pitch - lo + 1) * noteH;+ double ny = Math.Max(r.Y, r.Bottom - (n.Pitch - lo + 1) * step);double ww = Math.Min(nw, r.Right - nx);if (ww > 0) AddRect(g, nx, ny, ww, noteH);}@@ -1321,7 +1337,7 @@ public sealed partial class ArrangementView}private void DrawClipBody(DrawingContext ctx, int colorIndex, string label, ClipVM c, double y,- double rowH, bool selected, Drag edgeHi = Drag.None)+ double rowH, bool selected, Drag edgeHi = Drag.None, (int lo, int hi)? pitches = null){double w = Bounds.Width;double x0 = _o.BeatToX(c.StartBeat);@@ -1343,7 +1359,7 @@ public sealed partial class ArrangementView// 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);+ if (c.IsMidi) DrawNotes(ctx, c, contentRect, content, pitches);else DrawWaveform(ctx, c, contentRect, content);// 2px band in the track colour along the top edge: the clip's family marker.diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.csindex 96746e5b..07177eb1 100644--- a/src/managed/Nota.App/BrowserView.cs+++ b/src/managed/Nota.App/BrowserView.cs@@ -117,6 +117,8 @@ public sealed class BrowserView : UserControlprivate const string IconMidi = "M6 17.2 a2.6 2.4 0 1 0 5.2 0 a2.6 2.4 0 1 0 -5.2 0 M11.2 17.2 V5 c3 .9 5.6 2.4 5.6 5.6";// MIDI-learn map — two nodes joined by a link (a control mapped to a parameter).private const string IconMap = "M3.4 17.6 a2.6 2.6 0 1 0 5.2 0 a2.6 2.6 0 1 0 -5.2 0 M15.4 6.4 a2.6 2.6 0 1 0 5.2 0 a2.6 2.6 0 1 0 -5.2 0 M7.9 15.7 L16.1 8.3";+ // Collapse / expand — a window with its left sidebar ruled off.+ private const string IconSidebar = "M3.5 5.5 h17 v13 h-17 z M9.5 5.5 v13";// View options — three centred rules, shortening downward (a sort/·filter glyph).private const string IconOptions = "M4 7 H20 M7 12 H17 M10 17 H14";@@ -163,6 +165,16 @@ public sealed class BrowserView : UserControlprivate ISettingsService? _settings;private MidiMapView? _midiMap;+ // Collapsed: only the icon rail shows; clicking an icon unfolds the browser on that tab.+ private bool _collapsed;+ private readonly Control _body; // everything right of the rail+ private readonly Border _railDivider;+ private readonly Border _collapseBtn;++ /// <summary>Raised when the browser folds to its rail or unfolds (the host resizes its column).</summary>+ public event Action<bool>? CollapsedChanged;+ public bool IsCollapsed => _collapsed;+// Disclosure triangles for tree parent rows.private const string IconCollapsed = "M1 0 L6 4.5 L1 9 Z"; // ▸private const string IconExpanded = "M0 1 L9 1 L4.5 7 Z"; // ▾@@ -235,8 +247,15 @@ public sealed class BrowserView : UserControl_tabs[i].BorderThickness = new Thickness(0, 1, 0, 0);_tabs[i].BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");}- var rail = new StackPanel { Width = 40 };- foreach (var t in _tabs) rail.Children.Add(t);+ var tabStack = new StackPanel();+ foreach (var t in _tabs) tabStack.Children.Add(t);+ _collapseBtn = RailButton(IconSidebar, "Collapse browser", () => SetCollapsed(!_collapsed, persist: true));+ _collapseBtn.BorderThickness = new Thickness(0, 1, 0, 0);+ _collapseBtn.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");+ var rail = new DockPanel { Width = 40 };+ DockPanel.SetDock(_collapseBtn, Dock.Bottom);+ rail.Children.Add(_collapseBtn);+ rail.Children.Add(tabStack);// --- Search (26h): accent border on focus, match count on the right ---_search = new TextBox@@ -354,9 +373,10 @@ public sealed class BrowserView : UserControlright.Children.Add(_previewFooter);right.Children.Add(contentHost);- var railDivider = new Border { BorderThickness = new Thickness(0, 0, 1, 0), Child = rail };+ var railDivider = _railDivider = new Border { BorderThickness = new Thickness(0, 0, 1, 0), Child = rail };railDivider.BindResource(Border.BackgroundProperty, "Brush.Panel");railDivider.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");+ _body = right;var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };Grid.SetColumn(railDivider, 0);@@ -388,13 +408,35 @@ public sealed class BrowserView : UserControl}/// <summary>Reveal the MIDI-mappings tab (called when learn mode is armed).</summary>- public void ShowMidiMap() => SelectTab(MapTab);+ public void ShowMidiMap() { SelectTab(MapTab); SetCollapsed(false, persist: true); }++ /// <summary>Fold the browser down to its icon rail, or unfold it.</summary>+ public void SetCollapsed(bool collapsed, bool persist)+ {+ if (collapsed == _collapsed) return;+ _collapsed = collapsed;+ _body.IsVisible = !collapsed;+ MinWidth = collapsed ? 0 : 160;+ // Folded, the rail is the whole island — its divider would double the outer border.+ _railDivider.BorderThickness = new Thickness(0, 0, collapsed ? 0 : 1, 0);+ // Nothing is open while folded, so no tab is marked active.+ for (int i = 0; i < _tabs.Length; i++)+ _tabs[i].Classes.Set("active", !collapsed && i == _active);+ ToolTip.SetTip(_collapseBtn, collapsed ? "Expand browser" : "Collapse browser");+ if (persist && _settings is not null)+ {+ _settings.Current.BrowserCollapsed = collapsed;+ _settings.Save();+ }+ CollapsedChanged?.Invoke(collapsed);+ }/// <summary>Persist the view options (the ⋮ menu) across sessions. Optional: without it/// the browser still works, it just forgets the toggles on quit.</summary>public void SetSettings(ISettingsService settings){_settings = settings;+ SetCollapsed(settings.Current.BrowserCollapsed, persist: false);if (_vm is null) return;_vm.GroupBySource = settings.Current.BrowserGroupBySource;_vm.FavoritesFirst = settings.Current.BrowserFavoritesFirst;@@ -558,7 +600,7 @@ public sealed class BrowserView : UserControlif (index == _active) return;_active = index;for (int i = 0; i < _tabs.Length; i++)- _tabs[i].Classes.Set("active", i == index);+ _tabs[i].Classes.Set("active", !_collapsed && i == index);// The MIDI-map tab hosts a bespoke editor, not a filtered item list.bool isMap = index == MapTab;_content.Content = isMap ? (Control?)_midiMap : _pages[index];@@ -586,10 +628,31 @@ public sealed class BrowserView : UserControlinner.Children.Add(bar);var tab = new Border { Classes = { "RailTab" }, Child = inner };ToolTip.SetTip(tab, caption);- tab.PointerPressed += (_, _) => SelectTab(index);+ tab.PointerPressed += (_, _) =>+ {+ SelectTab(index);+ SetCollapsed(false, persist: true); // a click on the folded rail opens that tab+ };return tab;}+ // A rail-styled action (not a tab): same 36px cell and hover, never marked active.+ private static Border RailButton(string iconData, string caption, Action onClick)+ {+ var icon = GridIcon(iconData, 16);+ icon.HorizontalAlignment = HorizontalAlignment.Center;+ icon.VerticalAlignment = VerticalAlignment.Center;+ var btn = new Border { Classes = { "RailTab" }, Child = icon };+ ToolTip.SetTip(btn, caption);+ btn.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(btn).Properties.IsLeftButtonPressed) return;+ onClick();+ e.Handled = true;+ };+ return btn;+ }+// --- rows ----------------------------------------------------------------private IDataTemplate BuildItemTemplate() => new FuncDataTemplate<BrowserItem>((item, _) =>diff --git a/src/managed/Nota.App/MainWindow.Browser.cs b/src/managed/Nota.App/MainWindow.Browser.csindex 3ac98665..5e9a6ac8 100644--- a/src/managed/Nota.App/MainWindow.Browser.cs+++ b/src/managed/Nota.App/MainWindow.Browser.cs@@ -25,6 +25,27 @@ public partial class MainWindow{private int _lastInstrumentTrackId;+ // The browser column's width before it was folded to its rail, restored on unfold.+ private GridLength _browserWidth = new(288);++ // Folded, the column hugs the rail and the splitter goes away — there's nothing to resize.+ private void OnBrowserCollapsedChanged(bool collapsed)+ {+ var column = BrowserGrid.ColumnDefinitions[0];+ if (collapsed)+ {+ if (column.Width.IsAbsolute) _browserWidth = column.Width;+ column.MinWidth = 0;+ column.Width = GridLength.Auto;+ }+ else+ {+ column.MinWidth = 160;+ column.Width = _browserWidth;+ }+ BrowserSplitter.IsVisible = !collapsed;+ }+/// <summary>The fallback target when nothing is selected: the last instrument track added,/// but only while it still exists — it may have been deleted, cut or undone since, and/// acting on a dead track id silently edits nothing (or re-shows its stale device chain).</summary>diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex efbb4f74..c0fb27ac 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -377,14 +377,14 @@<!-- 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 themcarries no line of its own — it is a 2px transparent grab strip inside that gutter. -->- <Grid Grid.Row="0">+ <Grid x:Name="BrowserGrid" Grid.Row="0"><Grid.ColumnDefinitions><ColumnDefinition Width="288" MinWidth="160" MaxWidth="480"/><ColumnDefinition Width="Auto"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><app:BrowserView x:Name="Browser" Grid.Column="0" Margin="12,12,10,12"/>- <GridSplitter Grid.Column="1" Width="2" Background="Transparent"+ <GridSplitter x:Name="BrowserSplitter" Grid.Column="1" Width="2" Background="Transparent"ResizeDirection="Columns"/><Panel x:Name="MainContent" Grid.Column="2"><app:ArrangementView x:Name="Timeline" Margin="0,12,12,12"/>diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 18e28be7..5ba467d0 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -274,7 +274,8 @@ public partial class MainWindow : Windowvm.Transport.TracksChanged += () => { Timeline.Refresh(); ReloadEditorNotes(); };Timeline.LoopChanged += () => vm.Transport.SyncLoop(); // ruler drag / "Loop selection" → transport bar- Browser.SetSettings(vm.Settings); // the ⋮ view options persist+ Browser.CollapsedChanged += OnBrowserCollapsedChanged;+ Browser.SetSettings(vm.Settings); // the ⋮ view options persist (and the folded state)// 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;diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.csindex c3b8554c..31dd6324 100644--- a/src/managed/Nota.Application/Settings.cs+++ b/src/managed/Nota.Application/Settings.cs@@ -54,6 +54,8 @@ public sealed class Settingspublic bool BrowserGroupBySource { get; set; } = true;/// <summary>Float favorited devices to the top of their section.</summary>public bool BrowserFavoritesFirst { get; set; } = true;+ /// <summary>The browser is folded down to its icon rail.</summary>+ public bool BrowserCollapsed { get; set; }// --- arrangement view options (View menu) --------------------------------/// <summary>How many clips print their name on the lane: 0 every clip, 1 the head of each