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) Downloaded folder first in the Files tab, with its own icon

Egor Khindikaynen5fb465102fca
diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.cs
index 07a33158..87806ead 100644
--- a/src/managed/Nota.App/BrowserView.cs
+++ b/src/managed/Nota.App/BrowserView.cs
@@ -108,6 +108,7 @@ public sealed class BrowserView : UserControl
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 = "M3.5 7.5 h5.6 l2.1 2.6 h9.3 v9.4 h-17 z";
+ private const string IconDownloads = "M12 4 V15 M7 10 L12 15 L17 10 M5 19 H19"; // as Settings → Downloads
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 = "M6.5 4 h11 v16 l-5.5 -4.4 l-5.5 4.4 z";
@@ -744,6 +745,15 @@ public sealed class BrowserView : UserControl
disclosure = new Border { Width = 14 };
}
+ // The Downloaded folder (installed sample packs) carries the Downloads arrow.
+ Control? icon = null;
+ if (item.IsDownloads)
+ {
+ var arrow = new Path { Data = Geometry.Parse(IconDownloads), StrokeThickness = 2.2, StrokeLineCap = PenLineCap.Round, StrokeJoin = PenLineJoin.Round };
+ arrow.BindResource(Shape.StrokeProperty, "Brush.TextSecondary");
+ icon = new Viewbox { Width = 13, Height = 13, Child = new Canvas { Width = 24, Height = 24, Children = { arrow } } };
+ }
+
// "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" } }
@@ -768,6 +778,7 @@ public sealed class BrowserView : UserControl
Indent = 6 + item.Depth * 12,
Edge = edge,
Disclosure = disclosure,
+ Icon = icon,
Prefix = prefix,
Name2 = name,
Markers = BuildRowMarkers(item), // brass ★ + tag colour dots
@@ -793,6 +804,7 @@ public sealed class BrowserView : UserControl
public double Indent { get; init; }
public Border Edge { get; init; } = null!;
public Control Disclosure { get; init; } = null!;
+ public Control? Icon { get; init; }
public TextBlock? Prefix { get; init; }
public TextBlock Name2 { get; init; } = null!;
public Control? Markers { get; init; }
@@ -812,6 +824,7 @@ public sealed class BrowserView : UserControl
_built = true;
Children.Add(Edge);
Children.Add(Disclosure);
+ if (Icon is not null) Children.Add(Icon);
if (Prefix is not null) Children.Add(Prefix);
Children.Add(Name2);
if (Markers is not null) Children.Add(Markers);
@@ -828,6 +841,11 @@ public sealed class BrowserView : UserControl
Disclosure.Arrange(new Rect(Indent, 0, Disclosure.DesiredSize.Width, h));
double left = Indent + Disclosure.DesiredSize.Width + 3;
+ if (Icon is not null)
+ {
+ Place(Icon, left, Icon.DesiredSize.Width);
+ left += Icon.DesiredSize.Width + Gap;
+ }
if (Prefix is not null)
{
Place(Prefix, left, Prefix.DesiredSize.Width);
diff --git a/src/managed/Nota.Application/Ports/ISampleStore.cs b/src/managed/Nota.Application/Ports/ISampleStore.cs
index cb4c9bf4..e7ccd874 100644
--- a/src/managed/Nota.Application/Ports/ISampleStore.cs
+++ b/src/managed/Nota.Application/Ports/ISampleStore.cs
@@ -3,6 +3,13 @@
namespace Nota.Application;
+public static class SamplePacks
+{
+ /// <summary>The folder inside the Samples folder that registry packs install into; the
+ /// browser's Files tab gives it its own icon and lists it first.</summary>
+ public const string FolderName = "Downloaded";
+}
+
/// <summary>A sample pack listed in the Nota sample registry (github.com/nota-daw/nota-samples-registry).</summary>
public sealed record StorePack(
string Id,
diff --git a/src/managed/Nota.Infrastructure/SampleStore/SampleStore.cs b/src/managed/Nota.Infrastructure/SampleStore/SampleStore.cs
index 4dc3dbeb..b5c212e9 100644
--- a/src/managed/Nota.Infrastructure/SampleStore/SampleStore.cs
+++ b/src/managed/Nota.Infrastructure/SampleStore/SampleStore.cs
@@ -50,7 +50,7 @@ public sealed class SampleStore : ISampleStore
_installed = LoadInstalled();
}
- public string InstallDir => Path.Combine(_samplesFolder(), "Downloaded");
+ public string InstallDir => Path.Combine(_samplesFolder(), SamplePacks.FolderName);
private string InstalledPath => Path.Combine(_root, "installed.json");
diff --git a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
index 52ccaac6..c4d5a9e4 100644
--- a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
@@ -58,6 +58,8 @@ public sealed class BrowserItem
public List<BrowserItem> Children { get; } = new(); // presets and category folders under this device
public bool HasChildren => Children.Count > 0;
public bool IsExpanded { get; set; } // toggled by the view-model
+ /// <summary>The Files tab's Downloaded folder (installed sample packs): its own icon, listed first.</summary>
+ public bool IsDownloads { get; init; }
public string Display => string.IsNullOrEmpty(Sub) ? Name : $"{Name} · {Sub}";
public override string ToString() => Display;
@@ -612,14 +614,17 @@ public sealed partial class BrowserViewModel : ObservableObject
abs = Path.Combine(abs, segments[i]);
if (!folders.TryGetValue(abs, out var node))
{
+ bool downloads = i == 0 && string.Equals(segments[0], SamplePacks.FolderName, StringComparison.OrdinalIgnoreCase);
node = new BrowserItem
{
Name = segments[i],
Kind = BrowserItemKind.Folder,
Sub = "",
+ Tip = downloads ? "sample packs installed from Settings → Downloads" : "",
Path = abs,
Depth = i,
IsExpanded = _expandedTreeKeys.Contains(abs),
+ IsDownloads = downloads,
};
folders[abs] = node;
children.Add(node);
@@ -630,11 +635,12 @@ public sealed partial class BrowserViewModel : ObservableObject
return children;
}
- // Folders before files, each group alphabetical; recurses into subfolders.
+ // Downloaded first, then folders before files, each group alphabetical; recurses into subfolders.
private static void SortSampleTree(List<BrowserItem> nodes)
{
nodes.Sort((a, b) =>
{
+ if (a.IsDownloads != b.IsDownloads) return a.IsDownloads ? -1 : 1;
bool af = a.Kind == BrowserItemKind.Folder, bf = b.Kind == BrowserItemKind.Folder;
if (af != bf) return af ? -1 : 1;
return string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
diff --git a/tests/Nota.SmokeTest/SampleStoreTests.cs b/tests/Nota.SmokeTest/SampleStoreTests.cs
index 565d74df..8cc971e7 100644
--- a/tests/Nota.SmokeTest/SampleStoreTests.cs
+++ b/tests/Nota.SmokeTest/SampleStoreTests.cs
@@ -155,10 +155,31 @@ internal static class SampleStoreTests
yield return (Directory.Exists(loops) && store.Installed.All(i => i.Id != "loops"),
"a folder without its pack marker is dropped from the list but not deleted");
+ // The browser's Files tab: Downloaded gets its flag (icon) and heads the list.
+ Directory.CreateDirectory(Path.Combine(samples, "Acoustic"));
+ File.WriteAllText(Path.Combine(samples, "Acoustic", "a.wav"), "a");
+ File.WriteAllText(Path.Combine(samples, "Amen.wav"), "a");
+ var browser = new Nota.Presentation.BrowserViewModel(new EmptyPluginCatalog(), new EmptyPresetLibrary(), new FactoryPresetCatalog(), new FolderSettings(samples));
+ var rows = browser.Samples.Select(r => r.Name).ToList();
+ yield return (browser.Samples.FirstOrDefault() is { Name: SamplePacks.FolderName, IsDownloads: true }
+ && rows.IndexOf("Acoustic") > 0 && rows.IndexOf("Amen.wav") > rows.IndexOf("Acoustic")
+ && browser.Samples.Count(r => r.IsDownloads) == 1,
+ "the Files tab lists Downloaded first, flagged, ahead of other folders and files");
+
var offline = new SampleStore(Path.Combine(tmp, "store2"), () => samples, "https://127.0.0.1:1/index.json");
yield return (Throws(() => offline.FetchAsync().GetAwaiter().GetResult()), "offline with no cache is a clear error");
}
+ private sealed class FolderSettings(string samples) : ISettingsService
+ {
+ public Settings Current { get; } = new();
+ public void Save() { }
+ public event Action? Changed { add { } remove { } }
+ public string ResolvedSamplesFolder() => samples;
+ public string ResolvedProjectsFolder() => samples;
+ public string PresetsFolder() => samples;
+ }
+
private static string IndexJson(params string[] packs)
=> $"{{\n\"schema\": 1,\n\"generated\": \"2026-01-01T00:00:00Z\",\n\"packs\": [{string.Join(",", packs)}]\n}}";