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 tracks from the arrangement's context menus

Egor Khindikaynen65b910bc685d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 228ef130..aa7a96b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Add a track from the arrangement's context menus.** Right-clicking the empty space
+ below the tracks now offers `Add instrument track` / `Add audio track` / `Add return
+ track` above `Paste track`, and a track's own menu carries the same three under
+ `Add track ▸`. They route through the toolbar's handlers, so a track made this way is
+ seeded and reported exactly like one made with the `+` buttons.
- **Reverse for audio clips.** A `Reverse` item in a clip's context menu and a DIRECTION
toggle in the clip editor play a clip backwards. It is non-destructive — the file and
any warp cache stay in playing order and only the read direction flips — so toggling is
diff --git a/FEATURES.md b/FEATURES.md
index 158f51db..dc92fb94 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -90,6 +90,9 @@ the mixer opens as a separate floating window (**View → Mixer**, ⌘M).
- **Track types**: Audio, MIDI/Instrument, Return, Master, **Group** (nestable submixes —
⌘/Ctrl+G to group, ⌘/Ctrl+Shift+G to ungroup).
+- **Adding a track**: the `+ Instrument` / `+ Audio` / `+ Return` buttons above the
+ arrangement, or the context menu — right-click the empty space below the tracks, or use
+ `Add track ▸` in a track's own menu.
- **Per track**: volume, pan (bipolar bar), mute, solo, arm (ready to record).
Double-click resets to the default.
- **Reordering** by dragging the name row (with an accent insertion line); returns stay
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index 4d8dece8..fed90ef5 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -21,6 +21,9 @@ namespace Nota.App;
/// <summary>Audio-clip → MIDI conversion modes (arrangement clip context menu).</summary>
public enum ClipConvertMode { Drums, Slice, Melody, Harmony }
+/// <summary>Which kind of track an arrangement context menu asked for.</summary>
+public enum NewTrackKind { Instrument, Audio, Return }
+
public sealed partial class ArrangementView : UserControl
{
// --- coordinate model / shared state ---
@@ -123,6 +126,10 @@ public sealed partial class ArrangementView : UserControl
public event Action<BrowserItem, int, double>? ItemDropped;
/// <summary>Audio-clip context-menu "Convert / Slice to New MIDI Track" (track id, clip index, mode).</summary>
public event Action<int, int, ClipConvertMode>? ConvertClipRequested;
+ /// <summary>A context menu asked for a new track. MainWindow owns creation — the seed
+ /// MIDI clip, the session / modular / device-chain refreshes and the status line — so the
+ /// menu only asks, and the toolbar's + buttons and these entries stay one behaviour.</summary>
+ public event Action<NewTrackKind>? AddTrackRequested;
/// <summary>Raised after a clip's start/length changed in place (edge-drag trim or
/// stretch): track id, clip index. An open clip editor re-reads its geometry from this.</summary>
public event Action<int, int>? ClipGeometryChanged;
@@ -1457,11 +1464,30 @@ public sealed partial class ArrangementView : UserControl
private static readonly string[] TrackColorNames = { "Rust", "Amber", "Olive", "Sage", "Teal", "Slate", "Mauve", "Rose" };
private static readonly string[] ShadeNames = { "", " (light)", " (dark)" };
- // Right-click on the empty space below the tracks: paste a copied track.
+ // "Add …" entries shared by the arrangement's track-level menus. Return is left enabled
+ // when the buses are full, like the toolbar's + Return — MainWindow says so in the status
+ // line rather than the menu going quietly dead.
+ private IEnumerable<MenuItem> AddTrackItems()
+ {
+ MenuItem Item(string header, NewTrackKind kind)
+ {
+ var mi = new MenuItem { Header = header };
+ mi.Click += (_, _) => AddTrackRequested?.Invoke(kind);
+ return mi;
+ }
+ yield return Item("Add instrument track", NewTrackKind.Instrument);
+ yield return Item("Add audio track", NewTrackKind.Audio);
+ yield return Item("Add return track", NewTrackKind.Return);
+ }
+
+ // Right-click on the empty space below the tracks: add a track (the main thing to do
+ // down there) or paste a copied one.
private void ShowEmptyAreaMenu(Control anchor)
{
if (_engine is null) return;
var flyout = new MenuFlyout();
+ foreach (var mi in AddTrackItems()) flyout.Items.Add(mi);
+ flyout.Items.Add(new Separator());
var paste = new MenuItem { Header = "Paste track", IsEnabled = _engine.HasTrackClipboard() };
paste.Click += (_, _) =>
{
@@ -1593,7 +1619,11 @@ public sealed partial class ArrangementView : UserControl
flyout.Items.Add(new Separator());
flyout.Items.Add(group);
if (ungroup is not null) flyout.Items.Add(ungroup);
+ var addTrack = new MenuItem { Header = "Add track" }; // submenu: this menu is long already
+ foreach (var mi in AddTrackItems()) addTrack.Items.Add(mi);
+
flyout.Items.Add(new Separator());
+ flyout.Items.Add(addTrack);
flyout.Items.Add(copy);
flyout.Items.Add(cut);
flyout.Items.Add(paste);
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index 63da8e06..7d498af8 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -144,6 +144,17 @@ public partial class MainWindow : Window
Timeline.AudioClipActivated += OpenAudioClipEditor;
Timeline.ItemDropped += OnArrangementDrop; // browser drag & drop (M7-5)
Timeline.ConvertClipRequested += OnConvertClip; // audio clip → MIDI (Convert / Slice)
+ // Arrangement context menus add tracks through the toolbar's own handlers, so the two
+ // routes seed, refresh and report identically.
+ Timeline.AddTrackRequested += kind =>
+ {
+ switch (kind)
+ {
+ case NewTrackKind.Instrument: OnAddInstrumentClicked(this, new RoutedEventArgs()); break;
+ case NewTrackKind.Audio: OnAddAudioClicked(this, new RoutedEventArgs()); break;
+ case NewTrackKind.Return: OnAddReturnClicked(this, new RoutedEventArgs()); break;
+ }
+ };
_masterMeter = new MeterBar(horizontal: true);
MasterMeterHost.Children.Add(_masterMeter);