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.

Add fixes for browser

Egor Khindikaynenbf76933d48a8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfea2848..aec34a4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,25 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
restart — and the choice is remembered.
### Changed
+- **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
+ distinctive word, and the device type moved to the right edge as a quiet tag. The name
+ keeps its room: a long one pushes the tag out rather than being truncated by it. A
+ plug-in's tag carries its format and vendor, so the AU and VST3 builds of one plug-in are
+ no longer two identical rows. The icon rail was redrawn on a 24-unit grid with round caps
+ — the glyphs are sized against each other rather than each filling its box — and lost its
+ chip backgrounds along with the per-row amber icons; the active tab is marked by a brass
+ edge, with a hairline between the device tabs and the library tabs. The panel also opens
+ a little wider than before, so a device name and its type both fit on the line.
+ - A **⋮ button** beside the search box holds the view options — show type tags, group by
+ source, favourites first — and the tag editor, which used to need a chip of its own.
+ - The filter chips keep to **one line**; whatever does not fit collapses into a **+N**
+ that opens the rest, instead of wrapping and pushing the list down.
+ - A **status line** along the bottom counts what the tab is showing.
+- **The splitters between the browser, the arrangement and the detail panel are invisible
+ now** — 2px transparent grab strips inside the gutter, since the browser island's own
+ edge already draws the line.
- **Automation has no record modes any more.** Read / Touch / Latch / Write are gone, and
the **Automation** button now only shows and edits the lanes. Automation always plays
back, and recording is contextual, the way Live does it: engage the transport **Record**
diff --git a/FEATURES.md b/FEATURES.md
index 921ac597..e2b8c577 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -373,16 +373,28 @@ and user presets, automation, persistence and cloning.
## Browser and assets
-- Tabs: **Samples** (files, with folder tree navigation), **Projects**, **Presets** (a tree
- of category → device → preset), **Plugins** (AU/VST3), **Instruments / Audio Effects /
- MIDI Effects**, and **Map** (MIDI Learn mappings).
+- An **island panel** with an icon rail down its left edge: **Instruments / Audio Effects /
+ MIDI Effects**, then **Files** (with folder tree navigation), **Presets** (a tree of
+ category → device → preset), **Projects**, and **Map** (MIDI Learn mappings). A hairline
+ separates the device tabs from the library tabs, and the active one carries a brass edge.
+- **A compact index**: single-line rows, sectioned into **BUILT-IN** and **PLUG-INS** with
+ counts, so it is clear where Nota's own devices end and the scanned plug-ins begin. The
+ "Nota" prefix drops to tertiary ink — names scan on their distinctive word — and the
+ device type sits at the right edge as a quiet tag (a plug-in's tag names its format and
+ vendor, which tells the AU and VST3 builds of one plug-in apart). The name always wins
+ the room: the tag gives way rather than truncating it.
+- **View options** (the ⋮ button beside the search box): show type tags, group by source,
+ favourites first — each remembered across sessions — plus the tag editor.
+- A **status line** counts what the tab is showing (`13 built-in · 4 plug-ins`), and the
+ search box counts the matches.
- **Preview** a sample from the browser, and **drag and drop** onto a track, into the grid,
or into a rack chain.
- Dropping an instrument onto an existing track **replaces the instrument** in place
(clips, devices and volume are kept); dropping onto empty space creates a new track.
Racks are not replaced in place.
- **Favourites** (★) and **tags** (assign and clear, an editor with a title and colour,
- filter chips in the header); favourited devices sort to the top of their lists.
+ filter chips in the header); favourited devices sort to the top of their section. The
+ chips keep to one line — whatever does not fit collapses into a **+N** that opens the rest.
- **Context menus**: Projects — Open / Reveal in Finder / Delete (to the Trash, with
confirmation); Files — Reveal in Finder; Presets — Reveal in Finder.
- **Hints for empty tabs** — explaining what the tab is and how to add content to it.
diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.cs
index 3046d2e6..dd12c7bb 100644
--- a/src/managed/Nota.App/BrowserView.cs
+++ b/src/managed/Nota.App/BrowserView.cs
@@ -1,13 +1,18 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
-// M4.1-C / M7-4 + Phase 3 (HANDOFF 1g): left browser panel. A 46px icon rail
-// (Instruments / FX / Samples / Presets / Projects) swaps templated lists; a
-// search box filters the active list live; a pinned preview footer auditions the
-// selected sample. Double-clicking an item raises ItemActivated; the footer ▶ (or
+// M4.1-C / M7-4 + Phase 3 + the "compact index" refresh (mockup 1a): the left
+// browser, an island panel with a 40px icon rail (Instr / FX / MIDI / Files /
+// Preset / Proj / Map) down its left edge. Each tab shows one list of single-line
+// 24px rows, sectioned into BUILT-IN and PLUG-INS with counts; the "Nota" prefix
+// drops to tertiary ink so names scan on their distinctive word, and the device
+// type sits at the right edge as a quiet tag. A search box filters the active list
+// live, a ⋮ button holds the view options, chips filter by favorite/tag, a status
+// line counts what is on screen, and a pinned preview footer auditions the selected
+// sample (Files tab). Double-clicking an item raises ItemActivated; the footer ▶ (or
// Auto-audition on selection) raises PreviewRequested. Brushes bind via
-// GetResourceObservable (the control is built during MainWindow's XAML load,
-// before it is attached). Rows are drag sources (M7-5).
+// GetResourceObservable (the control is built during MainWindow's XAML load, before
+// it is attached). Rows are drag sources (M7-5).
using System;
using System.Collections.ObjectModel;
@@ -22,6 +27,7 @@ using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Platform.Storage;
+using Nota.Application;
using Nota.Presentation;
namespace Nota.App;
@@ -35,7 +41,7 @@ public sealed class BrowserView : UserControl
// session. So the drag carries a single native text item (pasteboard filler)
// and the actual BrowserItem is handed off in-process via this static (the drag
// is in-process anyway; DoDragDropAsync blocks the UI thread until drop).
- private const string DragSentinel = "nota-browser-item";
+ private const string DragSentinel = "nota-browser-item";
internal static BrowserItem? CurrentDrag { get; private set; }
/// <summary>True while a browser row is being dragged (used by drop targets).</summary>
@@ -89,29 +95,64 @@ public sealed class BrowserView : UserControl
private BrowserItem? _pressedItem;
private Point _pressPoint;
private PointerPressedEventArgs? _pressArgs;
- // Rail + row icons — Lucide-style stroke glyphs. Each maps to a browser context; no two
- // share a glyph. Reused by RailTab (tabs) and IconFor (list rows). Every glyph's bounding
- // box is a square [4,20]²: Path.Stretch=Uniform fills the box exactly, so the icon reads
- // centred (a non-square box would be top-left aligned by the stretch and drift up/left).
- // Instruments — a piano keyboard: case with key dividers hanging from the top.
- private const string IconKeyboard = "M4 4 H20 V20 H4 Z M8 4 V13 M12 4 V13 M16 4 V13";
+
+ // Rail icons — stroke glyphs on the design's 24-unit grid, 1.5 stroke, round caps and
+ // joins. Each sits in its OWN optical box inside that grid (roughly 18 wide by 14–18
+ // tall), which is how they end up looking the same weight next to each other — so they
+ // must all be scaled by one factor, not each stretched to fill the icon box. GridIcon
+ // does that; see the note there.
+ // Instruments — a piano keyboard: case with key dividers and three short black keys.
+ private const string IconKeyboard = "M3.5 6 h17 v12 h-17 z M9.2 6 v12 M14.8 6 v12 M6.3 6 v5 M12 6 v5 M17.7 6 v5";
// Audio effects — vertical faders with offset handles (a mixer/EQ strip).
- private const string IconSliders = "M6 4 V20 M12 4 V20 M18 4 V20 M4 9 H8 M10 14 H14 M16 8 H20";
+ private const string IconSliders = "M7 4.5 v15 M12 4.5 v15 M17 4.5 v15 M5 9 h4 M10 14.5 h4 M15 7.5 h4";
// Files — a folder with a raised tab on the left.
- private const string IconFolder = "M4 4 H9 L11 6 H20 V20 H4 Z";
+ private const string IconFolder = "M3.5 7.5 h5.6 l2.1 2.6 h9.3 v9.4 h-17 z";
private const string IconStar = "M12 3 L14.5 9 L21 9.3 L16 13.5 L17.7 20 L12 16.2 L6.3 20 L8 13.5 L3 9.3 L9.5 9 Z";
// Presets — a bookmark (a saved snapshot). Distinct from the fader glyphs above.
- private const string IconBookmark = "M4 4 H20 V20 L12 13 L4 20 Z";
+ private const string IconBookmark = "M6.5 4 h11 v16 l-5.5 -4.4 l-5.5 4.4 z";
// Projects — a document with a dog-ear and two content lines.
- private const string IconDoc = "M4 4 H14 L20 10 V20 H4 Z M14 4 V10 H20 M8 13 H16 M8 16 H16";
+ private const string IconDoc = "M6 3.5 h7.6 l4.8 4.8 v12.2 h-12.4 z M13.6 3.5 v4.8 h4.8 M9.2 13.4 h6 M9.2 16.8 h6";
private const string IconPlay = "M7 4 L19 12 L7 20 Z";
- // MIDI effects — a clean eighth note (head bottom-left, tall stem, flag to the top-right).
- private const string IconMidi = "M4 17 A3 3 0 0 1 10 17 A3 3 0 0 1 4 17 M10 17 V4 L20 7";
+ // MIDI effects — an eighth note: head bottom-left, tall stem, flag curling to the right.
+ private 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 = "M4 17.5 A2.5 2.5 0 0 1 9 17.5 A2.5 2.5 0 0 1 4 17.5 M15 6.5 A2.5 2.5 0 0 1 20 6.5 A2.5 2.5 0 0 1 15 6.5 M8.7 15.3 L15.3 8.7";
+ 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";
+ // View options — three centred rules, shortening downward (a sort/·filter glyph).
+ private const string IconOptions = "M4 7 H20 M7 12 H17 M10 17 H14";
+
+ /// <summary>One glyph off the design's 24-unit grid, rendered at <paramref name="size"/>.
+ /// The Path keeps the full 24×24 box and draws at its native coordinates; a Viewbox then
+ /// scales that square as a whole. Stretch.Uniform on the Path would instead normalise
+ /// every glyph to its own bounding box — a wide one and a tall one would come out the
+ /// same size, which is exactly the optical balance the grid exists to set. Pass
+ /// <paramref name="strokeToken"/> only where no style already paints the stroke: a local
+ /// value outranks a style setter, and the rail's active/inactive colours are styles.</summary>
+ private static Viewbox GridIcon(string data, double size, string? strokeToken = null, double strokeWidth = 1.5)
+ {
+ var path = new Path
+ {
+ Data = Geometry.Parse(data),
+ Width = 24, Height = 24,
+ Stretch = Stretch.None,
+ StrokeThickness = strokeWidth,
+ StrokeJoin = PenLineJoin.Round,
+ StrokeLineCap = PenLineCap.Round,
+ };
+ if (strokeToken is not null) path.BindResource(Shape.StrokeProperty, strokeToken);
+ return new Viewbox
+ {
+ Width = size, Height = size,
+ Stretch = Stretch.Uniform,
+ Child = path,
+ };
+ }
private const int TabCount = 7; // Instr / FX / MIDI / Files / Preset / Proj / Map
+ private const int FilesTab = 3; // the only tab with a sample auditioner
private const int MapTab = 6; // MIDI-learn mappings — hosts a MidiMapView, not a list
+ private const double RowH = 24; // single-line index row
+ private const double GroupRowH = 22;
+
private readonly ListBox[] _pages;
private readonly Border[] _tabs;
private readonly ObservableCollection<BrowserItem>[] _filtered;
@@ -119,6 +160,7 @@ public sealed class BrowserView : UserControl
private readonly ContentControl _content = new();
private int _active = -1;
private BrowserViewModel? _vm;
+ private ISettingsService? _settings;
private MidiMapView? _midiMap;
// Disclosure triangles for tree parent rows.
@@ -128,12 +170,13 @@ public sealed class BrowserView : UserControl
private readonly TextBox _search;
private readonly TextBlock _matchCount;
private readonly Border _searchWrap;
+ private readonly Border _optionsBtn;
// Centered empty-state message shown over a tab whose list is empty.
private readonly TextBlock _emptyText = new();
private readonly Border _emptyWrap;
- // Pinned preview footer.
+ // Pinned preview footer + the status line under it.
private readonly Button _previewBtn;
private readonly Path _previewIcon;
private readonly TextBlock _previewName;
@@ -141,6 +184,8 @@ public sealed class BrowserView : UserControl
private readonly ToggleButton _autoAudition;
private readonly PreviewWaveform _previewWave;
private readonly Border _previewFooter; // sample auditioner — Files tab only
+ private readonly Border _statusBar;
+ private readonly TextBlock _statusText;
private BrowserItem? _footerItem;
public event Action<BrowserItem>? ItemActivated;
@@ -154,8 +199,10 @@ public sealed class BrowserView : UserControl
public event Action<BrowserItem?>? EditTagsRequested;
// Header filter chips (★ Favorites + one per tag); rebuilt from the VM's tags.
- private StackPanel _chipsHost = null!;
- private WrapPanel _chipsPanel = null!;
+ private readonly Border _chipsHost;
+ private readonly ChipStrip _chipsPanel;
+ private readonly Border _overflowChip;
+ private readonly TextBlock _overflowText;
public BrowserView()
{
@@ -174,15 +221,21 @@ public sealed class BrowserView : UserControl
_tabs = new[]
{
- RailTab(0, "Instr", IconKeyboard),
- RailTab(1, "FX", IconSliders),
- RailTab(2, "MIDI", IconMidi),
+ RailTab(0, "Instruments", IconKeyboard),
+ RailTab(1, "Audio effects", IconSliders),
+ RailTab(2, "MIDI effects", IconMidi),
RailTab(3, "Files", IconFolder),
- RailTab(4, "Preset", IconBookmark),
- RailTab(5, "Proj", IconDoc),
- RailTab(6, "Map", IconMap),
+ RailTab(4, "Presets", IconBookmark),
+ RailTab(5, "Projects", IconDoc),
+ RailTab(6, "MIDI map", IconMap),
};
- var rail = new StackPanel { Width = 46 };
+ // A hairline above Files and above Map: devices · library · mappings.
+ foreach (int i in new[] { 3, 6 })
+ {
+ _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);
// --- Search (26h): accent border on focus, match count on the right ---
@@ -218,21 +271,57 @@ public sealed class BrowserView : UserControl
CornerRadius = new CornerRadius(5),
BorderThickness = new Thickness(1),
Padding = new Thickness(8, 0),
- Margin = new Thickness(8, 8, 8, 4),
Child = searchGrid,
};
_searchWrap.BindResource(Border.BackgroundProperty, "Brush.BgSunken");
_searchWrap.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ // Sort & view options — the row's shape, sectioning and tag management.
+ _optionsBtn = BuildOptionsButton();
+
+ var headerRow = new Grid
+ {
+ ColumnDefinitions = new ColumnDefinitions("*,Auto"),
+ Margin = new Thickness(8, 8, 8, 6),
+ };
+ headerRow.Children.Add(_searchWrap);
+ Grid.SetColumn(_optionsBtn, 1);
+ headerRow.Children.Add(_optionsBtn);
+
// Filter chips (★ Favorites + tags). Populated from the VM in SetViewModel and
- // shown only on the device tabs (Instr / FX / MIDI). Wraps so many tags still fit.
- _chipsPanel = new WrapPanel { Orientation = Orientation.Horizontal };
- _chipsHost = new StackPanel { Margin = new Thickness(10, 0, 8, 6), Children = { _chipsPanel } };
+ // shown only on the device tabs (Instr / FX / MIDI). One line: the chips that
+ // don't fit collapse into a "+N" that opens the rest.
+ _overflowText = new TextBlock { FontSize = 10, VerticalAlignment = VerticalAlignment.Center };
+ _overflowText.Classes.Add("Mono");
+ _overflowText.BindResource(TextBlock.ForegroundProperty, "Brush.TextTertiary");
+ _overflowChip = new Border
+ {
+ Height = 20,
+ Padding = new Thickness(4, 0),
+ Cursor = new Cursor(StandardCursorType.Hand),
+ Child = _overflowText,
+ };
+ _overflowChip.PointerPressed += (_, e) => { ShowOverflowChips(); e.Handled = true; };
+ _chipsPanel = new ChipStrip(_overflowChip, _overflowText);
+ _chipsHost = new Border { Margin = new Thickness(8, 0, 8, 7), Child = _chipsPanel };
- // Plugin rescan lives in Settings ▸ Plug-ins now (not the browser).
_previewFooter = BuildPreviewFooter(out _previewBtn, out _previewIcon, out _previewName,
out _previewSub, out _autoAudition, out _previewWave);
+ // Status line: what the active tab is showing, counted.
+ _statusText = new TextBlock { FontSize = 9, VerticalAlignment = VerticalAlignment.Center };
+ _statusText.Classes.Add("Mono");
+ _statusText.BindResource(TextBlock.ForegroundProperty, "Brush.TextTertiary");
+ _statusBar = new Border
+ {
+ Height = 26,
+ Padding = new Thickness(10, 0),
+ BorderThickness = new Thickness(0, 1, 0, 0),
+ Child = _statusText,
+ };
+ _statusBar.BindResource(Border.BackgroundProperty, "Brush.BgApp");
+ _statusBar.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+
// Empty-state message, centered over the list when a tab has nothing to show.
_emptyText.FontSize = 11;
_emptyText.TextWrapping = TextWrapping.Wrap;
@@ -254,16 +343,18 @@ public sealed class BrowserView : UserControl
contentHost.Children.Add(_emptyWrap);
var right = new DockPanel();
- var topStack = new StackPanel { Children = { _searchWrap, _chipsHost } };
+ var topStack = new StackPanel { Children = { headerRow, _chipsHost } };
DockPanel.SetDock(topStack, Dock.Top);
+ DockPanel.SetDock(_statusBar, Dock.Bottom);
DockPanel.SetDock(_previewFooter, Dock.Bottom);
right.Children.Add(topStack);
+ right.Children.Add(_statusBar);
right.Children.Add(_previewFooter);
right.Children.Add(contentHost);
- var railDivider = new Border { BorderThickness = new Thickness(0, 0, 1, 0) };
+ var railDivider = new Border { BorderThickness = new Thickness(0, 0, 1, 0), Child = rail };
+ railDivider.BindResource(Border.BackgroundProperty, "Brush.BgApp");
railDivider.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
- railDivider.Child = rail;
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
Grid.SetColumn(railDivider, 0);
@@ -271,7 +362,15 @@ public sealed class BrowserView : UserControl
grid.Children.Add(railDivider);
grid.Children.Add(right);
- var outer = new Border { BorderThickness = new Thickness(0, 0, 1, 0), Child = grid };
+ // The island: a rounded card floating on the app ground. ClipToBounds keeps the
+ // rail, the full-bleed rows and the status line inside the rounded corners.
+ var outer = new Border
+ {
+ BorderThickness = new Thickness(1),
+ ClipToBounds = true,
+ Child = grid,
+ };
+ outer.BindResource(Border.CornerRadiusProperty, "Radius.Md");
outer.BindResource(Border.BackgroundProperty, "Brush.SurfaceCard");
outer.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
Content = outer;
@@ -289,21 +388,37 @@ public sealed class BrowserView : UserControl
/// <summary>Reveal the MIDI-mappings tab (called when learn mode is armed).</summary>
public void ShowMidiMap() => SelectTab(MapTab);
+ /// <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;
+ if (_vm is null) return;
+ _vm.GroupBySource = settings.Current.BrowserGroupBySource;
+ _vm.FavoritesFirst = settings.Current.BrowserFavoritesFirst;
+ RefreshRows();
+ }
+
public void SetViewModel(BrowserViewModel vm)
{
_vm = vm;
- // Tree tabs (Instruments / FX / MIDI / Files) bind straight to the VM's flattened
- // visible collections; the VM owns their filtering + expand/collapse.
+ if (_settings is not null)
+ {
+ vm.GroupBySource = _settings.Current.BrowserGroupBySource;
+ vm.FavoritesFirst = _settings.Current.BrowserFavoritesFirst;
+ }
+ // Tree tabs (Instruments / FX / MIDI / Files / Presets) bind straight to the VM's
+ // flattened visible collections; the VM owns their filtering + expand/collapse.
_pages[0].ItemsSource = vm.Instruments;
_pages[1].ItemsSource = vm.Effects;
_pages[2].ItemsSource = vm.MidiEffects;
_pages[3].ItemsSource = vm.Samples;
_pages[4].ItemsSource = vm.Presets;
- vm.Instruments.CollectionChanged += (_, _) => { if (_active == 0) { _matchCount.Text = vm.Instruments.Count.ToString(); UpdateEmptyState(); } };
- vm.Effects.CollectionChanged += (_, _) => { if (_active == 1) { _matchCount.Text = vm.Effects.Count.ToString(); UpdateEmptyState(); } };
- vm.MidiEffects.CollectionChanged += (_, _) => { if (_active == 2) { _matchCount.Text = vm.MidiEffects.Count.ToString(); UpdateEmptyState(); } };
- vm.Samples.CollectionChanged += (_, _) => { if (_active == 3) { _matchCount.Text = vm.Samples.Count.ToString(); UpdateEmptyState(); } };
- vm.Presets.CollectionChanged += (_, _) => { if (_active == 4) { _matchCount.Text = vm.Presets.Count.ToString(); UpdateEmptyState(); } };
+ for (int i = 0; i <= 4; i++)
+ {
+ int idx = i;
+ VisibleOf(idx)!.CollectionChanged += (_, _) => { if (_active == idx) RefreshCounts(); };
+ }
// Flat tabs (Projects) keep the view-side substring filter.
var cols = new ObservableCollection<BrowserItem>?[] { null, null, null, null, null, vm.Projects };
@@ -314,25 +429,32 @@ public sealed class BrowserView : UserControl
cols[idx]!.CollectionChanged += (_, _) => ApplyFilter(idx);
ApplyFilter(idx);
}
- ApplyFilter(0);
- ApplyFilter(1);
- ApplyFilter(2);
- ApplyFilter(3);
- ApplyFilter(4);
+ for (int i = 0; i <= 4; i++) ApplyFilter(i);
// Rebuild the header chips whenever tags/favorites change (also refreshes active state).
vm.LibraryChanged += RebuildChips;
RebuildChips();
+ RefreshCounts();
}
+ private ObservableCollection<BrowserItem>? VisibleOf(int tab) => tab switch
+ {
+ 0 => _vm?.Instruments,
+ 1 => _vm?.Effects,
+ 2 => _vm?.MidiEffects,
+ 3 => _vm?.Samples,
+ 4 => _vm?.Presets,
+ _ => null,
+ };
+
private void ApplyFilter(int index)
{
if (index < 0 || index >= _filtered.Length) return;
// Tree tabs (devices + Files + Presets): the VM re-filters + flattens into its collections.
- if (index is 0 or 1 or 2 or 3 or 4)
+ if (index is >= 0 and <= 4)
{
_vm?.FilterTree(index, _search.Text?.Trim() ?? "");
- if (index == _active) { _matchCount.Text = VisibleCount(index).ToString(); UpdateEmptyState(); }
+ if (index == _active) RefreshCounts();
return;
}
var src = _sources[index];
@@ -349,7 +471,25 @@ public sealed class BrowserView : UserControl
dst.Add(it);
}
}
- if (index == _active) { _matchCount.Text = dst.Count.ToString(); UpdateEmptyState(); }
+ if (index == _active) RefreshCounts();
+ }
+
+ // Re-flatten the visible lists (after a view option changed) without touching the query.
+ private void RefreshRows()
+ {
+ if (_vm is null) return;
+ for (int i = 0; i <= 4; i++) _vm.FilterTree(i, _search.Text?.Trim() ?? "");
+ RefreshCounts();
+ }
+
+ // The search-box match count, the status line and the empty state all describe the
+ // same thing — what the active tab is showing — so they refresh together.
+ private void RefreshCounts()
+ {
+ if (_active < 0 || _active == MapTab) return;
+ _matchCount.Text = VisibleCount(_active).ToString();
+ _statusText.Text = StatusFor(_active);
+ UpdateEmptyState();
}
// Show the centered empty-state message when the active tab has nothing to display.
@@ -377,15 +517,37 @@ public sealed class BrowserView : UserControl
};
}
- private int VisibleCount(int index) => index switch
+ // Rows the user can actually act on — section headers are chrome, not matches.
+ private int VisibleCount(int index)
{
- 0 => _vm?.Instruments.Count ?? 0,
- 1 => _vm?.Effects.Count ?? 0,
- 2 => _vm?.MidiEffects.Count ?? 0,
- 3 => _vm?.Samples.Count ?? 0,
- 4 => _vm?.Presets.Count ?? 0,
- _ => _filtered[index].Count,
- };
+ var src = VisibleOf(index) ?? (IReadOnlyList<BrowserItem>)_filtered[index];
+ int n = 0;
+ foreach (var it in src) if (!it.IsGroup) n++;
+ return n;
+ }
+
+ // "13 instruments · 10 built-in · 3 plug-ins" — the device tabs split by source, the
+ // library tabs just counted. Everything here counts what is on screen, filters included.
+ private string StatusFor(int tab)
+ {
+ if (_vm is null) return "";
+ if (tab is 0 or 1 or 2)
+ {
+ var (bi, pl) = _vm.VisibleDeviceCounts(tab);
+ // The total is already in the search box, so spend the line on the split — it is
+ // the thing the sections exist to show, and it fits a narrow panel.
+ return $"{bi} built-in · {Plural(pl, "plug-in")}";
+ }
+ int n = VisibleCount(tab);
+ return tab switch
+ {
+ 3 => Plural(n, "sample"),
+ 4 => Plural(n, "preset"),
+ _ => Plural(n, "project"),
+ };
+ }
+
+ private static string Plural(int n, string noun) => $"{n} {noun}{(n == 1 ? "" : "s")}";
private void SelectTab(int index)
{
@@ -397,41 +559,81 @@ public sealed class BrowserView : UserControl
bool isMap = index == MapTab;
_content.Content = isMap ? (Control?)_midiMap : _pages[index];
_searchWrap.IsVisible = !isMap;
- // The sample auditioner only makes sense for the Files tab (index 3);
- // hide it for Instruments / FX / MIDI / Presets / Projects / Map.
- _previewFooter.IsVisible = index == 3;
+ _optionsBtn.IsVisible = !isMap;
+ // The sample auditioner only makes sense for the Files tab.
+ _previewFooter.IsVisible = index == FilesTab;
// Favorite/tag filter chips apply only to the device tabs.
_chipsHost.IsVisible = index is 0 or 1 or 2;
+ _statusBar.IsVisible = !isMap;
if (isMap) { _matchCount.Text = ""; _emptyWrap.IsVisible = false; return; }
- _matchCount.Text = VisibleCount(index).ToString();
- UpdateEmptyState();
+ RefreshCounts();
}
private Border RailTab(int index, string caption, string iconData)
{
- // Icon-only rail (HANDOFF 1g); the caption survives as a tooltip.
- // Mockup: 16px icons in a 36×36 tab, thin 1.8/24 stroke.
- var icon = new Path
- {
- Data = Geometry.Parse(iconData),
- StrokeThickness = 1.4,
- Stretch = Stretch.Uniform,
- Width = 16, Height = 16,
- HorizontalAlignment = HorizontalAlignment.Center,
- };
- var tab = new Border { Classes = { "RailTab" }, Child = icon };
+ // Icon-only rail; the caption survives as a tooltip. 16px icon in a 36px tab, with
+ // a 2px brass edge on the left when active.
+ var icon = GridIcon(iconData, 16);
+ icon.HorizontalAlignment = HorizontalAlignment.Center;
+ icon.VerticalAlignment = VerticalAlignment.Center;
+ var bar = new Border { Classes = { "RailBar" }, VerticalAlignment = VerticalAlignment.Stretch };
+ var inner = new Grid();
+ inner.Children.Add(icon);
+ inner.Children.Add(bar);
+ var tab = new Border { Classes = { "RailTab" }, Child = inner };
ToolTip.SetTip(tab, caption);
tab.PointerPressed += (_, _) => SelectTab(index);
return tab;
}
+ // --- rows ----------------------------------------------------------------
+
private IDataTemplate BuildItemTemplate() => new FuncDataTemplate<BrowserItem>((item, _) =>
{
if (item is null) return new Control();
+ return item.IsGroup ? GroupRow(item) : IndexRow(item);
+ }, supportsRecycling: false);
+
+ // A section header: caption, a hairline filling the gap, and the section's count.
+ private Control GroupRow(BrowserItem item)
+ {
+ var label = new TextBlock
+ {
+ Text = item.Name,
+ Classes = { "GroupLabel" },
+ VerticalAlignment = VerticalAlignment.Center,
+ Margin = new Thickness(10, 0, 0, 0),
+ };
+ var rule = new Border { Height = 1, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(7, 0, 7, 0) };
+ rule.BindResource(Border.BackgroundProperty, "Brush.BorderDefault");
+ var count = new TextBlock
+ {
+ Text = item.GroupCount.ToString(),
+ FontSize = 9,
+ VerticalAlignment = VerticalAlignment.Center,
+ Margin = new Thickness(0, 0, 10, 0),
+ };
+ count.Classes.Add("Mono");
+ count.BindResource(TextBlock.ForegroundProperty, "Brush.TextDisabled");
+
+ var grid = new Grid { Height = GroupRowH, ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto") };
+ grid.Children.Add(label);
+ Grid.SetColumn(rule, 1);
+ grid.Children.Add(rule);
+ Grid.SetColumn(count, 2);
+ grid.Children.Add(count);
+ return grid;
+ }
+
+ // One index row: [brass edge][caret][Nota][name] … [★][tag dots][type tag].
+ private Control IndexRow(BrowserItem item)
+ {
bool child = item.Depth > 0;
- // Column 0: disclosure triangle for parents with presets; a spacer otherwise
- // (so leaf rows and preset rows keep their icons aligned).
+ var edge = new Border { Classes = { "RowEdge" } };
+
+ // Disclosure triangle for parents with children; a spacer otherwise, so leaf rows
+ // and child rows keep their names aligned.
Control disclosure;
if (item.HasChildren)
{
@@ -447,7 +649,7 @@ public sealed class BrowserView : UserControl
var hit = new Border
{
Width = 14, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
- VerticalAlignment = VerticalAlignment.Stretch, Child = tri,
+ Child = tri,
};
hit.PointerPressed += (_, e) => { _vm?.ToggleExpand(item); e.Handled = true; };
disclosure = hit;
@@ -457,48 +659,125 @@ public sealed class BrowserView : UserControl
disclosure = new Border { Width = 14 };
}
- var icon = new Path
+ // "Nota" drops to tertiary ink so the eye lands on the distinctive word.
+ var prefix = item.Prefix.Length > 0
+ ? new TextBlock { Text = item.Prefix, Classes = { "RowPrefix" } }
+ : null;
+ var name = new TextBlock
{
- Data = Geometry.Parse(IconFor(item.Kind)),
- StrokeThickness = 1.5,
- Stretch = Stretch.Uniform,
- Width = child ? 13 : 15, Height = child ? 13 : 15,
- VerticalAlignment = VerticalAlignment.Center,
- Margin = new Thickness(0, 0, 9, 0),
+ Text = item.Prefix.Length > 0 ? item.ShortName : item.Name,
+ Classes = { "RowName" },
+ TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ if (child) name.Classes.Add("child");
+
+ // The type, as a quiet tag on the right edge (toggleable in the ⋮ menu).
+ string tag = RowTag(item);
+ TextBlock? tagText = null;
+ if (tag.Length > 0 && (_settings?.Current.BrowserShowTypeTags ?? true))
+ tagText = new TextBlock { Text = tag, Classes = { "RowTag" }, TextTrimming = TextTrimming.CharacterEllipsis };
+
+ var row = new IndexRowPanel
+ {
+ Height = RowH,
+ Indent = 6 + item.Depth * 12,
+ Edge = edge,
+ Disclosure = disclosure,
+ Prefix = prefix,
+ Name2 = name,
+ Markers = BuildRowMarkers(item), // brass ★ + tag colour dots
+ Tag2 = tagText,
};
- // Nota's own devices carry the brass brand accent so they stand out from external
- // plugins (which stay neutral grey); factory-preset children inherit the accent too.
- bool builtin = item.Kind is BrowserItemKind.BuiltinInstrument
- or BrowserItemKind.BuiltinEffect or BrowserItemKind.BuiltinMidiEffect;
- icon.BindResource(Shape.StrokeProperty, child || builtin ? "Brush.Accent" : "Brush.TextSecondary");
-
- var name = new TextBlock { Text = item.Name, FontSize = 11, FontWeight = child ? FontWeight.Normal : FontWeight.Medium, VerticalAlignment = VerticalAlignment.Center };
- name.BindResource(TextBlock.ForegroundProperty, child ? "Brush.TextSecondary" : "Brush.TextPrimary");
- var texts = new StackPanel { VerticalAlignment = VerticalAlignment.Center, Spacing = 1, Children = { name } };
- if (!child && !string.IsNullOrEmpty(item.Sub))
- {
- var sub = new TextBlock { Text = item.Sub, FontSize = 9, VerticalAlignment = VerticalAlignment.Center };
- sub.BindResource(TextBlock.ForegroundProperty, "Brush.TextTertiary");
- texts.Children.Add(sub);
+
+ // The row's full identity lives in the tooltip, where the tag has no room for it
+ // (a plug-in's format, a sample's folder).
+ ToolTip.SetTip(row, item.Sub.Length > 0 ? $"{item.Name} · {item.Sub}" : item.Name);
+ return row;
+ }
+
+ /// <summary>Lays out one index row. A Grid cannot express the priority this row needs:
+ /// the name is the thing being read, so it takes the space it wants first and the type
+ /// tag lives on whatever is left — an Auto tag column would instead trim every long
+ /// device name to keep "paraphonic synth" whole.</summary>
+ private sealed class IndexRowPanel : Panel
+ {
+ private const double Gutter = 9; // right margin, clear of the scrollbar
+ private const double Gap = 5;
+
+ public double Indent { get; init; }
+ public Border Edge { get; init; } = null!;
+ public Control Disclosure { get; init; } = null!;
+ public TextBlock? Prefix { get; init; }
+ public TextBlock Name2 { get; init; } = null!;
+ public Control? Markers { get; init; }
+ public TextBlock? Tag2 { get; init; }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ Build();
+ foreach (var c in Children) c.Measure(Size.Infinity);
+ return new Size(0, Height);
}
- var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*,Auto"), Margin = new Thickness(item.Depth * 16, 0, 0, 0) };
- Grid.SetColumn(disclosure, 0);
- Grid.SetColumn(icon, 1);
- Grid.SetColumn(texts, 2);
- grid.Children.Add(disclosure);
- grid.Children.Add(icon);
- grid.Children.Add(texts);
+ private bool _built;
+ private void Build()
+ {
+ if (_built) return;
+ _built = true;
+ Children.Add(Edge);
+ Children.Add(Disclosure);
+ if (Prefix is not null) Children.Add(Prefix);
+ Children.Add(Name2);
+ if (Markers is not null) Children.Add(Markers);
+ if (Tag2 is not null) Children.Add(Tag2);
+ }
- // Trailing favorite ★ + tag colour dots for device rows (Instr / FX / MIDI).
- var markers = BuildRowMarkers(item);
- if (markers is not null)
+ protected override Size ArrangeOverride(Size finalSize)
{
- Grid.SetColumn(markers, 3);
- grid.Children.Add(markers);
+ double h = finalSize.Height;
+ void Place(Control c, double x, double w)
+ => c.Arrange(new Rect(x, (h - c.DesiredSize.Height) / 2, w, c.DesiredSize.Height));
+
+ Edge.Arrange(new Rect(0, 0, Edge.Width, h));
+ Disclosure.Arrange(new Rect(Indent, 0, Disclosure.DesiredSize.Width, h));
+
+ double left = Indent + Disclosure.DesiredSize.Width + 3;
+ if (Prefix is not null)
+ {
+ Place(Prefix, left, Prefix.DesiredSize.Width);
+ left += Prefix.DesiredSize.Width + Gap;
+ }
+
+ double right = Math.Max(left, finalSize.Width - Gutter);
+ double markersW = Markers?.DesiredSize.Width ?? 0;
+ double avail = Math.Max(0, right - left - (markersW > 0 ? markersW + 6 : 0));
+
+ // The name first, then the tag on what survives — so a long name trims at the
+ // row's edge instead of being squeezed by a secondary label.
+ double nameW = Math.Min(Name2.DesiredSize.Width, avail);
+ double tagW = 0;
+ if (Tag2 is not null)
+ tagW = Math.Min(Tag2.DesiredSize.Width, Math.Max(0, avail - nameW - 6));
+ Place(Name2, left, nameW);
+
+ double x = right;
+ if (Tag2 is not null) { x -= tagW; Place(Tag2, x, tagW); if (tagW > 0) x -= 6; }
+ if (Markers is not null) { x -= markersW; Place(Markers, x, markersW); }
+ return finalSize;
}
- return grid;
- }, supportsRecycling: false);
+ }
+
+ // The right-edge tag: what kind of thing the row is, in as few words as possible.
+ // Nothing for rows whose indent already says it (presets under a device, folders).
+ private static string RowTag(BrowserItem it) => it.Kind switch
+ {
+ BrowserItemKind.Folder => "",
+ BrowserItemKind.Preset => it.Depth > 0 ? "" : it.Sub,
+ BrowserItemKind.Sample => System.IO.Path.GetExtension(it.Path).TrimStart('.').ToLowerInvariant(),
+ // A column of "project" down a tab that is only projects says nothing.
+ BrowserItemKind.Project => "",
+ _ => it.Sub,
+ };
// A small trailing strip of markers for a device row: a brass ★ when favorited, then up
// to three tag-colour dots. Null for non-device rows (presets / samples / folders / projects).
@@ -514,13 +793,13 @@ public sealed class BrowserView : UserControl
Orientation = Orientation.Horizontal,
Spacing = 3,
VerticalAlignment = VerticalAlignment.Center,
- Margin = new Thickness(6, 0, 4, 0),
+ Margin = new Thickness(6, 0, 0, 0),
};
if (fav)
{
var star = new Path
{
- Data = Geometry.Parse(IconStar), Stretch = Stretch.Uniform, Width = 10, Height = 10,
+ Data = Geometry.Parse(IconStar), Stretch = Stretch.Uniform, Width = 9, Height = 9,
VerticalAlignment = VerticalAlignment.Center,
};
star.BindResource(Shape.FillProperty, "Brush.Accent");
@@ -532,7 +811,7 @@ public sealed class BrowserView : UserControl
if (shown++ >= 3) break;
strip.Children.Add(new Ellipse
{
- Width = 7, Height = 7, VerticalAlignment = VerticalAlignment.Center,
+ Width = 6, Height = 6, VerticalAlignment = VerticalAlignment.Center,
Fill = BrushFromHex(t.Color),
});
}
@@ -547,6 +826,69 @@ public sealed class BrowserView : UserControl
catch { return Brushes.Gray; }
}
+ // --- view options ---------------------------------------------------------
+
+ private Border BuildOptionsButton()
+ {
+ var icon = GridIcon(IconOptions, 14, "Brush.TextSecondary", strokeWidth: 1.6);
+ icon.HorizontalAlignment = HorizontalAlignment.Center;
+ icon.VerticalAlignment = VerticalAlignment.Center;
+ var btn = new Border
+ {
+ Width = 26, Height = 26,
+ Margin = new Thickness(6, 0, 0, 0),
+ CornerRadius = new CornerRadius(5),
+ BorderThickness = new Thickness(1),
+ Cursor = new Cursor(StandardCursorType.Hand),
+ Child = icon,
+ };
+ btn.BindResource(Border.BackgroundProperty, "Brush.BgSunken");
+ btn.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ ToolTip.SetTip(btn, "Sort & view options");
+ btn.PointerPressed += (_, e) => { ShowOptionsMenu(btn); e.Handled = true; };
+ return btn;
+ }
+
+ private void ShowOptionsMenu(Control anchor)
+ {
+ var flyout = new MenuFlyout();
+ flyout.Items.Add(CheckItem("Show type tags", _settings?.Current.BrowserShowTypeTags ?? true, v =>
+ {
+ if (_settings is null) return;
+ _settings.Current.BrowserShowTypeTags = v;
+ _settings.Save();
+ RefreshRows();
+ }));
+ flyout.Items.Add(CheckItem("Group by source", _vm?.GroupBySource ?? true, v =>
+ {
+ if (_vm is not null) _vm.GroupBySource = v;
+ if (_settings is not null) { _settings.Current.BrowserGroupBySource = v; _settings.Save(); }
+ RefreshCounts();
+ }));
+ flyout.Items.Add(CheckItem("Favorites first", _vm?.FavoritesFirst ?? true, v =>
+ {
+ if (_vm is not null) _vm.FavoritesFirst = v;
+ if (_settings is not null) { _settings.Current.BrowserFavoritesFirst = v; _settings.Save(); }
+ RefreshCounts();
+ }));
+ flyout.Items.Add(new Separator());
+ var editTags = new MenuItem { Header = "Edit tags…" };
+ editTags.Click += (_, _) => EditTagsRequested?.Invoke(null);
+ flyout.Items.Add(editTags);
+ flyout.ShowAt(anchor);
+ }
+
+ // A checkable row, drawn the same way the tag menu marks assignment (a leading ✓ or
+ // its width in blanks) so the two menus read alike.
+ private static MenuItem CheckItem(string label, bool on, Action<bool> set)
+ {
+ var mi = new MenuItem { Header = (on ? "✓ " : " ") + label };
+ mi.Click += (_, _) => set(!on);
+ return mi;
+ }
+
+ // --- preview footer --------------------------------------------------------
+
private Border BuildPreviewFooter(out Button playBtn, out Path playIcon, out TextBlock name,
out TextBlock sub, out ToggleButton auto, out PreviewWaveform wave)
{
@@ -590,9 +932,9 @@ public sealed class BrowserView : UserControl
{
BorderThickness = new Thickness(0, 1, 0, 0),
Padding = new Thickness(10, 8),
- Background = NotaPalette.SurfaceInset,
Child = new StackPanel { Children = { infoRow, playRow, row3 } },
};
+ footer.BindResource(Border.BackgroundProperty, "Brush.BgApp");
footer.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
return footer;
}
@@ -608,16 +950,6 @@ public sealed class BrowserView : UserControl
if (isSample && (_autoAudition.IsChecked ?? false)) PreviewRequested?.Invoke(item!);
}
- private static string IconFor(BrowserItemKind kind) => kind switch
- {
- BrowserItemKind.BuiltinInstrument or BrowserItemKind.PluginInstrument => IconKeyboard,
- BrowserItemKind.BuiltinEffect or BrowserItemKind.PluginEffect => IconSliders,
- BrowserItemKind.BuiltinMidiEffect => IconMidi,
- BrowserItemKind.Preset => IconBookmark,
- BrowserItemKind.Project => IconDoc,
- _ => IconFolder,
- };
-
private TextBlock Caption(string text)
{
var t = new TextBlock { Text = text, FontSize = 9, VerticalAlignment = VerticalAlignment.Center };
@@ -627,9 +959,8 @@ public sealed class BrowserView : UserControl
private ListBox NewList(IDataTemplate itemTemplate) => new()
{
- Background = null,
- BorderThickness = new Thickness(0),
- Padding = new Thickness(4),
+ Classes = { "browser" },
+ Padding = new Thickness(0, 0, 0, 6),
ItemTemplate = itemTemplate,
};
@@ -637,10 +968,12 @@ public sealed class BrowserView : UserControl
{
list.DoubleTapped += (_, _) =>
{
- if (list.SelectedItem is BrowserItem item) ItemActivated?.Invoke(item);
+ if (list.SelectedItem is BrowserItem { IsGroup: false } item) ItemActivated?.Invoke(item);
};
list.SelectionChanged += (_, _) =>
{
+ // Section headers are chrome: never let one become the selection.
+ if (list.SelectedItem is BrowserItem { IsGroup: true }) { list.SelectedItem = null; return; }
if (_active >= 0 && list == _pages[_active]) UpdateFooter(list.SelectedItem as BrowserItem);
};
// Drag source (M7-5): start a copy-drag when the pointer leaves the row.
@@ -664,8 +997,9 @@ public sealed class BrowserView : UserControl
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
if (InButton(e.Source as StyledElement)) return; // preview button etc.
var item = (e.Source as StyledElement)?.DataContext as BrowserItem;
- // Projects and folders aren't draggable (folders are navigation, not payload).
- if (item is null || item.Kind is BrowserItemKind.Project or BrowserItemKind.Folder) return;
+ // Projects, folders and section headers aren't draggable (folders are navigation,
+ // not payload; headers are chrome).
+ if (item is null || item.IsGroup || item.Kind is BrowserItemKind.Project or BrowserItemKind.Folder) return;
_pressedItem = item;
_pressPoint = e.GetPosition(this);
_pressArgs = e; // DoDragDropAsync needs the PointerPressed args
@@ -704,7 +1038,7 @@ public sealed class BrowserView : UserControl
private void RebuildChips()
{
- _chipsPanel.Children.Clear();
+ _chipsPanel.ClearChips(); // the "+N" is a permanent child, not one of the chips
if (_vm is null) return;
_chipsPanel.Children.Add(MakeChip("★ Favorites", null,
_vm.FilterMode == BrowserFilter.Favorites, () => ToggleFilter(BrowserFilter.Favorites, "")));
@@ -714,8 +1048,24 @@ public sealed class BrowserView : UserControl
bool active = _vm.FilterMode == BrowserFilter.Tag && _vm.FilterTagId == tag.Id;
_chipsPanel.Children.Add(MakeChip(tag.Title, tag.Color, active, () => ToggleFilter(BrowserFilter.Tag, tag.Id)));
}
- // Trailing affordance to manage the tag list.
- _chipsPanel.Children.Add(MakeChip("Tags…", null, false, () => EditTagsRequested?.Invoke(null)));
+ _chipsPanel.InvalidateMeasure();
+ }
+
+ // The chips that didn't fit on the line, offered as a menu off the "+N".
+ private void ShowOverflowChips()
+ {
+ if (_vm is null) return;
+ var flyout = new MenuFlyout();
+ foreach (var item in _chipsPanel.Hidden)
+ {
+ var chip = item;
+ var mi = new MenuItem { Header = (chip.Active ? "✓ " : " ") + chip.Label };
+ if (chip.ColorHex is not null)
+ mi.Icon = new Ellipse { Width = 10, Height = 10, Fill = BrushFromHex(chip.ColorHex) };
+ mi.Click += (_, _) => chip.OnClick();
+ flyout.Items.Add(mi);
+ }
+ if (flyout.Items.Count > 0) flyout.ShowAt(_overflowChip);
}
private void ToggleFilter(BrowserFilter mode, string tagId)
@@ -724,22 +1074,23 @@ public sealed class BrowserView : UserControl
bool same = _vm.FilterMode == mode && (mode != BrowserFilter.Tag || _vm.FilterTagId == tagId);
_vm.SetLibraryFilter(same ? BrowserFilter.None : mode, tagId);
RebuildChips();
- if (_active is 0 or 1 or 2) _matchCount.Text = VisibleCount(_active).ToString();
+ RefreshCounts();
}
- private Border MakeChip(string text, string? colorHex, bool active, Action onClick)
+ private ChipBorder MakeChip(string text, string? colorHex, bool active, Action onClick)
{
var content = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5, VerticalAlignment = VerticalAlignment.Center };
if (colorHex is not null)
- content.Children.Add(new Ellipse { Width = 8, Height = 8, VerticalAlignment = VerticalAlignment.Center, Fill = BrushFromHex(colorHex) });
+ content.Children.Add(new Ellipse { Width = 7, Height = 7, VerticalAlignment = VerticalAlignment.Center, Fill = BrushFromHex(colorHex) });
var tb = new TextBlock { Text = text, FontSize = 10, VerticalAlignment = VerticalAlignment.Center };
tb.BindResource(TextBlock.ForegroundProperty, active ? "Brush.TextOnAccent" : "Brush.TextSecondary");
content.Children.Add(tb);
- var chip = new Border
+ var chip = new ChipBorder
{
+ Label = text, ColorHex = colorHex, Active = active, OnClick = onClick,
Height = 20, CornerRadius = new CornerRadius(10), Padding = new Thickness(8, 0),
- Margin = new Thickness(0, 0, 5, 5), BorderThickness = new Thickness(1),
+ BorderThickness = new Thickness(1),
Cursor = new Cursor(StandardCursorType.Hand), Child = content,
};
chip.BindResource(Border.BackgroundProperty, active ? "Brush.Accent" : "Brush.BgSunken");
@@ -748,6 +1099,107 @@ public sealed class BrowserView : UserControl
return chip;
}
+ /// <summary>A filter chip that remembers what it stands for, so the overflow menu can
+ /// offer the same choice the chip would have.</summary>
+ private sealed class ChipBorder : Border
+ {
+ public string Label { get; init; } = "";
+ public string? ColorHex { get; init; }
+ public bool Active { get; init; }
+ public Action OnClick { get; init; } = () => { };
+ }
+
+ /// <summary>One line of chips: lays them out left to right and collapses whatever runs
+ /// off the end into a trailing "+N" (which opens the rest as a menu). A WrapPanel would
+ /// grow the header instead, pushing the list down as tags are added.</summary>
+ private sealed class ChipStrip : Panel
+ {
+ private const double Gap = 5;
+ private readonly Border _overflow;
+ private readonly TextBlock _overflowText;
+ private readonly List<ChipBorder> _hidden = new();
+
+ public ChipStrip(Border overflow, TextBlock overflowText)
+ {
+ ClipToBounds = true;
+ _overflow = overflow;
+ _overflowText = overflowText;
+ Children.Add(overflow);
+ }
+
+ /// <summary>The chips that didn't fit, in order.</summary>
+ public IReadOnlyList<ChipBorder> Hidden => _hidden;
+
+ /// <summary>Drop every chip, keeping the overflow affordance.</summary>
+ public void ClearChips()
+ {
+ for (int i = Children.Count - 1; i >= 0; i--)
+ if (Children[i] is ChipBorder) Children.RemoveAt(i);
+ _hidden.Clear();
+ }
+
+ private IEnumerable<ChipBorder> Chips
+ {
+ get { foreach (var c in Children) if (c is ChipBorder cb) yield return cb; }
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ foreach (var c in Children) c.Measure(Size.Infinity);
+ return new Size(0, 20); // one chip row, whatever the width
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ _hidden.Clear();
+ var chips = new List<ChipBorder>(Chips);
+
+ // Park anything that doesn't fit outside the panel; ClipToBounds swallows it.
+ // Toggling IsVisible from inside Arrange would re-enter layout and leave a chip
+ // painted where it was last arranged.
+ void Park(Control c) => c.Arrange(new Rect(finalSize.Width, 0, 0, 0));
+
+ double total = 0;
+ foreach (var c in chips) total += c.DesiredSize.Width + Gap;
+ if (total - Gap <= finalSize.Width)
+ {
+ double x0 = 0;
+ foreach (var c in chips)
+ {
+ c.Arrange(new Rect(x0, 0, c.DesiredSize.Width, 20));
+ x0 += c.DesiredSize.Width + Gap;
+ }
+ Park(_overflow);
+ return finalSize;
+ }
+
+ // Reserve the "+N" width up front so the last chip never sits under it. Its
+ // widest form is the one where everything is hidden, so measure that.
+ _overflowText.Text = "+" + chips.Count;
+ _overflow.Measure(Size.Infinity);
+ double reserve = _overflow.DesiredSize.Width + Gap;
+ double x = 0;
+ foreach (var c in chips)
+ {
+ double w = c.DesiredSize.Width;
+ if (_hidden.Count == 0 && x + w + reserve <= finalSize.Width)
+ {
+ c.Arrange(new Rect(x, 0, w, 20));
+ x += w + Gap;
+ }
+ else
+ {
+ Park(c); // once one chip is out, the rest follow it — order stays
+ _hidden.Add(c);
+ }
+ }
+ _overflowText.Text = "+" + _hidden.Count;
+ _overflow.Measure(Size.Infinity);
+ _overflow.Arrange(new Rect(x, 0, _overflow.DesiredSize.Width, 20));
+ return finalSize;
+ }
+ }
+
// --- context menus -------------------------------------------------------
private void ShowContextMenu(Control owner, ContextRequestedEventArgs e)
@@ -755,7 +1207,7 @@ public sealed class BrowserView : UserControl
if (_vm is null) return;
var item = (e.Source as StyledElement)?.DataContext as BrowserItem
?? (owner as ListBox)?.SelectedItem as BrowserItem;
- if (item is null) return;
+ if (item is null || item.IsGroup) return;
var flyout = BuildContextMenu(item);
if (flyout is null) return;
flyout.ShowAt(owner, showAtPointer: true);
@@ -808,7 +1260,7 @@ public sealed class BrowserView : UserControl
flyout.Items.Add(reveal);
return flyout;
}
- case BrowserItemKind.Folder when _active == 3: // real sample folders (preset folders are synthetic)
+ case BrowserItemKind.Folder when _active == FilesTab: // real sample folders (preset folders are synthetic)
{
var reveal = new MenuItem { Header = "Reveal in Finder" };
reveal.Click += (_, _) => RevealRequested?.Invoke(item);
diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axaml
index 89b36164..8241b81c 100644
--- a/src/managed/Nota.App/MainWindow.axaml
+++ b/src/managed/Nota.App/MainWindow.axaml
@@ -287,15 +287,17 @@
<RowDefinition Height="0"/>
</Grid.RowDefinitions>
- <!-- Left browser (240) + main area (fills) -->
+ <!-- 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. -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
- <ColumnDefinition Width="240" MinWidth="160" MaxWidth="480"/>
+ <ColumnDefinition Width="288" MinWidth="160" MaxWidth="480"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
- <app:BrowserView x:Name="Browser" Grid.Column="0"/>
- <GridSplitter Grid.Column="1" Width="3" Background="{DynamicResource Brush.BorderDefault}"
+ <app:BrowserView x:Name="Browser" Grid.Column="0" Margin="8,8,6,8"/>
+ <GridSplitter Grid.Column="1" Width="2" Background="Transparent"
ResizeDirection="Columns"/>
<Panel x:Name="MainContent" Grid.Column="2">
<app:ArrangementView x:Name="Timeline"/>
@@ -305,10 +307,10 @@
<!-- Drag handle to resize the Detail panel (only shown when it is open). -->
<GridSplitter x:Name="DetailSplitter"
Grid.Row="1"
- Height="3"
+ Height="2"
IsVisible="False"
HorizontalAlignment="Stretch" ResizeDirection="Rows"
- Background="{DynamicResource Brush.BorderDefault}"/>
+ Background="Transparent"/>
<!-- Detail panel: Devices chain / Clip (piano roll) / Mixer for the selected track -->
<Border x:Name="DetailPanel" Grid.Row="2" Classes="Panel"
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index dbd39782..6b452041 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -231,6 +231,7 @@ public partial class MainWindow : Window
vm.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.SetViewModel(vm.Browser);
Browser.ItemActivated += OnBrowserItemActivated;
Browser.PreviewRequested += OnBrowserPreview;
diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axaml
index 399fbc73..5a65a5f1 100644
--- a/src/managed/Nota.App/Theme/NotaTheme.axaml
+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml
@@ -600,31 +600,88 @@
</Style>
<!-- ===== Browser icon rail (custom vertical tabs) ===== -->
- <!-- 36×36 tab, 4px gap, radius 6 (mockup 1g). -->
+ <!-- Full-bleed 36px tab in a 40px rail; the active one is marked by a 2px brass edge
+ on the left rather than a filled chip, so the rail stays quiet (mockup 1a). -->
<Style Selector="Border.RailTab">
<Setter Property="Background" Value="Transparent"/>
- <Setter Property="CornerRadius" Value="6"/>
- <Setter Property="Margin" Value="5,2"/>
- <Setter Property="Padding" Value="0,10"/>
+ <Setter Property="Height" Value="36"/>
</Style>
<Style Selector="Border.RailTab:pointerover">
<Setter Property="Background" Value="{DynamicResource Brush.SurfaceHover}"/>
</Style>
- <Style Selector="Border.RailTab.active">
- <Setter Property="Background" Value="{DynamicResource Brush.AccentSubtle}"/>
- </Style>
- <Style Selector="Border.RailTab TextBlock">
- <Setter Property="Foreground" Value="{DynamicResource Brush.TextTertiary}"/>
- </Style>
<Style Selector="Border.RailTab Path">
<Setter Property="Stroke" Value="{DynamicResource Brush.TextSecondary}"/>
</Style>
- <Style Selector="Border.RailTab.active TextBlock">
- <Setter Property="Foreground" Value="{DynamicResource Brush.AccentBright}"/>
- </Style>
<Style Selector="Border.RailTab.active Path">
<Setter Property="Stroke" Value="{DynamicResource Brush.AccentBright}"/>
</Style>
+ <!-- The active edge: a 2px brass bar inset from the tab's top and bottom. -->
+ <Style Selector="Border.RailBar">
+ <Setter Property="Background" Value="Transparent"/>
+ <Setter Property="Width" Value="2"/>
+ <Setter Property="Margin" Value="0,6"/>
+ <Setter Property="CornerRadius" Value="1"/>
+ <Setter Property="HorizontalAlignment" Value="Left"/>
+ </Style>
+ <Style Selector="Border.RailTab.active Border.RailBar">
+ <Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
+ </Style>
+
+ <!-- ===== Browser list (compact index rows, mockup 1a) ===== -->
+ <!-- Single-line 24px rows, full-bleed: the selection wash and its brass left edge run
+ to both margins, so the list reads as one column rather than a stack of chips. -->
+ <Style Selector="ListBox.browser">
+ <Setter Property="Background" Value="Transparent"/>
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="CornerRadius" Value="0"/>
+ <Setter Property="Padding" Value="0"/>
+ </Style>
+ <Style Selector="ListBox.browser ListBoxItem">
+ <Setter Property="Padding" Value="0"/>
+ <Setter Property="MinHeight" Value="0"/>
+ <Setter Property="CornerRadius" Value="0"/>
+ </Style>
+ <Style Selector="ListBox.browser ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
+ <Setter Property="Background" Value="{DynamicResource Brush.SurfaceHover}"/>
+ </Style>
+ <Style Selector="ListBox.browser ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
+ <Setter Property="Background" Value="{DynamicResource Brush.SurfaceSelected}"/>
+ </Style>
+ <!-- Row parts. Colours live here (not on the element) so selection can override them:
+ a local value would outrank the style setter. -->
+ <Style Selector="Border.RowEdge">
+ <Setter Property="Background" Value="Transparent"/>
+ <Setter Property="Width" Value="2"/>
+ </Style>
+ <Style Selector="ListBoxItem:selected Border.RowEdge">
+ <Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
+ </Style>
+ <Style Selector="TextBlock.RowName">
+ <Setter Property="FontSize" Value="11"/>
+ <Setter Property="FontWeight" Value="Medium"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextPrimary}"/>
+ </Style>
+ <Style Selector="TextBlock.RowName.child">
+ <Setter Property="FontWeight" Value="Normal"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextSecondary}"/>
+ </Style>
+ <Style Selector="TextBlock.RowPrefix">
+ <Setter Property="FontSize" Value="11"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextTertiary}"/>
+ </Style>
+ <Style Selector="TextBlock.RowTag">
+ <Setter Property="FontSize" Value="9"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextTertiary}"/>
+ </Style>
+ <Style Selector="ListBoxItem:selected TextBlock.RowTag">
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextSecondary}"/>
+ </Style>
+ <Style Selector="TextBlock.GroupLabel">
+ <Setter Property="FontSize" Value="9"/>
+ <Setter Property="FontWeight" Value="Bold"/>
+ <Setter Property="LetterSpacing" Value="0.9"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextTertiary}"/>
+ </Style>
<!-- ===== Flat search box ===== -->
<!-- Used inside a bordered wrapper (see BrowserView), so the TextBox itself must
diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.cs
index 49d555ca..f2b88c8e 100644
--- a/src/managed/Nota.Application/Settings.cs
+++ b/src/managed/Nota.Application/Settings.cs
@@ -46,6 +46,14 @@ public sealed class Settings
/// <summary>Base-octave shift for gamepad notes, in semitones ÷ 12 (d-pad
/// up/down live-shifts this)</summary>
public int GamepadOctave { get; set; }
+
+ // --- browser view options (the ⋮ button next to the browser search) ------
+ /// <summary>Show each row's type as a quiet tag on the right edge of the browser list.</summary>
+ public bool BrowserShowTypeTags { get; set; } = true;
+ /// <summary>Group the device tabs into BUILT-IN and PLUG-INS sections with counts.</summary>
+ public bool BrowserGroupBySource { get; set; } = true;
+ /// <summary>Float favorited devices to the top of their section.</summary>
+ public bool BrowserFavoritesFirst { get; set; } = true;
}
public interface ISettingsService
diff --git a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
index 129f27b6..4a52f525 100644
--- a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
@@ -16,6 +16,9 @@ namespace Nota.Presentation;
public enum BrowserItemKind
{
BuiltinInstrument, BuiltinEffect, BuiltinMidiEffect, PluginInstrument, PluginEffect, Sample, Project, Preset, Folder,
+ /// <summary>A section header row (BUILT-IN / PLUG-INS) inside a flattened list — never
+ /// selectable, draggable or activatable.</summary>
+ Group,
}
/// <summary>Active library filter for the device tabs (Instr / FX / MIDI).</summary>
@@ -27,9 +30,23 @@ public sealed class BrowserItem
public required BrowserItemKind Kind { get; init; }
public int CatalogIndex { get; init; } = -1; // plugins
public int BuiltinKind { get; init; } = -1; // effects: 0=EQ,1=Compressor,2=Reverb,3=Delay,4=Utility · instruments: 0=Synth,2=Physical,5=Aurora
- public string Sub { get; init; } = ""; // format / manufacturer / folder
+ public string Sub { get; init; } = ""; // type / manufacturer / folder
+ public string Format { get; init; } = ""; // plug-ins: "VST3" / "AU" (Sub carries the vendor)
public string Path { get; init; } = ""; // file/bundle path for samples/projects/presets
+ /// <summary>Section-header row (see <see cref="BrowserItemKind.Group"/>): Name is the
+ /// caption and <see cref="GroupCount"/> how many rows it heads.</summary>
+ public bool IsGroup => Kind == BrowserItemKind.Group;
+ public int GroupCount { get; init; }
+
+ /// <summary>The brand prefix a built-in device name carries ("Nota"), or "" — the browser
+ /// prints it in tertiary ink so names scan on their distinctive word.</summary>
+ public string Prefix => Name.StartsWith("Nota ", StringComparison.Ordinal) ? "Nota" : "";
+ /// <summary>The name without its brand prefix.</summary>
+ public string ShortName => Prefix.Length > 0 ? Name[5..] : Name;
+ /// <summary>True for a scanned AU/VST3 row (as opposed to one of Nota's own devices).</summary>
+ public bool IsPlugin => Kind is BrowserItemKind.PluginInstrument or BrowserItemKind.PluginEffect;
+
// --- tree (Instruments / FX): a built-in device parent with factory-preset children ---
public int Depth { get; init; } // 0 = device/plugin, 1 = preset child
public List<BrowserItem> Children { get; } = new(); // factory presets under this device
@@ -46,7 +63,9 @@ public sealed class BrowserItem
BrowserItemKind.BuiltinInstrument => $"bi:{BuiltinKind}",
BrowserItemKind.BuiltinEffect => $"be:{BuiltinKind}",
BrowserItemKind.BuiltinMidiEffect => $"bm:{BuiltinKind}",
- BrowserItemKind.PluginInstrument or BrowserItemKind.PluginEffect => $"pl:{Name}|{Sub}",
+ // Keyed on the format, not the (display-only) vendor, so favorites and tags
+ // saved before the vendor moved into Sub still resolve.
+ BrowserItemKind.PluginInstrument or BrowserItemKind.PluginEffect => $"pl:{Name}|{Format}",
_ => "",
};
}
@@ -74,6 +93,24 @@ public sealed partial class BrowserViewModel : ObservableObject
private BrowserFilter _filterMode = BrowserFilter.None;
private string _filterTagId = "";
+ private bool _groupBySource = true;
+ private bool _favoritesFirst = true;
+
+ /// <summary>Split the device tabs into BUILT-IN / PLUG-INS sections with counts.</summary>
+ public bool GroupBySource
+ {
+ get => _groupBySource;
+ set { if (_groupBySource == value) return; _groupBySource = value; RebuildDeviceTabs(); }
+ }
+
+ /// <summary>Float favorited devices to the top of their section.</summary>
+ public bool FavoritesFirst
+ {
+ get => _favoritesFirst;
+ set { if (_favoritesFirst == value) return; _favoritesFirst = value; RebuildDeviceTabs(); }
+ }
+
+ private void RebuildDeviceTabs() { RebuildVisible(0); RebuildVisible(1); RebuildVisible(2); }
public ObservableCollection<BrowserItem> Instruments { get; } = new();
public ObservableCollection<BrowserItem> Effects { get; } = new();
@@ -127,9 +164,7 @@ public sealed partial class BrowserViewModel : ObservableObject
{
_filterMode = mode;
_filterTagId = tagId ?? "";
- RebuildVisible(0);
- RebuildVisible(1);
- RebuildVisible(2);
+ RebuildDeviceTabs();
}
// Any favorite/tag mutation → refresh device rows (markers + active filter). If the
@@ -138,9 +173,7 @@ public sealed partial class BrowserViewModel : ObservableObject
{
if (_filterMode == BrowserFilter.Tag && !Tags.Any(t => t.Id == _filterTagId))
{ _filterMode = BrowserFilter.None; _filterTagId = ""; }
- RebuildVisible(0);
- RebuildVisible(1);
- RebuildVisible(2);
+ RebuildDeviceTabs();
LibraryChanged?.Invoke();
}
@@ -252,20 +285,24 @@ public sealed partial class BrowserViewModel : ObservableObject
var parts = desc.Split('|');
string name = parts.Length > 0 ? parts[0].Trim() : desc;
string fmt = parts.Length > 1 ? parts[1].Trim() : "";
+ string vendor = parts.Length > 3 ? parts[3].Trim() : "";
bool isInstrument = desc.Contains("| inst |");
var item = new BrowserItem
{
Name = name,
- Sub = fmt,
+ // The row's right-edge tag. Format first: the same plug-in is often installed
+ // in two formats, and those rows are otherwise identical. The vendor follows,
+ // and is what gets trimmed when the panel is narrow.
+ Sub = fmt.Length > 0 && vendor.Length > 0 ? $"{fmt} · {vendor}"
+ : vendor.Length > 0 ? vendor : fmt,
+ Format = fmt,
Kind = isInstrument ? BrowserItemKind.PluginInstrument : BrowserItemKind.PluginEffect,
CatalogIndex = i,
};
(isInstrument ? _instrTree : _fxTree).Add(item);
}
- RebuildVisible(0);
- RebuildVisible(1);
- RebuildVisible(2);
+ RebuildDeviceTabs();
RebuildSamples();
RebuildProjects();
RebuildPresets();
@@ -307,44 +344,81 @@ public sealed partial class BrowserViewModel : ObservableObject
// Flatten a tree into its visible ObservableCollection, honouring expand state and
// the current query. With a query, matching is name/sub substring; a matching device
- // shows all its presets, and a device with matching presets shows just those.
+ // shows all its presets, and a device with matching presets shows just those. With
+ // GroupBySource on, a BUILT-IN / PLUG-INS header carrying the section's device count
+ // is emitted ahead of each run — so it is clear where Nota's own devices end.
private void RebuildVisible(int tab)
{
var tree = tab == 2 ? _midiTree : tab == 1 ? _fxTree : _instrTree;
var dst = tab == 2 ? MidiEffects : tab == 1 ? Effects : Instruments;
string q = _treeQuery[tab].Trim();
dst.Clear();
- // Favorited devices float to the top (stable: keeps alphabetical order within each group).
- var ordered = _library is null ? (IEnumerable<BrowserItem>)tree
- : tree.OrderByDescending(n => _library.IsFavorite(n.LibraryKey));
+
+ // Favorited devices float to the top (stable sorts: alphabetical order survives
+ // inside each run, and the source sort keeps the favorites-first order within a section).
+ IEnumerable<BrowserItem> ordered = tree;
+ if (_favoritesFirst && _library is not null)
+ ordered = ordered.OrderByDescending(n => _library.IsFavorite(n.LibraryKey));
+ if (_groupBySource) ordered = ordered.OrderBy(n => n.IsPlugin ? 1 : 0);
+
+ // Visible devices first, so a section header can carry its real count.
+ var devices = new List<BrowserItem>();
foreach (var node in ordered)
{
if (!PassesLibraryFilter(node)) continue; // header favorite/tag chip
+ if (q.Length == 0 || Matches(node, q) || node.Children.Any(c => Matches(c, q)))
+ devices.Add(node);
+ }
+
+ string section = "";
+ foreach (var node in devices)
+ {
+ if (_groupBySource)
+ {
+ string s = node.IsPlugin ? "PLUG-INS" : "BUILT-IN";
+ if (s != section)
+ {
+ section = s;
+ dst.Add(new BrowserItem
+ {
+ Name = s,
+ Kind = BrowserItemKind.Group,
+ GroupCount = devices.Count(d => (d.IsPlugin ? "PLUG-INS" : "BUILT-IN") == s),
+ });
+ }
+ }
+ dst.Add(node);
+ // No query: presets follow only while the device is expanded. With a query, a
+ // device that matched shows all of its presets; one that didn't shows the hits.
if (q.Length == 0)
{
- dst.Add(node);
- if (node.IsExpanded)
- foreach (var c in node.Children) dst.Add(c);
- continue;
+ if (node.IsExpanded) foreach (var c in node.Children) dst.Add(c);
}
- bool nodeHit = Matches(node, q);
- if (nodeHit)
+ else if (Matches(node, q))
{
- dst.Add(node);
foreach (var c in node.Children) dst.Add(c);
}
else
{
- var hits = node.Children.Where(c => Matches(c, q)).ToList();
- if (hits.Count > 0)
- {
- dst.Add(node);
- foreach (var c in hits) dst.Add(c);
- }
+ foreach (var c in node.Children) if (Matches(c, q)) dst.Add(c);
}
}
}
+ /// <summary>Device rows on a tab, split by source — for the browser's status line.
+ /// Counts what is actually visible (search + favorite/tag filter applied).</summary>
+ public (int builtin, int plugins) VisibleDeviceCounts(int tab)
+ {
+ var src = tab == 2 ? MidiEffects : tab == 1 ? Effects : Instruments;
+ int bi = 0, pl = 0;
+ foreach (var it in src)
+ {
+ if (it.IsGroup || it.Depth > 0) continue;
+ if (it.IsPlugin) pl++; else bi++;
+ }
+ return (bi, pl);
+ }
+
private static bool Matches(BrowserItem it, string q)
=> it.Name.Contains(q, StringComparison.OrdinalIgnoreCase)
|| it.Sub.Contains(q, StringComparison.OrdinalIgnoreCase);