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
(style) Redesign of close window
Egor Khindikaynen2b79b2a48e77
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex aa5760f9..1d8de015 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -89,6 +89,9 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.- **A new look for the start window.** The Nota logo follows the light and dark themes,and recent projects sit in one compact list with their dates. Click a project to selectit and double-click to open it, or use the arrow keys and Return.+- **A new look for the "quit without saving" dialog.** It shows the project's name and how+ long its changes have gone unsaved. Return saves and Escape cancels. A saved project is+ saved right in the dialog, and Nota quits when it's done.- **A new look for Settings.** The window is larger, and the sidebar groups its pagesunder Devices, Plug-ins and General, each with an icon. Every page has a shortdescription under its title. MIDI inputs and the other on/off options use largerdiff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.csindex 7a844137..106d27d8 100644--- a/src/managed/Nota.App/MainWindow.Files.cs+++ b/src/managed/Nota.App/MainWindow.Files.cs@@ -152,10 +152,7 @@ public partial class MainWindow/// ("Nota — Untitled" until the bundle is named).</summary>private void UpdateWindowTitle(){- string name = _projectPath is { Length: > 0 } p- ? System.IO.Path.GetFileNameWithoutExtension(p.TrimEnd('/', '\\'))- : "Untitled";- string title = $"Nota — {name}";+ string title = $"Nota — {ProjectDisplayName()}";Title = title;DocTitleText.Text = title; // frameless title-bar caption mirrors the window title}@@ -347,8 +344,27 @@ public partial class MainWindowcatch { return null; }}+ // When the project first differed from its clean state, as seen by the 30 s autosave+ // tick (NoteDirtySince) — so the quit prompt can say how long changes have waited.+ private DateTime? _dirtySince;+/// <summary>Record the current state as saved (after New / Open / Save).</summary>- private void MarkProjectClean() => _cleanFingerprint = CurrentFingerprint();+ private void MarkProjectClean()+ {+ _cleanFingerprint = CurrentFingerprint();+ _dirtySince = null;+ }++ private void NoteDirtySince()+ {+ if (_dirtySince is null && HasUnsavedChanges()) _dirtySince = DateTime.Now;+ }++ /// <summary>The open project's name ("Untitled" until the bundle is named).</summary>+ private string ProjectDisplayName()+ => _projectPath is { Length: > 0 } p+ ? System.IO.Path.GetFileNameWithoutExtension(p.TrimEnd('/', '\\'))+ : "Untitled";/// <summary>True if the project changed since it was last created, opened or saved.</summary>private bool HasUnsavedChanges()diff --git a/src/managed/Nota.App/MainWindow.Recovery.cs b/src/managed/Nota.App/MainWindow.Recovery.csindex 542528f0..17a7661d 100644--- a/src/managed/Nota.App/MainWindow.Recovery.cs+++ b/src/managed/Nota.App/MainWindow.Recovery.cs@@ -31,6 +31,7 @@ public partial class MainWindowprivate void OnAutosaveTick(){if (_vm is null) return;+ NoteDirtySince();try { _recovery.Autosave(Engine, TransportSnapshot(), _projectPath); }catch { /* autosave is best-effort — never disrupt the session */ }}@@ -62,17 +63,32 @@ public partial class MainWindow_closePromptOpen = true;try{+ // A named project saves in place with the prompt up ("Saving…"); an untitled one+ // needs the file panel, so the prompt closes first.+ bool named = _projectPath is not null;var choice = await new SaveChangesWindow("Unsaved changes",- "Do you really want to quit without saving your changes?")+ "Do you really want to quit without saving your changes?",+ ProjectDisplayName(), UnsavedAgeText(),+ named ? () => DoSaveAsync(saveAs: false) : null).ShowDialog<SaveChoice>(this);if (choice == SaveChoice.Cancel) return;- if (choice == SaveChoice.Save && !await DoSaveAsync(saveAs: false)) return;+ if (choice == SaveChoice.Save && !named && !await DoSaveAsync(saveAs: false)) return;_closeConfirmed = true;}finally { _closePromptOpen = false; }Close();}+ // "unsaved changes · 14 min" — how long the oldest unsaved edit has waited.+ private string UnsavedAgeText()+ {+ var age = _dirtySince is { } since ? DateTime.Now - since : TimeSpan.Zero;+ string when = age.TotalMinutes < 1 ? "just now"+ : age.TotalHours < 1 ? NotaNum.F($"{(int)age.TotalMinutes}{NotaNum.Thin}min")+ : NotaNum.F($"{(int)age.TotalHours}{NotaNum.Thin}h {age.Minutes}{NotaNum.Thin}min");+ return "unsaved changes · " + when;+ }+private async void OnOpenedRecoveryCheck(object? sender, EventArgs e){if (_vm is null) return;diff --git a/src/managed/Nota.App/SaveChangesWindow.cs b/src/managed/Nota.App/SaveChangesWindow.csindex 7a3a958b..72367c93 100644--- a/src/managed/Nota.App/SaveChangesWindow.cs+++ b/src/managed/Nota.App/SaveChangesWindow.cs@@ -1,11 +1,17 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Save / Don't Save / Cancel modal shown before discarding unsaved project edits.+// Save / Don't Save / Cancel modal shown before discarding unsaved project edits, as drawn+// in nota-design/Nota Unsaved Dialog.html: the question, the project name with how long its+// changes have been waiting, and a footer strip — Don't Save alone on the left, Cancel and+// the brass Save on the right. Return saves, Escape cancels.// ShowDialog<SaveChoice> returns Cancel when the window is closed without a choice.+using System;+using System.Threading.Tasks;using Avalonia;using Avalonia.Controls;+using Avalonia.Input;using Avalonia.Layout;using Avalonia.Media;@@ -15,44 +21,136 @@ public enum SaveChoice { Cancel, Save, DontSave }public sealed class SaveChangesWindow : NotaWindow{- public SaveChangesWindow(string title, string message)+ private readonly Button _save, _dontSave, _cancel;+ private readonly Func<Task<bool>>? _saveInPlace;+ private bool _busy;++ /// <param name="project">The project's name, shown under the question.</param>+ /// <param name="detail">Mono meta beside the name ("unsaved changes · 14 min").</param>+ /// <param name="saveInPlace">When set, Save runs here with the dialog still up+ /// ("Saving…") and closes with <see cref="SaveChoice.Save"/> on success, or+ /// <see cref="SaveChoice.Cancel"/> if it fails. When null, Save just closes and the caller+ /// saves (an untitled project needs the file panel).</param>+ public SaveChangesWindow(string title, string message, string project, string detail,+ Func<Task<bool>>? saveInPlace = null){Title = title;Width = 420;SizeToContent = SizeToContent.Height;CanResize = false;WindowStartupLocation = WindowStartupLocation.CenterOwner;- Background = NotaPalette.BgApp;-- var save = new Button { Content = "Save", Classes = { "primary" } };- save.Click += (_, _) => Close(SaveChoice.Save);- var dontSave = new Button { Content = "Don't Save", Classes = { "ghost" } };- dontSave.Click += (_, _) => Close(SaveChoice.DontSave);- var cancel = new Button { Content = "Cancel", Classes = { "ghost" } };- cancel.Click += (_, _) => Close(SaveChoice.Cancel);+ Background = NotaPalette.Panel;+ BlendTitleBar();+ _saveInPlace = saveInPlace;- SetBody(new StackPanel+ var body = new StackPanel{- Margin = new Thickness(20),- Spacing = 16,+ Margin = new Thickness(20, 4, 20, 20),+ Spacing = 8,Children ={- new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap },- new DockPanel+ new TextBlock{- LastChildFill = false,- Children =- {- dontSave,- new StackPanel- {- Orientation = Orientation.Horizontal, Spacing = 8,- [DockPanel.DockProperty] = Dock.Right,- Children = { cancel, save },- },- },+ Text = message,+ FontSize = NotaType.Heading,+ FontWeight = FontWeight.SemiBold,+ LineHeight = 18,+ Foreground = NotaPalette.TextPrimary,+ TextWrapping = TextWrapping.Wrap,},+ MetaRow(project, detail),},- });+ };++ _dontSave = new Button+ {+ Content = "Don't Save",+ Classes = { "ghost" },+ Padding = new Thickness(12, 0),+ Margin = new Thickness(-12, 0, 0, 0), // the label, not the hover wash, lines up with the text+ Foreground = NotaPalette.TextSecondary,+ };+ _dontSave.Click += (_, _) => Choose(SaveChoice.DontSave);+ _cancel = new Button { Content = "Cancel" };+ _cancel.Click += (_, _) => Choose(SaveChoice.Cancel);+ _save = new Button { Content = "Save", Classes = { "primary" }, FontWeight = FontWeight.SemiBold, MinWidth = 64 };+ _save.Click += (_, _) => _ = SaveAsync();++ var buttons = new DockPanel { LastChildFill = false };+ DockPanel.SetDock(_dontSave, Dock.Left);+ buttons.Children.Add(_dontSave);+ var right = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { _cancel, _save } };+ DockPanel.SetDock(right, Dock.Right);+ buttons.Children.Add(right);++ var footer = new Border+ {+ Background = NotaPalette.SurfaceCard,+ BorderBrush = NotaPalette.GraphBorder,+ BorderThickness = new Thickness(0, 1, 0, 0),+ Padding = new Thickness(20, 12),+ Child = buttons,+ };++ var root = new DockPanel();+ DockPanel.SetDock(footer, Dock.Bottom);+ root.Children.Add(footer);+ root.Children.Add(body);+ SetBody(root);+ }++ // Name (trimmed if long) with the mono meta right after it on the same baseline.+ private static Control MetaRow(string project, string detail)+ {+ var name = new TextBlock+ {+ Text = project,+ FontSize = NotaType.Name,+ FontWeight = FontWeight.Medium,+ Foreground = NotaPalette.TextStrong,+ TextTrimming = TextTrimming.CharacterEllipsis,+ VerticalAlignment = VerticalAlignment.Bottom,+ };+ var meta = new TextBlock+ {+ Text = detail,+ FontFamily = NotaFonts.MonoFamily,+ FontSize = NotaType.Value,+ Foreground = NotaPalette.TextMuted,+ VerticalAlignment = VerticalAlignment.Bottom,+ Margin = new Thickness(8, 0, 0, 1),+ };+ var row = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto") };+ name.MaxWidth = 250;+ Grid.SetColumn(meta, 1);+ row.Children.Add(name);+ row.Children.Add(meta);+ return row;+ }++ protected override void OnKeyDown(KeyEventArgs e)+ {+ if (e.Key == Key.Enter) { _ = SaveAsync(); e.Handled = true; }+ else if (e.Key == Key.Escape) { Choose(SaveChoice.Cancel); e.Handled = true; }+ else base.OnKeyDown(e);+ }++ private void Choose(SaveChoice choice)+ {+ if (!_busy) Close(choice);+ }++ private async Task SaveAsync()+ {+ if (_busy) return;+ if (_saveInPlace is null) { Close(SaveChoice.Save); return; }++ _busy = true;+ _save.Content = "Saving…"; // the other buttons stay as drawn; Choose ignores them meanwhile+ bool ok;+ try { ok = await _saveInPlace(); }+ catch { ok = false; }+ _busy = false;+ Close(ok ? SaveChoice.Save : SaveChoice.Cancel);}}