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.

(fix) Drops select their track

Egor Khindikaynena6eaae4ba260
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51e73af9..3eb34398 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
maximized states. On Windows and Linux a new **View → Toggle Full Screen** command
(shortcut **F11**) enters and leaves full screen; on macOS the green button does it.
+### Changed
+- **Drops select their track:** dropping an instrument, effect, preset, sample or MIDI file
+ from the browser selects the track it landed on — a newly created track included — in
+ both the arrangement and the session view. Moving clips to another track, or dropping a
+ clip onto a Sampler / Drum Rack / Grain track, selects the destination track too.
+
### Fixed
- **Nota Reverb no longer fires a loud, looping metallic burst:** after a few minutes of
playback the reverb could suddenly ring at full level and keep ringing. The cause was a
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index 28835c85..61da0628 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -601,6 +601,7 @@ public sealed partial class ArrangementView
{
_o.Refresh(); // also restores the preview if the engine rejected the move
if (committed) _o.ReselectPlaced(); // cross-track moves change indices
+ if (committed && rowDelta != 0) _o.AnnounceSelectedTrack(); // the destination track is now the active one
}
else InvalidateVisual();
return;
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index c18fd1fe..bb57cec0 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -937,6 +937,12 @@ public sealed partial class ArrangementView : UserControl
if (placed.Length > 0) SetSelection(placed);
}
+ // Tell the window the primary track changed under a clip selection (devices / clip tab follow).
+ internal void AnnounceSelectedTrack()
+ {
+ if (SelTrackId > 0) TrackSelected?.Invoke(SelTrackId);
+ }
+
/// <summary>Duplicates the whole clip selection as one block, placed right after itself
/// (keyboard Cmd+D / context menu). The copies become the new selection. False if none.</summary>
public bool DuplicateSelectedClip()
diff --git a/src/managed/Nota.App/MainWindow.AudioImport.cs b/src/managed/Nota.App/MainWindow.AudioImport.cs
index 346ccb0b..774f6472 100644
--- a/src/managed/Nota.App/MainWindow.AudioImport.cs
+++ b/src/managed/Nota.App/MainWindow.AudioImport.cs
@@ -54,6 +54,7 @@ public partial class MainWindow
LengthBeats = 4, Label = $"{name} · Processing…", // real length arrives with the header
};
Timeline.AddPendingImport(pending);
+ Timeline.Select(t, -1); // the track it lands on (a new one included) is selected right away
_session?.Refresh();
_vm.StatusText = $"Importing {name}…";
diff --git a/src/managed/Nota.App/MainWindow.Dnd.cs b/src/managed/Nota.App/MainWindow.Dnd.cs
index efa71969..d8eeec04 100644
--- a/src/managed/Nota.App/MainWindow.Dnd.cs
+++ b/src/managed/Nota.App/MainWindow.Dnd.cs
@@ -31,21 +31,26 @@ public partial class MainWindow
if (_vm is null) return;
try
{
+ int landed = -1; // the track the drop ended up on (a new one included) — it becomes the selection
switch (item.Kind)
{
case BrowserItemKind.Sample:
- // Decodes in the background; the track shows a filling placeholder meanwhile.
+ // Decodes in the background; the track shows a filling placeholder meanwhile
+ // (and is selected there as soon as it exists).
_ = ImportAudioInBackgroundAsync(item.Path, Insertion.TrackIsAudio(trackId) ? trackId : -1, beat);
break;
case BrowserItemKind.MidiFile:
- ImportMidiFileToArrangement(item, trackId, beat);
+ landed = ImportMidiFileToArrangement(item, trackId, beat);
break;
default: // instruments replace / start a track; effects + presets target the track
- ApplyInsertResult(Insertion.DropOnArrangement(item, trackId, beat), revealDevices: item.Kind is not (BrowserItemKind.BuiltinInstrument or BrowserItemKind.PluginInstrument));
+ var r = Insertion.DropOnArrangement(item, trackId, beat);
+ ApplyInsertResult(r, revealDevices: item.Kind is not (BrowserItemKind.BuiltinInstrument or BrowserItemKind.PluginInstrument));
+ if (r.Ok) landed = r.TrackId;
break;
}
Timeline.Refresh();
_session?.Refresh();
+ if (landed > 0) Timeline.Select(landed, -1);
}
catch (Exception ex) { _vm.StatusText = $"Drop failed: {ex.Message}"; }
}
@@ -55,21 +60,28 @@ public partial class MainWindow
if (_vm is null) return;
try
{
+ bool landed = false; // the drop's slot (and so its track) becomes the selection
switch (item.Kind)
{
case BrowserItemKind.Sample:
if (instrumentTrack) { _vm.StatusText = "Drop samples onto audio slots."; break; }
if (Engine.AddSessionAudioFile(trackId, scene, item.Path))
+ {
_vm.StatusText = $"Added {item.Name} to slot";
+ landed = true;
+ }
break;
case BrowserItemKind.MidiFile:
+ landed = instrumentTrack;
ImportMidiFileToSlot(item, trackId, scene, instrumentTrack);
break;
case BrowserItemKind.BuiltinEffect:
case BrowserItemKind.PluginEffect:
case BrowserItemKind.BuiltinMidiEffect:
case BrowserItemKind.Preset:
- ApplyInsertResult(Insertion.RouteToTrack(item, trackId)); // a session column is a track
+ var r = Insertion.RouteToTrack(item, trackId); // a session column is a track
+ ApplyInsertResult(r);
+ landed = r.Ok;
break;
default: // instruments
_vm.StatusText = "Drop instruments onto the arrangement.";
@@ -77,6 +89,11 @@ public partial class MainWindow
}
_session?.Refresh();
Timeline.Refresh();
+ if (landed && trackId > 0)
+ {
+ _session?.SelectSlot(trackId, scene); // the arrangement follows to the same track
+ if (Timeline.SelectedTrackId != trackId) Timeline.Select(trackId, -1);
+ }
}
catch (Exception ex) { _vm.StatusText = $"Drop failed: {ex.Message}"; }
}
diff --git a/src/managed/Nota.App/MainWindow.MidiImport.cs b/src/managed/Nota.App/MainWindow.MidiImport.cs
index 5b459f09..2f3b5116 100644
--- a/src/managed/Nota.App/MainWindow.MidiImport.cs
+++ b/src/managed/Nota.App/MainWindow.MidiImport.cs
@@ -16,9 +16,9 @@ namespace Nota.App;
public partial class MainWindow
{
- private void ImportMidiFileToArrangement(BrowserItem item, int trackId, double beat)
+ private int ImportMidiFileToArrangement(BrowserItem item, int trackId, double beat)
{
- if (_vm is null || ReadMidiFile(item) is not { } file) return;
+ if (_vm is null || ReadMidiFile(item) is not { } file) return -1;
string baseName = Path.GetFileNameWithoutExtension(item.Path);
bool multi = file.Parts.Count > 1;
int firstTrack = -1;
@@ -41,6 +41,7 @@ public partial class MainWindow
finally { Engine.EndUndoGroup(); }
if (firstTrack > 0) _lastInstrumentTrackId = firstTrack;
_vm.StatusText = multi ? $"Imported {item.Name} ({file.Parts.Count} parts)" : $"Imported {item.Name}";
+ return firstTrack;
}
private void ImportMidiFileToSlot(BrowserItem item, int trackId, int scene, bool instrumentTrack)
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index bfd57d0e..afacd9bb 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -194,7 +194,7 @@ public partial class MainWindow : Window
Timeline.MidiClipActivated += OpenClipEditor;
Timeline.AudioClipActivated += OpenAudioClipEditor;
Timeline.ItemDropped += OnArrangementDrop; // browser drag & drop (M7-5)
- Timeline.SampleToInstrument += (item, t) => DropBrowserItem(item, t); // audio clip → Grain / Drum Rack / Sampler…
+ Timeline.SampleToInstrument += (item, t) => { DropBrowserItem(item, t); Timeline.Select(t, -1); }; // audio clip → Grain / Drum Rack / Sampler… (that track becomes the selection)
Timeline.DevicesPeekRequested += t => { if (_deviceChain?.TrackId != t) ShowDevices(t); };
Timeline.PasteBouncedRequested += (track, beat) => _ = PasteBouncedAsync(track, beat);
Timeline.ConvertClipRequested += OnConvertClip; // audio clip → MIDI (Convert / Slice)
diff --git a/src/managed/Nota.App/SessionView.cs b/src/managed/Nota.App/SessionView.cs
index 1937d5d5..afaa429e 100644
--- a/src/managed/Nota.App/SessionView.cs
+++ b/src/managed/Nota.App/SessionView.cs
@@ -291,6 +291,12 @@ public sealed partial class SessionView : UserControl
SlotSelected?.Invoke(sel.TrackId, sel.Scene);
}
+ /// <summary>Selects the slot at (<paramref name="trackId"/>, <paramref name="scene"/>) — e.g. where a browser drop landed.</summary>
+ internal void SelectSlot(int trackId, int scene)
+ {
+ if (ColumnFor(trackId) is not null) Select(new Selection(SelKind.Slot, trackId, scene));
+ }
+
private void InvalidateAll()
{
foreach (var c in _cols) { foreach (var cell in c.Cells) cell.InvalidateVisual(); c.Header?.Sync(); }