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) Minor UI fixes

Egor Khindikaynend50840de442b
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index 11b3731c..de95d5d5 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -1281,55 +1281,37 @@ public sealed partial class ArrangementView
// Draws one clip (fill + border + name strip + notes/waveform) at row-y with
// the given track colour. Reused for the live cross-track drag preview.
// Group lane preview: collapsed → each descendant clip as a mini-clip stacked into its
- // own sub-lane (child colour), so starts/ends read at a glance; expanded → a thin strip
- // in the group colour over each descendant clip's span, marking content boundaries.
+ // own sub-lane (child colour), so starts/ends read at a glance; expanded → nothing (the
+ // children are right below and show their own clips).
private void DrawGroupLane(DrawingContext ctx, ArrangementView.TrackVM g, double y, double rowH, double w, bool collapsed)
{
- if (g.GroupMini.Count == 0) return;
- if (collapsed)
+ if (!collapsed || g.GroupMini.Count == 0) return;
+ // Collapsed: the hidden children still have to read, so each takes a sub-lane
+ // of the (slim) row. Below ~3px a sub-lane stops being legible — past that the
+ // stack degrades to one merged span strip.
+ int slots = Math.Max(1, g.GroupSlotCount);
+ const double padTop = 5, padBot = 5;
+ double innerH = rowH - padTop - padBot;
+ double laneH = innerH / slots;
+ if (laneH >= 2.5)
{
- // Collapsed: the hidden children still have to read, so each takes a sub-lane
- // of the (slim) row. Below ~3px a sub-lane stops being legible — past that the
- // stack degrades to one merged span strip.
- int slots = Math.Max(1, g.GroupSlotCount);
- const double padTop = 5, padBot = 5;
- double innerH = rowH - padTop - padBot;
- double laneH = innerH / slots;
- if (laneH >= 2.5)
- {
- double barH = Math.Max(2, laneH - 1);
- foreach (var m in g.GroupMini)
- {
- double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
- if (x1 < 0 || x0 > w || m.Length <= 0) continue;
- var (fill, border, _, _) = ClipColors(m.ColorIndex);
- var r = new Rect(x0, y + padTop + m.Slot * laneH, Math.Max(2, x1 - x0), barH);
- ctx.DrawRectangle(fill, border, r, 1.5, 1.5);
- }
- return;
- }
+ double barH = Math.Max(2, laneH - 1);
foreach (var m in g.GroupMini)
{
double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
if (x1 < 0 || x0 > w || m.Length <= 0) continue;
var (fill, border, _, _) = ClipColors(m.ColorIndex);
- ctx.DrawRectangle(fill, border, new Rect(x0, y + padTop, Math.Max(2, x1 - x0), innerH), 1.5, 1.5);
+ var r = new Rect(x0, y + padTop + m.Slot * laneH, Math.Max(2, x1 - x0), barH);
+ ctx.DrawRectangle(fill, border, r, 1.5, 1.5);
}
+ return;
}
- else
+ foreach (var m in g.GroupMini)
{
- var col = TrackColorForIndex(g.ColorIndex);
- var fill = Alpha(col, 0.55);
- var border = new Pen(Alpha(col, 0.85), 1);
- double stripH = Math.Min(6, Math.Max(3, rowH - 12));
- double sy = y + (rowH - stripH) / 2;
- foreach (var m in g.GroupMini)
- {
- double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
- if (x1 < 0 || x0 > w || m.Length <= 0) continue;
- var r = new Rect(x0, sy, Math.Max(2, x1 - x0), stripH);
- ctx.DrawRectangle(fill, border, r, 3, 3);
- }
+ double x0 = _o.BeatToX(m.Start), x1 = _o.BeatToX(m.Start + m.Length);
+ if (x1 < 0 || x0 > w || m.Length <= 0) continue;
+ var (fill, border, _, _) = ClipColors(m.ColorIndex);
+ ctx.DrawRectangle(fill, border, new Rect(x0, y + padTop, Math.Max(2, x1 - x0), innerH), 1.5, 1.5);
}
}
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index fc5668b9..dd477f7e 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -553,26 +553,44 @@ public sealed partial class ArrangementView : UserControl
internal void SetLoopRegion(double startBeat, double endBeat)
{
if (_engine is null) return;
- double s = Math.Max(0, Snap(Math.Min(startBeat, endBeat)));
- double e = Math.Max(s + _snapBeats, Snap(Math.Max(startBeat, endBeat)));
+ var (s, e) = SnapLoopRange(startBeat, endBeat);
_engine.SetLoop(true, s, e);
_loopActive = true; _loopS = s; _loopE = e; _loopDragging = false;
Redraw();
LoopChanged?.Invoke();
}
+ private (double Start, double End) SnapLoopRange(double a, double b)
+ {
+ double s = Math.Max(0, Snap(Math.Min(a, b)));
+ return (s, Math.Max(s + _snapBeats, Snap(Math.Max(a, b))));
+ }
+
/// <summary>Loop over the beat span of the current clip selection. False if nothing selected.</summary>
public bool LoopSelection()
{
- if (_engine is null || _sel.Count == 0) return false;
+ if (_engine is null || ClipSelectionSpan() is not { } span) return false;
+ SetLoopRegion(span.Start, span.End);
+ return true;
+ }
+
+ private (double Start, double End)? ClipSelectionSpan()
+ {
+ if (_sel.Count == 0) return null;
double min = double.MaxValue, max = double.MinValue;
foreach (var t in _tracks)
foreach (var c in t.Clips)
if (_sel.Contains((t.Id, c.ClipIndex)))
{ min = Math.Min(min, c.StartBeat); max = Math.Max(max, c.StartBeat + c.LengthBeats); }
- if (max <= min) return false;
- SetLoopRegion(min, max);
- return true;
+ return max > min ? (min, max) : null;
+ }
+
+ /// <summary>The (snapped) loop region the current selection asks for — a time-range
+ /// selection wins, else the span of the selected clips. Null when nothing is selected.</summary>
+ public (double Start, double End)? SelectionLoopRange()
+ {
+ if (HasTimeSelection) return SnapLoopRange(_timeSelStart, _timeSelEnd);
+ return ClipSelectionSpan() is { } span ? SnapLoopRange(span.Start, span.End) : null;
}
/// <summary>Pushes fresh per-track meter readings into the header meters (~30 Hz, M6-2),
@@ -1311,14 +1329,6 @@ public sealed partial class ArrangementView : UserControl
return true;
}
- /// <summary>Cmd+L over a time selection: loop exactly that range. False when there's no range.</summary>
- public bool LoopTimeSelection()
- {
- if (_engine is null || !HasTimeSelection) return false;
- SetLoopRegion(_timeSelStart, _timeSelEnd);
- return true;
- }
-
/// <summary>Duplicate the time selection right after its end and move the selection onto
/// the copy, so repeated presses chain (req 4.1-range).</summary>
public bool DuplicateTimeSelection()
diff --git a/src/managed/Nota.App/MainWindow.Menu.cs b/src/managed/Nota.App/MainWindow.Menu.cs
index 371dafe9..b931c288 100644
--- a/src/managed/Nota.App/MainWindow.Menu.cs
+++ b/src/managed/Nota.App/MainWindow.Menu.cs
@@ -195,9 +195,17 @@ public partial class MainWindow
private void OnMenuLoop(object? sender, EventArgs e)
{
if (_vm is null) return;
- // A time-range selection wins: loop exactly that range (and enable looping).
- if (Timeline.LoopTimeSelection()) { _vm.StatusText = "Loop set to selection"; return; }
- _vm.Transport.LoopOn = !_vm.Transport.LoopOn;
+ // A selection (time range, else selected clips) sets the loop to exactly that
+ // range and enables it; pressing again once it already loops it turns looping off.
+ var t = _vm.Transport;
+ if (Timeline.SelectionLoopRange() is { } r
+ && !(t.LoopOn && Engine.LoopStart == r.Start && Engine.LoopEnd == r.End))
+ {
+ Timeline.SetLoopRegion(r.Start, r.End);
+ _vm.StatusText = "Loop set to selection";
+ return;
+ }
+ t.LoopOn = !t.LoopOn;
}
private void OnMenuMetronome(object? sender, EventArgs e) { if (_vm is not null) _vm.Transport.MetronomeOn = !_vm.Transport.MetronomeOn; }
}
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index 89e95fed..0eb47409 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -269,6 +269,7 @@ public partial class MainWindow : Window
vm.RecordingTick += () => { Timeline.Refresh(rebuildHeaders: false); ReloadEditorNotes(); };
// Hit Record with nothing armed → auto-arm the selected/last track (M-fix).
vm.Transport.RecordArmTarget = () => Timeline.RecordArmTarget();
+ vm.Transport.SelectionLoopRange = () => Timeline.SelectionLoopRange();
vm.Transport.TracksChanged += () => { Timeline.Refresh(); ReloadEditorNotes(); };
Timeline.LoopChanged += () => vm.Transport.SyncLoop(); // ruler drag / "Loop selection" → transport bar
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index a05928a2..55e9d588 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -650,7 +650,7 @@ public sealed class PreferencesWindow : NotaWindow
("Return", "Stop (again → back to the start)"),
("⌘R", "Record"),
("⌘M", "Metronome"),
- ("⌘L", "Loop on / off · loop the time selection"),
+ ("⌘L", "Loop on / off · loop the selected clips or time range"),
}),
("ARRANGEMENT & EDITING", new[]
{
diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axaml
index a84ba39e..54ed3f08 100644
--- a/src/managed/Nota.App/Theme/NotaTheme.axaml
+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml
@@ -353,6 +353,7 @@
</Style>
<Style Selector="Button.primary:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.AccentHover}"/>
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>
</Style>
<Style Selector="Button.ghost">
diff --git a/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs b/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
index 985d776f..146aafb0 100644
--- a/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs
@@ -43,6 +43,10 @@ public partial class TransportViewModel(IAudioEngine engine) : ObservableObject
/// armed (0 = none). Lets "hit Record" work without a separate arm click.</summary>
public Func<int>? RecordArmTarget { get; set; }
+ /// <summary>Supplies the loop region the current arrangement selection asks for (a
+ /// selected clip / time range), or null. Turning the loop on uses it when present.</summary>
+ public Func<(double Start, double End)?>? SelectionLoopRange { get; set; }
+
/// <summary>Fired after auto-arming a track so the track headers can refresh.</summary>
public event Action? TracksChanged;
@@ -67,7 +71,9 @@ public partial class TransportViewModel(IAudioEngine engine) : ObservableObject
if (_syncingLoop) return; // reflecting engine state, not a user toggle
// Toggle over the current region (set from the arrangement ruler / "Loop
// selection"); fall back to the first four bars if none has been set.
+ // Turning it on with something selected in the arrangement loops that selection.
double s = _engine.LoopStart, e = _engine.LoopEnd;
+ if (value && SelectionLoopRange?.Invoke() is { } sel) (s, e) = sel;
if (e <= s) { s = 0; e = 4 * BeatsPerBar; }
_engine.SetLoop(value, s, e);
LoopRangeText = FormatRange(s, e);