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.

(style) Redesign of plugin host window

Egor Khindikaynen08cd7cb576dc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1d8de015..96d30ae7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -92,6 +92,13 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
- **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 the device window.** This is the window that opens a device from a
+ Drum Rack, an Instrument Rack, an Audio Effect Rack or a Nota Rhythm voice. Its title
+ bar shows the device, the track, the preset picker and the bypass switch. A two-size
+ instrument such as Nota Synth also gets its S / L switch there. A bar at the bottom shows
+ where the device sits (pad, chain or voice), its live voice count and its type. On a
+ small window, the preset picker moves to its own row. Effects now open at their own
+ width with the usual padding, and a bypassed effect is marked in the window.
- **A new look for Settings.** The window is larger, and the sidebar groups its pages
under Devices, Plug-ins and General, each with an icon. Every page has a short
description under its title. MIDI inputs and the other on/off options use larger
diff --git a/src/managed/Nota.App/DeviceCardKit.cs b/src/managed/Nota.App/DeviceCardKit.cs
index 32ce8057..0dc91ed8 100644
--- a/src/managed/Nota.App/DeviceCardKit.cs
+++ b/src/managed/Nota.App/DeviceCardKit.cs
@@ -327,9 +327,9 @@ internal static class DeviceCardKit
// Clicks are handled so they neither select nor start dragging the card. Shared by the
// card shell and the rack chain full-UI popups.
internal static Control PresetPicker(IReadOnlyList<string> presets, int cur, string current,
- Action<int> apply, Action<int> step, double nameWidth = 132)
+ Action<int> apply, Action<int> step, double nameWidth = 132, double height = 18)
{
- const double H = 18;
+ double H = height; // 18 in a card header, 22 in the device window's title bar
var label = new TextBlock
{
Text = string.IsNullOrEmpty(current) ? "Init" : current, FontSize = NotaType.Value + 1, FontWeight = FontWeight.Medium,
@@ -339,7 +339,7 @@ internal static class DeviceCardKit
DockPanel.SetDock(chevron, Dock.Right);
var name = new Border
{
- Width = nameWidth, Padding = new Thickness(7, 0, 6, 0), Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
+ Width = nameWidth, Padding = new Thickness(7, 0, 6, 0), // NaN = stretch to the picker's width Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
Child = new DockPanel { Children = { chevron, label } },
};
ToolTip.SetTip(name, "Choose a preset");
@@ -380,7 +380,12 @@ internal static class DeviceCardKit
{
Height = H, Background = NotaPalette.BgSunken, BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(1),
CornerRadius = NotaRadius.Control, ClipToBounds = true, VerticalAlignment = VerticalAlignment.Center,
- Child = new StackPanel { Orientation = Orientation.Horizontal, Children = { Step(-1), Rule(), name, Rule(), Step(+1) } },
+ Child = new Grid
+ {
+ ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*,Auto,Auto"),
+ Children = { Step(-1), At(Rule(), 1), At(name, 2), At(Rule(), 3), At(Step(+1), 4) },
+ },
};
+ static Control At(Control c, int col) { Grid.SetColumn(c, col); return c; }
}
}
diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
index aeafc866..c0ca4be7 100644
--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
@@ -421,14 +421,94 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
// Full GUI: hosted plug-in → its native window; built-in Sampler → the tabbed editor
// (drop-to-load); other built-ins → their bespoke editor hosted over the chain's param
- // surface via a proxy engine (so Volt/Aurora/… show their real UI, not just knobs).
+ // surface via a proxy engine (so Volt/Aurora/… show their real UI, not just knobs) — both
+ // in the device window, with the card's presets and, for a two-size instrument, S / L.
private void OpenChainInstrumentGui(IRackAccess a, int sc, Control anchor)
{
int ik = a.ChainInstrumentKind(sc);
if (ik == -1) { try { E.RackOpenChainInstrumentEditor(T, sc); } catch { /* no-op */ } return; }
- if (ik == 1) { OpenChainSamplerWindow(anchor, sc, InstrumentPresets(a, sc, ik)); return; }
+ if (ik == 1) { OpenChainSamplerWindow(a, anchor, sc, InstrumentPresets(a, sc, ik)); return; }
string nm = string.IsNullOrEmpty(a.ChainInstrumentName(sc)) ? "Instrument" : a.ChainInstrumentName(sc);
- OpenFullUiWindow(anchor, nm, tickReg => BuildChainInstrumentBespoke(ik, sc, tickReg), InstrumentPresets(a, sc, ik));
+ var strategy = _irFactory.Resolve(ik, true);
+ var proxy = ChainInstrumentProxy(sc);
+ var presets = InstrumentPresets(a, sc, ik);
+ DeviceWindow win = null!;
+ win = new DeviceWindow(nm, E.GetTrackName(T), strategy.Subtitle, tickReg =>
+ {
+ bool two = InstrumentView.Index(proxy, T) >= 0;
+ double w = strategy.BodyOnly ? strategy.WidthFor(proxy, T) : 700;
+ return new DeviceWindowPage(BuildChainInstrumentBespoke(ik, sc, tickReg, w), w, CardBodyH, WindowPresets(presets, () => win.Refill()),
+ two ? new DeviceWindowSize(InstrumentView.IsMini(proxy, T), m => InstrumentView.SetMini(proxy, T, m)) : null);
+ }, status: () => InstrumentStatus(a, sc, proxy, strategy));
+ win.ShowFrom(anchor);
+ }
+
+ private const double CardBodyH = DeviceCardKit.CardH - DeviceCardKit.HeaderH;
+
+ // ---- device window: where the device lives + a live line for its status bar ----
+
+ // "Drum Rack · pad C1 Kick", "Instrument Rack · chain 2 Lead", "Audio Effect Rack ·
+ // chain 1", "Nota Rhythm · voice 3".
+ private string ChainLocation(IRackAccess a, int sc)
+ {
+ switch (a)
+ {
+ case InstrumentRackAccess:
+ string n = E.RackChainName(T, sc);
+ if (E.TrackInstrumentKind(T) == 4)
+ return $"Drum Rack · pad {NoteName(a.ChainTriggerNote(sc))}{(n.Length > 0 ? " " + n : "")}";
+ return $"Instrument Rack · chain {sc + 1}{(n.Length > 0 ? " " + n : "")}";
+ case EffectRackAccess:
+ return $"Audio Effect Rack · chain {sc + 1}";
+ case RhythmVoiceAccess:
+ return $"Nota Rhythm · voice {sc + 1}";
+ default:
+ return $"chain {sc + 1}";
+ }
+ }
+
+ private string InstrumentStatus(IRackAccess a, int sc, IAudioEngine proxy, IInstrumentCard strategy)
+ {
+ string where = ChainLocation(a, sc);
+ int v = proxy.InstrumentVoiceCount(T);
+ if (v < 0) return where;
+ string voices = strategy.VoiceLabel(proxy, T, v) ?? $"{Math.Max(0, v)}/16";
+ return $"{where} · voices {voices}";
+ }
+
+ private string DeviceStatus(IRackAccess a, int sc, int d)
+ {
+ int n = a.ChainDeviceCount(sc);
+ return d < n ? $"{ChainLocation(a, sc)} · effect {d + 1} of {n}" : ChainLocation(a, sc);
+ }
+
+ // A chain effect's bypass for its window; a flip there rebuilds the rack card so the
+ // slot follows (the window reads the state live, so a flip on the card follows too).
+ private DeviceWindowBypass ChainDeviceBypass(IRackAccess a, int sc, int d) => new(
+ () => d < a.ChainDeviceCount(sc) && a.ChainDeviceBypassed(sc, d),
+ b =>
+ {
+ if (d >= a.ChainDeviceCount(sc)) return;
+ a.SetChainDeviceBypassed(sc, d, b);
+ _ctx.RequestRebuild();
+ });
+
+ // The chain presets as the window's picker; applying one re-fills the window (so every
+ // control shows the new values) and nudges the rack's inline faders.
+ private DeviceWindowPresets? WindowPresets(ChainPresets presets, Action refill)
+ {
+ var items = presets.Items;
+ if (items.Count == 0) return null;
+ int cur = -1;
+ if (_chainPresetIds.TryGetValue(presets.Key, out var curId))
+ for (int i = 0; i < items.Count; i++) if (items[i].Id == curId) { cur = i; break; }
+ return new DeviceWindowPresets(items.Select(p => p.Name).ToList(), cur, i =>
+ {
+ presets.Apply(items[i].Id);
+ _chainPresetIds[presets.Key] = items[i].Id;
+ _ctx.InvokeRackParamRefreshers();
+ refill();
+ });
}
// ---- full-UI popup header: the device's name + its factory-preset picker ----
@@ -465,47 +545,10 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
return proxy;
}
- // The card shell's header, for a popup: name on the left, preset picker on the right.
- // Applying a preset re-fills the popup (so every control shows the new values) and
- // nudges the rack's inline faders.
- private Control WithPopupHeader(string title, ChainPresets presets, Control content, Action refill)
- {
- var name = new TextBlock
- {
- Text = title, FontSize = NotaType.DeviceName, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary,
- VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
- };
- var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8, Children = { name } };
- var items = presets.Items;
- if (items.Count > 0)
- {
- int cur = -1;
- if (_chainPresetIds.TryGetValue(presets.Key, out var curId))
- for (int i = 0; i < items.Count; i++) if (items[i].Id == curId) { cur = i; break; }
- void Apply(int i)
- {
- presets.Apply(items[i].Id);
- _chainPresetIds[presets.Key] = items[i].Id;
- _ctx.InvokeRackParamRefreshers();
- refill();
- }
- void Step(int dir) { int n = items.Count; Apply(cur < 0 ? (dir > 0 ? 0 : n - 1) : ((cur + dir) % n + n) % n); }
- var picker = PresetPicker(items.Select(p => p.Name).ToList(), cur, cur >= 0 ? items[cur].Name : "", Apply, Step);
- Grid.SetColumn(picker, 1); grid.Children.Add(picker);
- }
- var header = new Border
- {
- Height = HeaderH, Background = NotaPalette.SurfaceCard, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1),
- Padding = new Thickness(NotaSpace.DeviceInsetWide, 0), Child = grid,
- };
- DockPanel.SetDock(header, Dock.Top);
- return new DockPanel { Children = { header, content } };
- }
-
// Host a built-in instrument's own editor for a rack chain: a DispatchProxy redirects
// the editor's plugin-param calls (track, -1, i) to the chain surface (track, chain, i);
// a local tick drives its live graphs + knob follow.
- private Control BuildChainInstrumentBespoke(int ik, int sc, Action<Action> tickReg)
+ private Control BuildChainInstrumentBespoke(int ik, int sc, Action<Action> tickReg, double width = 700)
{
var proxy = ChainInstrumentProxy(sc);
var faders = new System.Collections.Generic.List<(int i, Knob k, TextBlock v, Func<float, string>? fmt)>();
@@ -514,43 +557,44 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
_ => { }, () => 0, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { }, _ctx.Factory);
var body = _irFactory.Resolve(ik, true).Build(ctx);
tickReg(() => { viz?.Invoke(); foreach (var f in faders) { if (f.k.Dragging) continue; float v = proxy.PluginParamGet(T, -1, f.i); if (Math.Abs(v - f.k.Value) > 1e-3) { f.k.Value = v; f.v.Text = (f.fmt ?? Pct)(v); } } });
- return new Border { Width = 700, Height = DeviceCardKit.CardH - DeviceCardKit.HeaderH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = body };
+ return new Border { Width = width, Height = CardBodyH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = body };
}
// Sampler pop-out that also accepts a dropped sample file (browser or Finder) → load it
// into the chain's Sampler and rebuild the editor.
- private void OpenChainSamplerWindow(Control anchor, int sc, ChainPresets presets)
+ private void OpenChainSamplerWindow(IRackAccess a, Control anchor, int sc, ChainPresets presets)
{
var acc = new ChainSamplerAccess(E, T, sc);
- var ticks = new System.Collections.Generic.List<Action>();
- var timer = new Avalonia.Threading.DispatcherTimer { Interval = TimeSpan.FromMilliseconds(33) };
- timer.Tick += (_, _) => { for (int i = 0; i < ticks.Count; i++) ticks[i](); };
- var win = new NotaPopupWindow { Title = "Nota Sampler", SizeToContent = SizeToContent.WidthAndHeight, CanResize = false, ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterOwner };
- void Rebuild()
+ DeviceWindow win = null!;
+ win = new DeviceWindow("Nota Sampler", E.GetTrackName(T), _irFactory.Resolve(1, true).Subtitle, tickReg =>
{
- ticks.Clear();
- var wrap = new Border { Width = 700, Height = DeviceCardKit.CardH - DeviceCardKit.HeaderH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = SamplerInstrumentCard.BuildEditor(E, acc, ticks.Add) };
+ var wrap = new Border { Width = 700, Height = CardBodyH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = SamplerInstrumentCard.BuildEditor(E, acc, tickReg) };
DragDrop.SetAllowDrop(wrap, true);
DragDrop.AddDragOverHandler(wrap, (_, e) => { if (!BrowserView.IsAcceptableDrag(e)) { e.DragEffects = DragDropEffects.None; return; } e.DragEffects = DragDropEffects.Copy; e.Handled = true; });
- DragDrop.AddDropHandler(wrap, (_, e) => { foreach (var it in BrowserView.DroppedItems(e)) if (it.Kind == Nota.Presentation.BrowserItemKind.Sample) { acc.LoadSample(it.Path); Rebuild(); break; } e.Handled = true; });
- win.SetContent(WithPopupHeader("Nota Sampler", presets, wrap, Rebuild));
- }
- Rebuild();
- win.Opened += (_, _) => timer.Start();
- win.Closed += (_, _) => timer.Stop();
- ShowPopup(win, anchor);
+ DragDrop.AddDropHandler(wrap, (_, e) => { foreach (var it in BrowserView.DroppedItems(e)) if (it.Kind == Nota.Presentation.BrowserItemKind.Sample) { acc.LoadSample(it.Path); win.Refill(); break; } e.Handled = true; });
+ return new DeviceWindowPage(wrap, 700, CardBodyH, WindowPresets(presets, () => win.Refill()));
+ }, status: () => InstrumentStatus(a, sc, ChainInstrumentProxy(sc), _irFactory.Resolve(1, true)));
+ win.ShowFrom(anchor);
}
private void OpenChainInstrumentParams(IRackAccess a, int sc, Control anchor)
{
string nm = string.IsNullOrEmpty(a.ChainInstrumentName(sc)) ? "Instrument" : a.ChainInstrumentName(sc);
- OpenFullUiWindow(anchor, nm + " · params", _ => ParamGridContent(nm, a.ChainInstrumentParamCount(sc), p => RackInstParamRow(a, sc, p)));
+ OpenParamWindow(anchor, nm, a.ChainInstrumentParamCount(sc), p => RackInstParamRow(a, sc, p), () => InstrumentStatus(a, sc, ChainInstrumentProxy(sc), _irFactory.Resolve(a.ChainInstrumentKind(sc), true)));
}
private void OpenChainDeviceGui(IRackAccess a, int sc, int d, Control anchor)
{
int kind = a.ChainDeviceBuiltinKind(sc, d);
if (kind < 0) { a.OpenChainDeviceEditor(sc, d); return; } // hosted plug-in → native window
string nm = a.ChainDeviceName(sc, d);
- OpenFullUiWindow(anchor, nm, tickReg => BuildChainDeviceBespoke(a, sc, d, kind, tickReg), DevicePresets(a, sc, d, kind)); // built-in → its real device card
+ var strategy = _irDeviceFactory.Resolve(kind);
+ var presets = DevicePresets(a, sc, d, kind);
+ DeviceWindow win = null!;
+ win = new DeviceWindow(nm, E.GetTrackName(T), strategy.Subtitle ?? "", tickReg => // built-in → its real device card
+ {
+ double w = strategy.AutoWidth ? double.NaN : strategy.Width;
+ return new DeviceWindowPage(BuildChainDeviceBespoke(a, sc, d, kind, tickReg), w, CardBodyH, WindowPresets(presets, () => win.Refill()));
+ }, ChainDeviceBypass(a, sc, d), () => DeviceStatus(a, sc, d));
+ win.ShowFrom(anchor);
}
// Host a built-in effect's own device card for a rack chain: a DispatchProxy redirects
@@ -560,13 +604,15 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
{
var proxy = ChainDeviceProxy(a, sc, d, kind);
var ctx = new DeviceCardContext(proxy, T, tickReg, () => { }, (_, _, _, _) => { }, _ => { }, _ => { }, () => sc, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { }, _ctx.Factory);
- var body = _irDeviceFactory.Resolve(kind).Build(ctx, a.AutomationDeviceIndex);
- return new Border { Width = 700, Height = DeviceCardKit.CardH - DeviceCardKit.HeaderH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = body };
+ var strategy = _irDeviceFactory.Resolve(kind);
+ var body = strategy.Build(ctx, a.AutomationDeviceIndex);
+ // As in the device chain: the almanac body inset (6) unless the body pads itself.
+ return strategy.FullBleed ? body : new Border { Padding = new Thickness(NotaSpace.DeviceInset), Child = body };
}
private void OpenChainDeviceParams(IRackAccess a, int sc, int d, Control anchor)
{
string dnm = a.ChainDeviceName(sc, d);
- OpenFullUiWindow(anchor, dnm + " · params", _ => ParamGridContent(dnm, a.ChainDeviceParamCount(sc, d), p => RackDeviceParamRow(a, sc, d, p)));
+ OpenParamWindow(anchor, dnm, a.ChainDeviceParamCount(sc, d), p => RackDeviceParamRow(a, sc, d, p), () => DeviceStatus(a, sc, d), ChainDeviceBypass(a, sc, d));
}
private void ShowAddChainMenu(IRackAccess a, Control anchor)
@@ -1157,64 +1203,36 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
Control fullBtn;
if (ik == -1) fullBtn = ActionChip("Full", () => { try { E.RackOpenChainInstrumentEditor(T, sc); } catch { /* no-op */ } });
- else if (ik == 1) { Border b = null!; b = ActionChip("Full", () => OpenChainSamplerWindow(b, sc, InstrumentPresets(a, sc, ik))); fullBtn = b; }
- else fullBtn = FullUiChip(nm, _ => ParamGridContent(nm, a.ChainInstrumentParamCount(sc), p => RackInstParamRow(a, sc, p)));
+ else if (ik == 1) { Border b = null!; b = ActionChip("Full", () => OpenChainSamplerWindow(a, b, sc, InstrumentPresets(a, sc, ik))); fullBtn = b; }
+ else fullBtn = FullUiChip(nm, a.ChainInstrumentParamCount(sc), p => RackInstParamRow(a, sc, p), () => ChainLocation(a, sc));
return DeviceCardShell(nm, fullBtn, body, 180);
}
- // A roomy, non-bespoke "full UI": every param as a knob in a 3-column grid.
- private Control ParamGridContent(string title, int count, Func<int, Control> row)
+ // A roomy, non-bespoke "full UI": every param as a knob in a 3-column grid (the name
+ // is on the device window's title bar).
+ private static Control ParamGridContent(int count, Func<int, Control> row)
{
var wrap = new WrapPanel { MaxWidth = 456 };
for (int p = 0; p < count; p++) wrap.Children.Add(new Border { Width = 148, Margin = new Thickness(2, 3), Child = row(p) });
var scroll = new ScrollViewer { Content = wrap, MaxHeight = 360, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, VerticalScrollBarVisibility = ScrollBarVisibility.Auto };
- return new Border { Width = 476, Background = NotaPalette.BgApp, Padding = new Thickness(10), Child =
- new StackPanel { Spacing = 7, Children = { new TextBlock { Text = title, FontSize = NotaType.DeviceName, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary }, scroll } } };
+ return new Border { Padding = new Thickness(10), Child = scroll };
}
- // A small header button that pops out a device's full UI in a floating window.
- private Border FullUiChip(string title, Func<Action<Action>, Control> build)
+ // Every param as knobs, in the device window (no presets or sizes: it is not the card).
+ private void OpenParamWindow(Control anchor, string name, int count, Func<int, Control> row, Func<string> status, DeviceWindowBypass? bypass = null)
{
- Border chip = null!;
- chip = ActionChip("Full", () => OpenFullUiWindow(chip, title, build));
- return chip;
+ var win = new DeviceWindow(name, E.GetTrackName(T), "PARAMS",
+ _ => new DeviceWindowPage(ParamGridContent(count, row), 476, double.NaN), bypass,
+ () => $"{status()} · {count} parameter{(count == 1 ? "" : "s")}");
+ win.ShowFrom(anchor);
}
- // With presets, the popup gets the name + preset header, and applying one rebuilds the
- // content (fresh tick list) so the editor shows the new values.
- private void OpenFullUiWindow(Control anchor, string title, Func<Action<Action>, Control> build, ChainPresets? presets = null)
+ // A small header button that pops out a device's knobs in the device window.
+ private Border FullUiChip(string name, int count, Func<int, Control> row, Func<string> status, DeviceWindowBypass? bypass = null)
{
- var ticks = new List<Action>();
- var win = new NotaPopupWindow
- {
- Title = title, SizeToContent = SizeToContent.WidthAndHeight, CanResize = false,
- ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterOwner,
- };
- void Fill()
- {
- ticks.Clear();
- var content = build(ticks.Add);
- win.SetContent(presets is null ? content : WithPopupHeader(title, presets, content, Fill));
- }
- Fill();
- var timer = new Avalonia.Threading.DispatcherTimer { Interval = TimeSpan.FromMilliseconds(33) };
- timer.Tick += (_, _) => { for (int i = 0; i < ticks.Count; i++) ticks[i](); };
- win.Opened += (_, _) => { if (ticks.Count > 0) timer.Start(); };
- win.Closed += (_, _) => timer.Stop();
- ShowPopup(win, anchor);
- }
-
- // Show a rack full-UI/params popup over its owner and, if that owner is the main
- // window, wire the popup's MIDI-learn glass to the shared service so its controls
- // can be highlighted/selected while learn is armed.
- private static void ShowPopup(NotaPopupWindow win, Control anchor)
- {
- if (TopLevel.GetTopLevel(anchor) is Window owner)
- {
- if (owner is MainWindow mw) win.EnableMidiLearn(mw.LearnService);
- win.Show(owner);
- }
- else win.Show();
+ Border chip = null!;
+ chip = ActionChip("Full", () => OpenParamWindow(chip, name, count, row, status, bypass));
+ return chip;
}
private Control ChainDeviceCard(IRackAccess a, int sc, int d)
@@ -1226,7 +1244,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
// Full UI: hosted-plugin effect → its native window; built-in effect → roomy knob grid.
ctrls.Children.Add(a.ChainDeviceBuiltinKind(sc, d) < 0
? ActionChip("Full", () => a.OpenChainDeviceEditor(sc, d))
- : FullUiChip(dnm, _ => ParamGridContent(dnm, a.ChainDeviceParamCount(sc, d), p => RackDeviceParamRow(a, sc, d, p))));
+ : FullUiChip(dnm, a.ChainDeviceParamCount(sc, d), p => RackDeviceParamRow(a, sc, d, p), () => DeviceStatus(a, sc, d), ChainDeviceBypass(a, sc, d)));
ctrls.Children.Add(Glyph(GlyphKind.StepLeft, d > 0, () => { a.MoveChainDevice(sc, d, d - 1); _ctx.RequestRebuild(); }));
ctrls.Children.Add(Glyph(GlyphKind.StepRight, d < dc - 1, () => { a.MoveChainDevice(sc, d, d + 1); _ctx.RequestRebuild(); }));
ctrls.Children.Add(Glyph(GlyphKind.Close, true, () => { a.RemoveChainDevice(sc, d); _ctx.RequestRebuild(); }));
diff --git a/src/managed/Nota.App/DeviceWindow.cs b/src/managed/Nota.App/DeviceWindow.cs
new file mode 100644
index 00000000..6c73554e
--- /dev/null
+++ b/src/managed/Nota.App/DeviceWindow.cs
@@ -0,0 +1,328 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The device window — a rack chain's instrument or effect popped out of a Drum Rack,
+// Instrument Rack, Audio Effect Rack or Nota Rhythm voice. The card's header moves into
+// the window's own title bar: name · track on the left, then the preset picker
+// "‹ Name ⌄ ›", the S / L size and the bypass switch. The device body sits below at its
+// card size, and a status bar closes the window (a one-line summary + the processing-type
+// badge).
+//
+// The title bar shares its row with the OS window buttons — the traffic lights on the
+// left on macOS, the caption buttons on the right on Windows (Linux keeps the native
+// frame above). Whatever does not fit beside them — always the preset picker on a mini
+// (260) body — moves to a second row under the title bar, so nothing slides under a
+// window button.
+
+using System;
+using System.Collections.Generic;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Threading;
+
+namespace Nota.App;
+
+/// <summary>A device's presets for the window's picker: names, the current one (-1 = none
+/// applied yet, shown as Init) and how to apply one.</summary>
+internal sealed record DeviceWindowPresets(IReadOnlyList<string> Names, int Current, Action<int> Apply);
+
+/// <summary>A device that comes in two sizes: whether it is at S, and how to switch.</summary>
+internal sealed record DeviceWindowSize(bool Mini, Action<bool> SetMini);
+
+/// <summary>A device that can be bypassed (read live, so a flip elsewhere follows).</summary>
+internal sealed record DeviceWindowBypass(Func<bool> Get, Action<bool> Set);
+
+/// <summary>One build of the window's content. <see cref="BodyHeight"/> NaN = the body's
+/// own height (the param grid); a device body is the card body height.</summary>
+internal sealed record DeviceWindowPage(Control Body, double BodyWidth, double BodyHeight,
+ DeviceWindowPresets? Presets = null, DeviceWindowSize? Size = null);
+
+internal sealed class DeviceWindow : NotaWindow
+{
+ public const double BarH = 32, RowH = 30, StatusH = 22, PickerW = 188, PickerH = 22;
+ private const double Gap = 10, NameMin = 90; // the least the name · track keeps in the title row
+ // Room the OS window buttons take in the title row: the macOS traffic lights (left) and
+ // the Windows caption buttons (3 × 46, right). Linux draws its frame above the window.
+ private static readonly double LeftInset = !NativeFrame && OperatingSystem.IsMacOS() ? 76 : 12;
+ private static readonly double RightInset = !NativeFrame && OperatingSystem.IsWindows() ? 8 + 138 : 8;
+
+ private readonly string _name, _context, _badge;
+ private readonly Func<Action<Action>, DeviceWindowPage> _build;
+ private readonly DeviceWindowBypass? _bypass;
+ private readonly Func<string>? _status;
+ private readonly List<Action> _ticks = new();
+ private readonly DispatcherTimer _timer = new() { Interval = TimeSpan.FromMilliseconds(33) };
+ private TextBlock _statusText = MonoText(10, NotaPalette.TextMuted);
+
+ private SwitchTrack? _switch;
+ private Control? _bypassTag, _bodyHost;
+ private bool? _shownBypassed; // null = not yet painted for the current body
+
+ /// <param name="name">The device name ("Nota Bass").</param>
+ /// <param name="context">Where it lives, shown after the name ("Keys · pad C1").</param>
+ /// <param name="badge">The processing type for the status bar ("SUBTRACTIVE").</param>
+ /// <param name="build">Builds the content; registers its live-follow ticks. Called again
+ /// by <see cref="Refill"/> (a preset applied, the size switched, a sample dropped).</param>
+ public DeviceWindow(string name, string context, string badge, Func<Action<Action>, DeviceWindowPage> build,
+ DeviceWindowBypass? bypass = null, Func<string>? status = null) : base(BarH)
+ {
+ _name = name; _context = context; _badge = badge.ToUpperInvariant();
+ _build = build; _bypass = bypass; _status = status;
+ Title = context.Length > 0 ? $"{name} · {context}" : name;
+ SizeToContent = SizeToContent.WidthAndHeight;
+ CanResize = false;
+ ShowInTaskbar = false;
+ WindowStartupLocation = WindowStartupLocation.CenterOwner;
+
+ _timer.Tick += (_, _) => Tick();
+ Opened += (_, _) => _timer.Start();
+ Closed += (_, _) => _timer.Stop();
+ Refill();
+ }
+
+ /// <summary>Rebuild the content (fresh ticks) so every control shows the current values.</summary>
+ public void Refill()
+ {
+ _ticks.Clear();
+ var page = _build(_ticks.Add);
+ SetBody(Layout(page));
+ _shownBypassed = null;
+ SyncBypass();
+ SyncStatus();
+ }
+
+ /// <summary>Show over the window that holds <paramref name="anchor"/>; over the main
+ /// window, wire MIDI Learn and forward its keys (transport, note keys, undo …).</summary>
+ public void ShowFrom(Control anchor)
+ {
+ if (TopLevel.GetTopLevel(anchor) is not Window owner) { Show(); return; }
+ if (owner is MainWindow mw)
+ {
+ EnableMidiLearn(mw.LearnService);
+ AddHandler(KeyDownEvent, (_, e) => mw.HandleTransportKeyTunnel(e), RoutingStrategies.Tunnel);
+ KeyDown += (_, e) => { if (!e.Handled) mw.HandleFloatingKeyDown(e); };
+ KeyUp += (_, e) => { if (!e.Handled) mw.HandleKeyUp(e); };
+ }
+ Show(owner);
+ }
+
+ private void Tick()
+ {
+ for (int i = 0; i < _ticks.Count; i++) _ticks[i]();
+ SyncBypass();
+ SyncStatus();
+ }
+
+ // ---- layout ---------------------------------------------------------------------
+
+ private Control Layout(DeviceWindowPage page)
+ {
+ double w = double.IsNaN(page.BodyWidth) ? 0 : page.BodyWidth;
+ double presetW = page.Presets is null ? 0 : PickerW + Gap;
+ double togglesW = (page.Size is null ? 0 : 34 + Gap) + (_bypass is null ? 0 : 26 + Gap);
+ double free = Math.Max(w, 260) - LeftInset - RightInset;
+ // Mini bodies (under 400) always drop the picker to its own row, as does a title
+ // row the window buttons leave too little of.
+ bool presetInBar = page.Presets is null || (w >= 400 && free - presetW - togglesW >= NameMin);
+ bool togglesInBar = page.Presets is not null && presetInBar || free - togglesW >= NameMin;
+
+ var barControls = Row();
+ var rowControls = Row();
+ Control? rowPicker = null;
+ if (page.Presets is { } p)
+ {
+ if (presetInBar) barControls.Children.Add(Picker(p, stretch: false));
+ else rowPicker = Picker(p, stretch: true);
+ }
+ foreach (var c in Toggles(page)) (togglesInBar ? barControls : rowControls).Children.Add(c);
+
+ var dock = new DockPanel();
+ var bar = TitleBar(barControls);
+ DockPanel.SetDock(bar, Dock.Top); dock.Children.Add(bar);
+ if (rowPicker is not null || rowControls.Children.Count > 0)
+ {
+ var row = SecondRow(rowPicker, rowControls);
+ DockPanel.SetDock(row, Dock.Top); dock.Children.Add(row);
+ }
+ var status = StatusBar();
+ DockPanel.SetDock(status, Dock.Bottom); dock.Children.Add(status);
+ dock.Children.Add(BodyArea(page));
+ return dock;
+ }
+
+ private static StackPanel Row() => new()
+ {
+ Orientation = Orientation.Horizontal, Spacing = Gap, VerticalAlignment = VerticalAlignment.Center,
+ };
+
+ // Name · track on the left, the controls that fit on the right. Empty bar area drags
+ // the window (controls handle their own presses).
+ private Control TitleBar(Control controls)
+ {
+ var name = new TextBlock
+ {
+ Text = _name, FontSize = NotaType.Name, FontWeight = FontWeight.SemiBold, Foreground = NotaPalette.TextPrimary,
+ VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ var context = MonoText(10, NotaPalette.TextMuted);
+ context.Text = _context.Length > 0 ? "· " + _context : "";
+ context.Margin = new Thickness(8, 1, 0, 0);
+ // The name keeps its width; the context trims first.
+ var names = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), VerticalAlignment = VerticalAlignment.Center };
+ name.MaxWidth = 260;
+ Grid.SetColumn(context, 1);
+ names.Children.Add(name); names.Children.Add(context);
+
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = Gap };
+ Grid.SetColumn(controls, 1);
+ grid.Children.Add(names); grid.Children.Add(controls);
+
+ var bar = new Border
+ {
+ Height = BarH, Background = NotaPalette.Panel, BorderBrush = NotaPalette.GraphBorder,
+ BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(LeftInset, 0, RightInset, 0), Child = grid,
+ };
+ if (!NativeFrame) bar.PointerPressed += OnChromePressed;
+ return bar;
+ }
+
+ private static Control SecondRow(Control? picker, StackPanel controls)
+ {
+ // The picker stretches across; S / L and bypass (when they moved here) sit right.
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = Gap, VerticalAlignment = VerticalAlignment.Center };
+ if (picker is not null) grid.Children.Add(picker);
+ Grid.SetColumn(controls, 1); grid.Children.Add(controls);
+ return new Border
+ {
+ Height = RowH, Background = NotaPalette.Panel, BorderBrush = NotaPalette.GraphBorder,
+ BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(6, 0), Child = grid,
+ };
+ }
+
+ private Control Picker(DeviceWindowPresets p, bool stretch)
+ {
+ int n = p.Names.Count;
+ void Step(int dir) => p.Apply(p.Current < 0 ? (dir > 0 ? 0 : n - 1) : ((p.Current + dir) % n + n) % n);
+ // The picker's frame + two step cells (20 each, with a rule) leave the rest for the name.
+ var picker = DeviceCardKit.PresetPicker(p.Names, p.Current, p.Current >= 0 ? p.Names[p.Current] : "", p.Apply, Step,
+ nameWidth: stretch ? double.NaN : PickerW - 2 * PickerH - 4, height: PickerH);
+ if (!stretch) picker.Width = PickerW;
+ return picker;
+ }
+
+ private IEnumerable<Control> Toggles(DeviceWindowPage page)
+ {
+ if (page.Size is { } size)
+ {
+ var seg = DeviceCardKit.Segments(new[] { "S", "L" }, () => size.Mini ? 0 : 1,
+ i => { if ((i == 0) != size.Mini) { size.SetMini(i == 0); Dispatcher.UIThread.Post(Refill); } },
+ out _, padX: 0, minSegWidth: 16, fontSize: 9);
+ ToolTip.SetTip(seg, "Size: S (260 × 260) / L (700 × 260)");
+ yield return seg;
+ }
+ if (_bypass is { } byp)
+ {
+ _switch = new SwitchTrack();
+ var host = new Border
+ {
+ Padding = new Thickness(4, 5), Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
+ VerticalAlignment = VerticalAlignment.Center, Child = _switch,
+ };
+ host.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(host).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ byp.Set(!byp.Get());
+ SyncBypass();
+ };
+ yield return host;
+ }
+ }
+
+ private Control BodyArea(DeviceWindowPage page)
+ {
+ _bodyHost = page.Body;
+ var tag = new Border
+ {
+ Height = 18, Padding = new Thickness(7, 0), CornerRadius = NotaRadius.Badge, BorderThickness = new Thickness(1),
+ Background = NotaPalette.AccentSubtle, BorderBrush = NotaPalette.BorderBrass,
+ HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(8),
+ IsHitTestVisible = false, IsVisible = false,
+ Child = Caps(MonoText(9, NotaPalette.AccentHover), "BYPASSED"),
+ };
+ _bypassTag = tag;
+ return new Border
+ {
+ Width = page.BodyWidth, Height = page.BodyHeight, Background = NotaPalette.BgApp, ClipToBounds = true,
+ Child = new Panel { Children = { page.Body, tag } },
+ };
+ }
+
+ private Control StatusBar()
+ {
+ _statusText = MonoText(10, NotaPalette.TextMuted); // fresh per layout: a refill drops the old tree
+ _statusText.TextTrimming = TextTrimming.CharacterEllipsis;
+ var badge = Caps(MonoText(9, NotaPalette.TextTertiary), _badge);
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 12, VerticalAlignment = VerticalAlignment.Center };
+ Grid.SetColumn(badge, 1);
+ grid.Children.Add(_statusText); grid.Children.Add(badge);
+ return new Border
+ {
+ Height = StatusH, Background = NotaPalette.Panel, BorderBrush = NotaPalette.GraphBorder,
+ BorderThickness = new Thickness(0, 1, 0, 0), Padding = new Thickness(10, 0), Child = grid,
+ };
+ }
+
+ // ---- live state -----------------------------------------------------------------
+
+ // Bypassed: the switch goes off, the body loses its brass but stays playable (no
+ // opacity for state) and carries the BYPASSED tag.
+ private void SyncBypass()
+ {
+ bool on = _bypass?.Get() ?? false;
+ if (on == _shownBypassed) return;
+ bool fresh = _shownBypassed is null;
+ _shownBypassed = on;
+ if (_switch is { } sw)
+ {
+ sw.IsOn = !on;
+ if (sw.Parent is Control host) ToolTip.SetTip(host, on ? "Bypassed — click to enable" : "Active — click to bypass");
+ }
+ if (_bypassTag is { } tag) tag.IsVisible = on;
+ if (_bodyHost is not { } body || (fresh && !on)) return;
+ // A fresh body is dimmed once it has laid out (a ScrollViewer's content only exists then).
+ if (body.IsLoaded) Inactive.Set(body, on, interactive: true);
+ else body.Loaded += Deactivate;
+ }
+
+ private void Deactivate(object? sender, RoutedEventArgs e)
+ {
+ if (sender is not Control c) return;
+ c.Loaded -= Deactivate;
+ if (_shownBypassed == true && ReferenceEquals(c, _bodyHost)) Inactive.Set(c, true, interactive: true);
+ }
+
+ private void SyncStatus()
+ {
+ string s = _status?.Invoke() ?? "";
+ if (_statusText.Text != s) _statusText.Text = s;
+ }
+
+ private static TextBlock MonoText(double size, IBrush ink)
+ {
+ var tb = new TextBlock { FontSize = size, Foreground = ink, VerticalAlignment = VerticalAlignment.Center };
+ tb.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");
+ return tb;
+ }
+
+ private static TextBlock Caps(TextBlock tb, string text)
+ {
+ tb.Text = text;
+ tb.LetterSpacing = tb.FontSize * 0.14;
+ return tb;
+ }
+}
diff --git a/src/managed/Nota.App/NotaWindow.cs b/src/managed/Nota.App/NotaWindow.cs
index eed039ec..557b72e5 100644
--- a/src/managed/Nota.App/NotaWindow.cs
+++ b/src/managed/Nota.App/NotaWindow.cs
@@ -29,7 +29,13 @@ public abstract class NotaWindow : Window
// popped-out device chains / clip editors / rack full-UI editors can be mapped too.
private readonly MidiLearnOverlay _learnGlass = new() { IsHitTestVisible = false };
- protected NotaWindow()
+ protected NotaWindow() : this(0) { }
+
+ /// <summary>With <paramref name="ownTitleBarHeight"/> &gt; 0 the subclass draws its own
+ /// title bar of that height at the top of its body (the device window): the client area
+ /// is still extended under the decorations on macOS/Windows, but no shared bar is built.
+ /// Linux keeps the native frame either way.</summary>
+ protected NotaWindow(double ownTitleBarHeight)
{
Background = NotaPalette.BgApp;
@@ -44,7 +50,12 @@ public abstract class NotaWindow : Window
// the window Title) — no extended client area, no custom bar. Matches MainWindow's
// Linux treatment. macOS/Windows get the frameless modern chrome with a slim custom
// title bar (extend the client area, 36px band), so every window reads as one family.
- if (!OperatingSystem.IsLinux())
+ if (!OperatingSystem.IsLinux() && ownTitleBarHeight > 0)
+ {
+ ExtendClientAreaToDecorationsHint = true;
+ ExtendClientAreaTitleBarHeightHint = ownTitleBarHeight;
+ }
+ else if (!OperatingSystem.IsLinux())
{
ExtendClientAreaToDecorationsHint = true;
ExtendClientAreaTitleBarHeightHint = 36;
@@ -109,8 +120,12 @@ public abstract class NotaWindow : Window
/// hosted here can be highlighted/selected while learn is armed.</summary>
public void EnableMidiLearn(MidiLearnService? service) => _learnGlass.Service = service;
+ /// <summary>True when the OS draws the window frame and title (Linux): a subclass's own
+ /// title bar then needs no inset for window buttons and does not drag the window.</summary>
+ protected static bool NativeFrame => OperatingSystem.IsLinux();
+
// Drag the window by its title bar; a double-click toggles maximise when resizable.
- private void OnChromePressed(object? sender, PointerPressedEventArgs e)
+ protected void OnChromePressed(object? sender, PointerPressedEventArgs e)
{
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
if (CanResize && e.ClickCount == 2)
@@ -123,10 +138,3 @@ public abstract class NotaWindow : Window
private IBrush? Res(string key) => this.TryFindResource(key, out var v) && v is IBrush b ? b : null;
}
-
-/// <summary>Concrete <see cref="NotaWindow"/> for code that builds a one-off popup window
-/// inline (rack sampler / full-UI editors). Set/replace its body via <see cref="SetContent"/>.</summary>
-public sealed class NotaPopupWindow : NotaWindow
-{
- public void SetContent(Control body) => SetBody(body);
-}