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
(feat) Skins: your own themes, with a typeface and corner radii, and MCP previews (#336) (#560)
Egor Khindikaynen45eb7ef7afaa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 528a51ec..b0a04ce3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,27 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Skins: your own themes** (#336, specs/087). Put a theme file in the **Themes** folder+ of Nota's data folder and it appears in **Preferences → Appearance**, next to the+ built-in themes, under Dark or Light. You pick it like any built-in theme, and the choice+ is kept after a restart.+ - A theme file sets every colour token. Format 2 can also name a typeface installed on+ the system and how round the corners are: one roundness from 0 (square) to 2, plus+ exact values for single steps. The whole app follows it live, device cards and drawn+ views included; sizes and layout stay the same.+ - Right-click any theme card and pick **Duplicate** to get a copy to edit. **Open themes+ folder** and **Reload** are under the cards.+ - A file that can't be loaded is listed under the cards with the reason, and the token+ it is about. A theme whose text may be hard to read loads anyway and shows how many+ warnings it has. A typeface that isn't installed falls back to Geist.+ - New MCP tools let an AI or a script design a skin:+ - `list_themes`, `get_theme`, `get_theme_catalogue` and `list_system_fonts` read what+ there is;+ - `validate_theme` checks a theme without saving it;+ - `preview_theme` returns one picture per part of the app in that theme, without+ changing the window;+ - `save_theme`, `apply_theme`, `try_on_theme` and `revert_try_on` save it, wear it or+ try it on.- **Custom wavetables in Nota Aurora** (specs/053): drop a WAV, FLAC or MP3 file on eitheroscillator, from the browser or the desktop, or pick **Import…** in its table drop-down.Aurora turns it into a table as follows:@@ -69,7 +90,7 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.track mid-take lands its part and the rest keep going. Arm more tracks with ⌘-click(Ctrl-click). For now an audio take records either the hardware inputs or one track'soutput (internal resampling), not both at once.-- **Name and switch off inputs** (#353, specs/086): Settings → Audio → **Inputs** lists every+- **Name and switch off inputs** (#353, specs/086): Settings → **Inputs** lists everyinput of the device with the name it gives it, a switch and a name of your own, then thestereo pairs, which can be named too. Track input menus list only the inputs that are on,under your names (an interface with more than 16 inputs groups them under **Mono inputs**@@ -117,6 +138,18 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.notes in their articulation's colour instead of the track's.### Changed+- **Settings, reorganised** (#427, specs/088): every setting is on a page named for it.+ - **Outputs** and **Inputs** are their own pages under Devices: the output device and the+ test tone on one, the input device and the list of inputs with their switches and names+ on the other. **Audio** keeps the audio system, sample rate, buffer, latency and the CPU+ check. With ASIO the driver is still picked on Audio; its output and input pairs are on+ Outputs and Inputs.+ - A new **Remote control** group holds **Remote** and **AI control (MCP)**, now its own page.+ - **Appearance** keeps only the look (theme, accent, waveform, track headers, scale, text+ size). **Language** is its own page, and a new **Editing** page holds the piano-roll note+ labels, fades on split audio clips and the detail-panel switch.+ - The command palette has a **Settings:** command for each new page, and the track input+ menu's **Audio I/O setup** opens Inputs. Every setting keeps its value.- **The manual opens in the interface language** (#539): Help ▸ Documentation and each device'sDocumentation item open the French manual (`/fr/`) when Nota runs in French, the Russian onefor Russian, and the English one otherwise. The choice used to follow the OS language, so adiff --git a/DESIGN.md b/DESIGN.mdindex 3cb7425b..6fb54cc1 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -90,8 +90,9 @@ freeze a view in the theme it was built in. Use the slot, a `Wash`, `InkOn`, a pA colour theme is one fixed look: an id, a name, a kind (**dark** or **light**) and onevalue for every token. The format is `specs/011-colour-themes/contracts/theme-file.md`.The kind sets the OS window chrome and Fluent's base, and decides which follow-system list-the theme appears in. A theme changes colour only: never shapes, type, layout, or which-element carries orange.+the theme appears in. A built-in theme changes colour only: never shapes, type, layout, or+which element carries orange. A user theme may also change the typeface and corner radii+(below), never layout or which element carries orange.| Theme | Kind | Values ||---|---|---|@@ -123,6 +124,25 @@ Remote get. Where the accent goes does not change.`NotaThemes.BuiltInOrder`. Nothing else names a theme. The smoke test checks the fileagainst the catalogue and the readability bar.+**User themes (skins, specs/087).** The same files in `<data>/Themes/` join the list after+the built-ins. One validator, `Nota.Application.Themes.ThemeFile`, serves the built-ins,+the folder, MCP and the tests. For a user theme the readability bar gives warnings and+does not block it. Format 2 (`specs/087-user-skins/contracts/theme-file-v2.md`) adds two+optional parts:+- `font`: a system typeface;+- `radius`: a roundness over the corner scale, and exact values per step.++Built-in themes are format 1: Geist and the scale below.++This is why code keeps writing the **design** values (`NotaRadius.*`, `Radius.*`,+`Font.UI` / `NotaFonts.*`). `NotaSkin` lays the worn skin's value over every `CornerRadius`,+`Rectangle` radius and Geist font family, at Animation priority. The value it lays over is+always worked out from the design base value, so going back to the built-ins is exact. Custom-drawn+views read `NotaRadius.*Value` at render time, and `NotaFormattedText` swaps the typeface.+A literal radius in a `DrawRectangle` / `FillRectangle` / `RoundedRect` call bypasses the+skin, so use `NotaRadius.*Value`, or `NotaSkin.MapRadius(x)` for a radius off the scale.+Never name another font family in a view.+### Readability barEvery theme meets these (WCAG 2.x contrast ratio; ΔE = CIE76). They are calibrated on@@ -572,6 +592,9 @@ R2). Each site picks the name for what it draws.`NotaRadius.Top(r)` rounds only the top corners (a header strip on a body).+A skin can re-round this scale (see § Colour themes → User themes). The values above are+the design values the code is written against.+### Sizes| Part | Size |diff --git a/FEATURES.md b/FEATURES.mdindex 4907a593..ef2b3444 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -369,7 +369,7 @@ docks as a panel under any of the three, or floats in its own window — seewhile a take is recording.- **Playable keys**: click a key to hear it, ⇧-drag to glide, ⌘-click to select every noteof that pitch; a vertical drag on the keys zooms the rows.- - **Key labels**: only C by default; Settings → Appearance → Piano roll labels every note+ - **Key labels**: only C by default; Settings → Editing → Piano roll labels every note(C, C#, D…) instead — an aid for beginners. Folded rows and Drum Rack pads are alwaysnamed either way.- Click the roll's ruler to put the playhead there, or drag along it to scrub (snapped to@@ -612,7 +612,7 @@ docks as a panel under any of the three, or floats in its own window — see`get_track_midi_input`.- **Several tracks in one pass**: Record records every armed audio track, each its own input,aligned, one undo step; a mono input records a mono file.-- **Inputs setup** (Settings → Audio → Inputs): switch inputs off and name inputs and stereo+- **Inputs setup** (Settings → Inputs): switch inputs off and name inputs and stereopairs per device; track input menus follow.- **Take lanes**: an Arrangement audio recording with the loop on keeps every pass. Theheader shows a disclosure and the take count; open it for one row per take (**Take 1**,@@ -647,7 +647,7 @@ docks as a panel under any of the three, or floats in its own window — seeSUSTAIN / RELEASE sliders. The waveform is drawn shaped the way it sounds. By default thesample plays its full length at full level; double-click a handle to reset its stage.Editing in either place updates the other, each edit is one undo step, split keeps the- attack on the left piece and the release on the right, and — unless Settings → Appearance →+ attack on the left piece and the release on the right, and — unless Settings → Editing →**Fade audio clips when splitting** is off — also writes a 4 ms fade at the cut (release onthe left, attack on the right) so the cut does not click. Drag those corner handles to makeit longer or shorter. **Fade at splits** (command palette, or an audio clip's menu; no@@ -1419,12 +1419,21 @@ audio effects after it keep running and keep their settings; saved with the projorange accent; the default, and what a DAW wants for long sessions in a dark room),**Studio Light** (the same system in light greys, the orange a shade deeper), and**Ember Graphite** / **Ember Paper** (warm browns with a brass accent, dark and light).- A theme changes colours only — track colours included — never the layout; the accent+ A built-in theme changes colours only — track colours included — never the layout; the accentcolour is a separate choice (see [Preferences](#preferences)). Panels dock edgeto edge on thin seams; orange (or the chosen accent) marks only what is playing, selected or switched on, and aknob or fader turns orange while you hover or drag it; mute is amber, solo blue,record-arm red; labels are in sentence case. Switching applies immediately, across everyopen window — including the custom-drawn arrangement, piano roll, mixer and device cards.+- **Skins (user themes)** — theme files in the **Themes** folder of the data folder appear+ next to the built-ins and are worn the same way. A file sets every colour token. Format 2+ can also name an installed system typeface, which replaces Geist for all of Nota's text,+ and a corner roundness from 0 (square) to 2, with optional exact radii per step. All+ three apply live in every window, device cards and drawn views included, without changing+ sizes. A file that fails is listed with the reason. A theme below the readability bar+ still loads, and shows its warnings. Over MCP an AI can validate a theme, get one picture+ per part of the app in it without the window changing, and save, wear or try it on (see+ [MCP](#mcp--ai-control)).- **Release splash art** — the launch splash shows an abstract picture generated from theversion number: piano-roll notes, rhythm rings, waveform strata, panels, a Lissajousfigure or fader rails, in a few of the theme's track colours, with one orange mark that@@ -1470,8 +1479,9 @@ audio effects after it keep running and keep their settings; saved with the projbackends don't yet, so there it never appears.- **About** — the app and engine versions, the copyright notice, and a pointer to thethird-party attribution notices (`LICENSES/THIRD-PARTY-NOTICES.md`).-- **Settings** — a larger window with a sidebar grouped into Devices, Plug-ins and General- (each page with an icon and a short description), large switches, latency in+- **Settings** — a larger window with a sidebar grouped into Devices, Remote control,+ Plug-ins and General (each page with an icon and a short description; every setting on the+ page named for it), large switches, latency inmilliseconds, colour themes shown as miniature Nota windows, and key-cap shortcuts with a filter.- **Device window** (a device opened from a Drum Rack, Instrument Rack, Audio Effect Rack ora Nota Rhythm voice): the title bar carries the device, track, preset picker, bypass and@@ -1481,7 +1491,7 @@ audio effects after it keep running and keep their settings; saved with the projits devices, a clip or a filled Session slot opens in the Clip tab; also View → Toggledetail panel and Show devices. A plain click on a track, clip, mixer strip or slot onlyselects; an open panel follows the selection. A plug-in instrument's own window opens- from **Open editor** on its card. Settings → Appearance → **Open the detail panel when+ from **Open editor** on its card. Settings → Editing → **Open the detail panel whenyou select a track or clip** makes every selection open it.- **Devices/Clip panel in its own window** — the ⧉ button in the bottom panel's headerdetaches it (the selected clip's piano roll on top, the device chain below, both at@@ -1509,13 +1519,16 @@ audio effects after it keep running and keep their settings; saved with the proj## Preferences-- **Audio**: device, sample rate, buffer size (latency); **WASAPI exclusive mode**- (Windows). On Windows, **Audio system** WASAPI / **ASIO**: the driver, the output and input- channel pairs (by the driver's channel names; other outputs silent), **Driver settings…**- for the driver's own panel (buffer size changes there are picked up without a restart);- the Latency line shows the driver's latency and round trip. Recorded takes are moved- earlier by the driver's reported latency; a missing or failed driver falls back to WASAPI- with the reason in the status bar, and **Try again** returns to ASIO.+- **Audio**: sample rate, buffer size (latency), the CPU check; **WASAPI exclusive mode**+ (Windows). On Windows, **Audio system** WASAPI / **ASIO**: the driver and **Driver+ settings…** for the driver's own panel (buffer size changes there are picked up without a+ restart); the Latency line shows the driver's latency and round trip. Recorded takes are+ moved earlier by the driver's reported latency; a missing or failed driver falls back to+ WASAPI with the reason in the status bar, and **Try again** returns to ASIO.+- **Outputs**: the output device (under ASIO, the driver's output channel pair, by its channel+ names; other outputs silent) and the test tone.+- **Inputs**: the input device (under ASIO, the driver's input channel pair) and the inputs+ setup — switch inputs off and name inputs and stereo pairs per device.- **MIDI**: which MIDI inputs are enabled (the house checkboxes); **MPE** on/off (on bydefault) and the per-note bend range (±12 / 24 / 48 / 96 semitones).- **Gamepads** (macOS): enable gamepad input (notes and mapped controls); the controller@@ -1531,7 +1544,10 @@ audio effects after it keep running and keep their settings; saved with the projrows of cards (Studio Dark and Ember Graphite; Studio Light and Ember Paper), each aminiature Nota window in its own colours. Pick one theme, or with Follow system one fordark mode and one for light mode, switched with the OS appearance; the choice applies- live and is remembered. **Accent** — the colour of what is live or chosen: seven presets+ live and is remembered. User themes (skins) join the rows, tagged **User theme** and with+ a warning count when they have one. **Duplicate** (right-click a card) copies any theme+ into the themes folder. **Open themes folder** and **Reload** sit under the cards, and+ files that could not be loaded are listed with the reason. **Accent** — the colour of what is live or chosen: seven presets(Orange — the default — Lime, Aqua, Sky, Violet, Magenta, Pink) or **Custom**, a colourpicker (saturation/brightness area, hue strip, hex field) that previews the colour in allfour themes. One accent for every theme, tuned to each so it stays readable; a grey or a@@ -1541,16 +1557,17 @@ audio effects after it keep running and keep their settings; saved with the projremembered; timeline, piano roll and audio editor zoom work on top of it. **Text size** —Smaller / Default / Larger / Largest steps every text by −1 to +2 pt without changing thelayout (device cards keep theirs), live and remembered. **Waveform** —- **Smooth** (default), **Solid** or **Bars** for audio clips on the lanes. **Fade audio- clips when splitting** — on by default; a split then writes a 4 ms fade at the cut, which- the corner handles can drag longer or shorter. **Track- headers** — Left / Right side of the arrangement's track list. **Open the detail panel- when you select a track or clip** (off by default: a double-click opens it). **Label every- note in the piano roll** — the keys column names every note instead of only C (off by- default; very short rows keep C only). Also- **AI control (MCP)** on/off, a port field, and "Copy config" (copies a- ready-made client JSON config to the clipboard).-- **Language** (Appearance): the interface language. Nota ships in **English**; every other+ **Smooth** (default), **Solid** or **Bars** for audio clips on the lanes. **Track+ headers** — Left / Right side of the arrangement's track list.+- **Editing**: **Label every note in the piano roll** — the keys column names every note+ instead of only C (off by default; very short rows keep C only). **Fade audio clips when+ splitting** — on by default; a split then writes a 4 ms fade at the cut, which the corner+ handles can drag longer or shorter. **Open the detail panel when you select a track or+ clip** (off by default: a double-click opens it).+- **Remote** and **AI control (MCP)** (the Remote control group): Nota Remote (see below);+ the MCP server on/off, a port field, and "Copy config" (copies a ready-made client JSON+ config to the clipboard).+- **Language**: the interface language. Nota ships in **English**; every otherlanguage is downloaded from [nota-translations](https://github.com/nota-daw/nota-translations).The drop-down lists English, the installed languages and those available for download, eachin its own name with how complete it is for this version; choosing one downloads it@@ -1575,8 +1592,8 @@ audio effects after it keep running and keep their settings; saved with the proj## MCP / AI controlA built-in **MCP server** (over HTTP, loopback `127.0.0.1` only) lets an AI (Claude Desktop-or Claude Code) write music directly in the open Nota project. Enable it in Preferences-(Appearance → "AI control (MCP)"); it is off by default. Every edit goes through undo and+or Claude Code) write music directly in the open Nota project. Enable it in Settings →+AI control (MCP); it is off by default. Every edit goes through undo andappears in the UI immediately.Coverage:@@ -1604,6 +1621,12 @@ Coverage:- **Automation**: create a lane (volume, pan, a device or instrument parameter),read and write points. A send is not a lane target.- **MIDI effects** and engine status.+- **Themes and skins**: `list_themes`, `get_theme` (the file, as a template),+ `get_theme_catalogue` (every colour token with what it colours, the radius steps),+ `list_system_fonts`, `validate_theme` (every problem and readability warning).+ `preview_theme` returns a PNG per part of the app (overview, top bar, arrangement, mixer,+ device rack, piano roll, browser, Preferences, a menu, a dialog) rendered offscreen in that+ theme. `save_theme`, `apply_theme`, `try_on_theme` / `revert_try_on`.- **Session**: the clip launcher (grid snapshot with clip and scene properties, create, copy,move and clear slots, read and write slot notes, loop length, clip name / colour / launchmode / quantize / legato / loop / follow actions, scene name / colour / tempo / signature /diff --git a/specs/087-user-skins/checklists/requirements.md b/specs/087-user-skins/checklists/requirements.mdnew file mode 100644index 00000000..bf694b81--- /dev/null+++ b/specs/087-user-skins/checklists/requirements.md@@ -0,0 +1,38 @@+# Specification Quality Checklist: User skins (colours, typeface, corner radii) with MCP support++**Purpose**: Validate specification completeness and quality before proceeding to planning+**Created**: 2026-11-10+**Feature**: [spec.md](../spec.md)++## Content Quality++- [x] No implementation details (languages, frameworks, APIs)+- [x] Focused on user value and business needs+- [x] Written for non-technical stakeholders+- [x] All mandatory sections completed++## Requirement Completeness++- [x] No [NEEDS CLARIFICATION] markers remain+- [x] Requirements are testable and unambiguous+- [x] Success criteria are measurable+- [x] Success criteria are technology-agnostic (no implementation details)+- [x] All acceptance scenarios are defined+- [x] Edge cases are identified+- [x] Scope is clearly bounded+- [x] Dependencies and assumptions identified++## Feature Readiness++- [x] All functional requirements have clear acceptance criteria+- [x] User scenarios cover primary flows+- [x] Feature meets measurable outcomes defined in Success Criteria+- [x] No implementation details leak into specification++## Notes++- MCP, PNG, the UI/audio thread and the spec 011 file format are named on purpose: MCP is+ the user-requested interface, the file format is an existing contract, and the thread+ rules come from the project constitution (Nota Context section of the template).+- Decisions taken as assumptions rather than clarifications: readability+ warns, not blocks; previews from a fixed sample scene. Revisit in `/speckit-clarify` if needed.diff --git a/specs/087-user-skins/contracts/mcp-tools.md b/specs/087-user-skins/contracts/mcp-tools.mdnew file mode 100644index 00000000..7836b0d2--- /dev/null+++ b/specs/087-user-skins/contracts/mcp-tools.md@@ -0,0 +1,34 @@+# Contract: MCP theme tools++Added to the in-app MCP server (`Nota.Mcp/Tools/ThemeTools.cs`), loopback only like every+other tool. All run on the UI thread through `IEngineDispatch`. A malformed `theme` argument+is a validation result, never a server error.++`theme` arguments are the theme document as a JSON **string** (so a client can send exactly+the file it would save).++| Tool | Arguments | Returns | Side effects |+|---|---|---|---|+| `list_themes` | — | `{ themes: [{ id, name, kind, source: "built-in"\|"user", warnings: int, fontMissing: bool }], worn: id, tryOn: bool, choice: { followSystem, single, dark, light }, problems: [{ file, reason }] }` | none |+| `get_theme` | `id` | the theme file text (format 1 or 2), keys in catalogue order | none |+| `get_theme_catalogue` | — | `{ tokens: [{ name, group, role, translucent }], radiusSteps: [{ name, design }], ranges: { scale: [0,2], step: [0,24], fontFamilyLength: [1,100] }, formatVersions: [1,2] }` | none |+| `list_system_fonts` | — | `{ families: [string] }` sorted | none |+| `validate_theme` | `theme` | `{ valid, problems: [{ rule, field, message }], warnings: [{ kind, pairing, tokens, measured, minimum, message }] }` | none |+| `preview_theme` | `theme`, `surfaces?: [name]`, `accent?: "user"\|"theme"` (default `user`) | content: 1 JSON text block = validate result + `{ rendered: [name], unknown: [name] }`, then per surface a text block `"<name> — <description>"` and an `image/png` block | none. Invalid theme → validate result only, no images. Unknown names reported in `unknown`; if all are unknown, no images. |+| `save_theme` | `theme`, `overwrite?: bool` (default false) | validate result + `{ saved: bool, file, reason? }` | writes `<id>.json` to the themes folder; reloads user themes. Refused: invalid; built-in id; existing user id without `overwrite`. |+| `apply_theme` | `id` | `{ worn, choice }` | wears and **stores** (single-theme mode), as a pick in Preferences; ends any try-on |+| `try_on_theme` | `theme` | validate result + `{ wearing: bool }` | wears live, **not stored**; replaces an earlier try-on |+| `revert_try_on` | — | `{ worn }` | ends the try-on, back to the stored choice; no-op if none |++## Preview size and order++Images are rendered at scale 1× at the sizes in [preview-surfaces.md](preview-surfaces.md),+in that table's order (or the order of `surfaces`). Same theme + accent option → identical+bytes on the same machine.++## Tool descriptions (for the model on the other end)++Each tool's `[Description]` states: the theme format is version 2 with optional `font` and+`radius`; start from `get_theme` of a built-in; `validate_theme` is cheap, `preview_theme`+takes seconds; readability warnings mean text may be hard to read and should usually be+fixed; `try_on_theme` is visible to the user and should be reverted if not kept.diff --git a/specs/087-user-skins/contracts/preview-surfaces.md b/specs/087-user-skins/contracts/preview-surfaces.mdnew file mode 100644index 00000000..a2bf2422--- /dev/null+++ b/specs/087-user-skins/contracts/preview-surfaces.md@@ -0,0 +1,35 @@+# Contract: Preview surfaces++Names are stable: clients may request them one by one. They are rendered at scale 1×,+at the default text size, with the requested accent option. Every surface is drawn in the+previewed theme inside one UI-thread job, and the screen never shows it (research R6).++Sources (a `settings` surface is built for the picture like a sample one, but shows the+user's current choices, so it is not byte-identical across changes to them):+- **Sample** surfaces are real views over the fixed sample scene (research R6), built for+ the picture and thrown away. Each is hosted in its own window, shown far off screen and+ fully transparent, so the layout manager, Loaded handlers and virtualising lists run; the+ skin is worn only in the job that draws them. They are deterministic: the same theme gives+ the same bytes.+- **Live** surfaces are the main window's own parts, so they show the user's open project+ and library. They are bound to the app's one engine and its view models, which a second+ copy cannot share. They are drawn at their size on screen, re-coerced for the skin during+ the job and given the live skin back right after. Their content follows the project, so+ SC-004 (identical images) covers the sample surfaces only.++| Name | Source | Size (px) | Description |+|---|---|---|---|+| `overview` | live | the window's | The main window: top bar, browser, arrangement and the detail panel |+| `top-bar` | live | the row's | Transport keys, position, tempo, view switches, CPU |+| `arrangement` | sample | 1200 × 520 | Track headers, MIDI and audio clips in the track colours, an automation lane (`ArrangementView`) |+| `mixer` | sample | 1200 × 520 | Channel strips with sends, a return and the master (`MixerView`) |+| `device-rack` | sample | 1200 × 300 | An instrument and two audio effects as device cards (`DeviceChainView`) |+| `piano-roll` | sample | 1200 × 480 | Chords on the keyboard grid with the velocity lane (`PianoRollView`) |+| `browser` | live | the panel's | Categories, the list and the search field |+| `preferences` | settings | 900 × 640 | Preferences → Appearance (`PreferencesWindow`): the theme cards, including the user's own, and the user's current accent, scale and text-size choices |+| `menu` | sample | 320 × content | A track context menu with the first row hovered (`ArrangementView.BuildTrackMenu`) |+| `dialog` | sample | 480 × content | A confirmation dialog with primary and secondary buttons (`ConfirmWindow`, never shown) |++A surface that cannot be drawn (no main window yet, a view that throws) is left out of the+result; the others still come back. Adding a surface later is additive. Removing or+renaming one is a breaking change for MCP clients and needs a CHANGELOG note.diff --git a/specs/087-user-skins/contracts/theme-file-v2.md b/specs/087-user-skins/contracts/theme-file-v2.mdnew file mode 100644index 00000000..9101b6c5--- /dev/null+++ b/specs/087-user-skins/contracts/theme-file-v2.md@@ -0,0 +1,49 @@+# Contract: Theme file, format version 2++Extends [spec 011's format version 1](../../011-colour-themes/contracts/theme-file.md).+Version 1 stays valid unchanged; the four built-ins stay version 1.++```json+{+ "formatVersion": 2,+ "id": "night-shift",+ "name": "Night Shift",+ "kind": "dark",+ "font": { "family": "IBM Plex Sans" },+ "radius": { "scale": 0.5, "steps": { "card": 4 } },+ "colors": { "BgApp": "#0B0A09", "...": "every catalogue token" }+}+```++## Rules++F1–F6 as in version 1, with F1 changed. F7 (readability) is a **warning** for user themes.+F8 applies to built-in Studio themes only.++| # | Rule | On violation |+|---|---|---|+| F1′ | `formatVersion` is `1` or `2`. | problem |+| V1 | `font` and `radius` appear only when `formatVersion` is `2`. | problem, names the key |+| V2 | `font`, if present, is an object with `family`: a string of 1–100 characters after trimming. No other keys. | problem, names `font.family` |+| V3 | `radius`, if present, is an object with optional `scale` (number, 0 ≤ scale ≤ 2, default 1) and optional `steps` (object). No other keys. | problem, names the key |+| V4 | `radius.steps` keys are among `card`, `group`, `field`, `cell`, `valueBar`, `switch`, `fine`; values are numbers 0–24. | problem, names `radius.steps.<key>` |+| W1 | `font.family` is installed on this system. | warning; Geist is used |+| W2 | Each T3 pairing ([011 ui-contract](../../011-colour-themes/contracts/ui-contract.md) § T3) meets its minimum. | warning per failed pairing: id, tokens, measured, minimum |++Validation reports **every** problem and warning (not the first one). A user theme loads when+it has no problems; warnings never block loading.++## Meaning++- **Typeface**: replaces Geist for all of Nota's own text, at the same sizes and weights.+- **Radius**: step radius = `steps[step]` if given, else `round(design × scale)`. Design values:+ card 9, group 7, field 6, cell 5, valueBar 4, switch 3, fine 2. Docked panels stay 0. Radii+ that are not on the scale are multiplied by `scale`.+- Omitted `font` → Geist. Omitted `radius` → the design scale.++## Files on disk++- Folder: `<Nota data folder>/Themes/` — the same root that `NOTA_DATA_DIR` relocates.+- Only `*.json` files are read, at most 256 KB each, in ordinal file-name order.+- The file name is free; the `id` inside is what Nota stores. Files saved by Nota (Duplicate,+ MCP `save_theme`) are named `<id>.json`, in catalogue key order, 2-space indented.diff --git a/specs/087-user-skins/contracts/ui-contract.md b/specs/087-user-skins/contracts/ui-contract.mdnew file mode 100644index 00000000..e64eae77--- /dev/null+++ b/specs/087-user-skins/contracts/ui-contract.md@@ -0,0 +1,40 @@+# Contract: Preferences → Appearance, user themes++Follows `DESIGN.md` and the `nota-design` skill; all strings via `Loc.T`, EN + RU.++## U1 — Theme cards++- User themes appear in the Dark or Light card list by kind, **after** the built-ins, sorted+ by name (culture-aware, case-insensitive).+- A user theme card carries a small "User" tag (caption style, secondary text) under its name.+- A card whose theme has warnings shows a warning glyph and the count; tooltip lists up to 5+ ("Text on Panel: 3.1 of 4.5", "Font 'X' is not installed — using Geist", "+N more").+- The card preview swatch shows the theme's colours **and** its radius (the swatch's own+ corners follow the theme's Card radius) and renders its name in the theme's typeface.+- Selecting a user card behaves exactly as selecting a built-in (single mode or a+ follow-system slot).++## U2 — Card context menu++- Every card (built-in or user): "Duplicate" → writes `<new-id>.json` (id = slug of+ "<name> copy", numbered on clash), reloads, selects the copy.+- User cards also: "Show in folder" (reveals the file).++## U3 — Themes folder row (below the cards)++- "Open themes folder" — creates the folder if missing, opens it in the system file manager.+- "Reload" — re-reads the folder; the page and the worn theme update.+- The page also reloads each time it is opened.++## U4 — Problems list++- Shown only when some file failed to load: a heading "Some theme files could not be loaded"+ and one row per file: `file name — reason` (reason as produced by validation; the first+ three problems, then "+N more").+- Not shown when there are no problems. Never a modal dialog.++## U5 — Fallback++- If the stored theme is missing or invalid after a reload, the page shows the fallback+ selected and a one-line note "'<id>' could not be loaded — showing Studio Dark" under the+ mode row; the stored choice is not overwritten until the user picks.diff --git a/specs/087-user-skins/data-model.md b/specs/087-user-skins/data-model.mdnew file mode 100644index 00000000..57cee532--- /dev/null+++ b/specs/087-user-skins/data-model.md@@ -0,0 +1,88 @@+# Data model: User skins (087)++Types are described by role. Names are proposals for the implementation, not a contract.++## ThemeFile (on disk / in MCP requests)++The JSON document. See [contracts/theme-file-v2.md](contracts/theme-file-v2.md).++| Field | Type | Rules |+|---|---|---|+| formatVersion | int | 1 or 2 |+| id | string | `^[a-z0-9]+(-[a-z0-9]+)*$`, not `system`, unique across built-in + user themes |+| name | string | 1–40 chars |+| kind | `dark` \| `light` | |+| colors | object | exactly the catalogue tokens; `#RRGGBB` / `#AARRGGBB`; opaque except translucent tokens |+| font | object? | v2 only; `{ "family": string(1–100) }` |+| radius | object? | v2 only; `{ "scale": number 0–2 = 1, "steps": { <step>: number 0–24 } }` |++## SkinGeometry (value, `Nota.Application`)++What a theme does to type and corners, once validated.++- `FontFamily: string?` — null = Geist.+- `Roundness: double` — 0–2, default 1.+- `StepOverrides: IReadOnlyDictionary<RadiusStep, double>` — exact pixels.+- `RadiusOf(step)` → override, else round(design[step] × Roundness).+- `Default` — no font, roundness 1, no overrides (what every v1 theme and built-in has).++`RadiusStep`: `Card 9, Group 7, Field 6, Cell 5, ValueBar 4, Switch 3, Fine 2` (design values,+style guide spec 038). `Docked` (0) is not a step and is never changed.++## ThemeValidation (value, `Nota.Application`)++Result of validating one theme document.++- `IsValid: bool` — no problems.+- `Problems: List<ThemeProblem>` — `{ Rule: "F1".."F6" | "V2-font" | "V2-radius" | "JSON", Field: string? (token / key path), Message: string }`. Every problem found, not only the first.+- `Warnings: List<ThemeWarning>` — `{ Kind: Readability | FontMissing, Pairing: "T3.1".., Tokens: string[], Measured: double, Minimum: double, Message }`.+- `Theme: ParsedTheme?` — id, name, kind, colours (`uint` ARGB by token), `SkinGeometry`; set when valid.++Readability warnings are computed only when the colours are valid. `FontMissing` needs the+installed-fonts list, so the app layer adds it (the pure validator takes an optional+`Func<string,bool> fontInstalled`).++## NotaColourTheme (existing, `Nota.App`) — extended++Adds:++- `Geometry: SkinGeometry` (Default for built-ins).+- `Source: ThemeSource` — `BuiltIn` | `User(path)` | `TryOn` | `Preview`.+- `Warnings: IReadOnlyList<ThemeWarning>` (empty for built-ins).++## User theme registry (`NotaThemes`, existing static) — extended++- `BuiltIn` (unchanged), `User` (loaded from the folder), `All` = BuiltIn then User by name.+- `UserLoadProblems: List<(string FileName, string Reason)>`.+- `ThemesFolder` = `NotaPaths.DataDir/Themes`.+- `ReloadUser()` — re-read the folder; replaces `User` and `UserLoadProblems`; raises+ `ThemesChanged`.+- `Find(id)` searches `All`.++Load order for the folder: `*.json` by file name (ordinal), size ≤ 256 KB, then validation;+ids already taken (built-in or earlier file) → problem "duplicate id".++## Theme state (`NotaThemeService`, existing) — extended++```+ Set(choice) / reload+ stored ──────────────────────────▶ worn = Find(choice.Active(os)) ?? fallback+ │ ▲+ │ TryOn(theme) │ RevertTryOn() / Set(choice) / restart+ └────────────▶ worn = theme (not stored) ┘+```++- `Choice` (stored), `TryOnTheme: NotaColourTheme?` (not stored).+- `Geometry` — the worn theme's `SkinGeometry`; `GeometryChanged` → re-coerce radii and+ fonts in every top level, then repaint (R2, R3).+- `RenderScoped(theme, Action)` — wear `theme` for the duration of the action within one UI+ job, then restore (previews, R6).++## Preview surface (`Nota.App`)++`{ Name: string (stable, kebab-case), Description: string, Size: (w,h) px, Build: (sampleEngine) → Control }`. The list: [contracts/preview-surfaces.md](contracts/preview-surfaces.md).++## Sample scene (`Nota.App`)++A private `NotaEngine` (never started) plus the view-models the surfaces need, built once+per app run on the first preview request. Content is fixed (see research R6).diff --git a/specs/087-user-skins/plan.md b/specs/087-user-skins/plan.mdnew file mode 100644index 00000000..49decd2f--- /dev/null+++ b/specs/087-user-skins/plan.md@@ -0,0 +1,190 @@+# Implementation Plan: User skins (colours, typeface, corner radii) with MCP support++**Branch**: `feat/user-skins` | **Date**: 2026-11-10 | **Spec**: [spec.md](spec.md)++**Input**: Feature specification from `specs/087-user-skins/spec.md` (issue nota-daw/nota#336)++## Summary++Users drop theme files (spec 011's format, extended to version 2 with an optional system+typeface and corner-radius settings) into `<data>/Themes/`. Nota validates them with one+shared validator, lists them in Preferences → Appearance next to the built-ins, wears them+live (colours through the existing palette path; radii and typeface through property+coercion, the way text size already works), and reports what failed. The in-app MCP server+gets ten theme tools — list, read, catalogue, fonts, validate, preview, save, apply, try-on,+revert — where `preview_theme` renders the real views over a private sample-scene engine+into PNGs without touching the live window.++## Nota: Read Before Planning++- **UI work** → [`DESIGN.md`](../../DESIGN.md) and the `nota-design` skill (Appearance page+ additions, warning badge, problems list).+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md).+- Prior specs: [011 colour themes](../011-colour-themes/spec.md) (format, T3 pairings),+ [038 style guide](../038-style-guide/spec.md) (radius scale, Geist), [084 accent+ colour](../084-accent-colour/spec.md) (accent worn over any theme), 077 key-based+ localization (EN + RU strings).++## Technical Context++**Language/Version**: C# / .NET 10 (managed only; no C++ change).++**Primary Dependencies**: Avalonia (existing), ModelContextProtocol 2.1.0 (existing;+`ImageContentBlock.FromBytes`). No new dependency.++**Storage**: `NotaPaths.DataDir/Themes/*.json` (honours `NOTA_DATA_DIR`); the theme choice in+the existing settings fields (`ColourTheme`, `SystemDarkTheme`, `SystemLightTheme`).++**Audio-Thread Impact**: None. Theme loading, validation, wearing and preview rendering are+UI-thread work. The preview engine is a second `NotaEngine` that is never started (no audio+thread, no device).++**Testing**: `tests/Nota.SmokeTest` — new `Skins` checks for the validator, geometry mapping+and the folder loader (no UI); the existing `DesignTokenCheck.RunThemes` stays. UI and MCP by+the headless/in-app recipes in [quickstart.md](quickstart.md).++**Target Platform**: macOS, Windows, Linux (the app's platforms). System font enumeration is+Avalonia's, per platform.++**Project Type**: desktop app.++**Performance Goals**: theme switch (including radius/font re-coerce) ≤ 250 ms on a typical+project; full `preview_theme` (10 surfaces) < 10 s (SC-003), scene built once per run.++**Constraints**: live window must not show preview colours (R6); preview images+deterministic (SC-004); MCP writes only `<themes>/<validated-id>.json`.++**Scale/Scope**: ~100 colour tokens; a handful of user files; 10 preview surfaces.++## Constitution Check++| Principle | Status |+|---|---|+| 0 Approved issue | ✅ #336 carries `approved`. Scope: skins + the screenshot API the issue describes; typeface/radius added at the user's request within "skins". |+| I Real-time audio safety | ✅ No audio-thread code. Preview engine never started. |+| II Boundary discipline | ✅ No C ABI change; uses existing engine API from managed code. |+| III Licensing | ✅ No new dependency; new files get the SPDX header. System fonts are used, not bundled. |+| IV Verification gate | ✅ Smoke test extended (validator, geometry, loader); `scripts/build.sh` before PR. |+| V One logical change | ⚠️ Large but one feature. Delivered as one PR with commits per phase; if review asks, MCP tools (Phase 5) can split into a follow-up PR without breaking Phases 1–4. |+| VI Docs in sync | ✅ Planned: CHANGELOG, FEATURES.md (`nota-features`), user manual EN+RU (`nota-docs`: Appearance page + new "Making a skin" page), DESIGN.md note on radius/typeface skinning. No shortcut change. |+| VII Spec-first | ✅ This spec/plan/tasks. |+| VIII Rules not weakened | ✅ |++**Post-design re-check**: unchanged — the design adds no native code, no dependency, no+audio-thread path.++## Design++### Phase 1 — Format and validation (`Nota.Application/Themes/`)++- `ThemeFile.Validate(json, catalogue, translucent, fontInstalled?) → ThemeValidation`+ (all problems, T3 warnings, v2 `font`/`radius`). `SkinGeometry`, `RadiusStep`.+ Pure, no Avalonia. ([data-model](data-model.md), [theme-file-v2](contracts/theme-file-v2.md))+- `ThemeFile.Write(parsed) → string` — canonical writer (catalogue order, 2-space indent).+- `NotaThemes.Parse` becomes a wrapper; built-in loading unchanged in behaviour.++### Phase 2 — User themes in the registry and Preferences++- `NotaThemes`: `User`, `All`, `UserLoadProblems`, `ThemesFolder`, `ReloadUser()`,+ `ThemesChanged`; `Find`/`OfKind`/`KnownThemes` over `All`; user themes load before+ `Appearance.Resolve` in startup.+- `NotaAccent`: synthetic ids for try-on/preview; cache cleared on reload (R5 gotcha).+- `NotaThemeService`: re-apply the worn theme after a reload if it changed or disappeared.+- `PreferencesWindow.Appearance`: U1–U5 ([ui-contract](contracts/ui-contract.md)).++### Phase 3 — Live radii and typeface++- `NotaSkin` (new, `Nota.App/Theme/`): the worn `SkinGeometry`, the resolved+ `FontFamily?`, `MapRadius(double)`, `MapFamily(FontFamily)`, `Install()` (metadata+ overrides with coerce callbacks — R2, R3), `Reapply()` (re-coerce every top level).+- `NotaRadius.*Value` → properties through `NotaSkin`. `NotaFormattedText` swaps the Geist+ typeface. `NotaThemeService.ApplyActive` sets `NotaSkin` from the worn theme and calls+ `Reapply()` when geometry changed.+- Smoke/geometry check (spec 012 `RunGeometry`) adapted: `*Value` are no longer `const`.++### Phase 4 — Try-on and preview rendering (`Nota.App`)++- `NotaThemeService.TryOn/RevertTryOn`, `RenderScoped(theme, action)`.+- `Skins/SampleScene.cs` — private engine + fixed content. `Skins/SkinPreviewRenderer.cs` —+ surfaces ([preview-surfaces](contracts/preview-surfaces.md)), offscreen host,+ `RenderTargetBitmap` → PNG bytes.+- **Spike first** (R6): offscreen host in the live app on macOS; no visible flash.++### Phase 5 — MCP++- `IThemeAccess` in `Nota.Mcp/Abstractions.cs`; `Nota.App/Mcp/ThemeAccess.cs` implements+ it; registered in `McpAppServices.ShareServices`.+- `Nota.Mcp/Tools/ThemeTools.cs` — the ten tools ([mcp-tools](contracts/mcp-tools.md)).++### Phase 6 — Docs and polish++CHANGELOG `[Unreleased]` Added; FEATURES.md; user docs EN+RU (Appearance + "Making a+skin", including the MCP loop); DESIGN.md: radius/typeface are skinnable, the design scale+is the base; localization EN+RU; PR evidence (Appearance before/after, one preview set).++## Project Structure++### Documentation (this feature)++```text+specs/087-user-skins/+├── spec.md+├── plan.md+├── research.md+├── data-model.md+├── quickstart.md+├── contracts/+│ ├── theme-file-v2.md+│ ├── mcp-tools.md+│ ├── preview-surfaces.md+│ └── ui-contract.md+├── checklists/requirements.md+└── tasks.md # /speckit-tasks+```++### Source Code++```text+src/managed/+├── Nota.Application/+│ ├── Themes/ThemeFile.cs # NEW validator + writer (v1/v2), T3 warnings+│ ├── Themes/SkinGeometry.cs # NEW+│ ├── Appearance.cs # unchanged API; user ids pass through `known`+│ └── Localization/en.json (+ ru) # new strings+├── Nota.App/+│ ├── Theme/NotaColourTheme.cs # Parse → wrapper; User/All/Reload; Geometry, Source+│ ├── Theme/NotaThemeService.cs # reload, try-on, RenderScoped, geometry apply+│ ├── Theme/NotaAccent.cs # synthetic ids, cache invalidation+│ ├── Theme/NotaSkin.cs # NEW coercion for radii + typeface+│ ├── Theme/NotaGeometry.cs # *Value → skinned properties+│ ├── Theme/NotaFonts.cs # NotaFormattedText family swap+│ ├── Skins/SampleScene.cs # NEW+│ ├── Skins/SkinPreviewRenderer.cs # NEW+│ ├── Mcp/ThemeAccess.cs # NEW IThemeAccess impl+│ ├── Mcp/McpAppServices.cs # register IThemeAccess+│ ├── App.axaml.cs # load user themes before Resolve; NotaSkin.Install+│ └── PreferencesWindow.cs (+ .Appearance partial) # U1–U5+├── Nota.Mcp/+│ ├── Abstractions.cs # IThemeAccess+│ └── Tools/ThemeTools.cs # NEW ten tools+tests/Nota.SmokeTest/+└── SkinTests.cs # NEW validator / geometry / loader checks+```++**Structure Decision**: Pure rules in `Nota.Application` (shared by app, MCP and tests);+everything Avalonia in `Nota.App`; MCP tools in `Nota.Mcp` behind an app facade — the+existing layering.++## Risks++| Risk | Mitigation |+|---|---|+| Offscreen rendering in the live app shows a flash or doesn't apply styles | Spike task first; fallback is a hidden real `Window` positioned offscreen. |+| Coercion catches a non-radius value equal to a step | Accepted per style guide; `RadiusAllowList` ratchet keeps literals visible. |+| Some views cache brushes/typefaces/radii in fields beyond the choke points | Audit task: grep `static readonly` `CornerRadius`/`Typeface`/`IBrush` in views; preview `roundness 0` + odd font makes misses visible. |+| A system font with very different metrics breaks fixed device-card layouts | Spec accepts truncation; device cards keep fixed size. Warning text in docs. |+| Views need services from DI bound to the live engine | Build surfaces only from constructors that take the engine; `overview` composed, not a second `MainWindow`. |++## Complexity Tracking++Not needed: no constitution violations. (Principle V noted above, with a split point.)diff --git a/specs/087-user-skins/quickstart.md b/specs/087-user-skins/quickstart.mdnew file mode 100644index 00000000..fbab8a05--- /dev/null+++ b/specs/087-user-skins/quickstart.md@@ -0,0 +1,57 @@+# Quickstart: validating user skins (087)++## Prerequisites++- `scripts/build.sh` green (native + managed + smoke test).+- An isolated data folder: `export NOTA_DATA_DIR=/tmp/nota-skins` (themes go to+ `$NOTA_DATA_DIR/Themes`).+- For MCP: Nota running with MCP on (Preferences → AI), an MCP client pointed at+ `http://127.0.0.1:<port>`.++## 1. Validation rules (no UI)++Smoke test group `Skins` (run by `scripts/build.sh`) covers:++- each of the four built-ins round-trips through the new validator with no problems and the+ same T3 results as `DesignTokenCheck.RunThemes`;+- the malformed set from SC-002 (missing / unknown token, bad hex, translucent opaque token,+ bad id, `system` id, bad kind, invalid JSON, v1 with `font`, scale 3, step `huge`, empty+ family) — each yields a problem naming the field; several at once are all reported;+- duplicate ids across files; the 256 KB cap;+- `SkinGeometry.RadiusOf` for scale 0 / 0.5 / 2 and overrides; `Map` keeps 0 at 0 and maps+ each design value to its step.++## 2. Wear a skin (Story 1, 2, 3)++1. Start Nota. Preferences → Appearance → right-click Studio Dark → Duplicate. Expected: a+ "Studio Dark copy" card with a "User" tag is selected; `$NOTA_DATA_DIR/Themes/studio-dark-copy.json` exists.+2. Edit that file: `"formatVersion": 2`, `"font": {"family": "Helvetica"}`,+ `"radius": {"scale": 0}`, change `Panel`. Click Reload. Expected: all text in Helvetica,+ every corner square, the new panel colour, layout sizes unchanged.+3. Pick Studio Dark. Expected: Geist and the normal radii are back.+4. Pick the copy again, restart Nota. Expected: starts in the copy.+5. Set `"family": "No Such Font"`, Reload. Expected: Geist, a warning badge on the card.+6. Delete a token, Reload. Expected: card gone, problems list names the file and token,+ the app shows Studio Dark with the fallback note; fix the file, Reload → back to the copy.++## 3. MCP loop (Story 4)++From the client, in order:++1. `list_themes` → four built-ins + the copy; `worn` is current.+2. `get_theme {id:"studio-light"}` → full v1 document.+3. Change `TextMuted` to `#E0E0E0`, `validate_theme` → valid, a T3.1 warning naming+ `TextMuted` on the light surfaces with measured < 4.5.+4. `preview_theme` with it → 10 images in contract order; the live window does not flicker+ or change. Call again → byte-identical images.+5. `preview_theme {surfaces:["mixer","nope"]}` → one image, `unknown:["nope"]`.+6. `save_theme` with id `studio-light` → refused; with a new id → saved, it appears in+ Preferences without restart; again without `overwrite` → refused.+7. `try_on_theme` → window wears it, Preferences still shows the stored pick;+ `revert_try_on` → back.+8. `apply_theme {id:<new>}` → worn and stored (restart keeps it).++## 4. Evidence for the PR++Before/after screenshots of Preferences → Appearance (nota-pr skill) and one `preview_theme`+image set for a sample skin.diff --git a/specs/087-user-skins/research.md b/specs/087-user-skins/research.mdnew file mode 100644index 00000000..4a5512cc--- /dev/null+++ b/specs/087-user-skins/research.md@@ -0,0 +1,192 @@+# Research: User skins (087)++Findings from the code as of `develop` @ 4508a93d, and the decisions they lead to.++## R1 — Where the theme file is parsed and validated++**Today**: `NotaThemes.Parse` (`Nota.App/Theme/NotaColourTheme.cs`) checks F1–F6 and stops at+the first problem. The T3 readability pairings exist only in the smoke test+(`tests/Nota.SmokeTest/DesignTokenCheck.Themes.cs`). `Nota.Mcp` references+`Nota.Application` but not `Nota.App` (Avalonia).++**Decision**: A new pure validator `ThemeFile` in `Nota.Application/Themes/` — no Avalonia+types, colours as `uint` ARGB. It takes the token catalogue and the translucent-token set as+inputs (they stay defined by `NotaPalette` in the app), collects **every** problem, computes+the T3 pairings as warnings, and returns a `ThemeValidation` (data-model.md). `NotaThemes.Parse`+becomes a thin wrapper that converts a valid result into `NotaColourTheme`.++**Rationale**: One validation for the loader and MCP (FR-011); testable from the smoke test+without a UI; the MCP project needs no reference to `Nota.App`.++**Alternatives**: Keep `Parse` in the app and expose it over an interface only — rejected, the+smoke test then can't exercise the rules directly. Move `NotaPalette.TokenNames` to+`Nota.Application` — rejected for now, it is tied to the slot brushes; passing the catalogue in+is enough.++The smoke test's own T3 copy stays: it is an independent check of the built-ins. A new test+checks the two agree on the built-ins.++## R2 — Live corner radii without touching ~430 call sites++**Today**: radii are XAML `StaticResource Radius.*` (39 uses) and C# `NotaRadius.*`+constants (~430 uses in 132 files; ~113 `DrawRoundedRect`-style custom draws, mostly through+`NotaRadius.*Value`). Nothing can change at runtime.++**Decision**: Coercion, the way `NotaTextSize` already steps font sizes live:++- Override the metadata of `Border.CornerRadiusProperty`, `TemplatedControl.CornerRadiusProperty`+ and `ContentPresenter.CornerRadiusProperty` with a coerce callback that maps each corner+ through `NotaRadiusSkin.Map(double)`: a value equal to a scale step's design value → that+ step's skinned value; `0` stays `0`; any other value → value × roundness, rounded to whole+ pixels. The **base** value stays the Studio design value, so mapping is always from the+ design scale and never compounds, and switching back restores it exactly.+- `NotaRadius.*Value` constants become `static double` properties that return the skinned+ value (custom-drawn views read them at render time; the theme service already repaints+ every window on a change). `NotaRadius.Card` etc. stay design values — coercion maps them.+- On a geometry change, walk every open top level and `CoerceValue` the three properties+ (the same pattern as `NotaTextSize`'s live re-coerce), then repaint.++Design values are distinct (9/7/6/5/4/3/2), so the step of a base value is unambiguous.+Values that are not on the scale (pill radii = height/2, the allow-listed literals in+`RadiusAllowList.txt`) scale with roundness, so roundness 0 squares everything (spec edge+case).++**Alternatives**: Replace every assignment with a `DynamicResource` binding — rejected+(~430 edits, easy to miss, no help for the custom-drawn layer). Rebuild windows on change —+rejected (loses state, FR-025 says live).++**Risk**: a `CornerRadius` that is not a radius-scale value but happens to equal one (e.g. a+literal `6`) is treated as that step. That is the intended reading of the style guide; the+`RadiusAllowList` ratchet keeps literals visible.++## R3 — Live typeface++**Today**: Geist is the app default via `FontManagerOptions.DefaultFamilyName` (fixed at+startup), XAML `StaticResource Font.UI` (14 uses), and `NotaFonts.UiFamily` / `Sans*`+typefaces (~230 uses, some cached in `static readonly` fields). **All** custom-drawn text is+built through `NotaFormattedText` (125 call sites, 0 raw `FormattedText`).++**Decision**:++- Controls: override `TextElement.FontFamilyProperty` metadata on `TextBlock`, `TextPresenter`,+ `TemplatedControl` and `TopLevel` with a coerce callback: a family that is Geist (the+ `Font.UI` URI or the default family) → the worn skin's family when one is set; anything else+ is left alone (explicit non-UI fonts keep working). Re-coerce on change as in R2.+- Custom-drawn: `NotaFormattedText`'s constructors swap a Geist typeface for the skin family+ with the same weight and style. One choke point covers every `static readonly Typeface`+ cache, because the swap happens when the text is built.+- Tabular figures stay requested (`+tnum`); a font without them just ignores the feature.+- Family resolution: `FontManager.Current.SystemFonts` names. Not found → Geist and a+ warning (FR-022). Checked at load and on wear (a font may be uninstalled meanwhile).++**Alternatives**: Restart to change the default family — rejected (FR-025). Change every+`NotaFonts.Sans` field to a property — unnecessary given the `NotaFormattedText` choke point.++## R4 — Format version 2++**Decision**: `formatVersion: 2` = v1 + optional `font` and `radius` objects (contracts/+theme-file-v2.md). v1 stays valid, and the four built-ins stay v1. `font`/`radius` in a v1+file are an error ("needs formatVersion 2"). Unknown top-level keys stay ignored, as today.+F8 is not run for user themes (it is a built-in Studio rule).++## R5 — Where user themes live and how they join the list++**Decision**: `NotaPaths.DataDir/Themes/*.json` (honours `NOTA_DATA_DIR`). `NotaThemes`+gains `User`, `All` (built-ins then user themes by name), `UserLoadProblems`, and+`ReloadUser()`; `Find`, `OfKind` and `NotaThemeService.KnownThemes` read `All`. User themes+load before `Appearance.Resolve` at startup, so a stored user id resolves. `Resolve` already+falls back to Studio Dark/Light for unknown ids without writing, so FR-006's "keep the stored+choice" holds as long as nothing calls `Store` with the fallback — the Appearance page only+stores on a user pick.++Reading is synchronous on the UI thread: small files, a 256 KB cap, a handful of files.++**Gotcha**: `NotaAccent.Wear` re-finds the theme by id (`NotaThemes.Find(theme.Id) ?? theme`)+and caches by id. A try-on or preview theme that reuses an existing id would be swapped for+the file version or hit a stale cache entry. Try-on/preview themes get a synthetic id+(`~tryon-<n>` / `~preview-<n>`, which no file can have under F2), and the accent cache is+invalidated on reload.++## R6 — Preview rendering inside the running app++**Today**: no in-app screenshot path. The docs harness (`../nota-docs/shots/app`) and the+headless recipes construct real views (`MixerView(engine)`, `DeviceChainView(engine, presets)`,+`PreferencesWindow`, menus via `Build*Menu`) and capture them. A `NotaEngine` can be created+and used without `Start()` (the smoke tests create several).++**Decision**:++- A `SkinPreviewRenderer` in `Nota.App` owns a private, never-started `NotaEngine` holding a+ fixed sample scene (built once on first use through the engine API: 6 coloured tracks of+ mixed kinds, MIDI and audio clips, an automation lane, built-in devices — an instrument, an+ audio effect, a MIDI effect — a return, a selection). It never touches the live engine.+- Each surface (contracts/preview-surfaces.md) is built from the real view classes over that+ engine, hosted in an offscreen top level, measured/arranged at a fixed size at scale 1×,+ and rendered with `RenderTargetBitmap` to PNG.+- The theme is applied for the duration of one UI-thread job: wear preview theme (palette+ re-tint + resources + radius/font skin) → build, lay out and render all requested surfaces+ → restore the live theme. The compositor commits only between dispatcher jobs, so the live+ window never presents the preview colours (FR-015). Live controls are not re-coerced during+ the job; only the offscreen tree is.+- Requests are serialised through `IEngineDispatch` (already one UI thread).++**Spike first (task)**: confirm (a) the offscreen top level (`EmbeddableControlRoot` or an+unshown `Window`) applies app styles and resources and renders via `RenderTargetBitmap` in+the live app on macOS, and (b) no frame with preview colours reaches the screen. Fallback for+(b): render under a cloned brush set by giving the offscreen root its own `Resources`+overriding every `Brush.*` key — needs custom-drawn views to read brushes from resources,+which they don't, so the job-scoped swap is the plan of record.++**Implementation finding** (T026): the top bar is ~240 lines of `MainWindow` markup bound+to `MainWindowViewModel`, and the browser needs the app's library view model (plug-in+catalogue, sample index, background scans). A second `MainWindow` or `BrowserViewModel` over+the sample engine would duplicate the app's services. So `overview`, `top-bar` and+`browser` render the **live** window's own controls inside the same scoped job: they are+re-coerced for the skin, drawn with `RenderTargetBitmap`, and re-coerced back after+`RenderScoped` restores the live skin. They show the user's project and are not+deterministic. The other seven surfaces are built from the sample scene. See+contracts/preview-surfaces.md.++**Live-app findings** (2026-11-10, real macOS app over MCP):+- A window shown off screen gets no client size from Width/Height set before `Show()`, and+ its position is clamped. Its size is set after `Show()`.+- The window's base font is Fluent's `fonts:Inter#Inter, $Default`. Nota ships no Inter,+ so this resolves to Geist. `NotaSkin` treats it as Geist, otherwise most text keeps Geist+ under a skin typeface.+- Measured: 10 images in about 1 s. A theme switch takes about 30 ms including the MCP round+ trip, on a near-empty project.++**Determinism**: fixed scene, fixed sizes, fixed scale, no meters or playhead (engine not+started), animations off in the offscreen root, text size step and UI scale forced to+defaults inside the job. Same theme → same bytes on the same machine (SC-004).++## R7 — MCP images++`ModelContextProtocol` 2.1.0 has `ImageContentBlock.FromBytes(bytes, "image/png")`. The+preview tool returns a `CallToolResult` whose content is, per surface, a `TextContentBlock`+("`mixer` — the mixer with six channel strips…") followed by the `ImageContentBlock`; the+structured problems/warnings come first as a JSON text block. No new dependency.++## R8 — MCP access to the app++New facade `IThemeAccess` in `Nota.Mcp/Abstractions.cs`, implemented in `Nota.App` (like+`IProjectVersionsAccess`), registered in `McpAppServices.ShareServices`. Every member runs on+the UI thread through `IEngineDispatch.InvokeAsync`. Tools in `Nota.Mcp/Tools/ThemeTools.cs`.++Writes are confined to the themes folder: the file name is derived from the validated id+(`<id>.json`), never from client input.++## R9 — Nota Remote++The phone page takes the worn theme's colours (`MainWindow.Remote.cs`). User themes and+try-ons flow through unchanged. Typeface and radii are not sent to the phone — out of scope+(the phone has its own type and geometry).++## R10 — Preferences UI++`PreferencesWindow.ThemePicker` builds cards with `ThemeCards(kind)` over `NotaThemes.OfKind`.+User themes join that list (after built-ins, by name) with a small "User" tag; a card+context menu offers "Duplicate". Below the cards: a row with "Open themes folder" and+"Reload", and — when there are problems — a compact list "file — reason". A card with+warnings shows a warning glyph + count with a tooltip. Follows `DESIGN.md` / `nota-design`;+strings are added to `Nota.Application/Localization/en.json` and its Russian twin (spec 077).diff --git a/specs/087-user-skins/spec.md b/specs/087-user-skins/spec.mdnew file mode 100644index 00000000..1103bb26--- /dev/null+++ b/specs/087-user-skins/spec.md@@ -0,0 +1,386 @@+# Feature Specification: User skins (colours, typeface, corner radii) with MCP support++**Feature Branch**: `feat/user-skins`++**Created**: 2026-11-10++**Status**: Draft++**Input**: User description: "Support for skins (GitHub issue nota-daw/nota#336, approved). Users can make their own colour theme ("skin") for Nota: a theme JSON file in the same shape as the built-in themes (specs/011-colour-themes contracts/theme-file.md, validated by NotaThemes.Parse) that the app loads from the user data folder, lists in Preferences next to the four built-in themes, and can wear. Plus MCP support: tools on the Nota MCP server to list themes, read a theme's JSON (as a starting template), validate a theme JSON, apply/preview a theme sent in the request body, and render preview screenshots — given a theme JSON, return an array of images, one per representative UI component/surface (e.g. arrangement, mixer, device cards, piano roll, browser, preferences, menus), showing how each looks in that skin — so an external client such as an AI can iterate on a palette and check it maps onto a usable skin (contrast, readability). Optionally save a validated theme as a user theme via MCP."++**Issue**: nota-daw/nota#336 — "Support for skins" (approved). The issue asks for user skins+and "an API hook where you edit the json (or send it in the request body), and it gives you+back an array of screenshots, one for how every component looks with your new skin", so that+something like an AI on the other end can help map a colour palette onto a usable skin.++## Nota Context *(fill in — drives plan and tasks)*++**Feature area** *(pick the main one)*:++- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`+- [ ] Docs only++Builds on spec 011 (colour themes — the theme file format and its rules F1–F8, the+readability pairings T3) and spec 084 (accent colour worn over any theme). The MCP side+extends the existing in-app MCP server (`src/managed/Nota.Mcp`).++**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md),+[`../011-colour-themes/contracts/theme-file.md`](../011-colour-themes/contracts/theme-file.md),+[`../011-colour-themes/contracts/ui-contract.md`](../011-colour-themes/contracts/ui-contract.md).++## Clarifications++### Session 2026-11-10++- Q: Is a skin colours only, or can it also change the typeface and corner radii? → A: A skin can also change the UI typeface and the corner radii (user request); spacing, sizes and icons stay fixed.+- Q: Where does a skin's typeface come from? → A: Only from fonts installed on the system, named by family; if the family is not installed the skin falls back to Geist with a warning.+- Q: How does a skin set the corner radii? → A: One roundness multiplier (0–2×) over the whole radius scale, plus optional exact values for individual radius steps; docked panels stay square.++## User Scenarios & Testing *(mandatory)*++### User Story 1 - Wear a skin I made (Priority: P1)++A user who wants Nota to look different copies a theme file (for example one of the+built-ins, exported as a starting point), changes its id, name and colours, and drops it in+Nota's themes folder. Nota lists it in Preferences → Appearance next to the built-in themes,+under Dark or Light according to its kind, and the user picks it like any built-in theme.+The whole app takes the new colours at once, and the choice survives a restart.++**Why this priority**: This is the feature the issue asks for. Without loading and wearing a+user theme, the MCP tools have nothing to save into or switch to.++**Independent Test**: Put a valid theme file with a new id in the themes folder, open+Preferences → Appearance, pick it, restart Nota. The app wears the skin before and after+the restart.++**Acceptance Scenarios**:++1. **Given** a valid theme file with a new id in the themes folder, **When** the user opens+ Preferences → Appearance, **Then** the theme shows as a card in the Dark or Light list+ (by its kind), after the built-in themes, marked as a user theme.+2. **Given** that user theme is listed, **When** the user picks it, **Then** every window+ repaints in its colours at once, exactly as picking a built-in theme does, and the user's+ accent colour (spec 084) is worn over it the same way.+3. **Given** a user theme is chosen, **When** Nota restarts, **Then** it starts in that theme.+4. **Given** a user theme that names an installed typeface and sets roundness 0, **When** it+ is worn, **Then** all of Nota's text uses that typeface and all rounded corners become+ square, with no change in layout sizes; picking a built-in theme again restores Geist and+ the standard radii.+5. **Given** a user theme is chosen in follow-system mode for one OS mode, **When** the OS+ switches mode, **Then** Nota switches between that theme and the theme chosen for the+ other mode.+6. **Given** the user adds or edits a file while Nota is running, **When** they reopen the+ Appearance page (or use its reload action), **Then** the list and the worn theme reflect+ the file as it is now.++---++### User Story 2 - Know why my skin did not load (Priority: P1)++A user's theme file has a mistake: a missing token, a typo in a colour, an id that clashes+with a built-in theme. Instead of the theme silently not appearing, Preferences → Appearance+names the file and the first problem in plain words, and the rest of the app is unaffected.++**Why this priority**: A hand-written file with ~100 tokens will be wrong the first few+times. Without feedback the feature is unusable for anyone not reading logs.++**Independent Test**: Put a file missing one token, and a second one with an invalid colour,+in the themes folder. Open Appearance: both files are named with their problem; neither is+in the theme lists; the app keeps its current theme.++**Acceptance Scenarios**:++1. **Given** a theme file that breaks a format rule (F1–F6 of the theme-file contract),+ **When** themes are loaded, **Then** the theme is left out and Appearance shows the file+ name and the reason, naming the token where there is one.+2. **Given** a theme file whose id equals a built-in theme's id or another user theme's id,+ **When** themes are loaded, **Then** only the first one (built-ins win) is loaded and the+ other is reported as a duplicate.+3. **Given** a valid theme that fails some readability pairings (T3), **When** it is loaded,+ **Then** it is listed and can be worn, and Appearance notes that it has readability+ warnings (how many) so the user knows text may be hard to read.+4. **Given** the chosen user theme's file is removed or becomes invalid, **When** Nota starts+ or themes are reloaded, **Then** Nota falls back to the default for that mode (Studio Dark+ or Studio Light) without an error dialog, as for a missing built-in theme.++---++### User Story 3 - Start from an existing theme (Priority: P2)++From Appearance the user opens the themes folder in the system file manager, and saves a copy+of any listed theme (built-in or user) into that folder under a new id and name, ready to edit.++**Why this priority**: A complete template is the practical way to write a ~100-token file.+It is a small addition that makes Story 1 reachable without reading the contract.++**Independent Test**: Use "Duplicate" on Studio Dark, edit one colour in the new file, reload:+the duplicate is listed and differs in that one colour.++**Acceptance Scenarios**:++1. **Given** Appearance is open, **When** the user chooses "Open themes folder", **Then** the+ folder (created if missing) opens in the system file manager.+2. **Given** any listed theme, **When** the user duplicates it, **Then** a new valid file with+ a fresh id and the name "<name> copy" is written to the themes folder, appears in the list+ and is selected for wearing.++---++### User Story 4 - An AI (or script) designs a skin over MCP (Priority: P1)++An MCP client connected to a running Nota — for example an AI assistant asked to "make a+skin from this palette" — lists the themes, reads a theme's full JSON as a template, sends a+modified theme JSON to be checked, gets back the format errors and the readability warnings,+gets back a set of preview images showing how each main part of Nota looks in that skin, and+iterates. When the skin is good it saves it as a user theme and, if asked, makes Nota wear it.++**Why this priority**: This is the second half of the issue ("an API hook … gives you back an+array of screenshots"), and the user asked for it explicitly. It shares everything with+Story 1 except the tools themselves.++**Independent Test**: With Nota running, call the tools in order from an MCP client: list,+read Studio Dark, validate a copy with one broken token (error names it), validate a copy+with low-contrast text (warning names the pairing and ratio), render previews of a valid copy+(one image per surface, each in the new colours, the live window unchanged), save it (it+appears in Preferences), apply it (the window wears it).++**Acceptance Scenarios**:++1. **Given** Nota is running with MCP on, **When** a client lists themes, **Then** it gets+ every loaded theme: id, name, kind, whether it is built-in or a user theme, and which theme+ is worn now; plus any user theme files that failed to load, with their reasons.+2. **Given** a theme id, **When** a client reads it, **Then** it gets the theme's complete+ file content in the theme-file format, with keys in catalogue order, usable as a template.+ The client can also get the token catalogue: every token name with a one-line role and+ whether it may be translucent.+3. **Given** a theme JSON in the request, **When** a client validates it, **Then** it gets:+ valid or not; every format problem found (not only the first), each naming the token; and+ every failed readability pairing with the two tokens, the measured value and the minimum.+ Nothing is saved or changed in the app.+4. **Given** a valid theme JSON in the request, **When** a client asks for previews, **Then**+ it gets back a list of images — one per named surface (see FR-016) — each paired with the+ surface's name and a one-line description, rendered in that skin. The user's live window+ does not change, flicker or lose its state while previews render.+5. **Given** an invalid theme JSON, **When** a client asks for previews, **Then** no images+ are rendered and the same problems as validate are returned.+6. **Given** a client asks for previews of only some surfaces (by name), **When** it renders,+ **Then** only those come back; an unknown surface name is reported, not ignored.+7. **Given** a valid theme JSON, **When** a client saves it, **Then** it is written to the+ themes folder as a user theme and appears in Preferences; saving over an existing user+ theme with the same id requires an explicit overwrite flag; saving with a built-in id is+ refused.+8. **Given** a listed theme id, **When** a client applies it, **Then** Nota wears it and+ stores the choice exactly as picking it in Preferences would (single-theme mode).+9. **Given** a valid theme JSON that is not saved, **When** a client applies it as a+ try-on, **Then** Nota wears it live without storing the choice; the try-on ends when the+ client reverts it, the user picks a theme in Preferences, or Nota restarts.++---++### Edge Cases++- **Themes folder missing**: treated as empty; created on first save, duplicate or "Open+ themes folder".+- **Huge or non-theme files in the folder**: only `*.json` files are read; a file larger than+ a sane limit (assumed 256 KB) is reported and skipped; other files are ignored.+- **Same id in two user files**: the first in file-name order loads; the other is reported as+ a duplicate.+- **File name and id differ**: allowed; the id inside the file is what Nota stores. Saving over+ MCP names the file after the id.+- **A user theme with the id `system`** or an id that is not lower-case-with-hyphens: rejected+ (rule F2).+- **Typeface not installed** (skin made on another machine): falls back to Geist with a+ warning; the skin's colours and radii still apply.+- **Font without tabular figures or without some weights**: numbers may change width and+ bold text may be synthesised; accepted, not an error.+- **Font lacking glyphs** (e.g. Cyrillic for the Russian UI): per-character fallback to the+ system font, as today for glyphs Geist lacks.+- **Roundness 0**: every corner square, including device cards and modal windows.+- **Translucent value on an opaque token**: rejected (rule F6), naming the token.+- **Ember-era value rule (F8)**: does not apply to user themes; only built-in Studio themes.+- **Theme file edited while it is worn**: takes effect on reload, not by watching the file.+- **Preview request while another preview is rendering**: requests are served one at a time;+ the second waits rather than failing.+- **Preview of a theme whose kind differs from the window's current kind** (light skin while+ the app is dark): the preview shows the skin's own kind correctly.+- **MCP request with a malformed or non-object JSON body**: returned as a validation error,+ never a server crash.+- **Accent colour**: previews and try-ons are shown with the user's current accent, as the+ skin would really be worn; a client can ask to render with the theme's own accent instead.++## Requirements *(mandatory)*++### Functional Requirements++**Loading and wearing user themes**++- **FR-001**: Nota MUST load user themes from a `Themes` folder inside the Nota user data+ folder (the same root that honours the test data-folder override), at startup and on demand.+- **FR-002**: A user theme MUST use the theme-file format of spec 011, either format version 1+ (colours only) or format version 2, which is version 1 plus two optional parts: `font` and+ `radius` (FR-021–FR-026). It MUST pass rules F1–F6, and the rules for those parts, to load. F7 (readability) failures MUST NOT block loading; they+ are reported as warnings. F8 does not apply to user themes.+- **FR-003**: A user theme's id MUST be unique: an id equal to a built-in theme's id, or to an+ already-loaded user theme's id, MUST be rejected for that file with a "duplicate id" reason.+- **FR-004**: Loaded user themes MUST appear in Preferences → Appearance in the Dark or Light+ card list according to their kind, after the built-in themes, sorted by name, visibly marked+ as user themes, and MUST be selectable everywhere a built-in theme is (single mode and each+ slot of follow-system mode).+- **FR-005**: Wearing a user theme MUST behave exactly as wearing a built-in theme: all+ windows, custom-drawn views, Fluent controls, shadows and Nota Remote follow it, and the+ user's accent colour is worn over it.+- **FR-006**: The theme choice MUST persist across restarts when it names a user theme. If the+ stored theme is not found or no longer valid at startup or reload, Nota MUST fall back as+ spec 011 defines for a missing theme, without an error dialog, and keep the stored choice+ so that the theme comes back if the file is fixed.+- **FR-007**: Appearance MUST offer a way to reload themes from the folder without+ restarting, and MUST reload them each time the page is opened.+- **FR-008**: Appearance MUST list every user theme file that failed to load, with the file+ name and the reason in plain words, and MUST show a readability-warning count on any loaded+ user theme that fails pairings.+- **FR-009**: Appearance MUST offer "Open themes folder" (creating it if missing) and a way+ to duplicate any listed theme into a new user theme file with a fresh id and the name+ "<name> copy".+- **FR-010**: Loading user themes MUST never crash or block the app: an unreadable, invalid or+ oversized file is skipped and reported. File reading MUST NOT happen on the audio thread+ (it is UI-side only).++**Typeface and corner radii**++- **FR-021**: A theme MAY name a UI typeface by the family name of a font installed on the+ system. When worn, that family MUST replace Geist for all of Nota's own text — shell,+ menus, dialogs, device cards and custom-drawn views — keeping the existing type scale,+ weights and tabular figures (where the font offers them). Plug-in windows are not affected.+- **FR-022**: If the named family is not installed, the theme MUST still load and be wearable;+ Nota MUST use Geist instead and show a warning on that theme (in Appearance and in MCP+ validation) naming the missing family. A theme with no typeface uses Geist.+- **FR-023**: A theme MAY set a roundness multiplier from 0 to 2 (default 1) applied to every+ step of the radius scale (Card, Group, Field, Cell, ValueBar, Switch, Fine), and MAY set an+ exact value in pixels (0–24) for any individual step, which wins over the multiplier for+ that step. Docked panels MUST stay at 0. Computed radii are rounded to whole pixels.+- **FR-024**: Values outside these ranges, an unknown radius step name, or a typeface value+ that is not a non-empty string of at most 100 characters MUST fail validation, naming the+ field.+- **FR-025**: Changing to a theme with a different typeface or radii MUST take effect live in+ every open window, like a colour change, without a restart and without changing layout+ sizes (text that no longer fits is truncated as it would be for any long label).+- **FR-026**: Each theme carries its own typeface and radii; in follow-system mode, switching+ OS mode switches them along with the colours.++**Validation shared by app and MCP**++- **FR-011**: There MUST be one validation used both by the loader and by MCP. For MCP it MUST+ report every format problem found (not only the first) and every failed readability pairing+ with the tokens, measured value and minimum, as structured data, plus a warning when the+ named typeface is not installed.++**MCP tools** (on the existing in-app MCP server)++- **FR-012**: A tool MUST list themes: id, name, kind, built-in or user, which theme is worn+ now (and the follow-system choice), plus failed user theme files with reasons.+- **FR-013**: A tool MUST return a theme's complete file content by id, and a tool (or the same+ tool) MUST return the token catalogue: name, group, short role, translucency allowed, plus+ the radius steps with their default values and the allowed ranges for font and radius.+- **FR-013a**: A tool MUST list the font families installed on the system, so a client can+ choose a typeface that will resolve.+- **FR-014**: A tool MUST validate a theme sent as JSON in the request and return the result+ of FR-011, without side effects.+- **FR-015**: A tool MUST render preview images of a theme sent as JSON in the request,+ returning a list of images (PNG), each with its surface name and description. It MUST NOT+ change the live window's theme, layout, selection or open project, and MUST NOT save+ anything.+- **FR-016**: The preview surfaces MUST cover the main parts of the app, at least: the main+ window overview, arrangement (tracks, clips, automation), mixer, device rack with built-in+ device cards, piano roll, browser, transport/top bar, Preferences → Appearance, a context+ menu, and a dialog. Each surface MUST have a stable name the client can request on its own.+- **FR-017**: Previews MUST be deterministic: rendered from a fixed built-in sample scene at a+ fixed size and scale, so the same theme gives the same images on the same machine, and+ differences between two calls come only from the theme (and the accent option). The+ exceptions are the main window's own parts (`overview`, `top-bar`, `browser`). They are+ drawn from the live window, so they show the user's open project (plan: research R6,+ implementation finding).+- **FR-018**: A tool MUST save a valid theme JSON as a user theme file named after its id;+ overwriting an existing user theme MUST require an explicit flag; a built-in id MUST be+ refused; the new theme MUST then be listed without a restart.+- **FR-019**: A tool MUST apply a listed theme by id, wearing it and storing the choice as+ Preferences would; and a tool MUST try on an unsaved valid theme JSON live without storing+ it, with a way to revert to the stored choice.+- **FR-020**: MCP theme tools that change what the user sees (apply, try-on, save) MUST run on+ the UI thread and MUST leave Preferences, if open, showing the current state.++### Key Entities++- **Theme file**: the spec 011 format — format version, id, name, kind (dark/light), and one+ colour per catalogue token. Format version 2 adds the optional typeface and radius settings. Built-in themes ship inside the app; user themes live in the+ user's themes folder.+- **User theme**: a theme loaded from the themes folder; same capabilities as a built-in,+ plus a source file path; cannot share an id with a built-in.+- **Load problem**: a file in the themes folder that did not load — file name, reason.+- **Validation result**: valid flag, list of format problems (rule, token, message), list of+ readability warnings (pairing, the tokens, measured value, minimum).+- **Token catalogue**: the ordered list of colour tokens a theme must define, each with group,+ role and whether it may be translucent.+- **Typeface (`font`)**: optional; the family name of an installed system font.+- **Radius settings (`radius`)**: optional; a roundness multiplier (0–2, default 1) and+ optional exact pixel values per radius step.+- **Preview surface**: a named part of the app (e.g. `mixer`) with a description, rendered to+ an image from the sample scene.+- **Try-on**: a live, unsaved theme the app wears until reverted or replaced.++## Success Criteria *(mandatory)*++### Measurable Outcomes++- **SC-001**: A user can go from a duplicated built-in theme to wearing their edited skin in+ under 5 minutes, without restarting Nota.+- **SC-002**: 100% of malformed theme files in a test set (missing token, unknown token, bad+ hex, translucent opaque token, bad id, duplicate id, bad kind, invalid JSON) are reported+ with a reason that names the problem and token, and none of them crash or change the app.+- **SC-003**: An MCP client gets the full set of preview images for one theme in under 10+ seconds on a typical development machine, and the user sees no change in the live window+ while it happens.+- **SC-004**: Rendering previews of the same theme twice gives identical images for every+ surface drawn from the sample scene.+- **SC-005**: Every one of the four built-in themes, read over MCP and saved back under a new+ id, loads as a user theme and looks identical to the original when worn.+- **SC-006**: A full design loop — list, read template, validate, preview, save, apply — can+ be completed by an MCP client with no human step in Nota.+- **SC-007**: A skin that sets an installed typeface and roundness 0 changes every visible+ text run and every rounded corner in the preview set, and none of the layout sizes.++## Assumptions++- A skin covers colours, the UI typeface and the corner radii. Sizes, spacing, type scale,+ icons and images stay as Nota's design language defines them. Theme files without a+ typeface or radius part (every format-version-1 file, including the four built-ins) keep+ Geist and the style guide's radius scale.+- Readability pairings warn but do not block, because a user is free to choose a low-contrast+ look for themselves; the warnings make the trade-off visible.+- Previews use a fixed built-in sample scene (a small project with several coloured tracks,+ clips, devices and notes) rather than the user's open project, so that results are+ comparable between calls and do not depend on or disturb the user's work.+- The MCP server only listens on loopback (existing behaviour), so the new tools need no extra+ authentication; writing files is limited to the themes folder.+- A full in-app colour editor is out of scope; the user edits files in any text editor, or an+ MCP client edits them.+- No sharing/gallery of skins and no import from other apps' theme formats.+- Previews are rendered by Nota's own UI renderer inside the running app, not by an external+ browser or tool; no new dependency is expected.++## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*++- [ ] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md)+- [x] No new dependency — or: license checked, AGPL-compatible, `LICENSES/third-party.md` row planned+- [x] Audio-thread impact considered: no alloc / lock / I/O on the audio thread (AR-6), command queue for data in (AR-4), immutable snapshots for structural edits (AR-5) — themes and previews are UI-side only+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/` — no native change+- [x] Smoke-test impact assessed: no engine behaviour change; theme validation of user files is covered by managed checks+- [ ] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned (and FEATURES.md / user docs via the nota-features / nota-docs skills)+- [ ] UI change → follows `DESIGN.md` (Studio design language)diff --git a/specs/087-user-skins/tasks.md b/specs/087-user-skins/tasks.mdnew file mode 100644index 00000000..2222f7b2--- /dev/null+++ b/specs/087-user-skins/tasks.md@@ -0,0 +1,244 @@+---+description: "Tasks for 087 — user skins (colours, typeface, corner radii) with MCP support"+---++# Tasks: User skins (colours, typeface, corner radii) with MCP support++**Input**: `specs/087-user-skins/` — plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md++**Issue**: nota-daw/nota#336 (approved)++**Tests**: Included. The constitution's verification gate needs the smoke test to cover the+new rules (quickstart.md § 1). They are pure checks with no UI, in `tests/Nota.SmokeTest/SkinTests.cs`.++**Organization**: Grouped by user story. US1, US2 and US4 are P1; US3 is P2.++## Format: `[ID] [P?] [Story] Description`++- **[P]**: can run in parallel (different files, no dependency on an unfinished task)+- **[Story]**: US1 wear a skin · US2 load problems · US3 start from a theme · US4 MCP++---++## Phase 1: Setup++- [X] T001 Create branch `feat/user-skins` off `develop` (spec dir `specs/087-user-skins/` comes along)+- [X] T002 Spike (research R6), throwaway and not committed: in the running app on macOS, host an `ArrangementView`/`MixerView` over a second, never-started `NotaEngine` in an offscreen top level (try `Avalonia.Controls.Embedding.EmbeddableControlRoot` first, then an unshown `Window`), `Measure`/`Arrange` at a fixed size, render it with `RenderTargetBitmap` and save the PNG. Inside the same UI-thread job, re-tint the palette (`NotaPalette.Apply` with another built-in theme) before rendering and restore it after. Confirm that (a) app styles and resources apply, (b) the live window never shows the other colours. Record the chosen host and any gotchas in specs/087-user-skins/research.md § R6++---++## Phase 2: Foundational (blocks every story)++**Purpose**: the format, the shared validator and skin geometry. Everything else builds on these.++- [X] T003 [P] Create `RadiusStep` enum (`Card, Group, Field, Cell, ValueBar, Switch, Fine`) with design values 9/7/6/5/4/3/2, and `SkinGeometry` record (`FontFamily: string?`, `Roundness: double` "0–2, default 1", `StepOverrides: IReadOnlyDictionary<RadiusStep,double>` "exact pixels 0–24"). Add `RadiusOf(step)` = override else `Math.Round(design × Roundness)`, `MapRadius(double v)`: 0 → 0; a design value → its step's `RadiusOf`; other → `Math.Round(v × Roundness)`. Add `Default` and `IsDefault`. File: src/managed/Nota.Application/Themes/SkinGeometry.cs+- [X] T004 Create `ThemeFile` in src/managed/Nota.Application/Themes/ThemeFile.cs (no Avalonia):+ - `Validate(string json, IReadOnlyList<string> catalogue, IReadOnlySet<string> translucent, Func<string,bool>? fontInstalled = null) → ThemeValidation`. It collects **every** problem: F1′ `formatVersion` 1 or 2; F2 id `^[a-z0-9]+(-[a-z0-9]+)*$`, not `system`; F3 name 1–40 chars; F4 kind dark|light; F5 exactly the catalogue tokens; F6 `#RRGGBB`/`#AARRGGBB`, opaque unless translucent; V1 `font`/`radius` only in v2; V2 `font` = `{ "family": string 1–100 chars after trim }` and no other keys; V3 `radius` = `{ scale?: 0–2, steps?: {} }` and no other keys; V4 step keys `card, group, field, cell, valueBar, switch, fine`, values 0–24; JSON errors. Each problem gets `Rule`, `Field` and `Message` (data-model.md § ThemeValidation).+ - Warnings: T3.1–T3.8 readability, ported from tests/Nota.SmokeTest/DesignTokenCheck.Themes.cs `Pairings` (same ids, minimums, WCAG contrast, CIE76 ΔE, ink `#17181A`/`#FFFFFF`), only when the colours are valid; `FontMissing` when `fontInstalled` returns false.+ - `ParsedTheme` (id, name, kind, `uint` ARGB colours by token, `SkinGeometry`).+ - `Write(ParsedTheme, IReadOnlyList<string> catalogue) → string`: catalogue key order, 2-space indent, `formatVersion` 2 only when geometry is not default.+- [X] T005 Make `NotaThemes.Parse` a wrapper over `ThemeFile.Validate` (first problem as `error`, same messages style), keep built-in loading behaviour; add `Geometry` (SkinGeometry), `Source` (`BuiltIn | User(path) | TryOn | Preview`) and `Warnings` to `NotaColourTheme` in src/managed/Nota.App/Theme/NotaColourTheme.cs+- [X] T006 [P] Smoke checks in tests/Nota.SmokeTest/SkinTests.cs (`SkinTests.Run()`), wired in tests/Nota.SmokeTest/Program.cs next to `RunThemes`:+ - the four built-ins validate with no problems, and their T3 warnings equal `DesignTokenCheck` pairings;+ - the SC-002 malformed set (missing/unknown token, bad hex, translucent opaque token, bad id, `system`, bad kind, invalid JSON, v1+`font`, scale 3, step `huge`, empty family) each names its field;+ - a file with three problems reports all three;+ - `Write`→`Validate` round-trips;+ - `SkinGeometry` at scale 0/0.5/2 with overrides; `MapRadius(0)==0`; each design value maps to its step.++**Checkpoint**: `dotnet build` + smoke green; app behaviour unchanged.++---++## Phase 3: User Story 1 — Wear a skin I made (P1) 🎯 MVP++**Goal**: theme files in `<data>/Themes` show up in Appearance and can be worn, typeface and radii included. The choice survives a restart.++**Independent Test**: quickstart.md § 2 steps 2–4.++### Registry and wearing++- [X] T007 [US1] In src/managed/Nota.App/Theme/NotaColourTheme.cs add `ThemesFolder` (`Path.Combine(NotaPaths.DataDir, "Themes")`), `User`, `All` (built-ins, then user themes by name, culture-aware, case-insensitive), `UserLoadProblems: List<(string FileName, string Reason)>`, `ReloadUser()` and `event ThemesChanged`. `ReloadUser` reads `*.json` in ordinal file-name order, skips files > 256 KB with a reason, validates with `fontInstalled` = `FontManager.Current.SystemFonts` names, and rejects ids taken by a built-in or an earlier file ("duplicate id"). It never throws. `Find` and `OfKind` search `All`+- [X] T008 [US1] In src/managed/Nota.App/Theme/NotaAccent.cs: `Wear` must not swap a non-built-in theme for `Find(id)` when `theme.Source` is TryOn/Preview, and the cache must clear on `NotaThemes.ThemesChanged` (research R5 gotcha)+- [X] T009 [US1] In src/managed/Nota.App/Theme/NotaThemeService.cs: `KnownThemes` over `All`; on `ThemesChanged`, re-apply the active theme (the object for the same id may have changed, so compare by content, not by reference). Raise `GeometryChanged` when the worn theme's `SkinGeometry` differs from the previous one+- [X] T010 [US1] Load user themes before `Appearance.Resolve` at startup in src/managed/Nota.App/App.axaml.cs (`NotaThemes.ReloadUser()`), so a stored user id resolves. The stored setting must not be overwritten when it falls back (FR-006)++### Live radii and typeface (research R2, R3)++- [X] T011 [US1] Create src/managed/Nota.App/Theme/NotaSkin.cs:+ - `Geometry` (current `SkinGeometry`) and `ResolvedFamily: FontFamily?` (null = Geist or font missing);+ - `Install()`, called before XAML loads: metadata overrides with coerce callbacks on `Border.CornerRadiusProperty`, `TemplatedControl.CornerRadiusProperty` and `ContentPresenter.CornerRadiusProperty` (each corner through `Geometry.MapRadius`), and on `TextElement.FontFamilyProperty` for `TextBlock`, `TextPresenter`, `TemplatedControl` and `TopLevel` (a Geist family → `ResolvedFamily`, else unchanged);+ - `Set(SkinGeometry)`;+ - `Reapply()`: walk every top level of the desktop lifetime and `CoerceValue` those properties on all visual descendants, then `InvalidateVisual`. Follow the pattern of src/managed/Nota.App/Theme/NotaTextSize.cs+- [X] T012 [US1] Call `NotaSkin.Install()` at startup next to `NotaFonts.InstallTabular()` / `NotaTextSize` install, in src/managed/Nota.App/App.axaml.cs (or Program.cs, wherever those are called)+- [X] T013 [US1] Make `NotaRadius.*Value` `static double` properties returning `NotaSkin.Geometry.RadiusOf(step)` (`DockedValue` stays 0) in src/managed/Nota.App/Theme/NotaGeometry.cs. Fix any compile errors where a `*Value` was used as a constant (attribute args, `const` locals, `switch` cases). Adapt `DesignTokenCheck.RunGeometry` in tests/Nota.SmokeTest/DesignTokenCheck.cs if it reads them as constants+- [X] T014 [US1] In src/managed/Nota.App/Theme/NotaFonts.cs `NotaFormattedText` constructors: when the typeface's family is Geist (`NotaFonts.UiFamily`, by name) and `NotaSkin.ResolvedFamily` is set, use `new Typeface(ResolvedFamily, style, weight)`; tabular figures stay+- [X] T015 [US1] In `NotaThemeService.ApplyActive` (src/managed/Nota.App/Theme/NotaThemeService.cs): `NotaSkin.Set(theme.Geometry)` and, when it changed, `NotaSkin.Reapply()` before `RepaintEverything()`. Resolve the family on every wear (a font may have been uninstalled)+- [X] T016 [US1] Audit views for cached radii and typefaces that bypass the choke points: `grep -rn "static readonly CornerRadius\|static readonly double.*Radius\|RadiusX = [0-9]"` in src/managed/Nota.App. Route radii through `NotaRadius`, or accept them via `MapRadius` (record intentional exceptions in tests/Nota.SmokeTest/RadiusAllowList.txt as that file's format requires)++### Preferences++- [X] T017 [US1] Appearance theme cards (contracts/ui-contract.md U1) in src/managed/Nota.App/PreferencesWindow.cs `ThemePicker`/`ThemeCards`:+ - user themes follow the built-ins and carry a "User" tag;+ - the swatch uses the theme's Card radius and typeface;+ - selecting a user card is the same as selecting a built-in;+ - `NotaThemes.ReloadUser()` runs whenever the page is built;+ - a "Reload" button (contracts/ui-contract.md U3) re-reads the folder and rebuilds the page.++ Follow DESIGN.md / nota-design.+- [ ] T018 [P] [US1] (EN done; RU goes to ../nota-translations after the reference has the keys — see Notes) Strings `preferences.themes.user_tag`, `preferences.themes.reload` (and the keys the later tasks add) in src/managed/Nota.Application/Localization/en.json and the Russian twin in the same folder++**Checkpoint**: quickstart § 2 steps 2–4 pass by hand (or headless harness). Built-in themes look exactly as before (Studio Dark screenshot diff empty).++---++## Phase 4: User Story 2 — Know why my skin did not load (P1)++**Goal**: problems and warnings are visible in Appearance, and the fallback is graceful.++**Independent Test**: quickstart.md § 2 steps 5–6.++- [X] T019 [US2] Problems list (U4) in src/managed/Nota.App/PreferencesWindow.cs: show it only when `NotaThemes.UserLoadProblems` is non-empty, one row per file `file — reason` (first three problems, then "+N more"), never a modal+- [X] T020 [US2] Warning badge on cards (U1) in src/managed/Nota.App/PreferencesWindow.cs: a glyph plus the count; the tooltip lists up to 5 (pairing with "measured of minimum", or "Font 'X' is not installed — using Geist"), then "+N more"+- [X] T021 [US2] Fallback note (U5) in src/managed/Nota.App/PreferencesWindow.cs: when the stored id (`Settings.ColourTheme` / the per-mode ids) is not in `KnownThemes`, show "'<id>' could not be loaded — showing <fallback>" under the mode row; do not call `Appearance.Store` until the user picks+- [ ] T022 [P] [US2] (EN done; RU follow-up as T018) Strings for U4/U5 and the warning tooltip in src/managed/Nota.Application/Localization/en.json + the Russian twin+- [X] T023 [P] [US2] Loader smoke checks in tests/Nota.SmokeTest/SkinTests.cs, using `ThemeFile` plus a temp folder. Either extract the folder scan into a pure `ThemeFolder.Scan(dir, …)` in src/managed/Nota.Application/Themes/ThemeFolder.cs that `NotaThemes.ReloadUser` calls, or test through it. Cover: duplicate id across two files (first wins, ordinal order), a built-in id rejected, a 300 KB file skipped, non-json ignored++**Checkpoint**: broken files are reported in the page, none of them crash the app, and fixing a file brings its theme back.++---++## Phase 5: User Story 4 — An AI designs a skin over MCP (P1)++**Goal**: the ten tools in contracts/mcp-tools.md, with `preview_theme` rendering the surfaces of contracts/preview-surfaces.md.++**Independent Test**: quickstart.md § 3.++### Try-on and scoped wearing++- [X] T024 [US4] In src/managed/Nota.App/Theme/NotaThemeService.cs add:+ - `TryOn(NotaColourTheme)`: Source TryOn, synthetic id `~tryon-<n>`; worn, not stored;+ - `RevertTryOn()`. `Set(choice)` also ends a try-on;+ - `TryOnTheme`;+ - `RenderScoped(NotaColourTheme theme, bool themeAccent, Action render)`: wear the theme (palette, resources, `NotaSkin`, user accent or the theme's own) without `RepaintEverything` or `Changed`, run `render`, restore the previous worn theme and skin in `finally`. Everything happens in one UI-thread job.++### Preview rendering++- [X] T025 [US4] Create src/managed/Nota.App/Skins/SampleScene.cs. It holds a private `NotaEngine` (never `Start()`ed, disposed with the app), built once on first use:+ - 6 tracks of mixed kinds with fixed names and colours, MIDI clips with notes, an audio clip from a bundled sample, an automation lane;+ - built-in instrument + audio effect + MIDI effect on one track, a return, a selection.++ Use only the public `IAudioEngine` API.+- [X] T026 [US4] Create src/managed/Nota.App/Skins/SkinPreviewRenderer.cs:+ - the surface table of contracts/preview-surfaces.md (stable names, descriptions, sizes), each built from the real view class over `SampleScene`. `top-bar` is extracted from MainWindow markup if the T002 spike requires it; `overview` is composed in a grid;+ - offscreen host per T002;+ - inside the job: animations off, text-size step 0, UI scale 1;+ - `Render(NotaColourTheme theme, bool themeAccent, IReadOnlyList<string>? names) → (rendered list of (name, description, png bytes), unknown names)`, all inside `NotaThemeService.RenderScoped`.+- [X] T027 [US4] Determinism check: render the same theme twice and compare the bytes. Add a debug-only `--skin-previews <theme.json> <outdir>` path in the smoke test only if it can run headless; otherwise document the manual check in quickstart.md § 3 step 4++### MCP++- [X] T028 [US4] Add `IThemeAccess` to src/managed/Nota.Mcp/Abstractions.cs. Its members, all run on the UI thread: `List()`, `GetFile(id)`, `Catalogue()`, `SystemFonts()`, `Validate(json)`, `Preview(json, surfaces, themeAccent)`, `Save(json, overwrite)`, `Apply(id)`, `TryOn(json)`, `RevertTryOn()`. Their DTO records follow contracts/mcp-tools.md+- [X] T029 [US4] Implement `ThemeAccess` in src/managed/Nota.App/Mcp/ThemeAccess.cs over `NotaThemes`, `NotaThemeService`, `ThemeFile` and `SkinPreviewRenderer`:+ - `Save` writes only `Path.Combine(ThemesFolder, id + ".json")`, using the validated id. It refuses an invalid theme, a built-in id, and an existing user id without `overwrite`, then calls `ReloadUser()`;+ - `Apply` = `Appearance.WithPick` + `Store` + `Set`, as the Preferences pick does;+ - the token catalogue carries a group and a one-line role per token, from `NotaPalette` (add a role table there if none exists).++ Register it in src/managed/Nota.App/Mcp/McpAppServices.cs `ShareServices`.+- [X] T030 [US4] Create src/managed/Nota.Mcp/Tools/ThemeTools.cs with the ten tools `list_themes`, `get_theme`, `get_theme_catalogue`, `list_system_fonts`, `validate_theme`, `preview_theme`, `save_theme`, `apply_theme`, `try_on_theme`, `revert_try_on`:+ - names, arguments and results as in contracts/mcp-tools.md, `theme` as a JSON string;+ - `preview_theme` returns a `CallToolResult`: one JSON text block (validation + `rendered`/`unknown`), then per surface a text block `"<name> — <description>"` and `ImageContentBlock.FromBytes(png, "image/png")`;+ - descriptions as in contracts/mcp-tools.md § Tool descriptions. A malformed JSON argument is a validation result, never an exception+- [X] T031 [US4] Keep Preferences current after MCP changes (FR-020): an open PreferencesWindow rebuilds its Appearance page on `NotaThemes.ThemesChanged` and `NotaThemeService.Changed`, in src/managed/Nota.App/PreferencesWindow.cs++**Checkpoint**: quickstart § 3 passes from a real MCP client against the running app.++---++## Phase 6: User Story 3 — Start from an existing theme (P2)++**Goal**: "Open themes folder" and "Duplicate".++**Independent Test**: quickstart.md § 2 step 1.++- [X] T032 [US3] "Open themes folder" (U3) in src/managed/Nota.App/PreferencesWindow.cs: `Directory.CreateDirectory(ThemesFolder)`, then open it in the system file manager the way the app already opens folders (find the existing helper, e.g. the one used for the samples or logs folder)+- [X] T033 [US3] Card context menu (U2) in src/managed/Nota.App/PreferencesWindow.cs:+ - "Duplicate" on every card: id = slug of "<name> copy", numbered `-2`, `-3`… on a clash; name "<name> copy" trimmed to 40 chars; written with `ThemeFile.Write`; then `ReloadUser()` and select it;+ - "Show in folder" on user cards.++ Build it with MenuKit like the other context menus.+- [ ] T034 [P] [US3] (EN done; RU follow-up as T018) Strings for U2/U3 in src/managed/Nota.Application/Localization/en.json + the Russian twin++---++## Phase 7: Polish & cross-cutting++- [X] T035 (live app: 10 previews ≈ 1 s; switch ≈ 30 ms incl. MCP, near-empty project — a large project not measured) Live performance: time a theme switch with a custom font and roundness on a large project (≤ 250 ms target, plan.md). Time a full `preview_theme` (< 10 s, SC-003). Record the numbers in specs/087-user-skins/research.md+- [ ] T036 Visual check with the headless harness recipe (memory: nota-ui-verify) for the four built-ins: before and after this change are pixel-identical (default geometry is a no-op)+- [X] T037 [P] DESIGN.md: a short section saying that radii and typeface are skinnable, the style guide's scale is the base and coercion maps it; new code keeps using `NotaRadius`/`NotaFonts`, never literals or other families+- [X] T038 (§ 1 smoke; § 3 over MCP in the live app incl. restart persistence; § 2 by hand-free equivalents — Preferences seen through preview images, no screen capture available) Run quickstart.md end to end (§§ 1–3)++### Nota closing tasks++- [ ] T039 (2026-11-10: native + managed build green; smoke 5600+ pass, every skins check passes; the only failures are the two render-pool "overloaded" timing checks, which flake under machine load and touch nothing here — re-run on an idle machine before the PR) Run `scripts/build.sh` until native + managed + smoke test are green+- [X] T040 AGPL-3.0-only SPDX two-line header on every new source file (SkinGeometry.cs, ThemeFile.cs, ThemeFolder.cs, NotaSkin.cs, SampleScene.cs, SkinPreviewRenderer.cs, ThemeAccess.cs, ThemeTools.cs, SkinTests.cs)+- [X] T041 New dependency: N/A (none added) — confirm+- [X] T042 `CHANGELOG.md` `[Unreleased]` → Added: user skins (colours, typeface, corner radii) in Preferences → Appearance; MCP theme tools with preview screenshots+- [X] T043 (FEATURES.md done; nota-docs EN+RU: Appearance ▸ Your own themes, reference/theme-files, ai/mcp ▸ Design a theme — nota-daw/nota-docs branch docs/user-skins) FEATURES.md via the `nota-features` skill; user manual EN + RU via `nota-docs` (Appearance page, new "Making a skin" page with the file format and the MCP loop); shortcuts: N/A+- [X] T044 Engine behaviour change: N/A (managed only); the smoke test is extended by T006/T023 for the new rules++---++## Dependencies & Execution Order++- **Phase 1** → **Phase 2** → stories.+- T002 (spike) blocks T025–T027 only. Phases 2–4 can go ahead while the spike is open.+- **US1** (Phase 3) is the base for US2, US3 and US4, which need the registry (T007) and wearing (T009, T015).+- **US2** depends on T007 and T017 (the page it extends).+- **US4** depends on T005, T007, T009 and T015, and on T002 for previews. `validate_theme`, `get_theme`, `list_*`, `save`, `apply` (T028–T030 without preview) work before T025–T026.+- **US3** depends on T004 (`Write`), T007 and T017.+- Within US1: T011 → T012, T013, T014 → T015 → T016.+- Same-file serialisation: PreferencesWindow.cs tasks T017 → T019 → T020 → T021 → T031 → T032 → T033; NotaThemeService.cs tasks T009 → T015 → T024.++## Parallel opportunities++- T003 ∥ T006 (test scaffolding) once T004's API is sketched.+- T018, T022, T034 (strings) ∥ any code task.+- After US1: US2 (Preferences) ∥ US4 MCP non-preview parts (T028–T030), since they touch different files except T031.+- T037 (DESIGN.md) ∥ anything.++```text+# Example: after Phase 3+Task: "T019–T021 Appearance problems/warnings/fallback in PreferencesWindow.cs"+Task: "T028 IThemeAccess in Nota.Mcp/Abstractions.cs"+Task: "T030 ThemeTools.cs (non-preview tools first)"+```++## Implementation strategy++1. **MVP** = Phases 1–3 (US1): user skins load, wear, persist, with typeface and radii. Validate with quickstart § 2 steps 2–4 and the built-in pixel check (T036).+2. Add **US2**, which is what makes hand-written files usable.+3. Add **US4** in two steps: non-preview tools first, then preview (after the spike).+4. Add **US3** (convenience).+5. Polish and closing tasks, then `/speckit-converge` and the PR (`nota-pr`, evidence: Appearance before/after plus one preview set).++If review asks to split (constitution V), the cut is after Phase 4: US1+US2+US3 in one PR, US4 (MCP) in a follow-up.++## Notes++- Implementation notes (2026-11-10):+ - Smoke checks live in `tests/Nota.SmokeTest/DesignTokenCheck.Skins.cs` (`RunSkins`),+ not `SkinTests.cs`.+ - Radii and the typeface are laid over the base value at Animation priority, not coerced.+ Avalonia refuses metadata overrides on Border and Rectangle, and a coerced inherited+ font did not come back reliably.+ - Previews are hosted in off-screen transparent windows (T002). They are verified+ headless by the `/tmp/skinharness` recipe:+ - the live window stays pixel-identical across a preview;+ - the live window is pixel-identical again after apply, try-on, revert and back;+ - the sample surfaces are byte-identical between runs.+ - RU strings are ready in `/tmp/nota-skins-tools/keys-ru.json` (the T018/T022/T034+ follow-up). They go to `../nota-translations`, whose check accepts only keys in its+ published reference, i.e. after this PR merges.++- Commit style `(feat) …` per repo history. The user makes commits themselves: leave changes for review.+- The live UI must never show preview colours. If T002 can't guarantee this, stop and revisit research R6 before T025.diff --git a/specs/088-settings-reorganisation/checklists/requirements.md b/specs/088-settings-reorganisation/checklists/requirements.mdnew file mode 100644index 00000000..7724f048--- /dev/null+++ b/specs/088-settings-reorganisation/checklists/requirements.md@@ -0,0 +1,37 @@+# Specification Quality Checklist: Settings reorganisation++**Purpose**: Validate specification completeness and quality before proceeding to planning+**Created**: 2026-11-10+**Feature**: [spec.md](../spec.md)++## Content Quality++- [x] No implementation details (languages, frameworks, APIs)+- [x] Focused on user value and business needs+- [x] Written for non-technical stakeholders+- [x] All mandatory sections completed++## Requirement Completeness++- [x] No [NEEDS CLARIFICATION] markers remain+- [x] Requirements are testable and unambiguous+- [x] Success criteria are measurable+- [x] Success criteria are technology-agnostic (no implementation details)+- [x] All acceptance scenarios are defined+- [x] Edge cases are identified+- [x] Scope is clearly bounded+- [x] Dependencies and assumptions identified++## Feature Readiness++- [x] All functional requirements have clear acceptance criteria+- [x] User scenarios cover primary flows+- [x] Feature meets measurable outcomes defined in Success Criteria+- [x] No implementation details leak into specification++## Notes++- FR-009 names "stable id" and the Nota Context names the specs the moved sections come from —+ kept on purpose: the id is the user-visible contract for every entry point into Settings.+- Scope agreed in nota-daw/nota#427 (updated 2026-11-10); Outputs per-channel naming/routing is+ explicitly out of scope.diff --git a/specs/088-settings-reorganisation/contracts/settings-pages.md b/specs/088-settings-reorganisation/contracts/settings-pages.mdnew file mode 100644index 00000000..abe77f0c--- /dev/null+++ b/specs/088-settings-reorganisation/contracts/settings-pages.md@@ -0,0 +1,60 @@+# Contract: Settings pages++## Page ids (stable — code, palette, docs links ask for these)++`Audio`, `Outputs`, `Inputs`, `MIDI`, `Gamepads`, `Remote`, `MCP`, `Plug-ins`, `Downloads`,+`Appearance`, `Language`, `Editing`, `Library`, `Shortcuts`, `Updates`.++- `PreferencesWindow.ShowPage(id)` selects the page with that id; an unknown id selects the+ first page and does not throw.+- `MainWindow.ShowPreferencesPage(id)` reuses an open Settings window.+- Every `prefs.<x>` palette command maps to one id; the smoke test fails if a command names an+ id that is not in the sidebar, or a page has no command.++## Page contents (top to bottom)++**Audio** — Audio device: [Windows] Audio system · [ASIO] Driver + Driver settings… ·+Sample rate · Buffer size · [Windows WASAPI] Exclusive mode + caption · Latency.+Test: Performance (CPU check).++**Outputs** — Output: Device (combo; under ASIO the driver name + "Change on the Audio page") ·+[ASIO, running] Output pair. Test: Output check (test tone).++**Inputs** — Input: Device (combo; under ASIO as above) · [ASIO, running] Input pair or "no+inputs on this driver". Inputs (spec 086): hint · each input · stereo pairs — or the "no+inputs" caption.++**AI control (MCP)** — the existing MCP section (switch, port, status, Copy config + caption).++**Appearance** — UI: Colour theme (+ follow-system caption) · Accent · Waveform · Track headers ·+Interface scale · Text size (each with its caption).++**Language** — Language picker + caption.++**Editing** — Piano roll: label every note + caption · Arrangement: fade audio clips when+splitting + caption · Detail panel: open on select + caption.++## Strings (new en.json keys; RU in nota-translations)++| Key | English |+|---|---|+| `preferences.remote_control` | Remote control |+| `preferences.outputs` | Outputs |+| `preferences.outputs_subtitle` | Where Nota plays and the test tone |+| `preferences.inputs_subtitle` | What Nota records from and what each input is called |+| `preferences.mcp_subtitle` | Let an AI assistant work in Nota |+| `preferences.language_subtitle` | The language of menus and panels |+| `preferences.editing` | Editing |+| `preferences.editing_subtitle` | Piano roll, arrangement and the detail panel |+| `preferences.appearance_subtitle` | Theme, scale, text and waveforms |+| `preferences.audio_subtitle` | Sample rate, buffer and latency |+| `preferences.arrangement` | Arrangement |+| `preferences.asio_device_on_audio` | {0} — the ASIO driver is both input and output. |+| `preferences.change_on_audio_page` | Change on the Audio page |+| `commands.settings_outputs` … `_inputs`, `_mcp`, `_language`, `_editing` | Settings: Outputs … |+| `main.no_audio_output_could_be_outputs` | … Choose a device in Settings → Outputs |+| `main.no_audio_output_device_opened_outputs` | … Choose a device in Settings → Outputs |++Existing keys reused where the wording is the same (`preferences.inputs`,+`preferences.ai_control_mcp`, `preferences.language`, `common.piano_roll`,+`preferences.detail_panel`). Keys that no longer have a caller are removed.diff --git a/specs/088-settings-reorganisation/data-model.md b/specs/088-settings-reorganisation/data-model.mdnew file mode 100644index 00000000..cb5e8619--- /dev/null+++ b/specs/088-settings-reorganisation/data-model.md@@ -0,0 +1,40 @@+# Data model: Settings reorganisation++No stored data changes. The only "model" is the sidebar table in `PreferencesWindow`.++## Page++| Field | Meaning | Rule |+|---|---|---|+| `Id` | stable English name callers ask for | unique; never translated; never reused for other content |+| `Title` | shown in sidebar and header | localised |+| `Subtitle` | shown beside the header title | localised; describes exactly what the page holds |+| `Icon` | `GlyphKind` | — |++## Group++| Field | Meaning |+|---|---|+| `Group` | localised heading |+| `Pages` | ordered pages |++## The table (order is the sidebar order)++| Group | Ids |+|---|---|+| Devices | `Audio`, `Outputs`, `Inputs`, `MIDI`, `Gamepads` |+| Remote control | `Remote`, `MCP` |+| Plug-ins | `Plug-ins`, `Downloads` |+| General | `Appearance`, `Language`, `Editing`, `Library`, `Shortcuts`, `Updates` |++## Settings each moved control writes (unchanged)++| Control | Page | Setting |+|---|---|---|+| MCP switch / port | MCP | `McpEnabled`, `McpPort` |+| Language picker | Language | UI language (spec 068) |+| Label every note | Editing | `PianoRollLabelAllNotes` |+| Fade audio clips when splitting | Editing | `SplitFades` (+ `Engine.SplitFades`) |+| Open the detail panel on select | Editing | `OpenDetailOnSelect` |+| Output device / ASIO output pair | Outputs | engine audio config |+| Input device / ASIO input pair / Inputs list | Inputs | engine audio config; input setup per device (spec 086) |diff --git a/specs/088-settings-reorganisation/plan.md b/specs/088-settings-reorganisation/plan.mdnew file mode 100644index 00000000..9f05576a--- /dev/null+++ b/specs/088-settings-reorganisation/plan.md@@ -0,0 +1,116 @@+# Implementation Plan: Settings reorganisation — every setting where you'd look for it++**Branch**: `feat/settings-reorganisation` | **Date**: 2026-11-10 | **Spec**: [spec.md](spec.md)++**Input**: Feature specification from `specs/088-settings-reorganisation/spec.md`++## Summary++The Settings window gets five new pages (Outputs, Inputs, AI control (MCP), Language, Editing)+and a new sidebar group (Remote control); Appearance and Audio shrink to what their names say.+Each existing section is moved, not rewritten: the MCP block, the language picker, the+piano-roll / split-fade / detail-panel switches and the Inputs list keep their code and their+settings keys. The window stops selecting pages by position — every page is found by its stable+`Id`, so the hard-coded indices (`RemoteIndex = 3`, `DownloadsIndex = 5`, `UpdatesIndex = 9`,+the `0`/`7` cases in `BuildPane`, `_selected == 0` for Audio) go, and every caller asks by id.+Entry points that pointed at the old place follow (palette commands, the record-input menu's+"Audio I/O setup", the "no audio output" status text). English strings in `en.json`; Russian in+the sibling `nota-translations` repo; docs in `nota-docs`.++## Nota: Read Before Planning++- **UI work** → [`DESIGN.md`](../../DESIGN.md) and the `nota-design` skill: pages reuse the+ existing `Section` / `Row` / `Caption` / `SwitchRow` builders, so no new visual language.+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md).++## Technical Context++**Language/Version**: C# / .NET 10 (managed app only)++**Primary Dependencies**: Avalonia (existing). No new dependency.++**Storage**: Unchanged — the same `ISettingsService` fields (`McpEnabled`, `McpPort`,+`PianoRollLabelAllNotes`, `OpenDetailOnSelect`, `SplitFades`, language, input setup per device).++**Audio-Thread Impact**: None: UI-only change. The panes call the same `IAudioEngine` setters+as today from the UI thread.++**Testing**: `scripts/build.sh` (smoke test) — the palette test already checks every catalog+command is bound; a new smoke check asserts every page id the app asks for exists in the+sidebar and every `prefs.*` command names a real page. Visual check with the headless-app+screenshot harness (memory: Nota UI verify recipe), EN and RU.++**Target Platform**: macOS, Windows (ASIO / WASAPI rows), Linux.++**Project Type**: desktop app.++**Performance Goals**: N/A (pages build on selection as today).++**Constraints**: Russian titles/subtitles must fit the 188 px sidebar and the header row.++**Scale/Scope**: ~5 files in `Nota.App`, `CommandCatalog.cs`, `MainWindow.Commands.cs`,+`MainWindow.AudioFormat.cs`, `ArrangementView.cs`, `en.json`, `Glyph.cs` (one new icon);+`nota-translations/languages/ru.json`; ~10 nota-docs pages × 2 languages.++## Constitution Check++| Principle | Status |+|---|---|+| 0. Approved issue first | ✅ #427 `approved`; widened scope written into the issue 2026-11-10 |+| I. Real-time audio safety | ✅ no audio-thread code touched |+| II. Boundary discipline | ✅ no ABI change |+| III. Licensing hygiene | ✅ new `.cs` files carry the SPDX header; no dependency |+| IV. Verification gate | ✅ `scripts/build.sh` + smoke check for page ids |+| V. One logical change per PR | ✅ one PR: the Settings move (RU strings and docs are their own repos) |+| VI. Documentation stays in sync | ✅ CHANGELOG, FEATURES.md, nota-docs EN+RU, screenshots |+| VII. Spec-first | ✅ this spec |+| VIII. Safety rules not weakened | ✅ |++Post-design re-check: unchanged — all green.++## Project Structure++### Documentation (this feature)++```text+specs/088-settings-reorganisation/+├── spec.md+├── plan.md+├── research.md+├── data-model.md+├── quickstart.md+├── contracts/settings-pages.md+└── tasks.md # /speckit-tasks+```++### Source Code++```text+src/managed/Nota.App/+├── PreferencesWindow.cs # Nav table (groups, pages, ids); Select/ShowPage by id; BuildPane by id;+│ # AudioPane → format only; AppearancePane → look only+├── PreferencesWindow.AudioIo.cs # + OutputsPane, InputsPane (device picker, ASIO pair, note, test tone / input list)+├── PreferencesWindow.Mcp.cs # NEW — McpPane (moved verbatim from AppearancePane)+├── PreferencesWindow.Editing.cs # NEW — EditingPane (piano roll, arrangement, detail panel)+├── PreferencesWindow.Language.cs # + LanguagePane (wraps LanguagePicker + caption)+├── PreferencesWindow.Remote.cs # ShowRemote → Select("Remote")+├── PreferencesWindow.Downloads.cs # DownloadsIndex → id+├── PreferencesWindow.Updates.cs # UpdatesIndex → id+├── MainWindow.Commands.cs # prefs.* → page ids (5 new)+├── MainWindow.AudioFormat.cs # ShowAudioPreferences(page) / ShowInputPreferences+├── ArrangementView.cs # record-input menu "Audio I/O setup" → Inputs+└── Controls/Glyph.cs # + Globe (Language page icon)+src/managed/Nota.Application/+├── Palette/CommandCatalog.cs # 5 new prefs.* commands, keywords moved+└── Localization/en.json # page titles/subtitles, group, ASIO note, commands; status text → Outputs+tests/Nota.SmokeTest/ # page-id check+../nota-translations/languages/ru.json # RU strings (separate repo / PR)+../nota-docs/src/content/docs/{,ru/}preferences/*.mdx (+ pages linking to Settings) # separate repo / PR+```++**Structure Decision**: Stay in the existing partial-class layout of `PreferencesWindow`; one+partial file per page group, matching `Remote`, `Updates`, `Downloads`, `Language`.++## Complexity Tracking++None.diff --git a/specs/088-settings-reorganisation/quickstart.md b/specs/088-settings-reorganisation/quickstart.mdnew file mode 100644index 00000000..377f7751--- /dev/null+++ b/specs/088-settings-reorganisation/quickstart.md@@ -0,0 +1,36 @@+# Quickstart: verify the Settings reorganisation++## Build gate++```bash+scripts/build.sh+```++Passes, including the palette checks (every `prefs.*` command bound) and the page-id check+(every id asked for exists; every page has a command).++## Walk-through (EN, then RU)++1. Open Settings (⌘,). Sidebar reads: Devices — Audio, Outputs, Inputs, MIDI, Gamepads ·+ Remote control — Remote, AI control (MCP) · Plug-ins — Plug-ins, Downloads · General —+ Appearance, Language, Editing, Library, Shortcuts, Updates.+2. **Audio**: sample rate, buffer, latency, CPU check; no device combos, no input list.+3. **Outputs**: pick another output → sound moves; Play test tone → tone; switch page → tone stops.+4. **Inputs**: pick another input device → the input list rebuilds with that device's names.+5. **AI control (MCP)**: switch on → status "Listening on http://127.0.0.1:<port>/"; Copy config.+6. **Appearance**: theme, accent, waveform, track headers, scale, text size — nothing else.+7. **Language**: switch to Russian → restart prompt as before.+8. **Editing**: toggle the three switches; piano-roll labels / split fades / detail panel follow;+ restart → choices kept.+9. Palette (⌘K): "Settings: Outputs", "Settings: Inputs", "Settings: AI control (MCP)",+ "Settings: Language", "Settings: Editing" open their pages; "mcp", "language", "piano roll"+ find them.+10. Track input menu → "Audio I/O setup" opens Inputs. Audio-format menu → "Audio settings…"+ opens Audio. Downloads badge / install-pack links → Downloads.+11. Windows + ASIO: Outputs/Inputs show the driver name and "Change on the Audio page"; the+ output / input pair combos are on Outputs / Inputs.++## Screenshots++Headless-app harness (see memory: Nota UI verify recipe) — each new page and the reduced+Audio / Appearance in Studio Dark, EN + RU; used for the PR and for nota-docs.diff --git a/specs/088-settings-reorganisation/research.md b/specs/088-settings-reorganisation/research.mdnew file mode 100644index 00000000..34314148--- /dev/null+++ b/specs/088-settings-reorganisation/research.md@@ -0,0 +1,80 @@+# Research: Settings reorganisation++## R1 — Select pages by id, not position++- **Decision**: The `Nav` table stays the single source of order. `Select(int)` stays the+ internal primitive (nav items are built with their index), but every caller goes through+ `Select(string id)` / `IndexOf(id)`; `BuildPane` switches on `page.Id`. The constants+ `RemoteIndex`, `DownloadsIndex`, `UpdatesIndex` and the literal `0` / `7` cases are removed.+ An unknown id selects page 0 (edge case: an old caller).+- **Rationale**: Inserting Outputs/Inputs at positions 1–2 and MCP after Remote shifts every+ index; positional constants silently open the wrong page (the issue's own risk).+- **Alternatives**: Re-number the constants — rejected, it breaks again with the next page.++## R2 — What moves where on the audio side++- **Decision**:+ - *Audio*: audio system (Windows), ASIO driver + "Driver settings…", sample rate, buffer size,+ exclusive mode (Windows WASAPI), latency, CPU check ("Performance" row).+ - *Outputs*: output device combo (WASAPI / CoreAudio / ALSA…), test tone ("Output check" row).+ Under ASIO: a read-only "Device" row naming the driver with "Change on the Audio page" link,+ the ASIO output pair combo, test tone.+ - *Inputs*: input device combo, then the spec-086 Inputs section (host rebuilt on change).+ Under ASIO: the driver row as above, the ASIO input pair combo (or "no inputs on this+ driver"), then the Inputs section.+- **Rationale**: The ASIO output/input *pair* is an output/input choice, so it moves with its+ side; the driver itself is the device for both sides and the format, so it stays on Audio+ (spec assumption). Exclusive mode dictates rate/buffer → stays with them.+- **Alternatives**: Duplicate the driver picker on all three pages — rejected (three places to+ change one thing, three rebuild paths).++## R3 — Rebuild and test lifecycle across three pages++- **Decision**: `RebuildAudioPane()` already re-selects the current page; it now applies to+ whichever of Audio / Outputs / Inputs is shown. `OnAudioDeviceRestarted` rebuilds when the+ selected page id is one of those three. `Apply()` keeps updating latency and inputs (both+ null-safe when their page isn't shown — `_latencyValue` / `_inputsHost` are cleared on+ `Select`). `StopTests()` on every `Select` keeps stopping the tone/CPU check on leaving.+- **Rationale**: Same behaviour as today, just per page.++## R4 — Editing page contents++- **Decision**: Three sections in this order: Piano roll ("Label every note…"), Arrangement+ ("Fade audio clips when splitting"), Detail panel ("Open the detail panel when…"). Each keeps+ its caption. `SplitFades` moves off Appearance (it sat under Waveform but is behaviour).+- **Alternatives**: a single-switch "Piano roll" page (issue's first idea) — rejected by the+ widened issue: Editing gathers all editing behaviour and answers the issue's open question.++## R5 — Icons++- **Decision**: Outputs → `Speaker`; Inputs → `Input`; AI control (MCP) → `Action`;+ Editing → `Edit`; Language → new `Globe` path glyph in the 24-unit `Paths` style.+- **Rationale**: Reuse where a glyph already says the thing; only language lacks one.++## R6 — Strings and keys++- **Decision**: New `en.json` keys for: group "Remote control"; page titles Outputs, Inputs,+ AI control (MCP) (reuses `preferences.ai_control_mcp`), Language (reuses+ `preferences.language`), Editing; subtitles for each new page; a new Appearance subtitle key+ (the old `preferences.theme_scale_waveforms_and_ai` is removed — the wording changed, so a+ translation of the old one must not stand in for it); the ASIO note; palette titles+ `commands.settings_outputs|inputs|mcp|language|editing`. Status text "Choose a device in+ Settings → Audio" changes to "… → Outputs" under new keys. Russian goes to+ `nota-translations/languages/ru.json` (the app falls back to English until it lands).+- **Rationale**: Keys are named after their English wording (spec 068); changed wording → new key.++## R7 — Entry points++| Caller | Today | After |+|---|---|---|+| Palette `prefs.*` | 10 pages | 15 pages (`prefs.outputs`, `prefs.inputs`, `prefs.mcp`, `prefs.language`, `prefs.editing`) |+| Audio-format menu "Audio settings…" | Audio | Audio (rate/buffer live there) |+| Record-input menu "Audio I/O setup" | Audio | Inputs |+| Status "no audio output … Settings → Audio" | text only | text says Outputs |+| Skin preview `ShowPage("Appearance")` | Appearance | unchanged |+| `ShowRemote`, `ShowDownloads`, Updates | by index | by id |++Palette keywords: `prefs.appearance` drops "language langue francais english" (→ `prefs.language`);+`prefs.mcp` gets "ai claude mcp server port"; `prefs.editing` gets "piano roll labels note names+split fades detail panel"; `prefs.inputs` "input channels microphone names"; `prefs.outputs`+"output speakers test tone".diff --git a/specs/088-settings-reorganisation/spec.md b/specs/088-settings-reorganisation/spec.mdnew file mode 100644index 00000000..1da9c1ec--- /dev/null+++ b/specs/088-settings-reorganisation/spec.md@@ -0,0 +1,233 @@+# Feature Specification: Settings reorganisation — every setting where you'd look for it++**Feature Branch**: `feat/settings-reorganisation`++**Created**: 2026-11-10++**Status**: Draft++**Input**: User description: "Settings reorganisation (issue #427, approved; scope widened in the issue on 2026-11-10). Reorganise the Preferences/Settings window sidebar so every setting lives where a user would look for it. Behaviour of every setting stays exactly the same — only where it lives changes. New sidebar: Devices group → Audio, Outputs (new), Inputs (new), MIDI, Gamepads. New "Remote control" group → Remote, AI control (MCP) (new page). Plug-ins group unchanged. General group → Appearance (the look only), Language (new), Editing (new), Library, Shortcuts, Updates. With ASIO one driver is both input and output. Outputs gets no per-channel naming/routing. Pages are selected by stable Id rather than position. EN + RU strings; nota-docs (EN + RU) and Settings screenshots updated."++**Issue**: nota-daw/nota#427 — "Settings: reorganise the pages — Inputs/Outputs, MCP, Language+and Editing get their own" (approved). Originally asked to split Appearance (MCP and Piano roll+out); on 2026-11-10 the issue was widened to the whole sidebar, with the table below.++## Nota Context *(fill in — drives plan and tasks)*++**Feature area** *(pick the main one)*:++- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`+- [ ] Docs only++Moves existing sections only: the Inputs list (spec 086), the colour theme and skins (specs+011, 087), the accent (spec 084), the MCP server switch, the piano-roll labels, split fades+and the detail-panel switch (#308). No engine change, no new setting, no stored-setting change.++**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md),+[`../086-multi-input-recording/spec.md`](../086-multi-input-recording/spec.md).++## The new sidebar++| Group | Page | Holds | Was |+|---|---|---|---|+| **Devices** | Audio | Audio system (Windows: WASAPI / ASIO, ASIO driver and its panel), sample rate, buffer size, exclusive mode (Windows), latency, CPU check | Audio |+| | **Outputs** *(new)* | Output device; test tone | Audio |+| | **Inputs** *(new)* | Input device; every input with its switch and name; stereo pairs | Audio |+| | MIDI | unchanged | — |+| | Gamepads | unchanged | — |+| **Remote control** *(new group)* | Remote | unchanged | Devices |+| | **AI control (MCP)** *(new)* | Enable, port, status, copy config | Appearance |+| **Plug-ins** | Plug-ins, Downloads | unchanged | — |+| **General** | Appearance | Colour theme (with skins), accent, interface scale, text size, waveform style, track-header side | Appearance |+| | **Language** *(new)* | Interface language | Appearance |+| | **Editing** *(new)* | Piano roll: label every note · Arrangement: fade audio clips when splitting · Detail panel: open on select | Appearance |+| | Library, Shortcuts, Updates | unchanged | — |++## User Scenarios & Testing *(mandatory)*++### User Story 1 - Find a setting on the page its name suggests (Priority: P1)++A user wants to turn on the MCP server, switch the interface language, or make the piano roll+label every note. They open Settings and find each one on a page whose name says what it is —+"AI control (MCP)", "Language", "Editing" — instead of under "Appearance".++**Why this priority**: This is the reason for the issue: settings that aren't about the look+are hidden under Appearance, and that page only grows.++**Independent Test**: Open Settings; the sidebar shows the groups and pages of the table above in+that order; each moved setting is on its new page, and Appearance holds only the look.++**Acceptance Scenarios**:++1. **Given** Settings is open, **When** the user reads the sidebar, **Then** it shows Devices+ (Audio, Outputs, Inputs, MIDI, Gamepads), Remote control (Remote, AI control (MCP)),+ Plug-ins (Plug-ins, Downloads), General (Appearance, Language, Editing, Library, Shortcuts,+ Updates), each page with its icon and subtitle.+2. **Given** the AI control (MCP) page, **When** the user switches the server on, edits the+ port and presses Copy config, **Then** the server starts, the status line, dimming and the+ copied JSON behave exactly as they did on Appearance.+3. **Given** the Editing page, **When** the user toggles "Label every note", "Fade audio clips+ when splitting" or "Open the detail panel", **Then** the piano roll, splitting and the detail+ panel react exactly as before, and the choice survives a restart.+4. **Given** the Language page, **When** the user picks another language, **Then** the same+ restart-to-apply behaviour as before follows.+5. **Given** the Appearance page, **When** the user reads it, **Then** it shows only colour+ theme (with skins), accent, interface scale, text size, waveform style and track-header+ side, and its subtitle no longer mentions AI control.++---++### User Story 2 - Set up inputs and outputs on their own pages (Priority: P1)++A user plugging in an interface picks the output device and plays the test tone on Outputs,+then picks the input device and switches on and names the inputs on Inputs, without scrolling+past sample rate, buffer and CPU check.++**Why this priority**: The Audio page carries device, format, the per-input list (which can be+dozens of rows on a large interface) and the tests on one page; inputs and outputs are what a+user comes for most often.++**Independent Test**: With a multi-input interface, choose output and input devices on their+pages; the Inputs list follows the input device; the Audio page shows format, latency and CPU+check only.++**Acceptance Scenarios**:++1. **Given** the Outputs page (WASAPI / CoreAudio / Linux), **When** the user picks an output+ device, **Then** the engine switches to it as before, and the test tone plays on it.+2. **Given** the Inputs page, **When** the user picks another input device, **Then** the input+ list below rebuilds for that device, with the names and switches kept for it (spec 086).+3. **Given** the Audio page, **When** the user changes sample rate or buffer size, **Then**+ latency updates there as before, and nothing about devices or inputs is on that page.+4. **Given** Windows with ASIO chosen on the Audio page, **When** the user opens Outputs or+ Inputs, **Then** the page says the ASIO driver on the Audio page is both input and output+ (with a way to go there), Outputs still offers the test tone, and Inputs still lists the+ driver's inputs with their switches and names.+5. **Given** no input device (or one with no inputs), **When** the user opens Inputs, **Then**+ it shows the same "no inputs" caption as today's Inputs section.++---++### User Story 3 - Everything that opens a Settings page still lands on the right one (Priority: P2)++Commands and links that open Settings on a page — the command palette's "Settings: …"+entries, the audio-format warning, Downloads, the skin preview — open the page that now holds+what they point at.++**Why this priority**: Without it, the move breaks existing entry points silently (wrong page,+or nothing).++**Independent Test**: Run each palette Settings command and each in-app link; each opens the+expected page.++**Acceptance Scenarios**:++1. **Given** the command palette, **When** the user runs "Settings: Appearance", "Settings:+ Audio" … **Then** each opens its page; new commands "Settings: Outputs", "Settings: Inputs",+ "Settings: AI control (MCP)", "Settings: Language", "Settings: Editing" open theirs, and+ searching "language", "mcp", "piano roll", "input" finds the page that now holds it.+2. **Given** the Downloads badge and "install pack" links, **When** used, **Then** the Downloads+ page opens on the requested source and its badge sits on the Downloads item, as before.+3. **Given** a remote-pairing request or an update, **When** Nota asks to show Remote or+ Updates, **Then** the right page opens even though its position in the list changed.++---++### Edge Cases++- A Settings page asked for by an id that no longer exists (an old caller) → nothing breaks;+ the window opens on its first page.+- Audio device changes while Settings is open (hot-plug, device lost): Outputs and Inputs+ refresh their device lists and the Inputs list the way Audio does today.+- Switching between Audio, Outputs and Inputs while a test tone or CPU check runs: they stop+ on leaving their page, as today on leaving Audio.+- Interface scale / text size / language changes rebuild the window: the page the user was on+ stays selected.+- Russian titles and subtitles fit the sidebar width without clipping.++## Requirements *(mandatory)*++### Functional Requirements++- **FR-001**: The Settings sidebar MUST show the groups and pages of "The new sidebar" table,+ in that order, with titles and subtitles in English and Russian.+- **FR-002**: Every setting MUST keep its current behaviour, stored value and default; only its+ page changes. No setting is added or removed.+- **FR-003**: Outputs MUST hold the output-device picker and the test tone; Inputs MUST hold the+ input-device picker and the Inputs list of spec 086 (inputs, switches, names, stereo pairs);+ Audio MUST keep the audio system (Windows), sample rate, buffer size, exclusive mode+ (Windows), latency and CPU check.+- **FR-004**: When ASIO is the audio system, Outputs and Inputs MUST explain that the ASIO+ driver chosen on Audio is the device for both, offer a way to go to Audio, and keep the test+ tone (Outputs) and the input list (Inputs). The ASIO output pair moves to Outputs and the+ ASIO input pair to Inputs; the driver picker and its panel stay on Audio.+- **FR-005**: AI control (MCP) MUST be its own page in the new Remote control group, next to+ Remote, holding the MCP switch, port, status and Copy config as they are now.+- **FR-006**: Language MUST be its own page in General, holding the language picker and its+ caption.+- **FR-007**: Editing MUST be its own page in General with three sections: Piano roll (label+ every note), Arrangement (fade audio clips when splitting), Detail panel (open on select).+- **FR-008**: Appearance MUST hold only colour theme (with skins), accent, interface scale, text+ size, waveform style and track-header side, with a subtitle that matches.+- **FR-009**: Pages MUST be chosen by a stable id, not by their position: every caller that+ opens a page (command palette, audio-format menu, the track input menu's "Audio I/O setup"+ → Inputs, Downloads and its badge, Remote, Updates, skin preview) MUST open the page that+ now holds its content, and text that names a Settings page ("Choose a device in Settings →+ Audio" → Outputs) MUST name the new one.+- **FR-010**: The command palette MUST offer a "Settings: …" command for every page, including+ the five new ones, with search keywords that follow the moved settings.+- **FR-011**: The user documentation (nota-docs, EN + RU) and the Settings screenshots MUST+ show the new pages; CHANGELOG `[Unreleased]` and FEATURES.md MUST note the move.++### Key Entities++- **Settings page**: a stable id (what callers ask for), a title, a subtitle, an icon, the group+ it belongs to, and the sections it shows.+- **Settings group**: a heading in the sidebar and its pages in order.++## Success Criteria *(mandatory)*++### Measurable Outcomes++- **SC-001**: Each of the moved settings (MCP, language, piano-roll labels, split fades,+ detail panel, output device, input device, input list) is reached in two clicks from opening+ Settings: the page named for it, then the control.+- **SC-002**: Appearance holds 6 settings instead of 11; Audio no longer contains device+ pickers or the input list.+- **SC-003**: 100% of in-app entry points into Settings (palette commands and links) open the+ page that holds their content.+- **SC-004**: Every setting keeps its stored value across the update — no user has to set+ anything again.++## Assumptions++- Outputs has no per-channel naming or routing: that needs engine work and is a separate+ feature; the page starts with the device and the test tone.+- With ASIO the driver picker stays on Audio (it chooses the audio system's device as a whole);+ Outputs / Inputs point there instead of duplicating it.+- The velocity wheel stays on Shortcuts (it documents a gesture); the Shortcuts page is not+ reorganised here.+- Remote and the MCP server both are "something outside Nota controls it", hence their own+ group; the group is called "Remote control" ("Удалённое управление").+- The new pages reuse existing sidebar icons where one fits; a missing icon is drawn in the+ existing glyph style.+- Skins (spec 087) land first; this branch sits on top of `feat/user-skins` and is rebased onto+ `develop` once skins merge.++## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*++- [x] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md)+- [x] No new dependency+- [x] Audio-thread impact considered: none — UI-only move; engine calls stay the same+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/`+- [x] Smoke-test impact assessed: no engine behaviour change → no smoke-test change+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned, FEATURES.md and nota-docs (EN + RU) via the nota-features / nota-docs skills+- [x] UI change → follows `DESIGN.md` (Studio design language)diff --git a/specs/088-settings-reorganisation/tasks.md b/specs/088-settings-reorganisation/tasks.mdnew file mode 100644index 00000000..4cdc314d--- /dev/null+++ b/specs/088-settings-reorganisation/tasks.md@@ -0,0 +1,103 @@+---+description: "Tasks: Settings reorganisation (#427)"+---++# Tasks: Settings reorganisation — every setting where you'd look for it++**Input**: `specs/088-settings-reorganisation/` — plan.md, spec.md, research.md, data-model.md,+contracts/settings-pages.md, quickstart.md++**Tests**: one smoke check (page ids ↔ palette commands), per plan; the rest is the build gate+and the visual walk-through in quickstart.md.++## Format: `[ID] [P?] [Story] Description`++---++## Phase 1: Setup++- [X] T001 Confirm branch `feat/settings-reorganisation` builds before changes: `dotnet build src/managed/Nota.App` (baseline)++---++## Phase 2: Foundational — pages by id (blocks every story)++- [X] T002 In `src/managed/Nota.App/PreferencesWindow.cs` add `IndexOf(string id)` (unknown id → 0) and `Select(string id)`; make `ShowPage(id)` use it; `BuildPane(int)` switches on `Pages.ElementAt(index).Id` instead of positions; the Downloads branch in `Select(int)` and `UpdateDownloadsBadge` compare/use `IndexOf("Downloads")`+- [X] T003 Remove the positional constants: `RemoteIndex` in `PreferencesWindow.Remote.cs` (`ShowRemote` → `Select("Remote")`), `DownloadsIndex` in `PreferencesWindow.Downloads.cs`, `UpdatesIndex` in `PreferencesWindow.Updates.cs`; `OnAudioDeviceRestarted` rebuilds when the selected id is `Audio`, `Outputs` or `Inputs` (`PreferencesWindow.cs`)+- [X] T004 Rewrite the `Nav` table in `PreferencesWindow.cs` to the contract order — Devices: `Audio`, `Outputs`, `Inputs`, `MIDI`, `Gamepads` · Remote control: `Remote`, `MCP` · Plug-ins: `Plug-ins`, `Downloads` · General: `Appearance`, `Language`, `Editing`, `Library`, `Shortcuts`, `Updates` — with icons Speaker / Input / Action / Globe / Edit (R5) and the subtitle keys of contracts/settings-pages.md+- [X] T005 [P] Add the `Globe` path glyph to `src/managed/Nota.App/Controls/Glyph.cs` (24-unit `Paths` style, stroke like `Appearance`)+- [X] T006 [P] Add the new keys of contracts/settings-pages.md to `src/managed/Nota.Application/Localization/en.json`; remove `preferences.theme_scale_waveforms_and_ai` once nothing uses it++**Checkpoint**: window opens; every page id resolves (new panes may still be placeholders).++---++## Phase 3: User Story 1 — find a setting on the page its name suggests (P1) 🎯 MVP++**Goal**: MCP, Language and Editing get their own pages; Appearance holds only the look.+**Independent test**: quickstart steps 1, 5–8.++- [X] T007 [P] [US1] Create `src/managed/Nota.App/PreferencesWindow.Mcp.cs` (SPDX header) with `McpPane()` — the MCP block moved verbatim from `AppearancePane` (port box, status, Copy config, `ApplyMcp`, `Refresh`), one `Section(Loc.T("preferences.ai_control_mcp"), 12, enable, details)`+- [X] T008 [P] [US1] Create `src/managed/Nota.App/PreferencesWindow.Editing.cs` (SPDX header) with `EditingPane()` — sections Piano roll (label every note + caption), Arrangement (`preferences.arrangement`: fade audio clips when splitting + caption, still sets `_main.Engine.SplitFades`), Detail panel (open on select + caption)+- [X] T009 [P] [US1] Add `LanguagePane()` to `src/managed/Nota.App/PreferencesWindow.Language.cs`: one section with `LanguagePicker()` and its caption `preferences.the_language_of_menus_panels`+- [X] T010 [US1] Reduce `AppearancePane()` in `PreferencesWindow.cs` to colour theme (+ follow-system caption), accent, waveform, track headers, interface scale, text size, each with its caption; wire `MCP` / `Language` / `Editing` ids in `BuildPane`++**Checkpoint**: US1 independently testable.++---++## Phase 4: User Story 2 — inputs and outputs on their own pages (P1)++**Goal**: Audio = format, latency, CPU check; Outputs = output device (+ ASIO output pair) and test tone; Inputs = input device (+ ASIO input pair) and the spec-086 list.+**Independent test**: quickstart steps 2–4, 11.++- [X] T011 [US2] Split `AudioPane()` in `PreferencesWindow.cs`: drop the output/input combos and `InputsHost`; keep audio system, ASIO driver row (+ Driver settings…), sample rate, buffer, exclusive (Windows), latency; Test section keeps only `CpuCheckRow`. Split `AsioRows` so the driver/rate/buffer rows stay and the output / input pair rows become helpers used by the new panes+- [X] T012 [US2] Add `OutputsPane()` to `src/managed/Nota.App/PreferencesWindow.AudioIo.cs`: non-ASIO → `Row(common.output, outputCombo)` (same `FillDeviceCombo` / `SetAudioOutputDevice` / `Apply`); ASIO → driver note row (`preferences.asio_device_on_audio` with the driver name + `preferences.change_on_audio_page` button → `Select("Audio")`) and, when running, the output pair combo; then a Test section with `TestToneRow()`+- [X] T013 [US2] Add `InputsPane()` to `PreferencesWindow.AudioIo.cs`: non-ASIO → input combo (`SetAudioInputDevice` / `Apply`); ASIO → the driver note row and, when running, the input pair combo or `preferences.no_inputs_on_this_driver`; then `InputsHost(engine)`; header comment updated (Inputs now its own page)+- [X] T014 [US2] Make `_latencyValue`, `_latencyDetail` and `_inputsHost` reset to null in `Select(int)` so `Apply()`/`UpdateLatency()`/`RebuildInputs()` touch only controls of the page shown (`PreferencesWindow.cs`, `PreferencesWindow.AudioIo.cs`); `_main is null` on Outputs/Inputs shows the same "unavailable" caption as Audio++**Checkpoint**: US2 independently testable.++---++## Phase 5: User Story 3 — entry points land on the right page (P2)++**Goal**: every caller opens the page that now holds its content.+**Independent test**: quickstart steps 9–10.++- [X] T015 [P] [US3] Add `prefs.outputs`, `prefs.inputs`, `prefs.mcp`, `prefs.language`, `prefs.editing` to `src/managed/Nota.Application/Palette/CommandCatalog.cs` with the R7 keywords; move "language langue francais english" off `prefs.appearance`+- [X] T016 [US3] Bind the five commands to their page ids in `src/managed/Nota.App/MainWindow.Commands.cs`+- [X] T017 [US3] Record-input menu "Audio I/O setup" → Inputs: add `ShowInputPreferences()` (`ShowPreferencesPage("Inputs")`) in `src/managed/Nota.App/MainWindow.AudioFormat.cs`, call it from `src/managed/Nota.App/ArrangementView.cs`; fix the `ShowAudioPreferences` doc comment (format menu → Audio)+- [X] T018 [US3] No-output status text names Outputs: new keys in `en.json`, used in `src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs`; drop the old keys+- [X] T019 [US3] Smoke check in `tests/Nota.SmokeTest/PaletteTests.cs`: every `prefs.*` page id bound in `MainWindow.Commands.cs` appears as a `new Page("<id>"` in `PreferencesWindow.cs`, and every page id has a `prefs.*` command++---++## Phase 6: Polish & cross-cutting++- [X] T020 Grep for leftover references: `ShowPage("`, `Select(` with literals, `preferences.theme_scale_waveforms_and_ai`, `RemoteIndex|DownloadsIndex|UpdatesIndex`; `grep` en.json for "Settings → Appearance"/"→ Audio" texts that now mean another page+- [X] T021 Build gate: `scripts/build.sh` passes (smoke test incl. T019 and palette checks)+- [X] T022 Visual check with the headless-app harness: every page EN, Studio Dark; Russian once RU strings exist; nothing clipped in the sidebar+- [X] T023 [P] `CHANGELOG.md` `[Unreleased]` → Changed entry (Settings reorganised, #427)+- [X] T024 [P] FEATURES.md via the `nota-features` skill+- [ ] T025 [P] Russian strings for the new keys in `../nota-translations/languages/ru.json` (separate repo/PR; remove the dropped keys there too)+- [X] T026 nota-docs EN + RU via the `nota-docs` skill: split `preferences/audio.mdx` into audio / outputs / inputs, `preferences/appearance.mdx` into appearance / language / editing, new `preferences/mcp.mdx`; fix links in `ai/mcp`, `views/detail-panel`, `editing/audio-clips`, `editing/time-ranges`, `views/arrangement`, `library/preview-player`, `control/nota-remote`; reshoot Settings screenshots (separate repo/PR)++---++## Dependencies & execution order++- Phase 2 blocks everything (T002–T004 sequential in one file; T005, T006 parallel).+- US1 (T007–T010) and US2 (T011–T014) are independent of each other; T010 and T011 both edit `PreferencesWindow.cs` — do them one after the other.+- US3 depends on the ids from Phase 2 only; T015 parallel with US1/US2.+- Polish after all stories; T023–T025 parallel.++## Parallel examples++- US1: T007, T008, T009 (three different files) together, then T010.+- US3: T015 alongside any US1/US2 task.++## Implementation strategy++MVP = Phase 2 + US1 (the issue's original ask). Then US2 (Audio split), US3 (entry points),+polish, docs/translations in their repos.diff --git a/src/managed/Nota.App/App.axaml.cs b/src/managed/Nota.App/App.axaml.csindex 50204f98..135dc97f 100644--- a/src/managed/Nota.App/App.axaml.cs+++ b/src/managed/Nota.App/App.axaml.cs@@ -27,6 +27,8 @@ public partial class App : Avalonia.Application// One typeface with tabular figures, so digits keep their width everywhere.NotaFonts.InstallTabular();NotaTextSize.Install();+ // A skin's typeface and corner radii (spec 087), by the same kind of coercion.+ NotaSkin.Install();// Rounded, bordered, clipping Borders clip their child to the inner edge.BorderInnerClip.Install();AvaloniaXamlLoader.Load(this);@@ -101,12 +103,21 @@ public partial class App : Avalonia.Applicatione.SetObserved();};+ // Interface language (spec 068), before any view model, window or static text table+ // exists — and before the themes, whose load problems are interface text (spec 087):+ // the language is fixed for the run, so those texts are built once, in it.+ InstallLanguage(Services.GetRequiredService<ISettingsService>().Current, log);// Colour theme (Preferences → Appearance), applied before the first window paints so// nothing flashes one theme on the way to another. Old Dark / Light / System// settings resolve onto the Studio themes (Appearance.Resolve).foreach (var err in NotaThemes.LoadErrors) log.Error($"Colour theme skipped — {err}", null);+ // User themes (spec 087) load first, so a stored user theme id resolves to itself.+ NotaThemes.ReloadUser();+ foreach (var (file, reason) in NotaThemes.UserLoadProblems) log.Info($"User theme skipped — {file}: {reason}");// The accent (spec 084) is resolved with it, so the first frame already wears it too.var startSettings = Services.GetRequiredService<ISettingsService>().Current;+ NotaThemeService.StoredChoice = () => Appearance.Resolve(+ Services.GetRequiredService<ISettingsService>().Current, NotaThemeService.KnownThemes);NotaThemeService.Set(Appearance.Resolve(startSettings, NotaThemeService.KnownThemes));NotaThemeService.SetAccent(Accent.Resolve(startSettings));// Interface scale (spec 027), likewise before the first window: windows and every@@ -115,9 +126,6 @@ public partial class App : Avalonia.ApplicationNotaUiScale.Set(Services.GetRequiredService<ISettingsService>().Current.InterfaceScale);// Text size (spec 038), likewise: every text the app draws takes its step.NotaTextSize.Set(Services.GetRequiredService<ISettingsService>().Current.TextSize);- // Interface language (spec 068), before any view model, window or static text table- // exists: the language is fixed for the run, so those texts are built once, in it.- InstallLanguage(Services.GetRequiredService<ISettingsService>().Current, log);TranslateAppMenu();TextBoxMenu.Install(); // the text boxes' Cut / Copy / Paste menu is Avalonia's, in Englishdiff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex 7b9e2bf6..9b1474ff 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -1247,7 +1247,7 @@ public sealed partial class ArrangementViewrx1 = Math.Max(rx0, _o.BeatToX(re.AudioRecordStartBeat + re.AudioRecordLengthBeatsOf(rt)));}var rr = new Rect(rx0, ry + 2, Math.Max(2, rx1 - rx0), rh - 4);- ctx.DrawRectangle(RecFill, RecBorder, rr, 4, 4);+ ctx.DrawRectangle(RecFill, RecBorder, rr, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);// Live waveform of what's being captured, so the take shows real// signal rather than an empty box (clips only materialise on stop).DrawRecPeaks(ctx, re, rr, rt);@@ -1312,7 +1312,7 @@ public sealed partial class ArrangementViewFlowDirection.LeftToRight, Typeface.Default, 10, TooltipText);double tx = Math.Clamp(_lastPos.X + 12, 6, Math.Max(6, w - ft.Width - 10));double ty = Math.Max(4, _lastPos.Y - 24);- ctx.DrawRectangle(TooltipBg, null, new Rect(tx - 5, ty - 3, ft.Width + 10, ft.Height + 6), 3, 3);+ ctx.DrawRectangle(TooltipBg, null, new Rect(tx - 5, ty - 3, ft.Width + 10, ft.Height + 6), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(tx, ty));}@@ -1323,7 +1323,7 @@ public sealed partial class ArrangementViewFlowDirection.LeftToRight, Typeface.Default, 10, TooltipText);double tx = Math.Clamp(_lastPos.X + 12, 6, Math.Max(6, w - ft.Width - 10));double ty = Math.Max(4, _lastPos.Y - 24);- ctx.DrawRectangle(TooltipBg, null, new Rect(tx - 5, ty - 3, ft.Width + 10, ft.Height + 6), 3, 3);+ ctx.DrawRectangle(TooltipBg, null, new Rect(tx - 5, ty - 3, ft.Width + 10, ft.Height + 6), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(tx, ty));}@@ -1545,7 +1545,7 @@ public sealed partial class ArrangementViewif (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);+ ctx.DrawRectangle(fill, border, r, NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));}return;}@@ -1554,7 +1554,7 @@ public sealed partial class ArrangementViewdouble 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);+ ctx.DrawRectangle(fill, border, new Rect(x0, y + padTop, Math.Max(2, x1 - x0), innerH), NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));}}@@ -1611,7 +1611,7 @@ public sealed partial class ArrangementViewprivate const double BandH = 2; // the content area starts under this (ADSR frame, notes)private const double LabelH = 18; // the clip name's line over the notes and waveformprivate const double NameMinClipH = 30; // a clip taller than this (a row over 34 px) shows its name- private const double ClipRadius = 6;+ private static double ClipRadius => NotaRadius.FieldValue; // 6, as the skin draws it// The clip's ADSR: the curve whenever it shapes the clip, the handles while the clip is// hovered, selected or being edited. Drawn in the clip's own colour; the hot handle is brass.diff --git a/src/managed/Nota.App/ArrangementView.Overview.cs b/src/managed/Nota.App/ArrangementView.Overview.csindex 6dd9b19a..5b0629aa 100644--- a/src/managed/Nota.App/ArrangementView.Overview.cs+++ b/src/managed/Nota.App/ArrangementView.Overview.cs@@ -329,7 +329,7 @@ public sealed partial class ArrangementView// at the very end is pushed left, not clamped to nothing).x0 = Math.Clamp(x0, 0, Math.Max(0, w - 2));x1 = Math.Clamp(x1, x0 + 2, Math.Max(x0 + 2, w));- ctx.DrawRectangle(OvWindow, OvFrame, new Rect(x0 + 0.5, 2.5, Math.Max(1, x1 - x0 - 1), h - 5), 2, 2);+ ctx.DrawRectangle(OvWindow, OvFrame, new Rect(x0 + 0.5, 2.5, Math.Max(1, x1 - x0 - 1), h - 5), NotaRadius.FineValue, NotaRadius.FineValue);// Loop region: a thin brass band along the top edge (the ruler owns the full// brace). Drawn over the scrim — a loop outside the viewport still has to show.diff --git a/src/managed/Nota.App/ArrangementView.Sections.cs b/src/managed/Nota.App/ArrangementView.Sections.csindex 8a828133..861b8d96 100644--- a/src/managed/Nota.App/ArrangementView.Sections.cs+++ b/src/managed/Nota.App/ArrangementView.Sections.cs@@ -621,7 +621,7 @@ public sealed partial class ArrangementViewprivate void DrawSpan(DrawingContext ctx, ArrangementSection s, Rect r, bool warm){- ctx.DrawRectangle(warm ? WarmFill : ColdFill, null, r, 3, 3);+ ctx.DrawRectangle(warm ? WarmFill : ColdFill, null, r, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.FillRectangle(warm ? WarmEdge : ColdEdge, new Rect(r.X, r.Y, 2, r.Height));if (r.Width <= 22) return;var ft = new NotaFormattedText(_o.SectionDisplayName(s), CultureInfo.InvariantCulture,@@ -664,7 +664,7 @@ public sealed partial class ArrangementViewvar r = new Rect(x0, 2, Math.Max(2, x1 - x0), h - 4);if (reorder && i == _from){- ctx.DrawRectangle(DraftFill, DraftPen, r, 3, 3); // the landing slot+ ctx.DrawRectangle(DraftFill, DraftPen, r, NotaRadius.SwitchValue, NotaRadius.SwitchValue); // the landing slotctx.FillRectangle(InsertBar, new Rect(r.X - 1, 0, 2, h));continue;}@@ -678,7 +678,7 @@ public sealed partial class ArrangementViewusing (ctx.PushOpacity(0.8)){DrawSpan(ctx, me, g, true);- ctx.DrawRectangle(null, GhostPen, g, 3, 3);+ ctx.DrawRectangle(null, GhostPen, g, NotaRadius.SwitchValue, NotaRadius.SwitchValue);}}}@@ -689,7 +689,7 @@ public sealed partial class ArrangementViewdouble a = _o.BeatToX(_o.SnapBar(Math.Min(_pressBeat, _draftEnd)));double b = _o.BeatToX(_o.SnapBar(Math.Max(_pressBeat, _draftEnd)));var r = new Rect(a, 2, Math.Max(2, b - a), h - 4);- ctx.DrawRectangle(DraftFill, DraftPen, r, 3, 3);+ ctx.DrawRectangle(DraftFill, DraftPen, r, NotaRadius.SwitchValue, NotaRadius.SwitchValue);}// Playhead tick, so the lane and the ruler read as one instrument.diff --git a/src/managed/Nota.App/ArrangementView.Takes.cs b/src/managed/Nota.App/ArrangementView.Takes.csindex c3ef9b0d..afa13a92 100644--- a/src/managed/Nota.App/ArrangementView.Takes.cs+++ b/src/managed/Nota.App/ArrangementView.Takes.cs@@ -290,7 +290,7 @@ public sealed partial class ArrangementViewFlowDirection.LeftToRight, NotaFonts.SansSemiBold, 9.5, RulerText);double lx = Math.Max(4, Math.Min(x0 + 4, w - ft.Width - 8));var plate = new Rect(lx - 3, y + 4, ft.Width + 6, ft.Height + 1);- ctx.DrawRectangle(LabelPlate, null, plate, 2, 2);+ ctx.DrawRectangle(LabelPlate, null, plate, NotaRadius.FineValue, NotaRadius.FineValue);ctx.DrawText(ft, new Point(lx, y + 4));}}diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex f9d03d8d..4b78fa8b 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -2805,7 +2805,7 @@ public sealed partial class ArrangementView : UserControlforeach (var c in choices.Skip(fixedCount)) recInput.Items.Add(c);recInput.Items.Add(new Separator());recInput.Items.Add(MenuKit.Item(Loc.T("record_input_pick.audio_io_setup"), GlyphKind.Levels,- () => (TopLevel.GetTopLevel(this) as MainWindow)?.ShowAudioPreferences()));+ () => (TopLevel.GetTopLevel(this) as MainWindow)?.ShowInputPreferences()));}// MIDI input ▸ (instrument tracks): which device and channel reach the track (specs/086).diff --git a/src/managed/Nota.App/AudioClipEditorView.cs b/src/managed/Nota.App/AudioClipEditorView.csindex 0f167014..8f6de424 100644--- a/src/managed/Nota.App/AudioClipEditorView.cs+++ b/src/managed/Nota.App/AudioClipEditorView.cs@@ -1801,7 +1801,7 @@ public sealed class AudioClipEditorView : UserControldouble cx = Math.Clamp((x0 + x1) / 2, cw / 2 + 2, w - cw / 2 - 2);if (cx < 0 || cx > w) continue;var chip = new Rect(cx - cw / 2, RulerH + 3, cw, chH);- ctx.DrawRectangle(hotChip ? ChipBgHot : ChipBg, hotChip ? ChipEdgeHot : ChipEdge, chip.Deflate(0.5), 3, 3);+ ctx.DrawRectangle(hotChip ? ChipBgHot : ChipBg, hotChip ? ChipEdgeHot : ChipEdge, chip.Deflate(0.5), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(num, new Point(chip.X + 6, chip.Y + (chH - num.Height) / 2));_bpmHot.Add((chip, i, bpm));}@@ -1819,7 +1819,7 @@ public sealed class AudioClipEditorView : UserControldouble cw = ft.Width + 12;double lx = x + 9 + cw > w ? x - 9 - cw : x + 9;var chip = new Rect(lx, RulerH + 3, cw, 16);- ctx.DrawRectangle(ChipBgHot, ChipEdgeHot, chip.Deflate(0.5), 3, 3);+ ctx.DrawRectangle(ChipBgHot, ChipEdgeHot, chip.Deflate(0.5), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(chip.X + 6, chip.Y + (16 - ft.Height) / 2));}}@@ -1897,7 +1897,7 @@ public sealed class AudioClipEditorView : UserControlvar ft = new NotaFormattedText(ClipAdsrKit.Readout(_adsrDrag, adsrFit, _bpm), NotaNum.Culture, FlowDirection.LeftToRight, GridFace, 9, ChipInkHot);double cw = ft.Width + 12;var chip = new Rect(Math.Clamp(adsrF.Left + 8, 2, Math.Max(2, w - cw - 2)), top + 6, cw, 16);- ctx.DrawRectangle(ChipBgHot, ChipEdgeHot, chip.Deflate(0.5), 3, 3);+ ctx.DrawRectangle(ChipBgHot, ChipEdgeHot, chip.Deflate(0.5), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(chip.X + 6, chip.Y + (16 - ft.Height) / 2));}}diff --git a/src/managed/Nota.App/Controls/ArpGrid.cs b/src/managed/Nota.App/Controls/ArpGrid.csindex db0b4aa9..26185d1a 100644--- a/src/managed/Nota.App/Controls/ArpGrid.cs+++ b/src/managed/Nota.App/Controls/ArpGrid.cs@@ -317,7 +317,7 @@ internal sealed class ArpGrid : Controlvar ft = new NotaFormattedText(DeviceCardKit.NoteName(top ? rows[0] : rows[^1]), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NumFace, NotaType.Axis, NotaPalette.TextTertiary, this);double x = w.X + 4, y = top ? w.Y + 3 : w.Bottom - 3 - ft.Height;if (!bottomFree && !topFree)- ctx.DrawRectangle(NotaGraph.Ground, null, new RoundedRect(new Rect(x - 2, y, ft.Width + 4, ft.Height), 2));+ ctx.DrawRectangle(NotaGraph.Ground, null, new RoundedRect(new Rect(x - 2, y, ft.Width + 4, ft.Height), NotaRadius.FineValue));ctx.DrawText(ft, new Point(x, y));}@@ -346,8 +346,8 @@ internal sealed class ArpGrid : Control{double x = w.X + c * cw + off + k * cellW / rat + 1;var rc = new Rect(x, w.Y + r * rh + 1, Math.Max(1, cellW / rat - 2), Math.Max(1, rh - 2));- if (muted) ctx.DrawRectangle(null, new Pen(border, 1), rc.Deflate(0.5), 2, 2);- else ctx.DrawRectangle(fill, null, rc, 2, 2);+ if (muted) ctx.DrawRectangle(null, new Pen(border, 1), rc.Deflate(0.5), NotaRadius.FineValue, NotaRadius.FineValue);+ else ctx.DrawRectangle(fill, null, rc, NotaRadius.FineValue, NotaRadius.FineValue);}}}@@ -365,17 +365,17 @@ internal sealed class ArpGrid : Controlif (lane.Base == LRatchet){double q = w.Height / 4;- for (int k = 0; k < (int)d; k++) ctx.DrawRectangle(fill, null, new Rect(x, w.Bottom - (k + 1) * q + 2, bw, Math.Max(1, q - 3)), 1, 1);+ for (int k = 0; k < (int)d; k++) ctx.DrawRectangle(fill, null, new Rect(x, w.Bottom - (k + 1) * q + 2, bw, Math.Max(1, q - 3)), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}else if (lane.Bipolar){double h = Math.Abs(f - 0.5) * w.Height, mid = w.Y + w.Height / 2;- ctx.DrawRectangle(fill, null, new Rect(x, f >= 0.5 ? mid - h : mid, bw, Math.Max(h, 1)), 1, 1);+ ctx.DrawRectangle(fill, null, new Rect(x, f >= 0.5 ? mid - h : mid, bw, Math.Max(h, 1)), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}else{double h = Math.Max(f, 0.02) * w.Height;- ctx.DrawRectangle(fill, null, new Rect(x, w.Bottom - h, bw, h), 1, 1);+ ctx.DrawRectangle(fill, null, new Rect(x, w.Bottom - h, bw, h), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}if (!Mini)diff --git a/src/managed/Nota.App/Controls/AutoShiftViews.cs b/src/managed/Nota.App/Controls/AutoShiftViews.csindex 906b77b2..559b26d6 100644--- a/src/managed/Nota.App/Controls/AutoShiftViews.cs+++ b/src/managed/Nota.App/Controls/AutoShiftViews.cs@@ -166,7 +166,7 @@ internal sealed class AsTraceView : Controlbool now = k >= _n;var r = new Rect(X(s), y - bh / 2, Math.Max(2, X(k - 1) - X(s)), bh);ctx.DrawRectangle(now ? NotaPalette.Wash(NotaPalette.Accent, 0x4C) : NotaPalette.Wash(NotaPalette.VizInk, 0x2E),- new Pen(now ? NotaPalette.AccentBright : NotaPalette.VizInk, now ? 1.2 : 1), new RoundedRect(r, 2));+ new Pen(now ? NotaPalette.AccentBright : NotaPalette.VizInk, now ? 1.2 : 1), new RoundedRect(r, NotaRadius.FineValue));}}diff --git a/src/managed/Nota.App/Controls/BeatRepeatViews.cs b/src/managed/Nota.App/Controls/BeatRepeatViews.csindex 436315d9..1513ac6c 100644--- a/src/managed/Nota.App/Controls/BeatRepeatViews.cs+++ b/src/managed/Nota.App/Controls/BeatRepeatViews.cs@@ -86,7 +86,7 @@ internal sealed class BrTimelineView : Control2 => NotaPalette.Wash(NotaPalette.VizInk, (byte)Math.Clamp(60 + 150 * g, 50, 210)),_ => NotaPalette.Wash(NotaPalette.TextTertiary, 0x38),};- ctx.DrawRectangle(fill, null, r, 2, 2);+ ctx.DrawRectangle(fill, null, r, NotaRadius.FineValue, NotaRadius.FineValue);}// Interval boundaries (dashed) and the trigger points (ticks at the top).diff --git a/src/managed/Nota.App/Controls/CeilingViews.cs b/src/managed/Nota.App/Controls/CeilingViews.csindex c7e1c51b..d1b48ed1 100644--- a/src/managed/Nota.App/Controls/CeilingViews.cs+++ b/src/managed/Nota.App/Controls/CeilingViews.cs@@ -88,13 +88,13 @@ internal sealed class CeLevelView : ShDragViewif (_in[i] > Lo){double iy = Y(_in[i]);- ctx.DrawRectangle(inFill, null, new Rect(x, iy, bw, bot - iy), 1, 1);- if (iy < cy - 0.5) ctx.DrawRectangle(overFill, null, new Rect(x, iy, bw, cy - iy), 1, 1);+ ctx.DrawRectangle(inFill, null, new Rect(x, iy, bw, bot - iy), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));+ if (iy < cy - 0.5) ctx.DrawRectangle(overFill, null, new Rect(x, iy, bw, cy - iy), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}if (_out[i] > Lo){double oy = Y(_out[i]);- ctx.DrawRectangle(NotaPalette.VizInk, null, new Rect(x, oy, bw, bot - oy), 1, 1);+ ctx.DrawRectangle(NotaPalette.VizInk, null, new Rect(x, oy, bw, bot - oy), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}// Reduction strip under the plot (0 … −12 dB hanging).double g = Math.Clamp(_gr[i] / 12.0, 0, 1);@@ -163,7 +163,7 @@ internal sealed class CeReductionView : Avalonia.Controls.Controlif (_gr[i] < 0.02) continue;double x = x0 + i * cw;ctx.DrawRectangle(_clip[i] > 0.5f ? NotaPalette.TextTertiary : NotaPalette.VizInk, null,- new Rect(x, top, Math.Max(0.6, cw - gap), Y(_gr[i]) - top), 1, 1);+ new Rect(x, top, Math.Max(0.6, cw - gap), Y(_gr[i]) - top), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}if (_avg > 0.05)diff --git a/src/managed/Nota.App/Controls/ChamberViews.cs b/src/managed/Nota.App/Controls/ChamberViews.csindex a79098ba..516ce854 100644--- a/src/managed/Nota.App/Controls/ChamberViews.cs+++ b/src/managed/Nota.App/Controls/ChamberViews.cs@@ -274,7 +274,7 @@ internal sealed class ChamberIrView : Control, IValueHandlesvar ink = hot ? NotaPalette.AccentBright : NotaPalette.VizInk;ctx.DrawLine(new Pen(ink, hot ? 1.6 : 1.2), new Point(x, r.Y), new Point(x, r.Bottom));var tab = left ? new Rect(x, r.Y, 5, 12) : new Rect(x - 5, r.Y, 5, 12);- ctx.DrawRectangle(ink, null, tab, 1.5, 1.5);+ ctx.DrawRectangle(ink, null, tab, NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));ctx.DrawLine(new Pen(ink, 2), new Point(left ? x : x - 5, r.Bottom - 0.5), new Point(left ? x + 5 : x, r.Bottom - 0.5));var ft = NotaGraph.AxisText(label, hot ? NotaPalette.AccentBright : NotaPalette.TextSecondary);double tx = left ? x + 8 : x - 8 - ft.Width;@@ -507,7 +507,7 @@ internal sealed class ChamberDecayGraph : Control, IValueHandlesvar dp = HandlePt(3);if (dampHot) ctx.DrawEllipse(NotaPalette.Wash(NotaPalette.Accent, 0x40), null, dp, 8, 8);var grip = new Rect(dp.X - 3.5, dp.Y - 3.5, 7, 7);- ctx.DrawRectangle(dampHot ? NotaPalette.AccentBright : NotaGraph.Ground, new Pen(NotaPalette.AccentBright, 1.4), grip, 1.5, 1.5);+ ctx.DrawRectangle(dampHot ? NotaPalette.AccentBright : NotaGraph.Ground, new Pen(NotaPalette.AccentBright, 1.4), grip, NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));var dl = NotaGraph.AxisText(Loc.T("device.chamber.damping") + " " + NotaNum.Hz(_damp), dampHot ? NotaPalette.AccentBright : NotaPalette.TextSecondary);double dx = dp.X + 8 + dl.Width > r.Right ? dp.X - 8 - dl.Width : dp.X + 8;NotaGraph.PlateText(ctx, dl, new Point(dx, dp.Y - dl.Height - 6));@@ -746,8 +746,8 @@ internal sealed class ChamberFlowView : ControlRect Block(double bx, double cy, double bw, string name, string value, bool on, bool hot, bool click){var b = new Rect(bx, cy - bh / 2, bw, bh);- if (on) ctx.DrawRectangle(NotaPalette.SurfaceCard, new Pen(hot ? NotaPalette.AccentBright : NotaPalette.BorderDefault, 1), b, 4, 4);- else ctx.DrawRectangle(null, new Pen(hot ? NotaPalette.AccentBright : NotaPalette.TextDisabled, 1) { DashStyle = new DashStyle(new double[] { 3, 2 }, 0) }, b, 4, 4);+ if (on) ctx.DrawRectangle(NotaPalette.SurfaceCard, new Pen(hot ? NotaPalette.AccentBright : NotaPalette.BorderDefault, 1), b, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);+ else ctx.DrawRectangle(null, new Pen(hot ? NotaPalette.AccentBright : NotaPalette.TextDisabled, 1) { DashStyle = new DashStyle(new double[] { 3, 2 }, 0) }, b, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);var n = new NotaFormattedText(name, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NotaFonts.SansMedium, NotaGraph.TitleSize,on ? NotaPalette.TextPrimary : NotaPalette.TextDisabled, NotaTextSize.InCard) { MaxTextWidth = bw - 6, Trimming = TextTrimming.CharacterEllipsis };var v = NotaGraph.AxisText(value, on ? (click && hot ? NotaPalette.AccentBright : NotaPalette.TextSecondary) : NotaPalette.TextDisabled);@@ -814,7 +814,7 @@ internal sealed class ChamberFlowView : Controlstring duckVal = !ducking ? Loc.T("device.chamber.off") : _s.DuckNowDb > 0.05 ? NotaNum.Unit(-_s.DuckNowDb, "0.0", "dB") : NotaNum.Unit(-_s.DuckAmountDb, "0", "dB") + " " + Loc.T("device.chamber.max");Block(xd, yMain, blkW, Loc.T("device.chamber.ducking"), duckVal, ducking, false, false);if (ducking && _s.DuckNowDb > 0.05)- ctx.DrawRectangle(NotaPalette.AccentBright, null, new Rect(xd + 4, yMain + bh / 2 - 3, (blkW - 8) * Math.Clamp(_s.DuckNowDb / Math.Max(1, _s.DuckAmountDb), 0, 1), 2), 1, 1);+ ctx.DrawRectangle(NotaPalette.AccentBright, null, new Rect(xd + 4, yMain + bh / 2 - 3, (blkW - 8) * Math.Clamp(_s.DuckNowDb / Math.Max(1, _s.DuckAmountDb), 0, 1), 2), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));cur = xd + blkW;// The mix: the wet in from the left, the dry up from below.diff --git a/src/managed/Nota.App/Controls/ConsortViews.cs b/src/managed/Nota.App/Controls/ConsortViews.csindex 942fb15a..fd4403c6 100644--- a/src/managed/Nota.App/Controls/ConsortViews.cs+++ b/src/managed/Nota.App/Controls/ConsortViews.cs@@ -350,10 +350,10 @@ internal sealed class ConsortStepGrid : Control(Color c, string lbl) = t switch { 1 => (mv, $"×{_ratchet}"), 2 => (tl, "~"), 3 => (Colors.Transparent, "·"), _ => (ac, (i + 1).ToString(NotaNum.Culture)) };IBrush fill = t == 3 ? NotaPalette.BgSunken : new SolidColorBrush(Color.FromArgb((byte)(inLen ? 0x40 : 0x14), c.R, c.G, c.B));IBrush stroke = t == 3 ? NotaPalette.BorderDefault : new SolidColorBrush(Color.FromArgb((byte)(inLen ? 0xE0 : 0x50), c.R, c.G, c.B));- ctx.DrawRectangle(fill, new Pen(stroke, i == _play ? 2 : 1), r, 3, 3);+ ctx.DrawRectangle(fill, new Pen(stroke, i == _play ? 2 : 1), r, NotaRadius.SwitchValue, NotaRadius.SwitchValue);var ft = new NotaFormattedText(lbl, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NumFace, NotaGraph.AxisSize, inLen ? (t == 3 ? NotaPalette.TextDisabled : NotaPalette.TextPrimary) : NotaPalette.TextDisabled, this);ctx.DrawText(ft, new Point(r.X + (r.Width - ft.Width) / 2, r.Y + (r.Height - ft.Height) / 2));- if (i == _play) ctx.DrawRectangle(null, new Pen(NotaPalette.AccentBright, 1), r.Inflate(1.5), 4, 4);+ if (i == _play) ctx.DrawRectangle(null, new Pen(NotaPalette.AccentBright, 1), r.Inflate(1.5), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);}}}@@ -421,8 +421,8 @@ internal sealed class ConsortPitchLane : Controlvar col = _t[i] == 2 ? tl : ac;double y = Y(_p[i]);var r = new Rect(i * cw + 3, y - 3.5, cw - 6, 7);- ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, col.R, col.G, col.B)), null, r, 2.5, 2.5);- if (_t[i] == 1) ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, mv.R, mv.G, mv.B)), null, new Rect(r.X, r.Bottom + 2, r.Width, 4), 2, 2);+ ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, col.R, col.G, col.B)), null, r, NotaSkin.MapRadius(2.5), NotaSkin.MapRadius(2.5));+ if (_t[i] == 1) ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, mv.R, mv.G, mv.B)), null, new Rect(r.X, r.Bottom + 2, r.Width, 4), NotaRadius.FineValue, NotaRadius.FineValue);}if (_play >= 0 && _play < 16){@@ -639,7 +639,7 @@ internal sealed class ConsortJackField : Controlvar t = new NotaFormattedText($"{j.Name} · {(j.Out ? "out" : "in")}", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Sans, NotaType.RowLabel, NotaPalette.TextPrimary, this);double x = Math.Clamp(p.X - t.Width / 2, 1, w - t.Width - 1), y = p.Y - 21;if (y < 1) y = p.Y + 15;- ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderStrong, 1), new Rect(x - 3, y - 1, t.Width + 6, t.Height + 2), 3, 3);+ ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderStrong, 1), new Rect(x - 3, y - 1, t.Width + 6, t.Height + 2), NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(t, new Point(x, y));}}@@ -788,7 +788,7 @@ internal sealed class ConsortPatchMatrix : Control, IValueEntryHostvar cab = Find(_rows[r], _cols[c]);if (cab is { } cb){- ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(0x30, tc.R, tc.G, tc.B)), new Pen(new SolidColorBrush(tc), 1.2), cell, 3, 3);+ ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(0x30, tc.R, tc.G, tc.B)), new Pen(new SolidColorBrush(tc), 1.2), cell, NotaRadius.SwitchValue, NotaRadius.SwitchValue);// depth bar from the centredouble mid = cell.X + cell.Width / 2, bw = cell.Width / 2 * Math.Abs(cb.Depth);ctx.FillRectangle(new SolidColorBrush(Color.FromArgb(0x38, tc.R, tc.G, tc.B)), new Rect(cb.Depth >= 0 ? mid : mid - bw, cell.Bottom - 3, bw, 2));@@ -797,7 +797,7 @@ internal sealed class ConsortPatchMatrix : Control, IValueEntryHost}else{- ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), cell, 3, 3);+ ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), cell, NotaRadius.SwitchValue, NotaRadius.SwitchValue);var v = new NotaFormattedText("·", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NumFace, NotaGraph.AxisSize, NotaPalette.TextDisabled, this);ctx.DrawText(v, new Point(cell.X + (cell.Width - v.Width) / 2, cell.Y + (cell.Height - v.Height) / 2));}diff --git a/src/managed/Nota.App/Controls/CrushViews.cs b/src/managed/Nota.App/Controls/CrushViews.csindex afb4ef8a..4d0e307b 100644--- a/src/managed/Nota.App/Controls/CrushViews.cs+++ b/src/managed/Nota.App/Controls/CrushViews.cs@@ -246,9 +246,9 @@ internal sealed class CrSpectrumView : ShDragViewdouble fc = FLo * Math.Pow(FHi / FLo, (b + 0.5) / _n);double yi = Y(_in[b]), yo = Y(_out[b]);double ys = Math.Max(yi, yo); // the signal part: up to the lower of in and out- if (ys < bot - 0.5) ctx.DrawRectangle(NotaPalette.VizInk, null, new Rect(x, ys, cw, bot - ys), 1, 1);+ if (ys < bot - 0.5) ctx.DrawRectangle(NotaPalette.VizInk, null, new Rect(x, ys, cw, bot - ys), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));if (_out[b] > _in[b] + 1 && yo < ys - 0.5)- ctx.DrawRectangle(fc > _nyq ? addHi : addLo, null, new Rect(x, yo, cw, ys - yo), 1, 1);+ ctx.DrawRectangle(fc > _nyq ? addHi : addLo, null, new Rect(x, yo, cw, ys - yo), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));if (_in[b] > _out[b] + 3 && yi < bot - 1)ctx.DrawRectangle(null, ghost, new Rect(x + 0.5, yi, cw - 1, yo - yi));}diff --git a/src/managed/Nota.App/Controls/FilterGraphBase.cs b/src/managed/Nota.App/Controls/FilterGraphBase.csindex eea8022b..85e09ef4 100644--- a/src/managed/Nota.App/Controls/FilterGraphBase.cs+++ b/src/managed/Nota.App/Controls/FilterGraphBase.cs@@ -220,7 +220,7 @@ internal abstract class FilterGraphBase : Controldouble tx = hx + 8 + tw > w ? hx - 8 - tw : hx + 8;double ty = Math.Clamp(y - th - 6, r.Y + 2, r.Bottom - th - 2);var tip = new Rect(tx, ty, tw, th);- ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderDefault, 1), tip, 3, 3);+ ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderDefault, 1), tip, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(t1, new Point(tx + 5, ty + 2));ctx.DrawText(t2, new Point(tx + 5, ty + 3 + t1.Height));}@@ -259,7 +259,7 @@ internal static class FilterAxisprivate static Rect DrawPill(DrawingContext ctx, FormattedText ft, Rect box, IBrush fill){- ctx.DrawRectangle(fill, null, box, 3, 3);+ ctx.DrawRectangle(fill, null, box, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(box.X + 4, box.Y + (box.Height - ft.Height) / 2));return box;}diff --git a/src/managed/Nota.App/Controls/Glyph.cs b/src/managed/Nota.App/Controls/Glyph.csindex 0458891f..33b49b8f 100644--- a/src/managed/Nota.App/Controls/Glyph.cs+++ b/src/managed/Nota.App/Controls/Glyph.cs@@ -36,6 +36,7 @@ internal enum GlyphKindPalette, Note, Input, Arrow, Grid, Select, Save, List, Compare, Flatten,// Path kinds (24-unit grid, see Paths)Arrangement, Session, Modular, Keyboard, Sliders, Downloads, Star, StarFilled, Bookmark, Doc, Midi, Map, History, Sidebar, Options, Search, CaretRight, CaretDown, Levels, Gamepad, Phone, Plug, Library, Appearance, Shortcuts, MidiPort, Action, Track, Device, Preset, Patch, Loop, Overdub, Replace, Speaker, SpeakerMute, SpeakerLow, SpeakerHigh, Metronome, Follow, Snap, Automation, Apple, Windows, Linux, ChainLink, Update,+ Output, Globe, // Settings → Outputs and LanguageLock, LockOpen, // a reference (read-only) clip in the multi-clip editor, and the unlocked toggleDockIn, // PopOut's opposite: bring a floating window back into the main oneExpand, Shrink, // a panel filling the window, and back to its split@@ -517,6 +518,10 @@ internal sealed class Glyph : Control[GlyphKind.Replace] = ("M4 10 H14 V20 H4 Z M9 7 A6 6 0 0 1 20 9.5 V14 M17.5 11.5 L20 14 L22.5 11.5", null),// A speaker cone; layer a Speaker* wave kind over it.[GlyphKind.Speaker] = ("M4 9 h4 l5 -4 v14 l-5 -4 h-4 z", null),+ // A speaker with one wave (Settings → Outputs).+ [GlyphKind.Output] = ("M4 9 h4 l5 -4 v14 l-5 -4 h-4 z M16 9.5 a3.5 3.5 0 0 1 0 5 M18.5 7 a7 7 0 0 1 0 10", null),+ // A globe: its outline, the equator and one meridian (Settings → Language).+ [GlyphKind.Globe] = ("M12 3 A9 9 0 1 0 12 21 A9 9 0 1 0 12 3 Z M3 12 H21 M12 3 A13.5 13.5 0 0 1 12 21 A13.5 13.5 0 0 1 12 3", null),// A cross beside the speaker (muted).[GlyphKind.SpeakerMute] = ("M16 9 l5 6 M21 9 l-5 6", null),// One wave beside the speaker (quiet).diff --git a/src/managed/Nota.App/Controls/KeysViews.cs b/src/managed/Nota.App/Controls/KeysViews.csindex 7761ee3f..87b13357 100644--- a/src/managed/Nota.App/Controls/KeysViews.cs+++ b/src/managed/Nota.App/Controls/KeysViews.cs@@ -195,7 +195,7 @@ internal sealed class KeysPickupView : Control, IMidiLearnRegions, IValueEntryHovar mags = KeysModel.Harmonics(sym, dist, model);double bw = 6, gap = 3, ih = 44, iw = 8 * bw + 7 * gap + 10;var inset = new Rect(frame.Right - iw - 8, frame.Bottom - ih - 6, iw, ih);- ctx.DrawRectangle(NotaGraph.Ground, NotaGraph.FramePen, new RoundedRect(inset, 3));+ ctx.DrawRectangle(NotaGraph.Ground, NotaGraph.FramePen, new RoundedRect(inset, NotaRadius.SwitchValue));ctx.DrawText(NotaGraph.AxisText("H1–H8"), new Point(inset.X + 4, inset.Y + 2));for (int k = 0; k < 8; k++){@@ -236,7 +236,7 @@ internal sealed class KeysPickupView : Control, IMidiLearnRegions, IValueEntryHovoid Pickup(double t, string label, bool lit){var rr = new Rect(X(t) - 8, cy + amp + 6, 16, 9);- ctx.DrawRectangle(lit ? NotaPalette.Accent : NotaPalette.BorderStrong, null, new RoundedRect(rr, 2));+ ctx.DrawRectangle(lit ? NotaPalette.Accent : NotaPalette.BorderStrong, null, new RoundedRect(rr, NotaRadius.FineValue));var ft = NotaGraph.AxisText(label, lit ? NotaPalette.AccentBright : NotaPalette.TextAxis);ctx.DrawText(ft, new Point(X(t) - ft.Width / 2, rr.Bottom + 2));}@@ -296,7 +296,7 @@ internal sealed class KeysTremView : Control// Where the sound sits: the pan dot (stereo) or the level (mono) at the playhead.double s = Shape(2 * Math.PI * (0.33 * 2.25 + _phase)) * _get("tremdepth");var bar = new Rect(8, h - barH + 1, w - 16, 6);- ctx.DrawRectangle(NotaPalette.BgSunken, NotaGraph.FramePen, new RoundedRect(bar, 3));+ ctx.DrawRectangle(NotaPalette.BgSunken, NotaGraph.FramePen, new RoundedRect(bar, NotaRadius.SwitchValue));double pos = stereo && on ? 0.5 + s * 0.5 : 0.5;double px = bar.X + pos * bar.Width;ctx.DrawEllipse(on ? NotaPalette.VizInk : NotaPalette.TextAxis, null, new Point(px, bar.Y + bar.Height / 2), 3, 3);@@ -329,7 +329,7 @@ internal sealed class KeysVoiceGrid : Control: i < _held ? NotaPalette.Accent: i < _held + _tail ? NotaPalette.TextTertiary: NotaPalette.BorderDefault;- ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(c * (cw + 1), r * 6, cw, 5), 1));+ ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(c * (cw + 1), r * 6, cw, 5), NotaSkin.MapRadius(1)));}}}diff --git a/src/managed/Nota.App/Controls/LevelViews.cs b/src/managed/Nota.App/Controls/LevelViews.csindex d87b0d9d..94dba5a5 100644--- a/src/managed/Nota.App/Controls/LevelViews.cs+++ b/src/managed/Nota.App/Controls/LevelViews.cs@@ -214,7 +214,7 @@ internal sealed class LvMeter : Controlif (_r > _l) ctx.FillRectangle(_ink, new Rect(_l * w, ty, (_r - _l) * w, 3));}if (!double.IsNaN(_mark))- ctx.FillRectangle(NotaPalette.TextSecondary, new Rect(Math.Round(Math.Clamp(_mark, 0, 1) * (w - 2)), 0, 2, h), 1);+ ctx.FillRectangle(NotaPalette.TextSecondary, new Rect(Math.Round(Math.Clamp(_mark, 0, 1) * (w - 2)), 0, 2, h), (float)NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/Controls/NotaGraph.cs b/src/managed/Nota.App/Controls/NotaGraph.csindex e02036c4..e9c06f0b 100644--- a/src/managed/Nota.App/Controls/NotaGraph.cs+++ b/src/managed/Nota.App/Controls/NotaGraph.cs@@ -23,7 +23,7 @@ namespace Nota.App;internal static class NotaGraph{- public const double Radius = NotaRadius.FieldValue; // 6+ public static double Radius => NotaRadius.FieldValue; // 6, as the skin draws itpublic const double PrimaryWidth = 1.8, SecondaryWidth = 1.4;public const double NodeD = 7, NodeRing = 2;public const double AxisSize = NotaType.Axis, TitleSize = 8; // axis labels 7.5 in ink 4; a graph title 8@@ -104,7 +104,7 @@ internal static class NotaGraph/// off the trace: the trace passes behind the plate instead of through the text.</summary>public static void PlateText(DrawingContext ctx, FormattedText ft, Point at){- ctx.DrawRectangle(Ground, null, new RoundedRect(new Rect(at.X - 2, at.Y, ft.Width + 4, ft.Height), 3));+ ctx.DrawRectangle(Ground, null, new RoundedRect(new Rect(at.X - 2, at.Y, ft.Width + 4, ft.Height), NotaRadius.SwitchValue));ctx.DrawText(ft, at);}@@ -146,7 +146,7 @@ internal static class NotaGraph{case Mark.Line: ctx.DrawLine(new Pen(ink, 1.4), new Point(x, cy), new Point(x + 10, cy)); break;case Mark.Dashed: ctx.DrawLine(new Pen(ink, 1.2, new DashStyle(new double[] { 2, 2 }, 0)), new Point(x, cy), new Point(x + 10, cy)); break;- default: ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(x + 2, cy - 3, 6, 6), 1)); break;+ default: ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(x + 2, cy - 3, 6, 6), NotaSkin.MapRadius(1))); break;}x -= 8;}@@ -155,7 +155,7 @@ internal static class NotaGraph/// <summary>A legend row drawn inside the window: a swatch, a name and its value.</summary>public static double LegendRow(DrawingContext ctx, Point at, IBrush swatch, string name, string value){- ctx.DrawRectangle(swatch, null, new RoundedRect(new Rect(at.X, at.Y + 5, 8, 2), 1));+ ctx.DrawRectangle(swatch, null, new RoundedRect(new Rect(at.X, at.Y + 5, 8, 2), NotaSkin.MapRadius(1)));var n = new NotaFormattedText(NotaText.Label(name), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NotaFonts.SansMedium, AxisSize, TitleInk, NotaTextSize.InCard);var v = AxisText(value, NotaPalette.TextPrimary);ctx.DrawText(n, new Point(at.X + 12, at.Y));diff --git a/src/managed/Nota.App/Controls/OperatorAlgoViz.cs b/src/managed/Nota.App/Controls/OperatorAlgoViz.csindex a0935da2..caf83abf 100644--- a/src/managed/Nota.App/Controls/OperatorAlgoViz.cs+++ b/src/managed/Nota.App/Controls/OperatorAlgoViz.cs@@ -133,7 +133,7 @@ internal sealed class OperatorAlgoMini : Controlvar p = Pt(o);var rect = new Rect(p.X - bs / 2, p.Y - bs / 2, bs, bs);var pen = new Pen(carrier[o] ? Ink : Teal, _active ? 1.2 : 0.9);- ctx.DrawRectangle(carrier[o] && _active ? InkSubtle : Sunken, pen, rect, 1.5, 1.5);+ ctx.DrawRectangle(carrier[o] && _active ? InkSubtle : Sunken, pen, rect, NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));}}}@@ -270,9 +270,9 @@ internal sealed class OperatorRoutingViz : Controlbool carr = _carrier[o];// Opaque ground first: the washes are translucent and a connection line passing// behind a box would otherwise strike through its letter.- ctx.DrawRectangle(Sunken, null, rect, 3, 3);+ ctx.DrawRectangle(Sunken, null, rect, NotaRadius.SwitchValue, NotaRadius.SwitchValue);bool dragged = o == _drag;- ctx.DrawRectangle(carr ? InkSubtle : TealSubtle, new Pen(dragged ? Accent : carr ? Ink : Teal, 1.3), rect, 3, 3);+ ctx.DrawRectangle(carr ? InkSubtle : TealSubtle, new Pen(dragged ? Accent : carr ? Ink : Teal, 1.3), rect, NotaRadius.SwitchValue, NotaRadius.SwitchValue);var ft = new NotaFormattedText(OperatorTopo.Names[o], CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Semi, 10, carr ? TextPrimary : Teal, this);ctx.DrawText(ft, new Point(c.X - ft.Width / 2, c.Y - ft.Height / 2));}diff --git a/src/managed/Nota.App/Controls/OrbitViews.cs b/src/managed/Nota.App/Controls/OrbitViews.csindex 7199adfb..ee98ec1e 100644--- a/src/managed/Nota.App/Controls/OrbitViews.cs+++ b/src/managed/Nota.App/Controls/OrbitViews.cs@@ -219,7 +219,7 @@ internal sealed class OrbitPanBar : Controlctx.DrawLine(new Pen(NotaPalette.BorderDefault, 1), new Point(0, cy), new Point(w, cy));ctx.DrawLine(new Pen(NotaPalette.BorderStrong, 1), new Point(Math.Round(w / 2) + 0.5, cy - 3.5), new Point(Math.Round(w / 2) + 0.5, cy + 3.5));if (_max > _min)- ctx.DrawRectangle(NotaPalette.TextTertiary, null, new RoundedRect(new Rect(X(_min), cy - 1.5, Math.Max(1, X(_max) - X(_min)), 3), 1.5));+ ctx.DrawRectangle(NotaPalette.TextTertiary, null, new RoundedRect(new Rect(X(_min), cy - 1.5, Math.Max(1, X(_max) - X(_min)), 3), NotaSkin.MapRadius(1.5)));ctx.DrawEllipse(NotaPalette.Accent, new Pen(NotaPalette.DeviceSection, 2), new Point(X(_pan), cy), 4, 4);}}diff --git a/src/managed/Nota.App/Controls/PendulumViews.cs b/src/managed/Nota.App/Controls/PendulumViews.csindex f7819452..311d7d62 100644--- a/src/managed/Nota.App/Controls/PendulumViews.cs+++ b/src/managed/Nota.App/Controls/PendulumViews.cs@@ -99,8 +99,8 @@ internal sealed class PendulumLanesView : Controlbool cameFrom = ball.Dir > 0 ? !high : ball.Dir < 0 && high;return cameFrom ? NotaPalette.TextSecondary : NotaPalette.BorderStrong;}- ctx.DrawRectangle(WallInk(false), null, new RoundedRect(new Rect(laneX0 - 1, wallTop, 2, wallBot - wallTop), 1));- ctx.DrawRectangle(WallInk(true), null, new RoundedRect(new Rect(laneX1 - 1, wallTop, 2, wallBot - wallTop), 1));+ ctx.DrawRectangle(WallInk(false), null, new RoundedRect(new Rect(laneX0 - 1, wallTop, 2, wallBot - wallTop), NotaSkin.MapRadius(1)));+ ctx.DrawRectangle(WallInk(true), null, new RoundedRect(new Rect(laneX1 - 1, wallTop, 2, wallBot - wallTop), NotaSkin.MapRadius(1)));double bx = laneX0 + Math.Clamp(ball.Pos, 0, 1) * laneW;@@ -212,7 +212,7 @@ internal sealed class PendulumBarView : Controlink = i == latest ? NotaPalette.Accent : st.Age == 0 ? NotaPalette.VizInk : NotaPalette.Wash(NotaPalette.VizInk, 0x60);}double bh = Math.Max(2, fullH * frac);- ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(x, gy1 - bh, Math.Max(1, cw - 1), bh), 1));+ ctx.DrawRectangle(ink, null, new RoundedRect(new Rect(x, gy1 - bh, Math.Max(1, cw - 1), bh), NotaSkin.MapRadius(1)));}double px = gx0 + Math.Clamp(_s.BarPos, 0, 1) * (gx1 - gx0);ctx.DrawLine(new Pen(NotaPalette.Accent, 1), new Point(px, gy0 - 2), new Point(px, gy1 + 2));diff --git a/src/managed/Nota.App/Controls/PentadViews.cs b/src/managed/Nota.App/Controls/PentadViews.csindex 92e101e6..ee5f541f 100644--- a/src/managed/Nota.App/Controls/PentadViews.cs+++ b/src/managed/Nota.App/Controls/PentadViews.cs@@ -147,7 +147,7 @@ internal sealed class PentadVoiceStrip : Controlfloat lv = _lv[i];bool lit = lv > 0.0005f;byte a = (byte)(lit ? 0x22 + (int)(Math.Clamp(lv, 0f, 1f) * 0x40) : 0);- ctx.DrawRectangle(lit ? new SolidColorBrush(Color.FromArgb(a, ac.R, ac.G, ac.B)) : NotaPalette.BgSunken, lit ? on : off, r, 3, 3);+ ctx.DrawRectangle(lit ? new SolidColorBrush(Color.FromArgb(a, ac.R, ac.G, ac.B)) : NotaPalette.BgSunken, lit ? on : off, r, NotaRadius.SwitchValue, NotaRadius.SwitchValue);if (cw >= 12){var ft = new NotaFormattedText((i + 1).ToString(NotaNum.Culture), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NumFace, NotaGraph.AxisSize, lit ? NotaPalette.AccentBright : NotaPalette.TextDisabled, this);diff --git a/src/managed/Nota.App/Controls/PerformWheel.cs b/src/managed/Nota.App/Controls/PerformWheel.csindex cdb46fb9..b5c38da4 100644--- a/src/managed/Nota.App/Controls/PerformWheel.cs+++ b/src/managed/Nota.App/Controls/PerformWheel.cs@@ -136,6 +136,6 @@ internal sealed class PerformWheel : Control// The value bar, on the face's centreline. Pitch rests in the middle of the well.double y = faceY + faceH / 2;bool live = Math.Abs(_norm - Default) > 1e-3;- ctx.DrawRectangle(_drag ? NotaPalette.Accent : live ? Bar : BarOff, null, new Rect(1.5, y - 1, w - 3, 2), 1, 1);+ ctx.DrawRectangle(_drag ? NotaPalette.Accent : live ? Bar : BarOff, null, new Rect(1.5, y - 1, w - 3, 2), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/Controls/PhysicalViews.cs b/src/managed/Nota.App/Controls/PhysicalViews.csindex 64231d2e..7aeb7d95 100644--- a/src/managed/Nota.App/Controls/PhysicalViews.cs+++ b/src/managed/Nota.App/Controls/PhysicalViews.cs@@ -92,7 +92,7 @@ internal sealed class PhysPartialsView : VtWindowBase// as the fundamental at full.byte a = (byte)Math.Clamp(90 + 165 * Math.Min(1, m.Tau / tau0), 60, 255);var c = ((ISolidColorBrush)ink).Color;- ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, c.R, c.G, c.B)), null, new Rect(x - 1.5, bot - bh, 3, bh), 1, 1);+ ctx.DrawRectangle(new SolidColorBrush(Color.FromArgb(a, c.R, c.G, c.B)), null, new Rect(x - 1.5, bot - bh, 3, bh), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));if (i == 0) ctx.DrawEllipse(_dim ? NotaPalette.TextDisabled : NotaPalette.VizInk, null, new Point(x, bot - bh - 3), 1.8, 1.8);}}diff --git a/src/managed/Nota.App/Controls/PrismViews.cs b/src/managed/Nota.App/Controls/PrismViews.csindex 13bfc235..e9f910af 100644--- a/src/managed/Nota.App/Controls/PrismViews.cs+++ b/src/managed/Nota.App/Controls/PrismViews.cs@@ -180,7 +180,7 @@ internal sealed class PrismSpectrum : Control, IValueHandlesdouble w = Bounds.Width, h = Bounds.Height;if (w < 8 || h < 8) return;var rect = new Rect(0, 0, w, h);- ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, 4, 4);+ ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);// Band tints (the selected band a little stronger).double[] edges = _bands switch { 1 => new[] { 0.0, 1.0 }, 2 => new[] { 0.0, _xl, 1.0 }, _ => new[] { 0.0, _xl, _xh, 1.0 } };@@ -232,7 +232,7 @@ internal sealed class PrismSpectrum : Control, IValueHandlesvar t = PrismInk.Text(PrismInk.HzShort(20 * Math.Pow(1000, v)), NotaGraph.AxisSize, _drag == idx ? NotaPalette.AccentBright : upper == 1 ? NotaPalette.TextPrimary : col);double tw = t.Width + 8, tx = Math.Clamp(x - tw / 2, 0, w - tw);var tag = new Rect(tx, 0, tw, 12);- ctx.DrawRectangle(hot ? NotaPalette.SurfaceRaised : NotaPalette.SurfaceCard, new Pen(col, 1), tag, 3, 3);+ ctx.DrawRectangle(hot ? NotaPalette.SurfaceRaised : NotaPalette.SurfaceCard, new Pen(col, 1), tag, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(t, new Point(tx + 4, 6 - t.Height / 2));}if (_bands >= 2) Cross(_xl, 1, 0);@@ -242,7 +242,7 @@ internal sealed class PrismSpectrum : Control, IValueHandlesctx.DrawText(l0, new Point(5, h - l0.Height - 1));var l1 = PrismInk.Text("20k Hz", NotaGraph.AxisSize, NotaPalette.TextDisabled);ctx.DrawText(l1, new Point(w - l1.Width - 5, h - l1.Height - 1));- ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), 4, 4);+ ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);}// In-place iterative radix-2 Cooley–Tukey FFT.@@ -365,7 +365,7 @@ internal sealed class PrismTransfer : Control, IValueHandlesdouble w = Bounds.Width, h = Bounds.Height;if (w < 8 || h < 8) return;var rect = new Rect(0, 0, w, h);- ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, 4, 4);+ ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);var grid = new Pen(NotaPalette.SurfaceCard, 1);ctx.DrawLine(grid, new Point(0, h / 2), new Point(w, h / 2));ctx.DrawLine(grid, new Point(w / 2, 0), new Point(w / 2, h));@@ -392,7 +392,7 @@ internal sealed class PrismTransfer : Control, IValueHandlesctx.DrawText(ta, new Point(4, 3));var tb = PrismInk.Text(_below ? NotaNum.F($"below {_thrB:0}") : "below off", NotaGraph.AxisSize, _below ? NotaPalette.TextSecondary : NotaPalette.TextDisabled);ctx.DrawText(tb, new Point(w - tb.Width - 4, h - tb.Height - 2)); // bottom right: the curve never comes down there- ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), 4, 4);+ ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);}}@@ -419,7 +419,7 @@ internal sealed class PrismEnvTrace : Controldouble w = Bounds.Width, h = Bounds.Height;if (w < 8 || h < 8) return;var rect = new Rect(0, 0, w, h);- ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, 4, 4);+ ctx.DrawRectangle(NotaPalette.BgSunken, null, rect, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);const double top = 14, range = 60; // 0 dB at `top`, −60 dB at the bottomdouble Y(double db) => top + Math.Clamp(-db / range, 0, 1) * (h - top - 2);var grid = new Pen(NotaPalette.SurfaceCard, 1);@@ -453,7 +453,7 @@ internal sealed class PrismEnvTrace : Controldouble x2 = w - l2.Width - 5, x1 = x2 - 14 - l1.Width - 12;ctx.FillRectangle(NotaPalette.BorderStrong, new Rect(x1, 9, 8, 2)); ctx.DrawText(l1, new Point(x1 + 11, 3));ctx.FillRectangle(col, new Rect(x2 - 11, 9, 8, 2)); ctx.DrawText(l2, new Point(x2, 3));- ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), 4, 4);+ ctx.DrawRectangle(null, PrismInk.InnerPen, rect.Deflate(0.5), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);}}@@ -488,7 +488,7 @@ internal sealed class PrismGrMeter : Controlctx.DrawRectangle(NotaPalette.Groove, Soloed ? new Pen(NotaPalette.Accent, 1) : null, rect, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);double ih = h - 3;var col = PrismInk.BandColor[Band];- if (_gr > 0.01) ctx.DrawRectangle(PrismInk.Band[Band], null, new Rect(1.5, 1.5, w - 3, ih * Math.Min(1, _gr / Scale)), 2, 2);+ if (_gr > 0.01) ctx.DrawRectangle(PrismInk.Band[Band], null, new Rect(1.5, 1.5, w - 3, ih * Math.Min(1, _gr / Scale)), NotaRadius.FineValue, NotaRadius.FineValue);if (_boost > 0.01) { double bh = ih * Math.Min(1, _boost / Scale); ctx.FillRectangle(PrismInk.Alpha(col, 0x70), new Rect(1.5, h - 1.5 - bh, w - 3, bh)); }if (_peakHold && _hold > 0.05){diff --git a/src/managed/Nota.App/Controls/RandomOutputViz.cs b/src/managed/Nota.App/Controls/RandomOutputViz.csindex 68351e9d..92d70406 100644--- a/src/managed/Nota.App/Controls/RandomOutputViz.cs+++ b/src/managed/Nota.App/Controls/RandomOutputViz.cs@@ -188,8 +188,8 @@ internal sealed class RandomOutputViz : Controldouble Y(int p) => win.Y + (hi - p - 0.5) * row;double X(double beat) => win.X + beat / RandomModel.BarBeats * win.Width;- ctx.DrawRectangle(Well, null, new RoundedRect(win, 6));- using (ctx.PushClip(new RoundedRect(win.Deflate(1), 3)))+ ctx.DrawRectangle(Well, null, new RoundedRect(win, NotaRadius.FieldValue));+ using (ctx.PushClip(new RoundedRect(win.Deflate(1), NotaRadius.SwitchValue))){for (int p = (int)Math.Ceiling(lo / 12.0) * 12; p <= hi; p += 12)ctx.FillRectangle(Edge, new Rect(win.X, Math.Round(win.Y + (hi - p) * row), win.Width, 1));@@ -257,7 +257,7 @@ internal sealed class RandomHistViz : Control{double w = Bounds.Width, h = Bounds.Height;if (w <= 0 || h <= 0) return;- ctx.DrawRectangle(Well, null, new RoundedRect(new Rect(0, 0, w, h), 6));+ ctx.DrawRectangle(Well, null, new RoundedRect(new Rect(0, 0, w, h), NotaRadius.FieldValue));int n = _bins.Length;if (n == 0) return;double x0 = 3, x1 = w - 3, top = 3, bot = h - 1, gap = 1;diff --git a/src/managed/Nota.App/Controls/RhythmViews.cs b/src/managed/Nota.App/Controls/RhythmViews.csindex 670098ac..1490d54d 100644--- a/src/managed/Nota.App/Controls/RhythmViews.cs+++ b/src/managed/Nota.App/Controls/RhythmViews.cs@@ -414,23 +414,23 @@ internal sealed class RhythmStepStrip : Controldouble x = s * (cw + Gap);var r = new Rect(x, 0, cw, cellH);bool on = On[s], acc = on && Acc[s], quiet = on && !acc && Vel[s] < RhythmModel.QuietBelow;- if (!on) ctx.DrawRectangle(s % 4 == 0 ? NotaPalette.Groove : NotaGraph.Ground, null, r, 4, 4);- else if (quiet) ctx.DrawRectangle(NotaPalette.AccentSoft, null, r, 4, 4);- else ctx.DrawRectangle(acc ? NotaPalette.AccentBright : NotaPalette.Accent, null, r, 4, 4);+ if (!on) ctx.DrawRectangle(s % 4 == 0 ? NotaPalette.Groove : NotaGraph.Ground, null, r, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);+ else if (quiet) ctx.DrawRectangle(NotaPalette.AccentSoft, null, r, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);+ else ctx.DrawRectangle(acc ? NotaPalette.AccentBright : NotaPalette.Accent, null, r, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);if (on){var ft = new NotaFormattedText((s + 1).ToString(NotaNum.Culture), NotaNum.Culture, FlowDirection.LeftToRight, NotaFonts.SansSemiBold,NotaType.KnobValue, quiet ? NotaPalette.AccentBright : NotaPalette.TextOnAccent, this);ctx.DrawText(ft, new Point(x + (cw - ft.Width) / 2, (cellH - ft.Height) / 2));}- if (s == _head) ctx.DrawRectangle(null, headPen, r.Deflate(0.5), 4, 4);+ if (s == _head) ctx.DrawRectangle(null, headPen, r.Deflate(0.5), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);// The velocity lane: grey by strength — accent the lightest, quiet the darkest.var lane = new Rect(x, h - LaneH, cw, LaneH);IBrush li = !on ? NotaPalette.Rule: acc ? NotaPalette.VizInk: NotaPalette.Wash(NotaPalette.VizInk, (byte)Math.Clamp(60 + Vel[s] * 140, 60, 200));- ctx.DrawRectangle(li, null, lane, 1.5, 1.5);+ ctx.DrawRectangle(li, null, lane, NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));}}}diff --git a/src/managed/Nota.App/Controls/ShutterViews.cs b/src/managed/Nota.App/Controls/ShutterViews.csindex 809fc0f0..69695bc8 100644--- a/src/managed/Nota.App/Controls/ShutterViews.cs+++ b/src/managed/Nota.App/Controls/ShutterViews.cs@@ -589,7 +589,7 @@ internal sealed class ShPatternView : Control}var ft = NotaGraph.AxisText(_label, _active ? NotaPalette.TextSecondary : NotaPalette.TextDisabled);var chip = new Rect(w - ft.Width - 12, 5, ft.Width + 8, ft.Height + 2);- ctx.FillRectangle(NotaPalette.BgSunken, chip, 3);+ ctx.FillRectangle(NotaPalette.BgSunken, chip, (float)NotaRadius.SwitchValue);ctx.DrawText(ft, new Point(chip.X + 4, chip.Y + 1));}}diff --git a/src/managed/Nota.App/Controls/TwinViews.cs b/src/managed/Nota.App/Controls/TwinViews.csindex 30381471..89c240b0 100644--- a/src/managed/Nota.App/Controls/TwinViews.cs+++ b/src/managed/Nota.App/Controls/TwinViews.cs@@ -520,7 +520,7 @@ internal sealed class TwinRouteView : TwinParamGraphvoid Box(double x, double y, string name){var b = new Rect(Math.Round(x) + 0.5, Math.Round(y) + 0.5, bw, bh);- ctx.DrawRectangle(null, pen, b, 2, 2);+ ctx.DrawRectangle(null, pen, b, NotaRadius.FineValue, NotaRadius.FineValue);var ft = NotaGraph.AxisText(name, NotaPalette.TextSecondary);ctx.DrawText(ft, new Point(b.X + (bw - ft.Width) / 2, b.Y + (bh - ft.Height) / 2));}@@ -599,12 +599,12 @@ internal sealed class TwinFxView : TwinParamGraphdouble sec = P("dlysync") >= 0.5f ? DivBeats[Math.Clamp((int)Math.Round(P("dlydiv") * 7), 0, 7)] * 0.5 : Math.Max(0.001, P("dlytime") * 2.0);double step = Math.Max(4, sec / 2.0 * (r.Width - 8)), fb = P("dlyfb"), amp = 0.8, h = r.Height / 2 - 4;bool ping = P("dlypingpong") >= 0.5f;- ctx.DrawRectangle(NotaPalette.TextFaint, null, new Rect(4, mid - h, 2, h), 1, 1);+ ctx.DrawRectangle(NotaPalette.TextFaint, null, new Rect(4, mid - h, 2, h), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));for (int i = 1; 4 + i * step < r.Width - 4 && amp > 0.03; i++, amp *= Math.Max(0.05, fb)){double x = Math.Round(4 + i * step), hh = Math.Max(1, amp * h);bool up = !ping || i % 2 == 1;- ctx.DrawRectangle(ink, null, new Rect(x, up ? mid - hh : mid, 2, hh), 1, 1);+ ctx.DrawRectangle(ink, null, new Rect(x, up ? mid - hh : mid, 2, hh), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}NotaGraph.Axis(ctx, r, NotaGraph.Corner.TopRight, "L");NotaGraph.Axis(ctx, r, NotaGraph.Corner.BottomRight, "R");@@ -807,7 +807,7 @@ internal sealed class TwinPatchMatrix : Control, IValueEntryHostvar cell = new Rect(RowHdrW + c * cw + 2, y + 2, cw - 4, rh - 4);if (Find(_rows[r], _cols[c]) is { } cb){- ctx.DrawRectangle(fill, edge, cell, 2, 2);+ ctx.DrawRectangle(fill, edge, cell, NotaRadius.FineValue, NotaRadius.FineValue);double mid = cell.X + cell.Width / 2, half = cell.Width / 2 - 2;double bw = half * Math.Abs(cb.Depth);ctx.FillRectangle(bar, new Rect(cb.Depth >= 0 ? mid : mid - bw, cell.Bottom - 3, bw, 2));@@ -821,7 +821,7 @@ internal sealed class TwinPatchMatrix : Control, IValueEntryHost}else{- ctx.DrawRectangle(NotaPalette.BgSunken, null, cell, 2, 2);+ ctx.DrawRectangle(NotaPalette.BgSunken, null, cell, NotaRadius.FineValue, NotaRadius.FineValue);var v = new NotaFormattedText("·", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Mono, NotaType.KnobValue, NotaPalette.TextFaint, this);ctx.DrawText(v, new Point(cell.X + (cell.Width - v.Width) / 2, cell.Y + (cell.Height - v.Height) / 2));}diff --git a/src/managed/Nota.App/Controls/UtilityViews.cs b/src/managed/Nota.App/Controls/UtilityViews.csindex 46b48198..ac82d774 100644--- a/src/managed/Nota.App/Controls/UtilityViews.cs+++ b/src/managed/Nota.App/Controls/UtilityViews.cs@@ -340,12 +340,12 @@ internal sealed class UtCorrBar : Controldouble w = Bounds.Width, h = Bounds.Height;if (w <= 2 || h <= 1) return;double cy = h / 2;- ctx.DrawRectangle(NotaPalette.Rule, null, new Rect(0, cy - 1.5, w, 3), 1.5, 1.5);+ ctx.DrawRectangle(NotaPalette.Rule, null, new Rect(0, cy - 1.5, w, 3), NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));// The out-of-phase half (below 0) is tinted in the warning colour, so the danger side reads at a glance.- ctx.DrawRectangle(OutOfPhase, null, new Rect(0, cy - 1.5, Math.Round(w / 2), 3), 1.5, 1.5);+ ctx.DrawRectangle(OutOfPhase, null, new Rect(0, cy - 1.5, Math.Round(w / 2), 3), NotaSkin.MapRadius(1.5), NotaSkin.MapRadius(1.5));ctx.FillRectangle(NotaPalette.TextTertiary, new Rect(Math.Round(w / 2) - 0.5, cy - 4, 1, 8));double x = (_c + 1) / 2 * w;var ink = _c < 0 ? NotaPalette.Danger : _c < 0.3 ? NotaPalette.Warning : NotaPalette.Success;- ctx.DrawRectangle(ink, null, new Rect(Math.Clamp(x - 1.5, 0, w - 3), 0, 3, h), 1, 1);+ ctx.DrawRectangle(ink, null, new Rect(Math.Clamp(x - 1.5, 0, w - 3), 0, 3, h), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/Controls/VFader.cs b/src/managed/Nota.App/Controls/VFader.csindex 378b006c..d61decbf 100644--- a/src/managed/Nota.App/Controls/VFader.cs+++ b/src/managed/Nota.App/Controls/VFader.cs@@ -69,11 +69,11 @@ internal sealed class VFader : Controlpublic override void Render(DrawingContext ctx){double w = Bounds.Width, h = Bounds.Height, cx = w / 2;- ctx.DrawRectangle(Track, null, new Rect(cx - 2, 0, 4, h), 2, 2);+ ctx.DrawRectangle(Track, null, new Rect(cx - 2, 0, 4, h), NotaRadius.FineValue, NotaRadius.FineValue);double frac = _value / Max;double capY = (h - CapH) * (1 - frac);var cap = new Rect(cx - 13, capY, 26, CapH);- ctx.DrawRectangle(Cap, CapBorder, cap, 4, 4);+ ctx.DrawRectangle(Cap, CapBorder, cap, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);ctx.FillRectangle(_capLine, new Rect(cx - 9, capY + 5, 18, 2));}}diff --git a/src/managed/Nota.App/Controls/VoltEnv.cs b/src/managed/Nota.App/Controls/VoltEnv.csindex 4be47be6..375fa2cd 100644--- a/src/managed/Nota.App/Controls/VoltEnv.cs+++ b/src/managed/Nota.App/Controls/VoltEnv.cs@@ -430,7 +430,7 @@ namespace Nota.App;double bw = Math.Max(24, sv.Width + 6);var badge = new Rect(w - bw - 2, Math.Clamp(n.sy - sv.Height / 2 - 1, 1, plot.Height - sv.Height - 3), bw, sv.Height + 2);ctx.DrawLine(dash, new Point(n.xh, n.sy), new Point(badge.X - 1, n.sy));- ctx.DrawRectangle(Wash(ink, 0x26), null, badge, 3, 3);+ ctx.DrawRectangle(Wash(ink, 0x26), null, badge, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(sv, new Point(badge.X + (badge.Width - sv.Width) / 2, badge.Y + 1));// The bend handles: a diamond in the middle of decay and release.@@ -466,7 +466,7 @@ namespace Nota.App;double lx = Math.Clamp(anchor.X - lt.Width / 2 - 4, 1, w - lt.Width - 9), ly = anchor.Y - lt.Height - 12;if (ly < 1) ly = anchor.Y + 10;var tip = new Rect(lx, ly, lt.Width + 8, lt.Height + 3);- ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderDefault, 1), tip, 3, 3);+ ctx.DrawRectangle(NotaPalette.SurfaceRaised, new Pen(NotaPalette.BorderDefault, 1), tip, NotaRadius.SwitchValue, NotaRadius.SwitchValue);ctx.DrawText(lt, new Point(lx + 4, ly + 1.5));}@@ -493,7 +493,7 @@ namespace Nota.App;var (a, b) = segs[k];var r = new Rect(a + 0.5, by, Math.Max(1, b - a - 1), BarH - 2);bool on = active == k;- ctx.DrawRectangle(on ? Wash(ink, 0x40) : NotaPalette.SurfaceRaised, null, r, 2, 2);+ ctx.DrawRectangle(on ? Wash(ink, 0x40) : NotaPalette.SurfaceRaised, null, r, NotaRadius.FineValue, NotaRadius.FineValue);var lt = Text(Letters[k].ToString(), on ? NotaPalette.TextPrimary : NotaPalette.TextTertiary, 8, FontWeight.SemiBold);if (r.Width > lt.Width + 2) ctx.DrawText(lt, new Point(r.X + (r.Width - lt.Width) / 2, r.Y + (r.Height - lt.Height) / 2));}diff --git a/src/managed/Nota.App/Controls/VoltMatrix.cs b/src/managed/Nota.App/Controls/VoltMatrix.csindex 4e69ce52..168ce1bc 100644--- a/src/managed/Nota.App/Controls/VoltMatrix.cs+++ b/src/managed/Nota.App/Controls/VoltMatrix.cs@@ -195,14 +195,14 @@ internal sealed class VoltMatrix : Control, IValueEntryHostdouble cx = LabelW + d * cw;var r = new Rect(cx + 1, cy + 1, cw - 2, ch - 2);int i = _idx[s, d];- if (i < 0) { ctx.DrawRectangle(Sunken, new Pen(GridB, 1), r, 2, 2); continue; }+ if (i < 0) { ctx.DrawRectangle(Sunken, new Pen(GridB, 1), r, NotaRadius.FineValue, NotaRadius.FineValue); continue; }double amt = (_e.PluginParamGet(_t, -1, i) - 0.5) * 2.0;bool on = Math.Abs(amt) > 0.01;- if (!on) { ctx.DrawRectangle(CellBg, new Pen(GridB, 1), r, 2, 2); continue; }+ if (!on) { ctx.DrawRectangle(CellBg, new Pen(GridB, 1), r, NotaRadius.FineValue, NotaRadius.FineValue); continue; }// A route lights the whole cell: a neutral wash that deepens with the amount,// a hairline, and the signed number in primary ink.var wash = NotaPalette.Wash(NotaPalette.VizInk, (byte)(0x18 + 0x40 * Math.Min(1.0, Math.Abs(amt))));- ctx.DrawRectangle(wash, new Pen(LitEdge, 1), r, 2, 2);+ ctx.DrawRectangle(wash, new Pen(LitEdge, 1), r, NotaRadius.FineValue, NotaRadius.FineValue);if (r.Width >= 18)Txt(ctx, (amt > 0 ? "+" : "−") + (int)Math.Round(Math.Abs(amt) * 100), r.X + r.Width / 2, r.Y + r.Height / 2 - 5, Lit, 8, true);}diff --git a/src/managed/Nota.App/DeviceCards/Mosaic/MosaicViews.cs b/src/managed/Nota.App/DeviceCards/Mosaic/MosaicViews.csindex edb4afa7..f5e53d94 100644--- a/src/managed/Nota.App/DeviceCards/Mosaic/MosaicViews.cs+++ b/src/managed/Nota.App/DeviceCards/Mosaic/MosaicViews.cs@@ -265,22 +265,22 @@ internal sealed class MosaicZoneMap : Controlroots.Add(z.Root);var r = ZoneRect(m, z).Deflate(0.5);if (_sounding.ContainsKey(i) || i == _sel || !drawn.Add(r)) continue;- ctx.DrawRectangle(NotaPalette.SurfaceCard, Hair, new RoundedRect(r, 1));- if (z.Excl != 0 || z.OffBy != 0) ctx.DrawRectangle(null, ExclPen, new RoundedRect(r.Deflate(1.5), 1));+ ctx.DrawRectangle(NotaPalette.SurfaceCard, Hair, new RoundedRect(r, NotaSkin.MapRadius(1)));+ if (z.Excl != 0 || z.OffBy != 0) ctx.DrawRectangle(null, ExclPen, new RoundedRect(r.Deflate(1.5), NotaSkin.MapRadius(1)));}foreach (var (i, st) in _sounding){if (i < 0 || i >= _zones.Count || !Shows(_zones[i])) continue;var r = ZoneRect(m, _zones[i]).Deflate(0.5);IBrush fill = st == 0 ? NotaPalette.Accent : st == 1 ? NotaPalette.AccentDim : NotaPalette.AccentMute;- ctx.DrawRectangle(fill, null, new RoundedRect(r, 1));+ ctx.DrawRectangle(fill, null, new RoundedRect(r, NotaSkin.MapRadius(1)));}if (_sel >= 0 && _sel < _zones.Count && Shows(_zones[_sel])){var z = _zones[_sel];var r = ZoneRect(m, z).Deflate(0.75);- if (!_sounding.ContainsKey(_sel)) ctx.DrawRectangle(NotaPalette.AccentSubtle, null, new RoundedRect(r, 1));- ctx.DrawRectangle(null, SelPen, new RoundedRect(r, 1));+ if (!_sounding.ContainsKey(_sel)) ctx.DrawRectangle(NotaPalette.AccentSubtle, null, new RoundedRect(r, NotaSkin.MapRadius(1)));+ ctx.DrawRectangle(null, SelPen, new RoundedRect(r, NotaSkin.MapRadius(1)));if (!Mini){var t = SamplerInk.Mono(MosaicNames.NoteName(z.Root), _sounding.ContainsKey(_sel) ? NotaPalette.TextOnAccent : NotaPalette.AccentBright, 6.5);diff --git a/src/managed/Nota.App/MainWindow.AudioFormat.cs b/src/managed/Nota.App/MainWindow.AudioFormat.csindex df7c6519..adb02614 100644--- a/src/managed/Nota.App/MainWindow.AudioFormat.cs+++ b/src/managed/Nota.App/MainWindow.AudioFormat.cs@@ -62,6 +62,9 @@ public partial class MainWindowreturn items.ToArray();}- /// <summary>Preferences on the Audio page (the input setup lives there, specs/086).</summary>+ /// <summary>Settings on the Audio page (sample rate, buffer — the format menu's way in).</summary>internal void ShowAudioPreferences() => ShowPreferencesPage("Audio");++ /// <summary>Settings on the Inputs page (the input setup, specs/086 and 088).</summary>+ internal void ShowInputPreferences() => ShowPreferencesPage("Inputs");}diff --git a/src/managed/Nota.App/MainWindow.Browser.cs b/src/managed/Nota.App/MainWindow.Browser.csindex a3843faf..dea8dddb 100644--- a/src/managed/Nota.App/MainWindow.Browser.cs+++ b/src/managed/Nota.App/MainWindow.Browser.cs@@ -135,6 +135,14 @@ public partial class MainWindowcatch (Exception ex) { _vm.StatusText = Loc.F("main.browser.reveal_failed", ex.Message); }}+ /// <summary>Open a folder itself in the OS file manager (not its parent with it selected).</summary>+ internal static void OpenFolderInFileManager(string dir)+ {+ if (OperatingSystem.IsMacOS()) Process.Start("open", new[] { dir });+ else if (OperatingSystem.IsWindows()) Process.Start("explorer.exe", $"\"{dir}\"");+ else Process.Start("xdg-open", new[] { dir });+ }+internal static void RevealInFileManager(string path){if (OperatingSystem.IsMacOS()) Process.Start("open", new[] { "-R", path });@@ -177,9 +185,7 @@ public partial class MainWindow{string dir = _vm.Settings.PresetsFolder();Directory.CreateDirectory(dir); // nothing saved yet: open it empty rather than fail- if (OperatingSystem.IsMacOS()) Process.Start("open", new[] { dir });- else if (OperatingSystem.IsWindows()) Process.Start("explorer.exe", $"\"{dir}\"");- else Process.Start("xdg-open", new[] { dir });+ OpenFolderInFileManager(dir);}catch (Exception ex) { _vm.StatusText = Loc.F("main.browser.reveal_failed", ex.Message); }}diff --git a/src/managed/Nota.App/MainWindow.Commands.cs b/src/managed/Nota.App/MainWindow.Commands.csindex 2a4bfbf1..032ff087 100644--- a/src/managed/Nota.App/MainWindow.Commands.cs+++ b/src/managed/Nota.App/MainWindow.Commands.cs@@ -157,9 +157,11 @@ public partial class MainWindowB("prefs.open", ShowPreferences);foreach (var (id, page) in new[]{- ("prefs.audio", "Audio"), ("prefs.midi", "MIDI"), ("prefs.gamepads", "Gamepads"), ("prefs.remote", "Remote"),- ("prefs.plugins", "Plug-ins"), ("prefs.downloads", "Downloads"), ("prefs.library", "Library"),- ("prefs.appearance", "Appearance"), ("prefs.shortcuts", "Shortcuts"), ("prefs.updates", "Updates"),+ ("prefs.audio", "Audio"), ("prefs.outputs", "Outputs"), ("prefs.inputs", "Inputs"), ("prefs.midi", "MIDI"),+ ("prefs.gamepads", "Gamepads"), ("prefs.remote", "Remote"), ("prefs.mcp", "MCP"),+ ("prefs.plugins", "Plug-ins"), ("prefs.downloads", "Downloads"),+ ("prefs.appearance", "Appearance"), ("prefs.language", "Language"), ("prefs.editing", "Editing"),+ ("prefs.library", "Library"), ("prefs.shortcuts", "Shortcuts"), ("prefs.updates", "Updates"),})B(id, () => ShowPreferencesPage(page));diff --git a/src/managed/Nota.App/Mcp/McpAppServices.cs b/src/managed/Nota.App/Mcp/McpAppServices.csindex 10be940a..7510c1e6 100644--- a/src/managed/Nota.App/Mcp/McpAppServices.cs+++ b/src/managed/Nota.App/Mcp/McpAppServices.cs@@ -119,6 +119,7 @@ public sealed class McpService(s.AddSingleton(mosaicPacks);s.AddSingleton(processCpu);s.AddSingleton<IProjectKeyAccess>(new ProjectKeyAccess(transport));+ s.AddSingleton<IThemeAccess>(new ThemeAccess());}/// <summary>Reconcile the server with <see cref="Settings.McpEnabled"/> / <see cref="Settings.McpPort"/>.</summary>diff --git a/src/managed/Nota.App/Mcp/ThemeAccess.cs b/src/managed/Nota.App/Mcp/ThemeAccess.csnew file mode 100644index 00000000..231e3160--- /dev/null+++ b/src/managed/Nota.App/Mcp/ThemeAccess.cs@@ -0,0 +1,166 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The MCP theme tools' view of the app (spec 087): the theme list, files, catalogue, the+// validator, the skin previews, and saving, wearing and trying on themes. Every member runs+// on the UI thread (the tools call it through IEngineDispatch). Writes go only to the themes+// folder, under a file name made from the validated id — never from the client's text.++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using System.Text.Json;+using System.Threading.Tasks;+using Nota.Application;+using Nota.Application.Themes;+using Nota.Mcp;++namespace Nota.App;++internal sealed class ThemeAccess : IThemeAccess+{+ private static IReadOnlyDictionary<string, (string Group, string Role)>? _roles;++ public ThemeListing List()+ {+ // The folder as it is now: a client may have written a file there by hand.+ NotaThemes.ReloadUser();+ var worn = NotaThemeService.TryOnTheme ?? NotaThemes.Find(NotaThemeService.WornTheme?.Id) ?? NotaThemes.Default;+ var c = NotaThemeService.Choice;+ return new ThemeListing(+ NotaThemes.All.Select(t => new ThemeListEntry(t.Id, t.Name, t.IsDark ? "dark" : "light",+ t.IsUser ? "user" : "built-in", t.Warnings.Count, t.Warnings.Any(w => w.Kind == ThemeWarning.FontMissing),+ t.Geometry.FontFamily, t.Geometry.Roundness)).ToArray(),+ worn.Id, NotaThemeService.TryOnTheme is not null,+ new ThemeChoiceInfo(c.FollowSystem, c.Single, c.Dark, c.Light),+ NotaThemes.UserLoadProblems.Select(p => new ThemeFileProblem(p.FileName, p.Reason)).ToArray());+ }++ public string? GetFile(string id) => NotaThemes.Find(id) is { } t ? NotaThemes.ToFile(t) : null;++ public ThemeCatalogue Catalogue()+ {+ var roles = Roles();+ return new ThemeCatalogue(+ NotaThemes.CatalogueList.Select(name =>+ {+ var (group, role) = roles.TryGetValue(name, out var r) ? r : ("", "");+ return new ThemeTokenInfo(name, group, role, NotaThemes.AlphaTokens.Contains(name));+ }).ToArray(),+ Enum.GetValues<RadiusStep>().Select(s => new ThemeRadiusStepInfo(SkinGeometry.Key(s), SkinGeometry.Design(s))).ToArray(),+ new ThemeRanges(+ new[] { SkinGeometry.MinRoundness, SkinGeometry.MaxRoundness },+ new[] { SkinGeometry.MinStep, SkinGeometry.MaxStep },+ new[] { 1, SkinGeometry.MaxFamilyLength }),+ new[] { 1, 2 });+ }++ public IReadOnlyList<string> SystemFonts() => NotaThemes.SystemFontNames();++ public ThemeValidation Validate(string json) => NotaThemes.Validate(json);++ public async Task<ThemePreviews> PreviewAsync(string json, IReadOnlyList<string>? surfaces, bool themeAccent)+ {+ var v = NotaThemes.Validate(json);+ if (!v.IsValid) return new ThemePreviews(v, Array.Empty<ThemePreviewImage>(), Array.Empty<string>(), Array.Empty<string>());+ var theme = NotaThemes.FromParsed(v, ThemeSource.Preview);+ var (images, unknown) = await SkinPreviewRenderer.RenderAsync(theme, themeAccent, surfaces);+ return new ThemePreviews(v,+ images.Select(i => new ThemePreviewImage(i.Name, i.Description, i.Png)).ToArray(),+ images.Select(i => i.Name).ToArray(), unknown.ToArray());+ }++ public ThemeSaveResult Save(string json, bool overwrite)+ {+ var v = NotaThemes.Validate(json);+ if (!v.IsValid) return new ThemeSaveResult(v, false, null, "the theme is not valid — see the problems");+ var id = v.Theme!.Id;+ if (NotaThemes.IsBuiltIn(id))+ return new ThemeSaveResult(v, false, null, $"'{id}' is a built-in theme — give the theme its own id");+ var existing = NotaThemes.User.FirstOrDefault(t => t.Id == id);+ var path = Path.Combine(NotaThemes.ThemesFolder, id + ".json");+ if (!overwrite && (existing is not null || File.Exists(path)))+ return new ThemeSaveResult(v, false, null, $"a user theme '{id}' exists — pass overwrite to replace it");+ try+ {+ Directory.CreateDirectory(NotaThemes.ThemesFolder);+ // Write the new file in full first (temp + move), so a failed write leaves the old theme.+ var temp = path + ".tmp";+ try+ {+ File.WriteAllText(temp, NotaThemes.ToFile(NotaThemes.FromParsed(v, ThemeSource.User)));+ File.Move(temp, path, overwrite: true);+ }+ finally+ {+ if (File.Exists(temp)) File.Delete(temp);+ }+ // Another file in the folder may hold this id under a different name: it is replaced+ // now, so it goes — only after the new one is safely on disk.+ if (existing?.FilePath is { } old && !SameFile(old, path))+ File.Delete(old);+ }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException)+ {+ return new ThemeSaveResult(v, false, null, e.Message);+ }+ NotaThemes.ReloadUser();+ return new ThemeSaveResult(v, true, path, null);+ }++ // Whether two paths in the themes folder name one file. Names that differ only in case+ // (My-Skin.json vs my-skin.json) are one file on a case-insensitive file system (Windows,+ // default macOS) — deleting one would delete the other — and two files on Linux. The+ // folder listing tells which: two entries for the name only when they are distinct.+ private static bool SameFile(string a, string b)+ {+ a = Path.GetFullPath(a);+ b = Path.GetFullPath(b);+ if (string.Equals(a, b, StringComparison.Ordinal)) return true;+ if (!string.Equals(a, b, StringComparison.OrdinalIgnoreCase)) return false;+ var name = Path.GetFileName(b);+ var dir = Path.GetDirectoryName(b);+ if (dir is null || !Directory.Exists(dir)) return false;+ return Directory.EnumerateFiles(dir)+ .Count(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)) < 2;+ }++ public string? Apply(string id)+ {+ if (NotaThemes.Find(id) is null) return $"No theme '{id}' — see list_themes.";+ // Single-theme mode (contract): under follow system the pick would only fill its kind's+ // slot, and on a desktop of the other kind another theme would stay on screen.+ PreferencesWindow.PickTheme(id, singleMode: true);+ return null;+ }++ public bool TryOn(string json, out ThemeValidation validation)+ {+ validation = NotaThemes.Validate(json);+ if (!validation.IsValid) return false;+ NotaThemeService.TryOn(NotaThemes.FromParsed(validation, ThemeSource.TryOn));+ return true;+ }++ public string RevertTryOn()+ {+ NotaThemeService.RevertTryOn();+ return NotaThemes.Find(NotaThemeService.WornTheme?.Id)?.Id ?? NotaThemeService.Choice.Single;+ }++ // What each token is for: Theme/token-roles.json, made from NotaPalette's comments.+ private static IReadOnlyDictionary<string, (string, string)> Roles()+ {+ if (_roles is not null) return _roles;+ var map = new Dictionary<string, (string, string)>();+ using var s = typeof(ThemeAccess).Assembly.GetManifestResourceStream("Nota.Themes.token-roles.json");+ if (s is not null)+ {+ using var doc = JsonDocument.Parse(s);+ foreach (var e in doc.RootElement.EnumerateArray())+ map[e.GetProperty("name").GetString() ?? ""] = (e.GetProperty("group").GetString() ?? "", e.GetProperty("role").GetString() ?? "");+ }+ return _roles = map;+ }+}diff --git a/src/managed/Nota.App/MidiLearnOverlay.cs b/src/managed/Nota.App/MidiLearnOverlay.csindex adaaff4d..974bf45e 100644--- a/src/managed/Nota.App/MidiLearnOverlay.cs+++ b/src/managed/Nota.App/MidiLearnOverlay.cs@@ -99,7 +99,7 @@ public sealed class MidiLearnOverlay : Control: mapped ? NotaPalette.Wash(NotaPalette.Success, 0x2E): NotaPalette.Wash(NotaPalette.Accent, 0x26);var pad = rect.Inflate(2);- ctx.DrawRectangle(fill, new Pen(outline, pending ? 2.5 : 1.5), pad, 4, 4);+ ctx.DrawRectangle(fill, new Pen(outline, pending ? 2.5 : 1.5), pad, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);}}diff --git a/src/managed/Nota.App/ModularView.Scope.cs b/src/managed/Nota.App/ModularView.Scope.csindex 4552afe2..ae823586 100644--- a/src/managed/Nota.App/ModularView.Scope.cs+++ b/src/managed/Nota.App/ModularView.Scope.cs@@ -287,7 +287,7 @@ public sealed partial class ModularView{double w = Bounds.Width, h = Bounds.Height;if (w <= 0 || h <= 0) return;- ctx.DrawRectangle(ScopeBg, null, new Rect(0, 0, w, h), 4, 4);+ ctx.DrawRectangle(ScopeBg, null, new Rect(0, 0, w, h), NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);double mid = h / 2;var grid = new Pen(BorderInner, 1);for (int i = 1; i < 4; i++) { double x = Math.Round(w * i / 4) + 0.5; ctx.DrawLine(grid, new Point(x, 2), new Point(x, h - 2)); }diff --git a/src/managed/Nota.App/ModularView.cs b/src/managed/Nota.App/ModularView.csindex 43443989..9d3c6712 100644--- a/src/managed/Nota.App/ModularView.cs+++ b/src/managed/Nota.App/ModularView.cs@@ -2564,7 +2564,7 @@ public sealed partial class ModularView : UserControl{if (_v._nodes.Count == 0) return;var bg = NotaPalette.Wash(NotaPalette.BgSunken, 0xB2);- ctx.DrawRectangle(bg, new Pen(BorderDef, 1), new Rect(0, 0, Width, Height), 5, 5);+ ctx.DrawRectangle(bg, new Pen(BorderDef, 1), new Rect(0, 0, Width, Height), NotaRadius.CellValue, NotaRadius.CellValue);double minX = double.MaxValue, minY = double.MaxValue, maxX = double.MinValue, maxY = double.MinValue;foreach (var n in _v._nodes)@@ -2585,7 +2585,7 @@ public sealed partial class ModularView : UserControldouble bw = n.NodeWidth * s, bh = (n.View.Bounds.Height > 0 ? n.View.Bounds.Height : 120) * s;var sc = ((ISolidColorBrush)n.Stripe).Color;var b = new SolidColorBrush(Color.FromArgb(0xB3, sc.R, sc.G, sc.B));- ctx.DrawRectangle(b, null, new Rect(p.X, p.Y, bw, bh), 2, 2);+ ctx.DrawRectangle(b, null, new Rect(p.X, p.Y, bw, bh), NotaRadius.FineValue, NotaRadius.FineValue);}// viewport rectangle (world region currently visible)@@ -2596,7 +2596,7 @@ public sealed partial class ModularView : UserControldouble wx1 = (vw - _v._pan.X) / _v._scale, wy1 = (vh - _v._pan.Y) / _v._scale;var a = M(wx0, wy0); var c = M(wx1, wy1);var rect = new Rect(a, c).Intersect(new Rect(0, 0, Width, Height));- ctx.DrawRectangle(null, new Pen(NotaPalette.Wash(NotaPalette.TextPrimary, 0x66), 1), rect, 3, 3);+ ctx.DrawRectangle(null, new Pen(NotaPalette.Wash(NotaPalette.TextPrimary, 0x66), 1), rect, NotaRadius.SwitchValue, NotaRadius.SwitchValue);}}}diff --git a/src/managed/Nota.App/Nota.App.csproj b/src/managed/Nota.App/Nota.App.csprojindex d07e2808..524f8f45 100644--- a/src/managed/Nota.App/Nota.App.csproj+++ b/src/managed/Nota.App/Nota.App.csproj@@ -50,6 +50,8 @@files from disk. --><ItemGroup><EmbeddedResource Include="Theme\Themes\*.json" LogicalName="Nota.Themes.%(Filename)%(Extension)" />+ <!-- What each colour token is for (spec 087): the MCP theme catalogue. -->+ <EmbeddedResource Include="Theme\token-roles.json" LogicalName="Nota.Themes.token-roles.json" /></ItemGroup><ItemGroup>diff --git a/src/managed/Nota.App/PianoRollView.Controllers.cs b/src/managed/Nota.App/PianoRollView.Controllers.csindex 84cbd456..c64d6979 100644--- a/src/managed/Nota.App/PianoRollView.Controllers.cs+++ b/src/managed/Nota.App/PianoRollView.Controllers.cs@@ -474,7 +474,7 @@ public sealed partial class PianoRollViewif (px < -4 || px > w + 4) continue;bool hot = k == _hoverPt || (_drag == Drag.Point && k == _pt);const double r = 2.5; // hover changes colour, not size- ctx.FillRectangle(hot ? PointHot : PointFill, new Rect(px - r, ValueToY(c[k].Value) - r, r * 2, r * 2), 1);+ ctx.FillRectangle(hot ? PointHot : PointFill, new Rect(px - r, ValueToY(c[k].Value) - r, r * 2, r * 2), (float)NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/PianoRollView.Expression.cs b/src/managed/Nota.App/PianoRollView.Expression.csindex 644f41f1..e458362c 100644--- a/src/managed/Nota.App/PianoRollView.Expression.cs+++ b/src/managed/Nota.App/PianoRollView.Expression.cs@@ -193,7 +193,7 @@ public sealed partial class PianoRollViewsize -= 0.5;} while ((ft.Width > Bounds.Width - 2 * pad - 2 || ft.Height > ChipH + 1) && size >= 6);double y = Top + i * RowStep;- if (on) ctx.DrawRectangle(NotaPalette.Well, null, new Rect(pad, y, Math.Max(0, Bounds.Width - 2 * pad), ChipH), 5, 5);+ if (on) ctx.DrawRectangle(NotaPalette.Well, null, new Rect(pad, y, Math.Max(0, Bounds.Width - 2 * pad), ChipH), NotaRadius.CellValue, NotaRadius.CellValue);ctx.DrawText(ft, new Point((Bounds.Width - ft.Width) / 2, y + (ChipH - ft.Height) / 2));}}@@ -360,7 +360,7 @@ public sealed partial class PianoRollViewif (px > x1 + 0.5) continue;bool hot = _hoverPt == (i, k) || (_drag == Drag.Point && _ptNote == i && _ptIdx == k);double r = hot ? 3.5 : 2.5;- ctx.FillRectangle(hot ? PointHot : PointFill, new Rect(px - r, ValueToY(c[k].Value) - r, r * 2, r * 2), 1);+ ctx.FillRectangle(hot ? PointHot : PointFill, new Rect(px - r, ValueToY(c[k].Value) - r, r * 2, r * 2), (float)NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/PianoRollView.cs b/src/managed/Nota.App/PianoRollView.csindex d1a24c7f..df57b3cc 100644--- a/src/managed/Nota.App/PianoRollView.cs+++ b/src/managed/Nota.App/PianoRollView.cs@@ -2238,10 +2238,10 @@ public sealed partial class PianoRollView : UserControlvar r = new Rect(x, y, Math.Max(2, nw - 1), RowH - 1);if (_o.IsGhost(i)) // a tool's preview: brass outline over the clip's own notes{- ctx.DrawRectangle(GhostFill, GhostEdge, r.Deflate(0.5), 2, 2);+ ctx.DrawRectangle(GhostFill, GhostEdge, r.Deflate(0.5), NotaRadius.FineValue, NotaRadius.FineValue);continue;}- if (sel) ctx.DrawRectangle(NoteSel, NoteSelEdge, r.Deflate(0.5), 2, 2);+ if (sel) ctx.DrawRectangle(NoteSel, NoteSelEdge, r.Deflate(0.5), NotaRadius.FineValue, NotaRadius.FineValue);else{// Track colour, quieter the softer the note — and, with several clips open,@@ -2255,23 +2255,23 @@ public sealed partial class PianoRollView : UserControl? NoteOverwrite.Fate(i, notes, _o.PlacedForRender(), _o._owner) : default;double appear = _o._recPreview?.Progress(n.Pitch, _o._recClipStart + n.StartBeat) ?? 1;if (fate.Kind == NoteFateKind.Kept && appear < 1)- ctx.FillRectangle(RecordPreview.AppearBrush(c, appear), r, 2);+ ctx.FillRectangle(RecordPreview.AppearBrush(c, appear), r, (float)NotaRadius.FineValue);else if (fate.Kind == NoteFateKind.Kept)- ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a), c.R, c.G, c.B)), r, 2);+ ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a), c.R, c.G, c.B)), r, (float)NotaRadius.FineValue);else{double keepW = fate.Kind == NoteFateKind.Cut ? Math.Min(r.Width, fate.CutLength * ppb) : 0;if (keepW > 0)- ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a), c.R, c.G, c.B)), r.WithWidth(keepW), 2);+ ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a), c.R, c.G, c.B)), r.WithWidth(keepW), (float)NotaRadius.FineValue);var doomed = new Rect(r.X + keepW, r.Y, Math.Max(1, r.Width - keepW), r.Height);- ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a * 0.25), c.R, c.G, c.B)), doomed, 2);+ ctx.FillRectangle(new SolidColorBrush(Color.FromArgb((byte)(255 * a * 0.25), c.R, c.G, c.B)), doomed, (float)NotaRadius.FineValue);_doomed.Add((doomed, c)); // its dashed edge goes on top of the notes covering it}}if (n.ExprId > 0 || _o._expr.Editing(i)) DrawExpression(ctx, i, n, r, sel, ppb);// FR-014: an articulation the map no longer holds — a warning notch at the note's start.if (n.ArticulationId > 0 && _o.HasMissingArticulation(i))- ctx.FillRectangle(NotaPalette.Warning, new Rect(r.X, r.Y, Math.Min(3, r.Width), r.Height), 1);+ ctx.FillRectangle(NotaPalette.Warning, new Rect(r.X, r.Y, Math.Min(3, r.Width), r.Height), (float)NotaSkin.MapRadius(1));// Resize-edge affordance: a bright bar on the edge a drag would trim.bool edgeHi = ((_drag == Mode.Resize || _drag == Mode.ResizeLeft || (_drag == Mode.Place && _placeKind == PlaceDragKind.Length)) && sel)|| (_drag == Mode.None && _hoverNote == i && !_o.IsLocked(i));@@ -2286,7 +2286,7 @@ public sealed partial class PianoRollView : UserControlif (_doomed.Count > 0){foreach (var (d, dc) in _doomed)- ctx.DrawRectangle(null, new Pen(new SolidColorBrush(dc), 1, DashStyle.Dash), d.Deflate(0.5), 2, 2);+ ctx.DrawRectangle(null, new Pen(new SolidColorBrush(dc), 1, DashStyle.Dash), d.Deflate(0.5), NotaRadius.FineValue, NotaRadius.FineValue);_doomed.Clear();}// Keys held into the recording take (#56): from the key-down to the capture clock,@@ -2302,7 +2302,7 @@ public sealed partial class PianoRollView : UserControldouble p = rp.Progress(hn.Pitch, hn.StartBeat);var hr = new Rect(hx, PitchToY(hn.Pitch), Math.Max(2, hw - 1), RowH - 1);ctx.FillRectangle(p < 1 ? RecordPreview.AppearBrush(c, p)- : new SolidColorBrush(Color.FromArgb((byte)(255 * (0.45 + 0.55 * Math.Clamp(hn.Velocity, 0, 1))), c.R, c.G, c.B)), hr, 2);+ : new SolidColorBrush(Color.FromArgb((byte)(255 * (0.45 + 0.55 * Math.Clamp(hn.Velocity, 0, 1))), c.R, c.G, c.B)), hr, (float)NotaRadius.FineValue);}_o.DrawOutsideClip(ctx, w, h);if (_drag == Mode.Marquee)@@ -2930,7 +2930,7 @@ public sealed partial class PianoRollView : UserControlb = new SolidColorBrush(Color.FromArgb((byte)(255 * a), c.R, c.G, c.B));}ctx.FillRectangle(b, new Rect(x, h - bh, 2, bh));- ctx.FillRectangle(hov && !sel ? EdgeHighlight : b, new Rect(x - 2, h - bh - 2, 6, 3), 1);+ ctx.FillRectangle(hov && !sel ? EdgeHighlight : b, new Rect(x - 2, h - bh - 2, 6, 3), (float)NotaSkin.MapRadius(1));}_o.DrawOutsideClip(ctx, w, h);}diff --git a/src/managed/Nota.App/PreferencesWindow.AudioIo.cs b/src/managed/Nota.App/PreferencesWindow.AudioIo.csindex ed39d53e..e327adfb 100644--- a/src/managed/Nota.App/PreferencesWindow.AudioIo.cs+++ b/src/managed/Nota.App/PreferencesWindow.AudioIo.cs@@ -1,10 +1,13 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Preferences → Audio → Inputs (specs/086, #353 option 2): every input of the capture device-// with the name the device gives it, a switch and a name of the user's; then the stereo-// pairs, which can be named too. Track input pickers list only switched-on inputs, under these-// names. Kept per device in the app settings (InputSetupAccess); edits apply at once.+// Settings → Outputs and Settings → Inputs (specs/088): which device Nota plays through and+// records from. Outputs carries the test tone. Inputs lists every input of the capture device+// (specs/086, #353 option 2) with the name the device gives it, a switch and a name of the+// user's; then the stereo pairs, which can be named too. Track input pickers list only+// switched-on inputs, under these names. Kept per device in the app settings+// (InputSetupAccess); edits apply at once. Under ASIO one driver is both sides: it is picked+// on the Audio page, and these pages pick its output / input pair.using System;using System.Collections.Generic;@@ -22,6 +25,82 @@ public sealed partial class PreferencesWindow{private const double InputNameW = 200, InputDeviceW = 170;+ private Control OutputsPane()+ {+ if (_main is null) return Caption(Loc.T("preferences.audio_settings_are_unavailable_in"));+ _loading = true;+ var engine = _main.Engine;+ var rows = new List<Control>();+ if (IsAsio(engine))+ {+ rows.Add(AsioDeviceRow(engine));+ if (engine.ActiveAudioSystem == AudioSystem.Asio)+ rows.Add(Row(Loc.T("common.output"), PairCombo(engine, input: false, engine.AsioChannels(false))));+ }+ else+ {+ var combo = Combo(280);+ FillDeviceCombo(combo, _outputUids, _audioDevices.OutputDevices(), engine.GetAudioConfig().OutputUid);+ combo.SelectionChanged += (_, _) => { int i = combo.SelectedIndex; if (i >= 0 && i < _outputUids.Count) { engine.SetAudioOutputDevice(_outputUids[i]); Apply(); } };+ rows.Add(Row(Loc.T("common.output"), combo));+ }+ var body = Sections(+ Section(Loc.T("preferences.audio_device"), 6, rows.ToArray()),+ Section(Loc.T("preferences.test"), 8, TestToneRow()));+ _loading = false;+ return body;+ }++ private Control InputsPane()+ {+ if (_main is null) return Caption(Loc.T("preferences.audio_settings_are_unavailable_in"));+ _loading = true;+ var engine = _main.Engine;+ var rows = new List<Control>();+ if (IsAsio(engine))+ {+ rows.Add(AsioDeviceRow(engine));+ if (engine.ActiveAudioSystem == AudioSystem.Asio)+ {+ var ins = engine.AsioChannels(true);+ rows.Add(Row(Loc.T("common.input"), ins.Count > 0 ? PairCombo(engine, input: true, ins) : Caption(Loc.T("preferences.no_inputs_on_this_driver"))));+ }+ }+ else+ {+ var combo = Combo(280);+ FillDeviceCombo(combo, _inputUids, _audioDevices.InputDevices(), engine.GetAudioConfig().InputUid);+ combo.SelectionChanged += (_, _) => { int i = combo.SelectedIndex; if (i >= 0 && i < _inputUids.Count) { engine.SetAudioInputDevice(_inputUids[i]); Apply(); } };+ rows.Add(Row(Loc.T("common.input"), combo));+ }+ var body = Sections(+ Section(Loc.T("preferences.audio_device"), 6, rows.ToArray()),+ InputsHost(engine));+ _loading = false;+ return body;+ }++ private static bool IsAsio(IAudioEngine engine) =>+ OperatingSystem.IsWindows() && engine.AsioAvailable && engine.AudioSystem == AudioSystem.Asio;++ // "Driver Focusrite USB ASIO — the ASIO driver is both input and output. [Change on the Audio page]"+ private Control AsioDeviceRow(IAudioEngine engine)+ {+ string uid = engine.AsioDriver;+ string name = uid;+ foreach (var d in engine.AsioDrivers())+ if (string.Equals(d.Uid, uid, StringComparison.OrdinalIgnoreCase)) name = d.Name;+ if (name.Length == 0) name = Loc.T("preferences.asio_caps");+ var go = Btn(Loc.T("preferences.change_on_audio_page"));+ go.HorizontalAlignment = HorizontalAlignment.Left;+ go.Click += (_, _) => Select("Audio");+ return Row(Loc.T("preferences.driver"), new StackPanel+ {+ Spacing = 8,+ Children = { Caption(Loc.F("preferences.asio_device_on_audio", name)), go },+ });+ }+// The Inputs section sits in a host so a device change can rebuild it alone: the list is// the device's inputs, its names and switches its own entry in the settings.private ContentControl? _inputsHost;diff --git a/src/managed/Nota.App/PreferencesWindow.Downloads.cs b/src/managed/Nota.App/PreferencesWindow.Downloads.csindex 1f3df518..585ccfb2 100644--- a/src/managed/Nota.App/PreferencesWindow.Downloads.cs+++ b/src/managed/Nota.App/PreferencesWindow.Downloads.cs@@ -20,7 +20,6 @@ namespace Nota.App;public sealed partial class PreferencesWindow{- private const int DownloadsIndex = 5;private static readonly string[] DownloadSources = { Loc.T("preferences.plug_ins"), Loc.T("preferences.downloads.sample_packs"), Loc.T("preferences.downloads.ai_models") };private int _downloadSource; // 0 = plug-ins, 1 = sample packs, 2 = AI models; kept for the window's life@@ -44,7 +43,7 @@ public sealed partial class PreferencesWindowsegs[idx].IsChecked = idx == _downloadSource; // a toggle never clears itselfif (idx == _downloadSource) return;_downloadSource = idx;- Select(DownloadsIndex);+ Select("Downloads");};strip.Children.Add(segs[i]);}diff --git a/src/managed/Nota.App/PreferencesWindow.Editing.cs b/src/managed/Nota.App/PreferencesWindow.Editing.csnew file mode 100644index 00000000..edd721df--- /dev/null+++ b/src/managed/Nota.App/PreferencesWindow.Editing.cs@@ -0,0 +1,53 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Settings → General → Editing (specs/088): how the editors behave — piano-roll key labels,+// fades on split audio clips, and whether a selection opens the detail panel. Moved off+// Appearance as they were (#427): they are behaviour, not the look.++using Avalonia.Controls;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Application.Localization;++namespace Nota.App;++public sealed partial class PreferencesWindow+{+ private Control EditingPane()+ {+ var settings = App.Services.GetService<ISettingsService>();++ // Piano-roll key labels: every note for beginners, C-only by default.+ var labelAll = SwitchRow(Loc.T("preferences.label_every_note_in_the"), settings?.Current.PianoRollLabelAllNotes ?? false, on =>+ {+ if (settings is null) return;+ settings.Current.PianoRollLabelAllNotes = on;+ settings.Save();+ });++ // Detail panel (#308): a selection opens a closed panel only when this is on.+ var openOnSelect = SwitchRow(Loc.T("preferences.open_the_detail_panel_when"), settings?.Current.OpenDetailOnSelect ?? false, on =>+ {+ if (settings is null) return;+ settings.Current.OpenDetailOnSelect = on;+ settings.Save();+ });++ var splitFades = SwitchRow(Loc.T("preferences.fade_audio_clips_when_splitting"), settings?.Current.SplitFades ?? true, on =>+ {+ if (settings is null) return;+ settings.Current.SplitFades = on;+ settings.Save();+ if (_main is not null) _main.Engine.SplitFades = on;+ });++ return Sections(+ Section(Loc.T("common.piano_roll"), 10, labelAll,+ Caption(Loc.T("preferences.shows_every_note_name_c"))),+ Section(Loc.T("preferences.arrangement"), 10, splitFades,+ Caption(Loc.T("preferences.splitting_an_audio_clip_adds"))),+ Section(Loc.T("preferences.detail_panel"), 10, openOnSelect,+ Caption(Loc.T("preferences.off_a_click_only_selects"))));+ }+}diff --git a/src/managed/Nota.App/PreferencesWindow.Language.cs b/src/managed/Nota.App/PreferencesWindow.Language.csindex 698493a8..154ea310 100644--- a/src/managed/Nota.App/PreferencesWindow.Language.cs+++ b/src/managed/Nota.App/PreferencesWindow.Language.cs@@ -37,6 +37,12 @@ public sealed partial class PreferencesWindowprivate sealed record LanguageItem(string Code, string Name, LanguageKind Kind, string Detail,InstalledLanguage? Installed, CatalogLanguage? Offered);+ // Settings → General → Language (specs/088): its own page, off Appearance (#427).+ private Control LanguagePane() => Sections(+ Section(Loc.T("preferences.language"), 10,+ Row(Loc.T("preferences.language"), LanguagePicker()),+ Row("", Caption(Loc.T("preferences.the_language_of_menus_panels")))));+private Control LanguagePicker(){var settings = App.Services.GetRequiredService<ISettingsService>();diff --git a/src/managed/Nota.App/PreferencesWindow.Mcp.cs b/src/managed/Nota.App/PreferencesWindow.Mcp.csnew file mode 100644index 00000000..47ef6f93--- /dev/null+++ b/src/managed/Nota.App/PreferencesWindow.Mcp.cs@@ -0,0 +1,105 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Settings → Remote control → AI control (MCP) (specs/088): the in-app MCP server's switch,+// port, status and a ready client config. Moved off Appearance as it was (#427).++using System;+using Avalonia.Controls;+using Avalonia.Input.Platform;+using Avalonia.Layout;+using Avalonia.Media;+using Avalonia.Threading;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Application.Localization;+using Nota.Presentation;++namespace Nota.App;++public sealed partial class PreferencesWindow+{+ private Control McpPane()+ {+ var settings = App.Services.GetService<ISettingsService>();+ var mcp = App.Services.GetService<McpService>();++ var portBox = new TextBox+ {+ Text = (settings?.Current.McpPort ?? 3900).ToString(), Width = 96, Classes = { "field" },+ FontSize = 11, FontFamily = NotaFonts.UiFamily, HorizontalAlignment = HorizontalAlignment.Left,+ };+ var statusDot = Dot(BorderStrong);+ var status = new TextBlock+ {+ FontSize = 10, FontFamily = NotaFonts.UiFamily, Foreground = TextSecondary,+ VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,+ };+ var copyBtn = Btn(Loc.T("preferences.copy_config"));+ copyBtn.HorizontalAlignment = HorizontalAlignment.Left;+ var details = new StackPanel+ {+ Spacing = 10,+ Children =+ {+ Row(Loc.T("preferences.port"), portBox),+ Row(Loc.T("preferences.status"), new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { statusDot, status } }),+ Row("", new StackPanel+ {+ Spacing = 10,+ Children =+ {+ copyBtn,+ Caption(Loc.T("preferences.add_this_config_or_the")),+ },+ }),+ },+ };++ bool Enabled() => settings?.Current.McpEnabled ?? false;+ void Refresh()+ {+ bool on = Enabled();+ status.Text = on ? Loc.F("preferences.listening_on_http_127_0", settings!.Current.McpPort) : Loc.T("common.off");+ statusDot.Fill = on ? NotaPalette.SuccessDim : BorderStrong;+ portBox.IsEnabled = on;+ portBox.Foreground = on ? TextPrimary : TextDisabled;+ copyBtn.IsEnabled = on;+ Inactive.Set(details, !on);+ }+ void ApplyMcp(bool on)+ {+ if (settings is null) return;+ settings.Current.McpEnabled = on;+ if (int.TryParse(portBox.Text, out var p) && p is > 0 and < 65536) settings.Current.McpPort = p;+ settings.Save();+ _ = mcp?.ApplyAsync();+ Refresh();+ }+ var enable = SwitchRow(Loc.T("preferences.enable_mcp_server_let_an"), Enabled(), ApplyMcp);+ portBox.LostFocus += (_, _) => ApplyMcp(Enabled());++ // Copy a ready client-config JSON (Claude Desktop / Claude Code) with the current port.+ string McpConfigJson()+ {+ int port = settings?.Current.McpPort ?? 3900;+ return "{\n \"mcpServers\": {\n \"nota\": {\n \"type\": \"http\",\n \"url\": \"http://127.0.0.1:" + port + "/\"\n }\n }\n}";+ }+ DispatcherTimer? copied = null;+ copyBtn.Click += async (_, _) =>+ {+ var cb = TopLevel.GetTopLevel(this)?.Clipboard;+ if (cb is null) return;+ await cb.SetTextAsync(McpConfigJson());+ copyBtn.Content = Loc.T("preferences.copied");+ copied?.Stop();+ copied = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1500) };+ copied.Tick += (_, _) => { copied!.Stop(); copyBtn.Content = Loc.T("preferences.copy_config"); };+ copied.Start();+ };+ // Inactive.Set walks the visual tree, so the dimming waits until the pane is shown.+ details.AttachedToVisualTree += (_, _) => Refresh();++ return Sections(Section(Loc.T("preferences.ai_control_mcp"), 12, enable, details));+ }+}diff --git a/src/managed/Nota.App/PreferencesWindow.Remote.cs b/src/managed/Nota.App/PreferencesWindow.Remote.csindex db4f2cb4..e87bd325 100644--- a/src/managed/Nota.App/PreferencesWindow.Remote.cs+++ b/src/managed/Nota.App/PreferencesWindow.Remote.cs@@ -25,10 +25,8 @@ namespace Nota.App;public sealed partial class PreferencesWindow{- private const int RemoteIndex = 3;-/// <summary>Open Settings on the Remote page.</summary>- public void ShowRemote() => Select(RemoteIndex);+ public void ShowRemote() => Select("Remote");private Control RemotePane(){diff --git a/src/managed/Nota.App/PreferencesWindow.Skins.cs b/src/managed/Nota.App/PreferencesWindow.Skins.csnew file mode 100644index 00000000..e796855a--- /dev/null+++ b/src/managed/Nota.App/PreferencesWindow.Skins.cs@@ -0,0 +1,174 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Preferences → Appearance, the user themes part (spec 087, contracts/ui-contract.md U1–U5):+// a user theme's card (its name in its own typeface, a "User theme" tag, a warning count),+// the card menu (Duplicate, Show in folder), the themes folder row (Open, Reload) and the+// list of files that could not be loaded. Problems never open a dialog: they are lines here.++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using Avalonia.Controls;+using Avalonia.Layout;+using Avalonia.Media;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Application.Localization;+using Nota.Application.Themes;++namespace Nota.App;++public sealed partial class PreferencesWindow+{+ // The last thing the themes row has to say (a failed duplicate), shown until the next action.+ private static string _skinsStatus = "";++ /// <summary>The theme ids the settings ask for now: the single theme, or both follow-system slots.</summary>+ private static IEnumerable<string> StoredThemeIds(Settings s)+ {+ if (s.ColourTheme == Appearance.System)+ {+ yield return s.SystemDarkTheme;+ yield return s.SystemLightTheme;+ }+ else if (!string.IsNullOrEmpty(s.ColourTheme)) yield return s.ColourTheme;+ }++ // One card: the preview, the name (in the theme's own typeface), and for a user theme a+ // caption with its tag and, when it has any, the warning count with the details on hover.+ private static Control ThemeCard(NotaColourTheme t)+ {+ var name = new TextBlock { Text = t.Name, Classes = { "RowName" }, MaxWidth = ThemePreview.W, TextTrimming = TextTrimming.CharacterEllipsis };+ if (t.Geometry.FontFamily is { } family && NotaThemes.IsFontInstalled(family)) name.FontFamily = new FontFamily(family);+ var card = new StackPanel+ {+ Spacing = 6,+ Children = { new Border { Classes = { "ThemeFrame" }, Child = new ThemePreview(t) }, name },+ };++ if (t.IsUser)+ {+ var caption = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Margin = new Avalonia.Thickness(0, -4, 0, 0) };+ caption.Children.Add(new TextBlock { Text = Loc.T("preferences.skins.user_tag"), Classes = { "Caption" }, Foreground = TextMuted });+ if (t.Warnings.Count > 0)+ {+ var warn = new TextBlock+ {+ Text = Loc.Plural("preferences.skins.warnings", t.Warnings.Count),+ Classes = { "Caption" }, Foreground = NotaPalette.Warning,+ };+ ToolTip.SetTip(warn, WarningsTip(t.Warnings));+ caption.Children.Add(warn);+ }+ card.Children.Add(caption);+ }++ var menu = new MenuFlyout();+ menu.Items.Add(MenuKit.Item(Loc.T("preferences.skins.duplicate"), GlyphKind.Duplicate, () => DuplicateTheme(t)));+ if (t is { IsUser: true, FilePath: { } path })+ menu.Items.Add(MenuKit.Item(MenuKit.RevealLabel, GlyphKind.Folder, () => TryShell(() => MainWindow.RevealInFileManager(path))));+ card.ContextFlyout = menu;+ return card;+ }++ private static string WarningsTip(IReadOnlyList<ThemeWarning> warnings)+ {+ var lines = warnings.Take(5).Select(w => w.Message).ToList();+ if (warnings.Count > 5) lines.Add(Loc.F("preferences.skins.more", warnings.Count - 5));+ return string.Join("\n", lines);+ }++ // Open themes folder · Reload, with the hint (or the last failure) beside them.+ private static Control ThemesFolderRow()+ {+ var open = Btn(Loc.T("preferences.skins.open_folder"));+ var reload = Btn(Loc.T("preferences.skins.reload"));+ open.Click += (_, _) => TryShell(() =>+ {+ Directory.CreateDirectory(NotaThemes.ThemesFolder);+ MainWindow.OpenFolderInFileManager(NotaThemes.ThemesFolder);+ });+ reload.Click += (_, _) => { _skinsStatus = ""; NotaThemes.ReloadUser(); };+ var note = new TextBlock+ {+ Text = _skinsStatus.Length > 0 ? _skinsStatus : Loc.T("preferences.skins.hint"),+ Classes = { "Caption" }, Foreground = _skinsStatus.Length > 0 ? NotaPalette.Warning : TextMuted,+ TextWrapping = TextWrapping.Wrap, MaxWidth = 560,+ };+ return new StackPanel+ {+ Spacing = 8, Margin = new Avalonia.Thickness(0, 6, 0, 0),+ Children =+ {+ new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { open, reload } },+ note,+ },+ };+ }++ // The files in the folder that could not be loaded, one line each — or nothing at all.+ private static Control? ThemeProblems()+ {+ var problems = NotaThemes.UserLoadProblems;+ if (problems.Count == 0) return null;+ var list = new StackPanel { Spacing = 4 };+ list.Children.Add(new TextBlock { Text = Loc.T("preferences.skins.problems_heading"), FontSize = 11, Foreground = NotaPalette.Warning });+ foreach (var (file, reason) in problems)+ list.Children.Add(new TextBlock+ {+ Text = $"{file} — {reason}", Classes = { "Caption" }, Foreground = TextSecondary,+ TextWrapping = TextWrapping.Wrap, MaxWidth = 560,+ });+ return list;+ }++ /// <summary>Wear <paramref name="id"/> and store it, exactly as a pick on a card does.</summary>+ internal static void PickTheme(string id, bool singleMode = false)+ {+ var theme = NotaThemes.Find(id);+ if (theme is null) return;+ var settings = App.Services.GetRequiredService<ISettingsService>();+ var current = singleMode ? NotaThemeService.Choice with { FollowSystem = false } : NotaThemeService.Choice;+ var choice = Appearance.WithPick(current, theme.Id, theme.IsDark);+ var single = NotaThemes.Find(choice.Single) ?? NotaThemes.Default;+ Appearance.Store(settings.Current, choice, single.IsDark);+ settings.Save();+ NotaThemeService.Set(choice);+ }++ // A copy of any theme in the themes folder, under a free id and "<name> copy", then worn.+ private static void DuplicateTheme(NotaColourTheme t)+ {+ var source = NotaThemes.Find(t.Id) ?? t; // the file's own colours, not the accented ones+ var name = Loc.F("preferences.skins.copy_name", source.Name);+ if (name.Length > ThemeFile.MaxNameLength) name = name[..ThemeFile.MaxNameLength].TrimEnd();+ var folder = NotaThemes.ThemesFolder;+ var id = ThemeFile.FreeId(name, x => NotaThemes.Find(x) is not null || File.Exists(Path.Combine(folder, x + ".json")));+ try+ {+ Directory.CreateDirectory(folder);+ File.WriteAllText(Path.Combine(folder, id + ".json"), NotaThemes.ToFile(source with { Id = id, Name = name, Source = ThemeSource.User }));+ _skinsStatus = "";+ }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException)+ {+ _skinsStatus = Loc.F("preferences.skins.cant_save", e.Message);+ NotaThemes.ReloadUser(); // rebuilds the page with the message+ return;+ }+ NotaThemes.ReloadUser();+ PickTheme(id);+ }++ private static void TryShell(Action run)+ {+ try { run(); }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException or System.ComponentModel.Win32Exception)+ {+ _skinsStatus = Loc.F("main.browser.reveal_failed", e.Message);+ NotaThemes.ReloadUser(); // rebuilds the page with the message+ }+ }+}diff --git a/src/managed/Nota.App/PreferencesWindow.Updates.cs b/src/managed/Nota.App/PreferencesWindow.Updates.csindex f64d8653..0e54fc15 100644--- a/src/managed/Nota.App/PreferencesWindow.Updates.cs+++ b/src/managed/Nota.App/PreferencesWindow.Updates.cs@@ -17,8 +17,6 @@ namespace Nota.App;public sealed partial class PreferencesWindow{- private const int UpdatesIndex = 9;-private Control UpdatesPane(){var settings = App.Services.GetRequiredService<ISettingsService>();diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 03843f9d..c0c77d34 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -30,6 +30,7 @@ using Avalonia.Threading;using Microsoft.Extensions.DependencyInjection;using Nota.Application;using Nota.Application.Localization;+using Nota.Application.Themes;using Nota.Presentation;namespace Nota.App;@@ -65,10 +66,17 @@ public sealed partial class PreferencesWindow : NotaWindow{(Loc.T("preferences.devices_settings"), new[]{- new Page("Audio", Loc.T("common.audio"), Loc.T("preferences.device_sample_rate_and_buffer"), GlyphKind.Levels),+ new Page("Audio", Loc.T("common.audio"), Loc.T("preferences.audio_subtitle"), GlyphKind.Levels),+ new Page("Outputs", Loc.T("preferences.outputs"), Loc.T("preferences.outputs_subtitle"), GlyphKind.Output),+ new Page("Inputs", Loc.T("preferences.inputs"), Loc.T("preferences.inputs_subtitle"), GlyphKind.Input),new Page("MIDI", "MIDI", Loc.T("preferences.controllers_nota_listens_to"), GlyphKind.MidiPort),new Page("Gamepads", Loc.T("preferences.gamepads"), Loc.T("preferences.play_notes_or_drive_mapped"), GlyphKind.Gamepad),+ }),+ // Things outside Nota that drive it: a phone on the network, an AI assistant over MCP.+ (Loc.T("preferences.remote_control"), new[]+ {new Page("Remote", Loc.T("preferences.remote"), Loc.T("preferences.phones_and_tablets_on_this"), GlyphKind.Phone),+ new Page("MCP", Loc.T("preferences.ai_control_mcp"), Loc.T("preferences.mcp_subtitle"), GlyphKind.Action),}),(Loc.T("preferences.plug_ins"), new[]{@@ -77,8 +85,10 @@ public sealed partial class PreferencesWindow : NotaWindow}),(Loc.T("preferences.general"), new[]{+ new Page("Appearance", Loc.T("preferences.appearance"), Loc.T("preferences.appearance_subtitle"), GlyphKind.Appearance),+ new Page("Language", Loc.T("preferences.language"), Loc.T("preferences.language_subtitle"), GlyphKind.Globe),+ new Page("Editing", Loc.T("preferences.editing"), Loc.T("preferences.editing_subtitle"), GlyphKind.Edit),new Page("Library", Loc.T("preferences.library"), Loc.T("preferences.content_folders_and_version_history"), GlyphKind.Library),- new Page("Appearance", Loc.T("preferences.appearance"), Loc.T("preferences.theme_scale_waveforms_and_ai"), GlyphKind.Appearance),new Page("Shortcuts", Loc.T("preferences.shortcuts"), Loc.T("preferences.keyboard_reference"), GlyphKind.Shortcuts),new Page("Updates", Loc.T("preferences.updates"), Loc.T("preferences.new_versions_of_nota"), GlyphKind.Update),}),@@ -148,7 +158,14 @@ public sealed partial class PreferencesWindow : NotaWindow}var sidebar = new Border{- Width = 188, Background = Sidebar, BorderBrush = Divider, BorderThickness = new Thickness(0, 0, 1, 0), Child = nav,+ Width = 188, Background = Sidebar, BorderBrush = Divider, BorderThickness = new Thickness(0, 0, 1, 0),+ // Fifteen pages outgrow the 480 px minimum height: the list scrolls so Shortcuts and+ // Updates stay reachable in a short window.+ Child = new ScrollViewer+ {+ Content = nav,+ HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled,+ },};// The download dock is its own row under the scrolled pane: it shortens the pane@@ -185,19 +202,29 @@ public sealed partial class PreferencesWindow : NotaWindowpublic void ShowDownloads(int source){_downloadSource = Math.Clamp(source, 0, DownloadSources.Length - 1);- Select(DownloadsIndex);+ Select("Downloads");}private static IEnumerable<Page> Pages => Nav.SelectMany(g => g.Pages);- /// <summary>Switches to the page with this title ("Audio", "Shortcuts" …) — the palette's- /// Settings: … commands.</summary>- public void ShowPage(string title)+ // Pages are found by their stable id, never by position: inserting a page must not send+ // a caller (palette, Remote pairing, Downloads, Updates) to its neighbour. An unknown id+ // (an old caller) lands on the first page.+ private static int IndexOf(string id){int i = 0;- foreach (var p in Pages) { if (p.Id == title) { Select(i); return; } i++; }+ foreach (var p in Pages) { if (p.Id == id) return i; i++; }+ return 0;}+ private string SelectedId => _selected >= 0 ? Pages.ElementAt(_selected).Id : "";++ private void Select(string id) => Select(IndexOf(id));++ /// <summary>Switches to the page with this id ("Audio", "Inputs", "MCP" …) — the palette's+ /// Settings: … commands and every other way into a page.</summary>+ public void ShowPage(string id) => Select(id);+private Control BuildNavItem(Page page, int idx){var edge = new Border@@ -232,7 +259,10 @@ public sealed partial class PreferencesWindow : NotaWindowprivate void Select(int index){- StopTests(); // the Audio pane is rebuilt on every visit — don't leave a tone / check orphaned+ StopTests(); // the audio panes are rebuilt on every visit — don't leave a tone / check orphaned+ // Apply() refreshes latency and the input list only while their page is the one shown.+ _latencyValue = _latencyDetail = null;+ _inputsHost = null;_selected = index;for (int i = 0; i < _navItems.Count; i++){@@ -244,6 +274,13 @@ public sealed partial class PreferencesWindow : NotaWindown.Label.Foreground = on ? TextPrimary : TextSecondary;n.Label.FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal;}+ // A page opened from elsewhere (ShowPage("Updates")) shows its row even when the sidebar is scrolled.+ // Posted past layout: called before the window is measured, the row has no place to scroll to yet.+ if (index >= 0 && index < _navItems.Count)+ {+ var row = _navItems[index].Root;+ Dispatcher.UIThread.Post(() => row.BringIntoView(), DispatcherPriority.Loaded);+ }var page = Pages.ElementAt(index);// The subtitle takes the width left beside the title and wraps: a longer translation must@@ -254,7 +291,7 @@ public sealed partial class PreferencesWindow : NotaWindowGrid.SetColumn(subtitle, 1);header.Children.Add(subtitle);- if (index == DownloadsIndex) { _content.Content = DownloadsPane(header); return; }+ if (page.Id == "Downloads") { _content.Content = DownloadsPane(header); return; }// Padding lives inside the scrolled content: a ScrollViewer's own Padding isn't part of// its extent, so the last rows of a long pane (Shortcuts) couldn't be scrolled into view.@@ -263,7 +300,7 @@ public sealed partial class PreferencesWindow : NotaWindowContent = new Border{Padding = new Thickness(32, 26, 32, 40),- Child = new StackPanel { Children = { header, BuildPane(index) } },+ Child = new StackPanel { Children = { header, BuildPane(page.Id) } },},};}@@ -271,26 +308,34 @@ public sealed partial class PreferencesWindow : NotaWindow// The Downloads item carries the number of registry plugins not installed yet.private void UpdateDownloadsBadge(int count){- var badge = _navItems[DownloadsIndex].Badge;+ var badge = _navItems[IndexOf("Downloads")].Badge;badge.Text = count.ToString();badge.IsVisible = count > 0;}- private Control BuildPane(int index) => index switch+ private Control BuildPane(string id) => id switch{- 0 => AudioPane(),- 1 => MidiPane(),- 2 => GamepadsPane(),- RemoteIndex => RemotePane(),- 4 => PluginsPane(),- 6 => LibraryPane(),- 7 => AppearancePane(),- UpdatesIndex => UpdatesPane(),+ "Audio" => AudioPane(),+ "Outputs" => OutputsPane(),+ "Inputs" => InputsPane(),+ "MIDI" => MidiPane(),+ "Gamepads" => GamepadsPane(),+ "Remote" => RemotePane(),+ "MCP" => McpPane(),+ "Plug-ins" => PluginsPane(),+ "Appearance" => AppearancePane(),+ "Language" => LanguagePane(),+ "Editing" => EditingPane(),+ "Library" => LibraryPane(),+ "Updates" => UpdatesPane(),_ => ShortcutsPane(),};// ---- Audio ------------------------------------------------------------+ // Audio: how the device runs — audio system and driver (Windows), sample rate, buffer,+ // exclusive mode, latency and the CPU check. Which output and which inputs are on their+ // own pages (Outputs, Inputs — specs/088).private Control AudioPane(){if (_main is null) return Caption(Loc.T("preferences.audio_settings_are_unavailable_in"));@@ -299,14 +344,6 @@ public sealed partial class PreferencesWindow : NotaWindowvar engine = _main.Engine;var cfg = engine.GetAudioConfig();- var outputCombo = Combo(280);- FillDeviceCombo(outputCombo, _outputUids, _audioDevices.OutputDevices(), cfg.OutputUid);- outputCombo.SelectionChanged += (_, _) => { int i = outputCombo.SelectedIndex; if (i >= 0 && i < _outputUids.Count) { engine.SetAudioOutputDevice(_outputUids[i]); Apply(); } };-- var inputCombo = Combo(280);- FillDeviceCombo(inputCombo, _inputUids, _audioDevices.InputDevices(), cfg.InputUid);- inputCombo.SelectionChanged += (_, _) => { int i = inputCombo.SelectedIndex; if (i >= 0 && i < _inputUids.Count) { engine.SetAudioInputDevice(_inputUids[i]); Apply(); } };-var srCombo = Combo(150);foreach (var sr in SampleRates) srCombo.Items.Add(sr == 0 ? Loc.T("preferences.device_default") : NotaNum.Unit(sr, "0", "Hz"));srCombo.SelectedIndex = IndexOf(SampleRates, cfg.SampleRate);@@ -328,41 +365,31 @@ public sealed partial class PreferencesWindow : NotaWindowbool asio = asioUi && engine.AudioSystem == AudioSystem.Asio;if (asioUi) AudioSystemRows(device, engine, asio);if (asio)- {AsioRows(device, engine, srCombo);- device.Add(Row(Loc.T("preferences.latency"), latency));- var asioBody = Sections(- Section(Loc.T("preferences.audio_device"), 6, device.ToArray()),- InputsHost(engine),- Section(Loc.T("preferences.test"), 8, TestToneRow(), CpuCheckRow(engine)));- _loading = false;- return asioBody;- }- device.AddRange(new[]- {- Row(Loc.T("common.output"), outputCombo), Row(Loc.T("common.input"), inputCombo),- Row(Loc.T("preferences.sample_rate"), srCombo), Row(Loc.T("preferences.buffer_size"), bufCombo),- });- // WASAPI exclusive (Windows only): lets Nota own the output device for the lowest- // latency, at the cost of muting other apps. The device then dictates the sample rate /- // buffer, so those are ignored while it's on. If the device refuses exclusive (busy /- // not allowed), the backend falls back to shared mode and the latency line says so.- if (OperatingSystem.IsWindows())+ else{- device.Add(Row(Loc.T("preferences.exclusive_mode"), SwitchRow(Loc.T("preferences.wasapi_exclusive_lowest_latency_mutes"), cfg.WasapiExclusive, on =>+ device.Add(Row(Loc.T("preferences.sample_rate"), srCombo));+ device.Add(Row(Loc.T("preferences.buffer_size"), bufCombo));+ // WASAPI exclusive (Windows only): lets Nota own the output device for the lowest+ // latency, at the cost of muting other apps. The device then dictates the sample rate /+ // buffer, so those are ignored while it's on. If the device refuses exclusive (busy /+ // not allowed), the backend falls back to shared mode and the latency line says so.+ if (OperatingSystem.IsWindows()){- if (_loading) return;- engine.SetAudioWasapiExclusive(on);- Apply();- })));- device.Add(Row("", Caption(Loc.T("preferences.the_devices_native_sample_rate"))));+ device.Add(Row(Loc.T("preferences.exclusive_mode"), SwitchRow(Loc.T("preferences.wasapi_exclusive_lowest_latency_mutes"), cfg.WasapiExclusive, on =>+ {+ if (_loading) return;+ engine.SetAudioWasapiExclusive(on);+ Apply();+ })));+ device.Add(Row("", Caption(Loc.T("preferences.the_devices_native_sample_rate"))));+ }}device.Add(Row(Loc.T("preferences.latency"), latency));var body = Sections(Section(Loc.T("preferences.audio_device"), 6, device.ToArray()),- InputsHost(engine),- Section(Loc.T("preferences.test"), 8, TestToneRow(), CpuCheckRow(engine)));+ Section(Loc.T("preferences.test"), 8, CpuCheckRow(engine)));_loading = false;return body;}@@ -392,7 +419,8 @@ public sealed partial class PreferencesWindow : NotaWindow: Loc.T("preferences.no_asio_driver_found_install"))));}- // Driver · Output pair · Input pair · Sample rate · Buffer size (read-only) under ASIO.+ // Driver · Sample rate · Buffer size (read-only) under ASIO. The output and input pairs are+ // on the Outputs and Inputs pages (specs/088).// Pairs come from the open driver, so they show once it runs; the buffer size is the// driver's own setting (FR-008), changed in its panel ("Driver settings…").private void AsioRows(List<Control> device, IAudioEngine engine, ComboBox srCombo)@@ -435,13 +463,6 @@ public sealed partial class PreferencesWindow : NotaWindow};device.Add(Row(Loc.T("preferences.driver"), new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { driverCombo, panel } }));- if (running)- {- device.Add(Row(Loc.T("common.output"), PairCombo(engine, input: false, engine.AsioChannels(false))));- var ins = engine.AsioChannels(true);- device.Add(Row(Loc.T("common.input"), ins.Count > 0 ? PairCombo(engine, input: true, ins) : Caption(Loc.T("preferences.no_inputs_on_this_driver"))));- }-// Sample rate is a request: a rate the driver refuses is reverted and explained (FR-007).// The view model remembers the refusal, so it also shows after an apply that waited for// the driver's panel to close (the pane is rebuilt then).@@ -512,7 +533,7 @@ public sealed partial class PreferencesWindow : NotaWindowprivate void OnAudioDeviceRestarted(){- if (_selected == 0) RebuildAudioPane(); // 0 = the Audio page+ if (SelectedId is "Audio" or "Outputs" or "Inputs") RebuildAudioPane();}private Control TestToneRow()@@ -1010,7 +1031,25 @@ public sealed partial class PreferencesWindow : NotaWindow// theme, one per row while following the system. Picking a card of the other kind// switches mode. Every pick applies at once (NotaThemeService re-tints the palette and// repaints every open window) and is saved.+ //+ // User themes (spec 087) join the rows after the built-ins. The page re-reads the themes+ // folder each time it opens and on Reload, and rebuilds itself when the folder or the worn+ // theme changes from elsewhere (an MCP client), so it always shows what is true.private static Control ThemePicker()+ {+ if (!NotaThemeService.InScope) NotaThemes.ReloadUser();+ var host = new ContentControl();+ Action? show = null;+ void Build() { var (content, s) = BuildThemePicker(); host.Content = content; show = s; }+ Build();+ void OnThemes() => Dispatcher.UIThread.Post(Build);+ void OnWorn() => Dispatcher.UIThread.Post(() => show?.Invoke());+ host.AttachedToVisualTree += (_, _) => { NotaThemes.ThemesChanged += OnThemes; NotaThemeService.Changed += OnWorn; };+ host.DetachedFromVisualTree += (_, _) => { NotaThemes.ThemesChanged -= OnThemes; NotaThemeService.Changed -= OnWorn; };+ return host;+ }++ private static (Control Content, Action Show) BuildThemePicker(){var settings = App.Services.GetRequiredService<ISettingsService>();var darkCards = ThemeCards(NotaThemeKind.Dark);@@ -1028,11 +1067,17 @@ public sealed partial class PreferencesWindow : NotaWindow}var segmented = new Border { Classes = { "segmented" }, HorizontalAlignment = HorizontalAlignment.Left, Child = strip };+ var fallbackNote = new TextBlock { Classes = { "Caption" }, Foreground = NotaPalette.Warning, TextWrapping = TextWrapping.Wrap, MaxWidth = 560 };+bool loading = true;void Show(){loading = true;var c = NotaThemeService.Choice;+ var missing = StoredThemeIds(settings.Current).FirstOrDefault(id => NotaThemes.Find(id) is null);+ fallbackNote.Text = missing is null ? "" : Loc.F("preferences.skins.fallback_note", missing,+ (NotaThemeService.WornTheme is { } worn ? (NotaThemes.Find(worn.Id) ?? worn).Name : NotaThemes.Default.Name));+ fallbackNote.IsVisible = missing is not null;var mode = Appearance.ModeOf(c, (NotaThemes.Find(c.Single) ?? NotaThemes.Default).IsDark);for (int i = 0; i < modes.Count; i++) modes[i].IsChecked = i == (int)mode;bool follow = mode == AppearanceMode.FollowSystem;@@ -1070,11 +1115,13 @@ public sealed partial class PreferencesWindow : NotaWindow};Show();- return new StackPanel+ var panel = new StackPanel{Spacing = 10,- Children = { segmented, darkLabel, darkCards, lightLabel, lightCards },+ Children = { segmented, fallbackNote, darkLabel, darkCards, lightLabel, lightCards, ThemesFolderRow() },};+ if (ThemeProblems() is { } problems) panel.Children.Add(problems);+ return (panel, Show);}// The themes of one kind as cards in a row: the preview in a frame that takes the@@ -1085,18 +1132,13 @@ public sealed partial class PreferencesWindow : NotaWindow{Classes = { "themes" }, SelectionMode = SelectionMode.Single,HorizontalAlignment = HorizontalAlignment.Left,- ItemsPanel = new FuncTemplate<Panel?>(() => new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12 }),+ // Wraps: user themes (spec 087) can make a row longer than the page is wide.+ ItemsPanel = new FuncTemplate<Panel?>(() => new WrapPanel { Orientation = Orientation.Horizontal, ItemSpacing = 12, LineSpacing = 12 }),ItemsSource = NotaThemes.OfKind(kind).ToList(),};- list.ItemTemplate = new FuncDataTemplate<NotaColourTheme>((t, _) => t is null ? new TextBlock() : new StackPanel- {- Spacing = 6,- Children =- {- new Border { Classes = { "ThemeFrame" }, Child = new ThemePreview(t) },- new TextBlock { Text = t.Name, Classes = { "RowName" } },- },- });+ // No sideways scrolling, so the wrap panel gets the page's width to wrap at.+ ScrollViewer.SetHorizontalScrollBarVisibility(list, Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled);+ list.ItemTemplate = new FuncDataTemplate<NotaColourTheme>((t, _) => t is null ? new TextBlock() : ThemeCard(t));return list;}@@ -1116,10 +1158,12 @@ public sealed partial class PreferencesWindow : NotaWindowpublic override void Render(DrawingContext ctx){+ // The theme's own corners (spec 087): a square skin previews square.+ double fieldR = _theme.Geometry.RadiusOf(RadiusStep.Field);var seam = new Pen(B(NotaPalette.Seam), 1);void Fill(SolidColorBrush slot, double x, double y, double w, double h) => ctx.FillRectangle(B(slot), new Rect(x, y, w, h));void Key(SolidColorBrush slot, double x, double y, double w, double h) =>- ctx.DrawRectangle(B(slot), seam, new RoundedRect(new Rect(x + 0.5, y + 0.5, w - 1, h - 1), NotaRadius.FieldValue));+ ctx.DrawRectangle(B(slot), seam, new RoundedRect(new Rect(x + 0.5, y + 0.5, w - 1, h - 1), fieldR));void HLine(double y, double x0, double x1) => ctx.DrawLine(seam, new Point(x0, y + 0.5), new Point(x1, y + 0.5));void VLine(double x, double y0, double y1) => ctx.DrawLine(seam, new Point(x + 0.5, y0), new Point(x + 0.5, y1));@@ -1150,7 +1194,7 @@ public sealed partial class PreferencesWindow : NotaWindowdouble y = top + i * laneH, span = W - x0;var track = NotaPalette.TrackBrushes[i % NotaPalette.TrackBrushes.Length];var r = new Rect(x0 + span * clips[i].At, y + 2, span * clips[i].Len, laneH - 4);- ctx.FillRectangle(B(track), r, (float)NotaRadius.FieldValue);+ ctx.FillRectangle(B(track), r, (float)fieldR);if (i < 3) HLine(y + laneH - 1, x0, W);}ctx.FillRectangle(B(NotaPalette.Accent), new Rect(x0 + (W - x0) * 0.46, top, 1, detailTop - top));@@ -1297,136 +1341,20 @@ public sealed partial class PreferencesWindow : NotaWindowreturn new Border { Classes = { "segmented" }, HorizontalAlignment = HorizontalAlignment.Left, Child = strip };}- private Control AppearancePane()- {- var settings = App.Services.GetService<ISettingsService>();- var mcp = App.Services.GetService<McpService>();-- // ---- AI control (MCP server) ----- var portBox = new TextBox- {- Text = (settings?.Current.McpPort ?? 3900).ToString(), Width = 96, Classes = { "field" },- FontSize = 11, FontFamily = NotaFonts.UiFamily, HorizontalAlignment = HorizontalAlignment.Left,- };- var statusDot = Dot(BorderStrong);- var status = new TextBlock- {- FontSize = 10, FontFamily = NotaFonts.UiFamily, Foreground = TextSecondary,- VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,- };- var copyBtn = Btn(Loc.T("preferences.copy_config"));- copyBtn.HorizontalAlignment = HorizontalAlignment.Left;- var details = new StackPanel- {- Spacing = 10,- Children =- {- Row(Loc.T("preferences.port"), portBox),- Row(Loc.T("preferences.status"), new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { statusDot, status } }),- Row("", new StackPanel- {- Spacing = 10,- Children =- {- copyBtn,- Caption(Loc.T("preferences.add_this_config_or_the")),- },- }),- },- };-- bool Enabled() => settings?.Current.McpEnabled ?? false;- void Refresh()- {- bool on = Enabled();- status.Text = on ? Loc.F("preferences.listening_on_http_127_0", settings!.Current.McpPort) : Loc.T("common.off");- statusDot.Fill = on ? NotaPalette.SuccessDim : BorderStrong;- portBox.IsEnabled = on;- portBox.Foreground = on ? TextPrimary : TextDisabled;- copyBtn.IsEnabled = on;- Inactive.Set(details, !on);- }- void ApplyMcp(bool on)- {- if (settings is null) return;- settings.Current.McpEnabled = on;- if (int.TryParse(portBox.Text, out var p) && p is > 0 and < 65536) settings.Current.McpPort = p;- settings.Save();- _ = mcp?.ApplyAsync();- Refresh();- }- var enable = SwitchRow(Loc.T("preferences.enable_mcp_server_let_an"), Enabled(), ApplyMcp);- portBox.LostFocus += (_, _) => ApplyMcp(Enabled());-- // Copy a ready client-config JSON (Claude Desktop / Claude Code) with the current port.- string McpConfigJson()- {- int port = settings?.Current.McpPort ?? 3900;- return "{\n \"mcpServers\": {\n \"nota\": {\n \"type\": \"http\",\n \"url\": \"http://127.0.0.1:" + port + "/\"\n }\n }\n}";- }- DispatcherTimer? copied = null;- copyBtn.Click += async (_, _) =>- {- var cb = TopLevel.GetTopLevel(this)?.Clipboard;- if (cb is null) return;- await cb.SetTextAsync(McpConfigJson());- copyBtn.Content = Loc.T("preferences.copied");- copied?.Stop();- copied = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1500) };- copied.Tick += (_, _) => { copied!.Stop(); copyBtn.Content = Loc.T("preferences.copy_config"); };- copied.Start();- };- // Inactive.Set walks the visual tree, so the dimming waits until the pane is shown.- details.AttachedToVisualTree += (_, _) => Refresh();-- // Piano-roll key labels: every note for beginners, C-only by default.- var labelAll = SwitchRow(Loc.T("preferences.label_every_note_in_the"), settings?.Current.PianoRollLabelAllNotes ?? false, on =>- {- if (settings is null) return;- settings.Current.PianoRollLabelAllNotes = on;- settings.Save();- });-- // Detail panel (#308): a selection opens a closed panel only when this is on.- var openOnSelect = SwitchRow(Loc.T("preferences.open_the_detail_panel_when"), settings?.Current.OpenDetailOnSelect ?? false, on =>- {- if (settings is null) return;- settings.Current.OpenDetailOnSelect = on;- settings.Save();- });-- var splitFades = SwitchRow(Loc.T("preferences.fade_audio_clips_when_splitting"), settings?.Current.SplitFades ?? true, on =>- {- if (settings is null) return;- settings.Current.SplitFades = on;- settings.Save();- _main.Engine.SplitFades = on;- });-- return Sections(- Section("UI", 10,- TopRow(Loc.T("preferences.colour_theme"), ThemePicker()),- Row("", Caption(Loc.T("preferences.themes_change_colours_only_follow"))),- TopRow(Loc.T("preferences.accent"), AccentPicker()),- Row("", Caption(Loc.T("preferences.accent_caption"))),- Row(Loc.T("preferences.waveform"), WaveformPicker()),- Row("", Caption(Loc.T("preferences.how_audio_clips_draw_on"))),- Row("", splitFades),- Row("", Caption(Loc.T("preferences.splitting_an_audio_clip_adds"))),- Row(Loc.T("preferences.track_headers"), HeaderSidePicker()),- Row("", Caption(Loc.T("preferences.which_side_of_the_arrangement"))),- Row(Loc.T("preferences.interface_scale"), ScalePicker()),- Row("", Caption(Loc.T("preferences.makes_the_whole_interface_larger"))),- Row(Loc.T("preferences.text_size"), TextSizePicker()),- Row("", Caption(Loc.T("preferences.text_size_caption"))),- Row(Loc.T("preferences.language"), LanguagePicker()),- Row("", Caption(Loc.T("preferences.the_language_of_menus_panels")))),- Section(Loc.T("common.piano_roll"), 10, labelAll,- Caption(Loc.T("preferences.shows_every_note_name_c"))),- Section(Loc.T("preferences.detail_panel"), 10, openOnSelect,- Caption(Loc.T("preferences.off_a_click_only_selects"))),- Section(Loc.T("preferences.ai_control_mcp"), 12, enable, details));- }+ private Control AppearancePane() => Sections(+ Section("UI", 10,+ TopRow(Loc.T("preferences.colour_theme"), ThemePicker()),+ Row("", Caption(Loc.T("preferences.skins.follow_system_hint"))),+ TopRow(Loc.T("preferences.accent"), AccentPicker()),+ Row("", Caption(Loc.T("preferences.accent_caption"))),+ Row(Loc.T("preferences.waveform"), WaveformPicker()),+ Row("", Caption(Loc.T("preferences.how_audio_clips_draw_on"))),+ Row(Loc.T("preferences.track_headers"), HeaderSidePicker()),+ Row("", Caption(Loc.T("preferences.which_side_of_the_arrangement"))),+ Row(Loc.T("preferences.interface_scale"), ScalePicker()),+ Row("", Caption(Loc.T("preferences.makes_the_whole_interface_larger"))),+ Row(Loc.T("preferences.text_size"), TextSizePicker()),+ Row("", Caption(Loc.T("preferences.text_size_caption")))));// ---- Shortcuts --------------------------------------------------------diff --git a/src/managed/Nota.App/PreviewPlayer.cs b/src/managed/Nota.App/PreviewPlayer.csindex b54d7f0e..814db573 100644--- a/src/managed/Nota.App/PreviewPlayer.cs+++ b/src/managed/Nota.App/PreviewPlayer.cs@@ -1083,7 +1083,7 @@ public sealed class PreviewWaveform : ControlNotaFonts.Sans, 8, NotaPalette.TextPrimary);double tw = ft.Width + 8, th = ft.Height + 2;double tx = f > 0.75 ? hx - tw - 4 : hx + 4;- ctx.FillRectangle(NotaPalette.TrackOff, new Rect(tx, InsetY, tw, th), 2);+ ctx.FillRectangle(NotaPalette.TrackOff, new Rect(tx, InsetY, tw, th), (float)NotaRadius.FineValue);ctx.DrawText(ft, new Point(tx + 4, InsetY + 1));}@@ -1102,7 +1102,7 @@ public sealed class PreviewWaveform : Controlvar spec = NotaGraph.AxisText(Loc.T("preview_player.spec"), _spectrum ? NotaPalette.Accent : NotaPalette.TextTertiary, 7, this);double lw = wave.Width + 5 + spec.Width, lx = w - lw - 5, ly = 3;_toggleRect = new Rect(lx - 4, 0, lw + 9, ly + wave.Height + 3);- ctx.FillRectangle(NotaPalette.BgSunken, new Rect(lx - 2, ly - 1, lw + 4, wave.Height + 2), 2);+ ctx.FillRectangle(NotaPalette.BgSunken, new Rect(lx - 2, ly - 1, lw + 4, wave.Height + 2), (float)NotaRadius.FineValue);ctx.DrawText(wave, new Point(lx, ly));ctx.DrawText(spec, new Point(lx + wave.Width + 5, ly));}@@ -1174,9 +1174,9 @@ public sealed class PreviewVolume : Controldouble w = Bounds.Width;if (w <= 0) return;ctx.FillRectangle(Brushes.Transparent, new Rect(Bounds.Size)); // whole box hit-tests- ctx.FillRectangle(NotaPalette.BorderDefault, new Rect(0, 7, w, 3), 2);+ ctx.FillRectangle(NotaPalette.BorderDefault, new Rect(0, 7, w, 3), (float)NotaRadius.FineValue);double x = w * _value;- ctx.FillRectangle(NotaPalette.TextSecondary, new Rect(0, 7, x, 3), 2);- ctx.FillRectangle(NotaPalette.TextPrimary, new Rect(x - 2, 3, 4, 11), 1);+ ctx.FillRectangle(NotaPalette.TextSecondary, new Rect(0, 7, x, 3), (float)NotaRadius.FineValue);+ ctx.FillRectangle(NotaPalette.TextPrimary, new Rect(x - 2, 3, 4, 11), (float)NotaSkin.MapRadius(1));}}diff --git a/src/managed/Nota.App/SessionView.Grid.cs b/src/managed/Nota.App/SessionView.Grid.csindex 3f227256..9982c15a 100644--- a/src/managed/Nota.App/SessionView.Grid.cs+++ b/src/managed/Nota.App/SessionView.Grid.cs@@ -506,7 +506,7 @@ public sealed partial class SessionViewif (_o._armed.Contains(_c.TrackId))ctx.DrawEllipse(null, new Pen(_hoverCentre ? NotaPalette.Record : NotaPalette.TextMuted, 1.5), c, 3.25, 3.25);else if (_stopButton)- ctx.DrawRectangle(_hoverCentre ? NotaPalette.TextSecondary : NotaPalette.BorderStrong, null, new Rect(c.X - 3, c.Y - 3, 6, 6), 1, 1);+ ctx.DrawRectangle(_hoverCentre ? NotaPalette.TextSecondary : NotaPalette.BorderStrong, null, new Rect(c.X - 3, c.Y - 3, 6, 6), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));if (selected) DrawSelection(ctx, r);return;}@@ -573,7 +573,7 @@ public sealed partial class SessionViewdouble x = area.X + n.Start / _lenBeats * area.Width;double w = Math.Max(1.5, Math.Min(n.Len, _lenBeats - n.Start) / _lenBeats * area.Width);double y = area.Y + (_maxPitch - n.Pitch) / (double)range * (area.Height - 3);- ctx.DrawRectangle(_brush, null, new Rect(x, y, w, 3), 1, 1);+ ctx.DrawRectangle(_brush, null, new Rect(x, y, w, 3), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}return;}@@ -627,7 +627,7 @@ public sealed partial class SessionViewdouble wd = Math.Max(1.5, Math.Min(length, len - start) / len * area.Width);double y = area.Y + (hi - pitch) / (double)range * (area.Height - 3);var b = prog < 1 ? RecordPreview.AppearBrush(ink.Color, prog) : ink;- ctx.DrawRectangle(b, null, new Rect(x, y, wd, 3), 1, 1);+ ctx.DrawRectangle(b, null, new Rect(x, y, wd, 3), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}foreach (var n in stored)if (n.StartBeat < len) Bar(n.Pitch, n.StartBeat, n.LengthBeats, rp?.Progress(n.Pitch, n.StartBeat) ?? 1);@@ -652,7 +652,7 @@ public sealed partial class SessionView{double a = Math.Max(Math.Abs(peaks[i * 2]), Math.Abs(peaks[i * 2 + 1])) / max;double h = Math.Max(1, a * area.Height);- ctx.DrawRectangle(ink, null, new Rect(area.X + i * step, area.Y + (area.Height - h) / 2, bw, h), 0.5, 0.5);+ ctx.DrawRectangle(ink, null, new Rect(area.X + i * step, area.Y + (area.Height - h) / 2, bw, h), NotaSkin.MapRadius(0.5), NotaSkin.MapRadius(0.5));}}@@ -711,7 +711,7 @@ public sealed partial class SessionViewif (!Any){FillCell(ctx, r, NotaPalette.Well, null);- ctx.DrawRectangle(NotaPalette.BorderStrong, null, new Rect(r.Center.X - 3, r.Center.Y - 3, 6, 6), 1, 1);+ ctx.DrawRectangle(NotaPalette.BorderStrong, null, new Rect(r.Center.X - 3, r.Center.Y - 3, 6, 6), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));if (selected) DrawSelection(ctx, r);return;}@@ -727,7 +727,7 @@ public sealed partial class SessionView{var k = _kids[i];IBrush ink = !k.Has ? NotaPalette.BorderDefault : eng.SessionSlotState(k.Id, _scene) == 3 ? NotaPalette.Success : k.Brush;- ctx.DrawRectangle(ink, null, new Rect(7, y, r.Width - 14, 3), 1, 1);+ ctx.DrawRectangle(ink, null, new Rect(7, y, r.Width - 14, 3), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}if (selected) DrawSelection(ctx, r);}@@ -863,7 +863,7 @@ public sealed partial class SessionViewDrawTriangle(ctx, LaunchBox.Center, 8, 9, tri);double x = LaunchBox.Right + 8;- ctx.DrawRectangle(_color, null, new Rect(x, r.Height / 2 - 3, 6, 6), 1, 1);+ ctx.DrawRectangle(_color, null, new Rect(x, r.Height / 2 - 3, 6, 6), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));x += 14;double right = r.Width - 8;if (_badge.Length > 0)diff --git a/src/managed/Nota.App/SessionView.Inspector.cs b/src/managed/Nota.App/SessionView.Inspector.csindex 2c3d73a1..6688f930 100644--- a/src/managed/Nota.App/SessionView.Inspector.cs+++ b/src/managed/Nota.App/SessionView.Inspector.cs@@ -492,7 +492,7 @@ public sealed partial class SessionViewdouble x = area.X + n.StartBeat / _len * area.Width;double w = Math.Max(2, Math.Min(n.LengthBeats, _len - n.StartBeat) / _len * area.Width);double y = area.Y + (hi - n.Pitch) / (double)range * (area.Height - 5);- ctx.DrawRectangle(_brush, null, new Rect(x, y, w, 5), 1, 1);+ ctx.DrawRectangle(_brush, null, new Rect(x, y, w, 5), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}else if (!_c.IsInstrument) DrawPeaks(ctx, area, _peaks, _peakCount, _brush);diff --git a/src/managed/Nota.App/SessionView.Mixer.cs b/src/managed/Nota.App/SessionView.Mixer.csindex def5363c..f01aebd8 100644--- a/src/managed/Nota.App/SessionView.Mixer.cs+++ b/src/managed/Nota.App/SessionView.Mixer.cs@@ -412,8 +412,8 @@ public sealed partial class SessionViewpublic override void Render(DrawingContext ctx){double w = Bounds.Width;- ctx.DrawRectangle(NotaPalette.SurfaceRaised, null, new Rect(0, 0, w, 2), 1, 1);- if (_level > 0) ctx.DrawRectangle(NotaPalette.Success, null, new Rect(0, 0, w * _level, 2), 1, 1);+ ctx.DrawRectangle(NotaPalette.SurfaceRaised, null, new Rect(0, 0, w, 2), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));+ if (_level > 0) ctx.DrawRectangle(NotaPalette.Success, null, new Rect(0, 0, w * _level, 2), NotaSkin.MapRadius(1), NotaSkin.MapRadius(1));}}}diff --git a/src/managed/Nota.App/Skins/SampleScene.cs b/src/managed/Nota.App/Skins/SampleScene.csnew file mode 100644index 00000000..fcb217f1--- /dev/null+++ b/src/managed/Nota.App/Skins/SampleScene.cs@@ -0,0 +1,190 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The fixed little project the skin previews are drawn from (spec 087, research R6): its own+// engine, never started — no audio thread, no device — so a preview never touches the user's+// project and the same theme always gives the same pictures. Six coloured tracks of mixed+// kinds, MIDI and audio clips, an automation lane, built-in instruments and effects, an+// arpeggiator, a return. Built once, on the first preview request.++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using Nota.Application;+using Nota.Infrastructure;++namespace Nota.App;++internal sealed class SampleScene : IDisposable+{+ private static SampleScene? _shared;++ /// <summary>The scene, built on first use (on the UI thread).</summary>+ public static SampleScene Shared => _shared ??= new SampleScene();++ public NotaEngine Engine { get; }+ public int Drums { get; }+ public int Bass { get; }+ public int Keys { get; }+ public int Lead { get; }+ public int Texture { get; }+ public int Reverb { get; }+ /// <summary>The Keys track's first clip — the piano roll's.</summary>+ public int KeysClip { get; }++ private SampleScene()+ {+ Engine = new NotaEngine();+ var e = Engine;+ e.SetTimeSignature(4, 4);++ Drums = Instrument("Drums", 12, 0);+ Bass = Instrument("Bass", 7, 2);+ Keys = Instrument("Keys", 14, 3);+ Lead = Instrument("Lead", 6, 6);+ Texture = e.AddAudioTrack();+ Name(Texture, "Texture", 4);+ Reverb = e.AddReturnTrack();+ Name(Reverb, "Reverb", 8);++ for (int bar = 0; bar < 16; bar += 4) Clip(Drums, bar, 4, DrumBar(bar >= 8), "Beat");+ for (int bar = 4; bar < 16; bar += 4) Clip(Bass, bar, 4, BassLine(), "Bass");+ KeysClip = Clip(Keys, 0, 4, Chords(), "Chords");+ for (int bar = 4; bar < 16; bar += 4) Clip(Keys, bar, 4, Chords(), "Chords");+ Clip(Lead, 8, 8, Melody(), "Hook");+ var pad = PadSample();+ if (pad is not null) e.SetClipName(Texture, e.AddAudioClip(Texture, pad, 16), "Pad");++ e.AddBuiltinDevice(Bass, 1); // Compressor+ e.AddBuiltinDevice(Keys, 0); // EQ-8+ e.AddBuiltinDevice(Keys, 20); // Chamber+ e.AddBuiltinDevice(Lead, 3); // Delay+ e.AddMidiEffect(Lead, 0); // Arpeggiator+ e.AddBuiltinDevice(Reverb, 2);+ e.SetTrackSend(Keys, 0, 0.35f);+ e.SetTrackSend(Lead, 0, 0.25f);+ e.SetTrackVolume(Texture, 0.6f);+ e.SetTrackPan(Lead, 0.15f);++ int lane = e.AddAutomationLane(Lead, AutomationTarget.Volume, -1, -1);+ if (lane >= 0)+ e.SetAutomationPoints(Lead, lane, new[]+ {+ new AutomationPoint(32, 0.25f), new AutomationPoint(44, 0.85f, 0.4f),+ new AutomationPoint(56, 0.85f), new AutomationPoint(60, 0.45f),+ });+ }++ public void Dispose()+ {+ Engine.Dispose();+ if (ReferenceEquals(_shared, this)) _shared = null;+ }++ // ── tracks and clips ────────────────────────────────────────────────────────────────++ private int Instrument(string name, int kind, int color)+ {+ int t = Engine.AddInstrumentTrack();+ Engine.SetTrackBuiltinInstrument(t, kind);+ Name(t, name, color);+ return t;+ }++ private void Name(int track, string name, int color)+ {+ Engine.SetTrackName(track, name);+ Engine.SetTrackColorIndex(track, color);+ }++ private int Clip(int track, int bar, int bars, NotaNote[] notes, string name)+ {+ int c = Engine.AddMidiClip(track, bar * 4, bars * 4);+ Engine.SetClipNotes(track, c, notes.Where(n => n.StartBeat < bars * 4).ToArray());+ Engine.SetClipName(track, c, name);+ return c;+ }++ private static NotaNote N(int pitch, double start, double len, float vel = 0.8f) => new(pitch, start, len, vel);++ private static NotaNote[] DrumBar(bool full)+ {+ var l = new List<NotaNote>();+ for (int b = 0; b < 4; b++)+ {+ double o = b * 4;+ l.Add(N(36, o, 0.25)); l.Add(N(36, o + 2, 0.25));+ if (full) l.Add(N(36, o + 2.75, 0.25, 0.6f));+ l.Add(N(38, o + 1, 0.25)); l.Add(N(38, o + 3, 0.25));+ for (int h = 0; h < 8; h++) l.Add(N(42, o + h * 0.5, 0.2, h % 2 == 0 ? 0.7f : 0.45f));+ }+ return l.ToArray();+ }++ private static readonly int[][] Chords4 = { new[] { 57, 60, 64 }, new[] { 53, 57, 60 }, new[] { 48, 52, 55 }, new[] { 55, 59, 62 } };++ private static NotaNote[] Chords() => Chords4.SelectMany((ch, i) => ch.Select(p => N(p, i * 4, 3.75, 0.55f + 0.1f * (i % 3)))).ToArray();++ private static NotaNote[] BassLine()+ {+ int[] roots = { 33, 29, 36, 31 };+ return roots.SelectMany((r, i) => new[] { N(r, i * 4, 0.75), N(r, i * 4 + 1.5, 0.5, 0.6f), N(r + 12, i * 4 + 2.5, 0.5, 0.7f), N(r, i * 4 + 3, 0.75) }).ToArray();+ }++ private static NotaNote[] Melody()+ {+ int[] p = { 69, 72, 76, 74, 72, 69, 67, 69, 72, 74, 76, 79, 76, 74, 72, 71 };+ return p.Select((x, i) => N(x, i * 2, i % 4 == 3 ? 1.75 : 1.0, 0.75f)).ToArray();+ }++ // ── audio: a soft chord pad, synthesised so the scene needs no file from outside ─────++ private static string? PadSample()+ {+ try+ {+ var dir = Path.Combine(Path.GetTempPath(), "nota-skin-preview");+ Directory.CreateDirectory(dir);+ var path = Path.Combine(dir, "pad.wav");+ if (!File.Exists(path)) WriteWav(path, Pad(new[] { 57, 60, 64, 69 }, 8));+ return path;+ }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return null; }+ }++ private const int Rate = 48000;++ private static float[] Pad(int[] midi, int beats)+ {+ int n = (int)(Rate * 60 / 120.0 * beats);+ var s = new float[n];+ foreach (var m in midi)+ {+ double f = 440 * Math.Pow(2, (m - 69) / 12.0);+ for (int i = 0; i < n; i++)+ {+ double t = i / (double)Rate;+ double env = Math.Min(1, t / 0.6) * Math.Min(1, (n - i) / (Rate * 0.8));+ s[i] += (float)(env * Math.Sin(2 * Math.PI * f * t) * (1 + 0.3 * Math.Sin(2 * Math.PI * 0.25 * t)));+ }+ }+ float peak = s.Max(Math.Abs);+ if (peak > 0) for (int i = 0; i < n; i++) s[i] *= 0.5f / peak;+ return s;+ }++ private static void WriteWav(string path, float[] mono)+ {+ using var w = new BinaryWriter(File.Create(path));+ int bytes = mono.Length * 2 * 2;+ w.Write("RIFF"u8); w.Write(36 + bytes); w.Write("WAVE"u8);+ w.Write("fmt "u8); w.Write(16); w.Write((short)1); w.Write((short)2); w.Write(Rate); w.Write(Rate * 4); w.Write((short)4); w.Write((short)16);+ w.Write("data"u8); w.Write(bytes);+ foreach (var x in mono)+ {+ short v = (short)Math.Clamp(x * 32767f, -32768f, 32767f);+ w.Write(v); w.Write(v);+ }+ }+}diff --git a/src/managed/Nota.App/Skins/SkinPreviewRenderer.cs b/src/managed/Nota.App/Skins/SkinPreviewRenderer.csnew file mode 100644index 00000000..5098efda--- /dev/null+++ b/src/managed/Nota.App/Skins/SkinPreviewRenderer.cs@@ -0,0 +1,288 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Pictures of the app in a skin (spec 087, contracts/preview-surfaces.md) — what the MCP+// preview_theme tool sends back, so a client can see how a palette maps onto Nota. Everything+// happens inside one UI-thread job: wear the skin (NotaThemeService.RenderScoped), build each+// surface, lay it out at a fixed size and render it to a PNG, then put the live theme back.+// The compositor only sends frames between jobs, so the screen never shows the skin.+//+// Most surfaces are real views over the sample scene's own engine (never started), built for+// the picture and thrown away: the same theme gives the same pictures. Three are the live+// window's own parts — the whole window, its transport row and its browser — because they+// are bound to the app's one engine and library: they show the user's project as it is,+// re-coerced for the skin during the job and back right after.++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using System.Threading.Tasks;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Controls.ApplicationLifetimes;+using Avalonia.Controls.Primitives;+using Avalonia.Layout;+using Avalonia.Media;+using Avalonia.Media.Imaging;+using Avalonia.Threading;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Application.Localization;+using Nota.Infrastructure;+using Nota.Presentation;++namespace Nota.App;++internal static class SkinPreviewRenderer+{+ private sealed record Surface(string Name, string Description, double Width, double Height, bool Live);++ /// <summary>The surfaces in the order they are rendered. Names are stable (MCP clients ask for them).</summary>+ private static readonly Surface[] Surfaces =+ {+ new("overview", "The main window as it is now: top bar, browser, arrangement and the detail panel (the user's open project)", 0, 0, true),+ new("top-bar", "The transport row: transport keys, position, tempo, view switches, CPU (live values)", 0, 0, true),+ new("arrangement", "Arrangement: track headers, MIDI and audio clips in the track colours, an automation lane", 1200, 520, false),+ new("mixer", "Mixer: channel strips with sends, a return and the master", 1200, 520, false),+ new("device-rack", "Device rack: an instrument and two audio effects as device cards", 1200, 300, false),+ new("piano-roll", "Piano roll: chords on the keyboard grid with the velocity lane", 1200, 480, false),+ new("browser", "The browser as it is now: categories, the list and the search field (the user's library)", 0, 0, true),+ new("preferences", "Preferences → Appearance: the theme cards, accent, scale and text size", 900, 640, false),+ new("menu", "A track context menu: rows with icons and shortcuts, a submenu, a separator", 320, 0, false),+ new("dialog", "A confirmation dialog with a primary and a secondary button", 480, 0, false),+ };++ public static IReadOnlyList<string> Names => Surfaces.Select(s => s.Name).ToList();++ public sealed record Image(string Name, string Description, byte[] Png);++ /// <summary>Render <paramref name="theme"/> on <paramref name="names"/> (every surface when null).+ /// Starts and ends on the UI thread. Unknown names come back in <c>Unknown</c>.+ ///+ /// Two phases. First the sample views are built in their own windows, shown far off screen+ /// and fully transparent, wearing the live theme. The UI thread is then let go a few times,+ /// so Loaded handlers, posted work and virtualising lists (realised from the layout manager's+ /// viewport events) settle. Then one job wears the skin, re-skins and lays out every tree,+ /// draws them and puts the live theme back.</summary>+ public static async Task<(List<Image> Images, List<string> Unknown)> RenderAsync(NotaColourTheme theme, bool themeAccent, IReadOnlyList<string>? names)+ {+ var wanted = names is { Count: > 0 } ? names : Names;+ var unknown = wanted.Where(n => Surfaces.All(s => s.Name != n)).Distinct().ToList();+ var surfaces = Surfaces.Where(s => wanted.Contains(s.Name)).ToList();+ var images = new List<Image>();+ if (surfaces.Count == 0) return (images, unknown);++ var hosts = new List<(Surface Surface, Window Host, Control Content)>();+ try+ {+ var scene = surfaces.Any(s => !s.Live) ? SampleScene.Shared : null;+ // Built at the default text size: a text that is laid out only once (a closed+ // ComboBox draws its item, detached, through a brush) would keep the user's size.+ NotaTextSize.Scoped(0, () =>+ {+ foreach (var s in surfaces.Where(s => !s.Live))+ {+ try { if (Host(s, scene!) is { } h) hosts.Add(h); }+ catch (Exception e) when (e is InvalidOperationException or ArgumentException or NullReferenceException) { }+ }+ });+ for (int i = 0; i < 4; i++) await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Background);++ var live = new List<Visual>();+ NotaThemeService.RenderScoped(theme, themeAccent, () => NotaTextSize.Scoped(0, () =>+ {+ foreach (var s in surfaces)+ {+ byte[]? png = null;+ try+ {+ if (s.Live) png = RenderLive(s, live);+ else if (hosts.FirstOrDefault(h => h.Surface == s) is { Host: not null } h) png = Snap(h.Host, h.Content);+ }+ catch (Exception e) when (e is InvalidOperationException or ArgumentException or NullReferenceException)+ {+ png = null; // a surface that cannot be drawn is left out, the rest still come back+ }+ if (png is not null) images.Add(new Image(s.Name, s.Description, png));+ }+ }));+ // The live parts were re-skinned for the picture; give them the live skin and text size back.+ foreach (var v in live) { NotaSkin.Reapply(v); NotaTextSize.Reapply(v); }+ }+ finally+ {+ foreach (var (_, host, _) in hosts) host.Close();+ }+ return (images, unknown);+ }++ // ── the live window's own parts ─────────────────────────────────────────────────────++ private static byte[]? RenderLive(Surface s, List<Visual> touched)+ {+ if (Avalonia.Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime { MainWindow: MainWindow main })+ return null;+ Control? target = s.Name switch+ {+ "overview" => main,+ "top-bar" => main.FindControl<Border>("TransportBar"),+ "browser" => main.FindControl<BrowserView>("Browser"),+ _ => null,+ };+ if (target is null || target.Bounds.Width < 1 || target.Bounds.Height < 1) return null;+ touched.Add(target);+ NotaSkin.Reapply(target);+ NotaTextSize.Reapply(target); // built at the user's text size; the preview draws at the default+ // Layout with the skin's typeface, at the size it has on screen.+ if (target is TopLevel top)+ {+ var size = top.ClientSize;+ top.Measure(size);+ top.Arrange(new Rect(size));+ return Snap(top, size);+ }+ var bounds = target.Bounds;+ target.Measure(bounds.Size);+ target.Arrange(bounds);+ return Snap(target, bounds.Size);+ }++ // ── built from the sample scene ─────────────────────────────────────────────────────++ // A surface in its own window: shown, so the layout manager and Loaded run, but far off+ // screen, fully transparent, not activated and not in the task bar.+ private static (Surface, Window, Control)? Host(Surface s, SampleScene scene)+ {+ Window host;+ Control content;+ switch (s.Name)+ {+ case "preferences":+ {+ var settings = App.Services.GetRequiredService<ISettingsService>();+ var win = new PreferencesWindow(new SettingsViewModel(settings));+ win.ShowPage("Appearance");+ host = win;+ break;+ }+ case "dialog":+ host = new ConfirmWindow(Loc.T("main.browser.delete_project"),+ Loc.F("main.browser.move_to_the_trash", "Night Drive"), Loc.T("common.delete"), Loc.T("common.cancel"));+ break;+ default:+ var built = Build(s, scene);+ if (built is null) return null;+ host = new Window { Background = NotaPalette.BgApp, Content = built };+ break;+ }+ host.ShowInTaskbar = false;+ host.ShowActivated = false;+ host.CanResize = false;+ host.Opacity = 0;+ host.WindowStartupLocation = WindowStartupLocation.Manual;+ host.Position = new PixelPoint(-32000, -32000);+ host.SizeToContent = s.Height > 0 ? SizeToContent.Manual : SizeToContent.Height;+ host.Width = s.Width;+ if (s.Height > 0) host.Height = s.Height;+ host.Show();+ // macOS gives a window shown off screen no size of its own: set it once it exists.+ host.Width = s.Width;+ if (s.Height > 0) host.Height = s.Height;+ content = host.Content as Control ?? throw new InvalidOperationException("nothing to draw");+ Refresh(content, scene);+ return (s, host, content);+ }++ private static Control? Build(Surface s, SampleScene scene) => s.Name switch+ {+ "arrangement" => new ArrangementView { Engine = scene.Engine },+ "mixer" => new MixerView(scene.Engine),+ "device-rack" => new DeviceChainView(scene.Engine, App.Services.GetRequiredService<IFactoryPresets>()),+ "piano-roll" => PianoRoll(scene),+ "menu" => Menu(scene),+ _ => null,+ };++ // Views that fill themselves from the engine once they are in a tree.+ private static void Refresh(Control content, SampleScene scene)+ {+ switch (content)+ {+ case ArrangementView a: a.Refresh(); break;+ case MixerView m: m.Refresh(); break;+ case DeviceChainView d: d.Show(scene.Keys); d.RefreshSynthLive(); break;+ }+ }++ private static Control PianoRoll(SampleScene scene)+ {+ var e = scene.Engine;+ e.TryGetClipInfo(scene.Keys, scene.KeysClip, out var info);+ var set = new Nota.Application.Editing.ClipSet(+ new[] { new Nota.Application.Editing.OpenClip(scene.Keys, scene.KeysClip, info.StartBeat, info.LengthBeats > 0 ? info.LengthBeats : 16) },+ scene.Keys, scene.KeysClip, 4);+ var roll = new PianoRollView { BeatsPerBar = 4 };+ SolidColorBrush Brush(int track) => ArrangementView.TrackBrush(ArrangementView.EffectiveColorIndex(e, track));+ roll.SetTrackColor(Brush(scene.Keys));+ roll.SetClipIdentity(scene.Keys, scene.KeysClip);+ roll.SetClips(set, set.Clips.Select(c => new Nota.Application.Editing.ClipNotes(c.TrackId, c.ClipIndex, e.GetClipNotes(c.TrackId, c.ClipIndex))).ToList(), Brush);+ return roll;+ }++ // The track menu's rows laid out as the menu presenter draws them (a popup has no window+ // to render here), with the first row hovered.+ private static Control? Menu(SampleScene scene)+ {+ var arrangement = new ArrangementView { Engine = scene.Engine };+ var flyout = arrangement.BuildTrackMenu(arrangement, scene.Keys);+ if (flyout is null) return null;+ var items = flyout.Items.OfType<Control>().ToList();+ flyout.Items.Clear();+ var panel = new StackPanel();+ Grid.SetIsSharedSizeScope(panel, true);+ foreach (var item in items) panel.Children.Add(item);+ if (items.OfType<MenuItem>().FirstOrDefault(m => m.IsEnabled) is { } first)+ ((IPseudoClasses)first.Classes).Set(":pointerover", true);+ return new Border+ {+ Background = NotaPalette.SurfaceRaised, BorderBrush = NotaPalette.Seam, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Field, Padding = new Thickness(4), Child = panel,+ HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top,+ };+ }++ // ── layout and pixels ───────────────────────────────────────────────────────────────++ // One hosted surface, in the worn skin: re-skin its tree, lay it out, and draw its content on+ // the window's ground (the window itself is transparent and off screen).+ private static byte[] Snap(Window host, Control content)+ {+ NotaSkin.Reapply(host);+ NotaTextSize.Reapply(host); // built before the scope, at the user's text size+ host.UpdateLayout();+ host.UpdateLayout();+ var size = content.Bounds.Size;+ var px = new PixelSize(Math.Max(1, (int)Math.Ceiling(size.Width)), Math.Max(1, (int)Math.Ceiling(size.Height)));+ using var bitmap = new RenderTargetBitmap(px, new Vector(96, 96));+ using (var ctx = bitmap.CreateDrawingContext())+ ctx.FillRectangle(host.Background ?? NotaPalette.BgApp, new Rect(0, 0, px.Width, px.Height));+ using var top = new RenderTargetBitmap(px, new Vector(96, 96));+ top.Render(content);+ using (var ctx = bitmap.CreateDrawingContext(false))+ ctx.DrawImage(top, new Rect(0, 0, px.Width, px.Height));+ using var ms = new MemoryStream();+ bitmap.Save(ms);+ return ms.ToArray();+ }++ private static byte[] Snap(Visual visual, Size size)+ {+ var px = new PixelSize(Math.Max(1, (int)Math.Ceiling(size.Width)), Math.Max(1, (int)Math.Ceiling(size.Height)));+ using var bitmap = new RenderTargetBitmap(px, new Vector(96, 96));+ bitmap.Render(visual);+ using var ms = new MemoryStream();+ bitmap.Save(ms);+ return ms.ToArray();+ }+}diff --git a/src/managed/Nota.App/StereoMapView.cs b/src/managed/Nota.App/StereoMapView.csindex 110e94b5..40a52d39 100644--- a/src/managed/Nota.App/StereoMapView.cs+++ b/src/managed/Nota.App/StereoMapView.cs@@ -231,7 +231,7 @@ public sealed class StereoMapView : Control, IValueEntryHostctx.DrawLine(new Pen(NotaPalette.BorderDefault, 1), new Point(0, HeaderH), new Point(b.Width, HeaderH));DrawText(ctx, Loc.T("common.stereo_map"), NotaFonts.SansBold, 10, NotaPalette.TextPrimary, new Point(12, HeaderH / 2), vCenter: true);var well = new Rect(Inset, HeaderH + Inset, b.Width - 2 * Inset, b.Height - HeaderH - BottomH - 2 * Inset);- ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), well, 4, 4);+ ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), well, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);DrawGrid(ctx, plot);// Clouds, then handles and labels, in draw order.@@ -325,7 +325,7 @@ public sealed class StereoMapView : Control, IValueEntryHostx += DrawText(ctx, Loc.T("stereo_map.correlation"), NotaFonts.SansBold, 8, NotaPalette.TextTertiary, new Point(x, cy), vCenter: true) + 10;x += DrawText(ctx, "−1", NotaFonts.Sans, 8, NotaPalette.TextTertiary, new Point(x, cy), vCenter: true) + 6;var bar = new Rect(x, cy - 3, 180, 6);- ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), bar, 2, 2);+ ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), bar, NotaRadius.FineValue, NotaRadius.FineValue);double mid = bar.Left + bar.Width / 2;float corr = 1f;foreach (var it in _items) if (it.Master && it.Has && !it.M.Silent) corr = it.M.Correlation;@@ -383,7 +383,7 @@ public sealed class StereoMapView : Control, IValueEntryHostdouble x = c.X + 16 + W > b.Width ? c.X - 16 - W : c.X + 16;double y = c.Y - 8 + h > b.Height ? c.Y + 8 - h : c.Y - 8;var r = new Rect(x, Math.Max(0, y), W, h);- ctx.DrawRectangle(NotaPalette.TooltipBg, new Pen(NotaPalette.BorderStrong, 1), r, 4, 4);+ ctx.DrawRectangle(NotaPalette.TooltipBg, new Pen(NotaPalette.BorderStrong, 1), r, NotaRadius.ValueBarValue, NotaRadius.ValueBarValue);double ty = r.Top + 8;ctx.DrawEllipse(it.Color, null, new Point(r.Left + Pad + 4, ty + 7), 4, 4);DrawText(ctx, it.Name, NotaFonts.SansSemiBold, 11, NotaPalette.TextPrimary, new Point(r.Left + Pad + 14, ty + 7), vCenter: true);diff --git a/src/managed/Nota.App/Theme/NotaAccent.cs b/src/managed/Nota.App/Theme/NotaAccent.csindex 7031bca8..9792652d 100644--- a/src/managed/Nota.App/Theme/NotaAccent.cs+++ b/src/managed/Nota.App/Theme/NotaAccent.cs@@ -19,15 +19,22 @@ internal static class NotaAccent{private static readonly Dictionary<(string Id, AccentChoice Choice), NotaColourTheme> Cache = new();+ /// <summary>A reload may change a user theme under the same id: wear it afresh. Called by+ /// <see cref="NotaThemes.ReloadUser"/> before it raises ThemesChanged, so no handler can+ /// wear a stale cached theme (an event handler here could run after NotaThemeService's).</summary>+ public static void Forget() => Cache.Clear();+/// <summary><paramref name="theme"/> wearing <paramref name="choice"/>. Orange — and a/// choice the theme cannot wear, which no preset is — is the theme itself.</summary>public static NotaColourTheme Wear(NotaColourTheme theme, AccentChoice choice){// Always from the theme file's own colours: a theme already wearing another accent// would otherwise be re-coloured relative to that accent.- theme = NotaThemes.Find(theme.Id) ?? theme;+ // A try-on or preview theme (spec 087) is not in the list: it is its own file.+ bool listed = theme.Source is ThemeSource.BuiltIn or ThemeSource.User;+ if (listed) theme = NotaThemes.Find(theme.Id) ?? theme;if (choice.IsDefault) return theme;- if (Cache.TryGetValue((theme.Id, choice), out var worn)) return worn;+ if (listed && Cache.TryGetValue((theme.Id, choice), out var worn)) return worn;var result = AccentColours.Wear(Rgb(theme), choice);if (result.Tokens is null) worn = theme;else@@ -39,6 +46,7 @@ internal static class NotaAccent// Presets are a fixed set; custom colours are not — a drag in the picker wears a new// one every step. Keep only the latest custom colour, so the cache stays at the// presets × themes plus one colour × themes.+ if (!listed) return worn; // one-off: never cached, so previews don't pile upif (choice.Preset == Accent.Custom)foreach (var stale in Cache.Keys.Where(k => k.Choice.Preset == Accent.Custom && k.Choice != choice).ToList())Cache.Remove(stale);@@ -58,8 +66,9 @@ internal static class NotaAccentprivate static IReadOnlyDictionary<string, uint> Rgb(NotaColourTheme theme){- if (!RgbCache.TryGetValue(theme, out var m))- RgbCache[theme] = m = Enumerable.ToDictionary(theme.Colors, c => c.Key, c => c.Value.ToUInt32() & 0xFFFFFF);+ if (RgbCache.TryGetValue(theme, out var m)) return m;+ m = Enumerable.ToDictionary(theme.Colors, c => c.Key, c => c.Value.ToUInt32() & 0xFFFFFF);+ if (theme.Source is ThemeSource.BuiltIn) RgbCache[theme] = m; // user themes are re-read on reloadreturn m;}diff --git a/src/managed/Nota.App/Theme/NotaColourTheme.cs b/src/managed/Nota.App/Theme/NotaColourTheme.csindex 6e7a5a80..ca422b67 100644--- a/src/managed/Nota.App/Theme/NotaColourTheme.cs+++ b/src/managed/Nota.App/Theme/NotaColourTheme.cs@@ -8,23 +8,41 @@// take later (specs/011-colour-themes/contracts/theme-file.md), so the loader validates// rather than trusts: a file that fails is left out of the list and noted in LoadErrors,// never thrown at the UI.+//+// User themes (spec 087) are the same files in <data>/Themes. They join the list after the+// built-ins and can also carry a typeface and corner radii (format 2). One validator —+// Nota.Application.Themes.ThemeFile — serves the built-ins, the folder, MCP and the tests.using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text.Json;-using System.Text.RegularExpressions;using Avalonia.Media;+using Nota.Application.Themes;+using Nota.Infrastructure;namespace Nota.App;internal enum NotaThemeKind { Dark, Light }+/// <summary>Where a worn theme came from. Try-on and preview themes are never in the list.</summary>+internal enum ThemeSource { BuiltIn, User, TryOn, Preview }+internal sealed record NotaColourTheme(string Id, string Name, NotaThemeKind Kind, IReadOnlyDictionary<string, Color> Colors){public bool IsDark => Kind == NotaThemeKind.Dark;public Color this[string token] => Colors[token];++ /// <summary>Typeface and corner radii (spec 087). Default for every built-in.</summary>+ public SkinGeometry Geometry { get; init; } = SkinGeometry.Default;+ public ThemeSource Source { get; init; } = ThemeSource.BuiltIn;+ /// <summary>The file a user theme was read from.</summary>+ public string? FilePath { get; init; }+ /// <summary>Readability pairings below their minimum, and a missing typeface.</summary>+ public IReadOnlyList<ThemeWarning> Warnings { get; init; } = Array.Empty<ThemeWarning>();++ public bool IsUser => Source == ThemeSource.User;}internal static class NotaThemes@@ -44,17 +62,19 @@ internal static class NotaThemes// Translucent by design; every other token must be opaque. The wells and the device// bevel are a faint white (dark themes) or black (light themes) over whatever they sit on.- private static readonly HashSet<string> AlphaTokens = new()+ public static readonly IReadOnlySet<string> AlphaTokens = new HashSet<string>{"ShadowBevel", "ShadowPopover", "ShadowModal","Well", "WellTrack", "KnobTrack", "DeviceSectionEdge", "Bevel",};- private static readonly Regex IdPattern = new("^[a-z0-9]+(-[a-z0-9]+)*$", RegexOptions.Compiled);- private static readonly Regex HexPattern = new("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$", RegexOptions.Compiled);-private static IReadOnlyList<NotaColourTheme>? _builtIn;private static readonly List<string> _loadErrors = new();+ private static IReadOnlyList<NotaColourTheme> _user = Array.Empty<NotaColourTheme>();+ private static IReadOnlyList<NotaColourTheme>? _all;+ private static IReadOnlyList<(string FileName, string Reason)> _userProblems = Array.Empty<(string, string)>();+ private static IReadOnlyList<string>? _catalogueList;+ private static HashSet<string>? _systemFonts;/// <summary>Why a built-in theme file was left out, if any was. Logged at startup.</summary>public static IReadOnlyList<string> LoadErrors { get { _ = BuiltIn; return _loadErrors; } }@@ -62,16 +82,95 @@ internal static class NotaThemes/// <summary>Every built-in theme that loaded and validated, in <see cref="BuiltInOrder"/>.</summary>public static IReadOnlyList<NotaColourTheme> BuiltIn => _builtIn ??= LoadBuiltIn();- public static NotaColourTheme? Find(string? id) => id is null ? null : BuiltIn.FirstOrDefault(t => t.Id == id);+ /// <summary>The user themes that loaded from <see cref="ThemesFolder"/>, by name.</summary>+ public static IReadOnlyList<NotaColourTheme> User => _user;++ /// <summary>Built-ins, then user themes — every theme Preferences lists and a choice can name.</summary>+ public static IReadOnlyList<NotaColourTheme> All => _all ??= BuiltIn.Concat(_user).ToList();++ /// <summary>User theme files that could not be loaded, with the reason in plain words.</summary>+ public static IReadOnlyList<(string FileName, string Reason)> UserLoadProblems => _userProblems;++ /// <summary>Where user themes live: Themes in the Nota data folder (NOTA_DATA_DIR moves it).</summary>+ public static string ThemesFolder => Path.Combine(NotaPaths.DataDir, "Themes");++ /// <summary>Raised after <see cref="ReloadUser"/> on the UI thread.</summary>+ public static event Action? ThemesChanged;- public static IEnumerable<NotaColourTheme> OfKind(NotaThemeKind kind) => BuiltIn.Where(t => t.Kind == kind);+ public static NotaColourTheme? Find(string? id) => id is null ? null : All.FirstOrDefault(t => t.Id == id);++ public static bool IsBuiltIn(string id) => BuiltIn.Any(t => t.Id == id);++ public static IEnumerable<NotaColourTheme> OfKind(NotaThemeKind kind) => All.Where(t => t.Kind == kind);/// <summary>Studio Dark, the default and the last resort.</summary>- public static NotaColourTheme Default => Find("studio-dark") ?? BuiltIn[0];+ public static NotaColourTheme Default => BuiltIn.FirstOrDefault(t => t.Id == "studio-dark") ?? BuiltIn[0];/// <summary>The token catalogue every theme must match exactly.</summary>public static IEnumerable<string> Catalogue => NotaPalette.TokenNames.Concat(ExtraTokens);+ /// <summary>The catalogue in file order — what the validator and the writer take.</summary>+ public static IReadOnlyList<string> CatalogueList => _catalogueList ??= Catalogue.ToList();++ /// <summary>Whether <paramref name="family"/> is a font installed on this system (case-insensitive).</summary>+ public static bool IsFontInstalled(string family)+ {+ if (_systemFonts is null)+ {+ _systemFonts = new HashSet<string>(StringComparer.OrdinalIgnoreCase);+ try { foreach (var f in FontManager.Current.SystemFonts) _systemFonts.Add(f.Name); }+ catch (Exception) { /* no font manager (tests): treat every family as missing */ }+ }+ return _systemFonts.Contains(family);+ }++ /// <summary>The font families installed on this system, sorted.</summary>+ public static IReadOnlyList<string> SystemFontNames()+ {+ _ = IsFontInstalled("");+ return _systemFonts!.OrderBy(n => n, StringComparer.CurrentCultureIgnoreCase).ToList();+ }++ /// <summary>Validate a theme document with this app's catalogue and installed fonts.</summary>+ public static ThemeValidation Validate(string json) =>+ ThemeFile.Validate(json, CatalogueList, AlphaTokens, IsFontInstalled);++ /// <summary>A validated document as a theme the app can wear.</summary>+ public static NotaColourTheme FromParsed(ThemeValidation v, ThemeSource source, string? path = null)+ {+ var t = v.Theme ?? throw new ArgumentException("the theme is not valid", nameof(v));+ return new NotaColourTheme(t.Id, t.Name, t.IsDark ? NotaThemeKind.Dark : NotaThemeKind.Light,+ t.Colors.ToDictionary(kv => kv.Key, kv => Color.FromUInt32(kv.Value)))+ {+ Geometry = t.Geometry,+ Source = source,+ FilePath = path,+ Warnings = v.Warnings,+ };+ }++ /// <summary>The theme as a file (format 1 or 2), tokens in catalogue order.</summary>+ public static string ToFile(NotaColourTheme theme) =>+ ThemeFile.Write(new ParsedTheme(theme.Id, theme.Name, theme.IsDark,+ theme.Colors.ToDictionary(kv => kv.Key, kv => kv.Value.ToUInt32()), theme.Geometry, theme.Geometry.IsDefault ? 1 : 2),+ CatalogueList);++ /// <summary>Re-read the user themes folder. Never throws; a bad file goes to+ /// <see cref="UserLoadProblems"/>. Raises <see cref="ThemesChanged"/>.</summary>+ public static void ReloadUser()+ {+ _systemFonts = null; // a font may have been installed or removed meanwhile+ var scan = ThemeFolder.Scan(ThemesFolder, CatalogueList, AlphaTokens, IsBuiltIn, IsFontInstalled);+ _user = scan.Loaded+ .Select(e => FromParsed(e.Validation, ThemeSource.User, e.Path))+ .OrderBy(t => t.Name, StringComparer.CurrentCultureIgnoreCase)+ .ToList();+ _userProblems = scan.Problems;+ _all = null;+ NotaAccent.Forget();+ ThemesChanged?.Invoke();+ }+private static IReadOnlyList<NotaColourTheme> LoadBuiltIn(){var catalogue = new HashSet<string>(Catalogue);@@ -83,7 +182,8 @@ internal static class NotaThemesvar theme = Parse(json, catalogue, out var error);if (theme is null) { _loadErrors.Add($"{id}: {error}"); continue; }if (theme.Id != id) { _loadErrors.Add($"{id}: file declares id '{theme.Id}'"); continue; }- list.Add(theme);+ // Built-ins are held to the readability bar by the smoke test, not warned about here.+ list.Add(theme with { Warnings = Array.Empty<ThemeWarning>() });}if (list.Count == 0) throw new InvalidOperationException("No colour theme could be loaded: " + string.Join("; ", _loadErrors));return list;@@ -106,60 +206,18 @@ internal static class NotaThemesreturn r.ReadToEnd();}- /// <summary>Parse and validate one theme file (rules F1–F6). Returns null with a reason- /// on the first problem; reasons name the token so a broken file is easy to fix.</summary>+ /// <summary>Parse and validate one theme file (rules F1–F6, and the format-2 parts).+ /// Returns null with the first reason on a problem; reasons name the token so a broken+ /// file is easy to fix. <see cref="ThemeFile.Validate"/> gives every problem.</summary>public static NotaColourTheme? Parse(string json, IReadOnlySet<string> catalogue, out string? error){- error = null;- try- {- using var doc = JsonDocument.Parse(json);- var root = doc.RootElement;- if (root.ValueKind != JsonValueKind.Object) return Fail("the file must hold one JSON object", out error);- if (!root.TryGetProperty("formatVersion", out var fv) || fv.ValueKind != JsonValueKind.Number- || !fv.TryGetInt32(out var version) || version != 1)- return Fail("formatVersion must be 1", out error);- // Metadata is read only when it is a string: a number or object here fails this- // theme with a reason instead of throwing out of the loader.- static string Str(JsonElement root, string key)- => root.TryGetProperty(key, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() ?? "" : "";- var id = Str(root, "id");- if (!IdPattern.IsMatch(id) || id == "system") return Fail($"invalid id '{id}'", out error);- var name = Str(root, "name");- if (name.Length is < 1 or > 40) return Fail("name must be 1–40 characters", out error);- var kindText = Str(root, "kind");- NotaThemeKind kind;- if (kindText == "dark") kind = NotaThemeKind.Dark;- else if (kindText == "light") kind = NotaThemeKind.Light;- else return Fail($"kind must be dark or light, not '{kindText}'", out error);- if (!root.TryGetProperty("colors", out var colors) || colors.ValueKind != JsonValueKind.Object)- return Fail("colors missing", out error);-- var map = new Dictionary<string, Color>();- foreach (var p in colors.EnumerateObject())- {- if (!catalogue.Contains(p.Name)) return Fail($"unknown token '{p.Name}'", out error);- var hex = p.Value.ValueKind == JsonValueKind.String ? p.Value.GetString() ?? "" : "";- if (!HexPattern.IsMatch(hex)) return Fail($"token '{p.Name}' has invalid colour '{hex}'", out error);- var c = Color.Parse(hex);- if (c.A != 0xFF && !AlphaTokens.Contains(p.Name)) return Fail($"token '{p.Name}' must be opaque", out error);- map[p.Name] = c;- }- var missing = catalogue.Where(t => !map.ContainsKey(t)).ToList();- if (missing.Count > 0) return Fail("missing token(s) " + string.Join(", ", missing), out error);- return new NotaColourTheme(id, name, kind, map);- }- catch (JsonException e)+ var v = ThemeFile.Validate(json, catalogue.Count == CatalogueList.Count ? CatalogueList : catalogue.ToList(), AlphaTokens);+ if (!v.IsValid){- return Fail("not valid JSON: " + e.Message, out error);- }- catch (Exception e) when (e is InvalidOperationException or FormatException)- {- // A JSON value of the wrong kind somewhere the checks above don't look: fail this- // theme with a reason (the loader logs and skips it) rather than throw out of startup.- return Fail("unexpected value: " + e.Message, out error);+ error = v.Problems.FirstOrDefault()?.Message ?? "";+ return null;}+ error = null;+ return FromParsed(v, ThemeSource.BuiltIn);}-- private static NotaColourTheme? Fail(string reason, out string? error) { error = reason; return null; }}diff --git a/src/managed/Nota.App/Theme/NotaFonts.cs b/src/managed/Nota.App/Theme/NotaFonts.csindex 898be304..e19b6a6b 100644--- a/src/managed/Nota.App/Theme/NotaFonts.cs+++ b/src/managed/Nota.App/Theme/NotaFonts.cs@@ -13,6 +13,9 @@// view: a name the app does not bundle ("Inter", "Menlo", "monospace") silently resolves// to whatever the OS has.//+// A skin may name a system typeface instead (spec 087): NotaSkin coerces controls' Geist to it+// and NotaFormattedText swaps it in when the text is built, so cached Typeface fields follow.+//// Geist is bundled (assets/fonts, SIL OFL 1.1). Glyphs it lacks — ■ ▾ ✓ ★ — fall back to// the system font per character.@@ -65,13 +68,13 @@ public class NotaFormattedText : FormattedText{public NotaFormattedText(string textToFormat, CultureInfo culture, FlowDirection flowDirection,Typeface typeface, double emSize, IBrush? foreground)- : base(textToFormat, culture, flowDirection, typeface, NotaTextSize.Apply(emSize), foreground)+ : base(textToFormat, culture, flowDirection, NotaSkin.Map(typeface), NotaTextSize.Apply(emSize), foreground)=> SetFontFeatures(NotaFonts.Tabular);/// <summary>Text drawn by <paramref name="owner"/>: inside a device card it keeps its size.</summary>public NotaFormattedText(string textToFormat, CultureInfo culture, FlowDirection flowDirection,Typeface typeface, double emSize, IBrush? foreground, AvaloniaObject? owner)- : base(textToFormat, culture, flowDirection, typeface, NotaTextSize.Apply(emSize, owner), foreground)+ : base(textToFormat, culture, flowDirection, NotaSkin.Map(typeface), NotaTextSize.Apply(emSize, owner), foreground)=> SetFontFeatures(NotaFonts.Tabular);}diff --git a/src/managed/Nota.App/Theme/NotaGeometry.cs b/src/managed/Nota.App/Theme/NotaGeometry.csindex f6253c8b..2c97cdd7 100644--- a/src/managed/Nota.App/Theme/NotaGeometry.cs+++ b/src/managed/Nota.App/Theme/NotaGeometry.cs@@ -8,32 +8,47 @@//// Radius follows the style guide's scale (spec 038): 9 on the largest surfaces down to 2 on// the smallest parts, and 0 for docked panels, which meet their neighbours on a seam.+//+// A skin can re-round the scale (spec 087). The CornerRadius values below stay the design+// values — NotaSkin coerces every control's CornerRadius from them — while the *Value numbers+// custom-drawn views read at render time are the skin's (they repaint on every theme change).using Avalonia;+using Nota.Application.Themes;namespace Nota.App;internal static class NotaRadius{- public const double DockedValue = 0, CardValue = 9, GroupValue = 7, FieldValue = 6, CellValue = 5,- ValueBarValue = 4, SwitchValue = 3, FineValue = 2;+ public const double DockedValue = 0;++ // Custom-drawn radii, as the worn skin draws them.+ public static double CardValue => NotaSkin.Radius(RadiusStep.Card);+ public static double GroupValue => NotaSkin.Radius(RadiusStep.Group);+ public static double FieldValue => NotaSkin.Radius(RadiusStep.Field);+ public static double CellValue => NotaSkin.Radius(RadiusStep.Cell);+ public static double ValueBarValue => NotaSkin.Radius(RadiusStep.ValueBar);+ public static double SwitchValue => NotaSkin.Radius(RadiusStep.Switch);+ public static double FineValue => NotaSkin.Radius(RadiusStep.Fine);++ private static CornerRadius Design(RadiusStep step) => new(SkinGeometry.Design(step));/// <summary>0 — a docked panel; it meets its neighbours on a 1px seam.</summary>public static readonly CornerRadius Docked = new(DockedValue);/// <summary>9 — device card, toolbar view group, modal window.</summary>- public static readonly CornerRadius Card = new(CardValue);+ public static readonly CornerRadius Card = Design(RadiusStep.Card);/// <summary>7 — icon button, chip, segment group, device section, search, menu.</summary>- public static readonly CornerRadius Group = new(GroupValue);+ public static readonly CornerRadius Group = Design(RadiusStep.Group);/// <summary>6 — field, dropdown, clip, toggle pill, row highlight, graph window.</summary>- public static readonly CornerRadius Field = new(FieldValue);+ public static readonly CornerRadius Field = Design(RadiusStep.Field);/// <summary>5 — one segment cell, track button, EQ band cell, tooltip, inner key.</summary>- public static readonly CornerRadius Cell = new(CellValue);+ public static readonly CornerRadius Cell = Design(RadiusStep.Cell);/// <summary>4 — value bar, fader cap, overview strip.</summary>- public static readonly CornerRadius ValueBar = new(ValueBarValue);+ public static readonly CornerRadius ValueBar = Design(RadiusStep.ValueBar);/// <summary>3 — switch track.</summary>- public static readonly CornerRadius Switch = new(SwitchValue);+ public static readonly CornerRadius Switch = Design(RadiusStep.Switch);/// <summary>2 — switch knob, notes, bars inside a plot.</summary>- public static readonly CornerRadius Fine = new(FineValue);+ public static readonly CornerRadius Fine = Design(RadiusStep.Fine);/// <summary>Rounded top only — a header strip or a stripe sitting on a body.</summary>public static CornerRadius Top(double r) => new(r, r, 0, 0);diff --git a/src/managed/Nota.App/Theme/NotaSkin.cs b/src/managed/Nota.App/Theme/NotaSkin.csnew file mode 100644index 00000000..2b63dd9e--- /dev/null+++ b/src/managed/Nota.App/Theme/NotaSkin.cs@@ -0,0 +1,204 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The worn theme's typeface and corner radii (spec 087), applied live. Every control keeps+// the value it was written with — a design radius from the style guide's scale, Geist from+// Font.UI — as its base value, and the skin's value is laid over it. So a skin never+// compounds, the default skin is an exact no-op, and switching back restores every control+// without a rebuild.+//+// Not by coercion, the way text size is (NotaTextSize): CornerRadius and Rectangle's radii+// are registered on Border and Rectangle themselves, and Avalonia refuses to override an+// owner's metadata; and a coerced inherited typeface does not reliably come back. So the+// skin's value is set at Animation priority, above local values and styles, worked out from+// the base value (GetBaseValue) whenever that changes and on every skin change, and cleared+// again — by a flag, never touching anyone else's animation — when it matches the base. The custom-drawn layer takes the+// same skin from NotaRadius.*Value and NotaFormattedText, which it reads at render time.++using System;+using System.Collections.Generic;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Controls.ApplicationLifetimes;+using Avalonia.Controls.Documents;+using Avalonia.Controls.Presenters;+using Avalonia.Controls.Primitives;+using Avalonia.Controls.Shapes;+using Avalonia.Data;+using Avalonia.Layout;+using Avalonia.Media;+using Avalonia.VisualTree;+using Nota.Application.Themes;++namespace Nota.App;++internal static class NotaSkin+{+ private static SkinGeometry _geometry = SkinGeometry.Default;+ private static FontFamily? _family;+ private static bool _installed;++ /// <summary>The worn skin's typeface and radii.</summary>+ public static SkinGeometry Geometry => _geometry;++ /// <summary>The worn skin's typeface, when it names one that is installed; otherwise null (Geist).</summary>+ public static FontFamily? Family => _family;++ /// <summary>A radius step as the worn skin draws it.</summary>+ public static double Radius(RadiusStep step) => _geometry.RadiusOf(step);++ /// <summary>A design radius as the worn skin draws it.</summary>+ public static double MapRadius(double value) => _geometry.MapRadius(value);++ public static CornerRadius Map(CornerRadius r) => _geometry.IsDefault ? r+ : new CornerRadius(MapRadius(r.TopLeft), MapRadius(r.TopRight), MapRadius(r.BottomRight), MapRadius(r.BottomLeft));++ /// <summary>Geist (by URI, by name, or as the app's default family) becomes the skin's typeface.</summary>+ public static FontFamily MapFamily(FontFamily family) =>+ _family is not null && IsGeist(family) ? _family : family;++ /// <summary>A Geist typeface in the skin's family, same weight and style — for NotaFormattedText.</summary>+ public static Typeface Map(Typeface face) =>+ _family is not null && IsGeist(face.FontFamily) ? new Typeface(_family, face.Style, face.Weight, face.Stretch) : face;++ // Geist by any of its names: Font.UI, the app's default family, and Fluent's own default+ // ("fonts:Inter#Inter, $Default"), which the window templates carry. Nota ships no Inter,+ // so that one resolves to the default family, Geist.+ private static bool IsGeist(FontFamily? f)+ {+ if (f is null) return false;+ if (ReferenceEquals(f, NotaFonts.UiFamily) || f == FontFamily.Default) return true;+ var first = f.FamilyNames.Count > 0 ? f.FamilyNames[0] : f.Name;+ return first == NotaFonts.UiFamily.Name || first == FontFamily.Default.Name || first == "Inter";+ }++ /// <summary>Hook the coercion in. Once, before the XAML loads.</summary>+ public static void Install()+ {+ if (_installed) return;+ _installed = true;++ // CornerRadius is one property shared by Border, TemplatedControl and ContentPresenter.+ // A base value that changes (a style, a local value) gets the skin laid over it again.+ Border.CornerRadiusProperty.Changed.AddClassHandler<AvaloniaObject>((o, e) =>+ {+ if (e.Priority != BindingPriority.Animation) SkinCorner(o);+ });+ Rectangle.RadiusXProperty.Changed.AddClassHandler<Rectangle>((r, e) =>+ {+ if (e.Priority != BindingPriority.Animation) SkinRadius(r, Rectangle.RadiusXProperty, RadiusXBit);+ });+ Rectangle.RadiusYProperty.Changed.AddClassHandler<Rectangle>((r, e) =>+ {+ if (e.Priority != BindingPriority.Animation) SkinRadius(r, Rectangle.RadiusYProperty, RadiusYBit);+ });++ // The typeface is inherited: a top level that wears it hands it to every text that does+ // not name a family, and the explicit Font.UI setters get it laid over where they land.+ TextElement.FontFamilyProperty.Changed.AddClassHandler<StyledElement>((o, e) =>+ {+ if (e.Priority is not (BindingPriority.Animation or BindingPriority.Inherited) && TakesFont(o)) SkinFont(o);+ });+ }++ // The skin values laid over base values, by object and property, so going back to the+ // design scale removes exactly those (and never an animation of someone else's). An+ // Animation-priority SetValue returns the handle that removes it.+ private static readonly System.Runtime.CompilerServices.ConditionalWeakTable<AvaloniaObject, Dictionary<int, IDisposable>> Overlays = new();++ private const int CornerBit = 1, RadiusXBit = 2, RadiusYBit = 4, FontBit = 8;++ private static bool TakesFont(AvaloniaObject o) => o is TopLevel or TemplatedControl or TextBlock or TextPresenter;++ // The skin's typeface over a Geist base value (a top level with no value of its own counts+ // as Geist: the app's default family is Geist).+ private static void SkinFont(AvaloniaObject o)+ {+ var p = TextElement.FontFamilyProperty;+ var b = o.GetBaseValue(p);+ FontFamily? baseValue = b.HasValue ? b.Value : o is TopLevel ? FontFamily.Default : null;+ if (baseValue is null)+ {+ Overlay(o, p, FontFamily.Default, FontFamily.Default, FontBit); // clears an old overlay+ return;+ }+ Overlay(o, p, baseValue, MapFamily(baseValue), FontBit);+ }++ // The skin's radius over the base value, or nothing over it when they agree.+ private static void SkinCorner(AvaloniaObject o)+ {+ var p = Border.CornerRadiusProperty;+ var b = o.GetBaseValue(p);+ var baseValue = b.HasValue ? b.Value : p.GetDefaultValue(o.GetType());+ Overlay(o, p, baseValue, Map(baseValue), CornerBit);+ }++ private static void SkinRadius(Rectangle r, StyledProperty<double> p, int bit)+ {+ var b = r.GetBaseValue(p);+ var baseValue = b.HasValue ? b.Value : p.GetDefaultValue(typeof(Rectangle));+ Overlay(r, p, baseValue, MapRadius(baseValue), bit);+ }++ private static void Overlay<T>(AvaloniaObject o, StyledProperty<T> p, T baseValue, T mapped, int bit)+ {+ Overlays.TryGetValue(o, out var mine);+ IDisposable? old = null;+ mine?.TryGetValue(bit, out old);+ if (EqualityComparer<T>.Default.Equals(mapped, baseValue))+ {+ if (old is null) return;+ mine!.Remove(bit);+ old.Dispose();+ return;+ }+ // Replace, never stack: the new value first, then the old handle goes.+ var handle = o.SetValue(p, mapped, BindingPriority.Animation);+ old?.Dispose();+ if (handle is null) { mine?.Remove(bit); return; }+ (mine ??= Overlays.GetValue(o, _ => new Dictionary<int, IDisposable>()))[bit] = handle;+ }++ /// <summary>Wear <paramref name="geometry"/>. Returns whether anything a control shows changed;+ /// the caller re-coerces (<see cref="Reapply"/>) and repaints.</summary>+ public static bool Set(SkinGeometry geometry)+ {+ var family = geometry.FontFamily is { } name && NotaThemes.IsFontInstalled(name) ? new FontFamily(name) : null;+ bool changed = !_geometry.Equals(geometry) || _family?.Name != family?.Name;+ _geometry = geometry;+ _family = family;+ return changed;+ }++ /// <summary>Re-coerce every open window, so controls built under another skin take this one.</summary>+ public static void Reapply()+ {+ if (Avalonia.Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;+ foreach (var window in desktop.Windows) Reapply(window);+ }++ /// <summary>Re-coerce one tree (a window, or an offscreen preview root).</summary>+ public static void Reapply(Visual root)+ {+ foreach (var v in root.GetSelfAndVisualDescendants())+ {+ // A dropdown's or menu's content lives in its own popup root, outside the window's+ // tree — open now, or shown later (a closed ComboBox also draws its item from there).+ if (v is Avalonia.Controls.Primitives.Popup { Child: { } content }) Reapply(content);+ switch (v)+ {+ case Border or TemplatedControl or ContentPresenter:+ SkinCorner(v);+ break;+ case Rectangle r:+ SkinRadius(r, Rectangle.RadiusXProperty, RadiusXBit);+ SkinRadius(r, Rectangle.RadiusYProperty, RadiusYBit);+ break;+ }+ if (TakesFont(v)) SkinFont(v);+ if (v is Layoutable l) l.InvalidateMeasure();+ v.InvalidateVisual(); // custom-drawn radii and text re-read the skin on their next render+ }+ }+}diff --git a/src/managed/Nota.App/Theme/NotaTextSize.cs b/src/managed/Nota.App/Theme/NotaTextSize.csindex c773f179..bd456b6a 100644--- a/src/managed/Nota.App/Theme/NotaTextSize.cs+++ b/src/managed/Nota.App/Theme/NotaTextSize.cs@@ -62,6 +62,16 @@ internal static class NotaTextSizeFixedProperty.Changed.AddClassHandler<TextPresenter>((tp, _) => tp.CoerceValue(TextElement.FontSizeProperty));}+ /// <summary>Build and draw with <paramref name="step"/> for the length of <paramref name="run"/>,+ /// without touching the open windows — the skin previews (spec 087) draw at the default size.</summary>+ public static void Scoped(int step, Action run)+ {+ int live = _step;+ _step = TextSize.Normalize(step);+ try { run(); }+ finally { _step = live; }+ }+/// <summary>Wear <paramref name="step"/> (normalised) everywhere, live.</summary>public static void Set(int step){@@ -72,10 +82,13 @@ internal static class NotaTextSizeforeach (var window in desktop.Windows) Reapply(window);}- private static void Reapply(Visual root)+ /// <summary>Re-coerce the text in one tree to the current step (a window, or a preview root).</summary>+ public static void Reapply(Visual root){foreach (var v in root.GetSelfAndVisualDescendants()){+ // A popup's content (a ComboBox's items, which its closed box also shows) is outside the tree.+ if (v is Avalonia.Controls.Primitives.Popup { Child: { } content }) Reapply(content);if (v is TextBlock tb) tb.CoerceValue(TextBlock.FontSizeProperty);else if (v is TextPresenter tp) tp.CoerceValue(TextElement.FontSizeProperty);if (v is Layoutable l) l.InvalidateMeasure();diff --git a/src/managed/Nota.App/Theme/NotaThemeService.cs b/src/managed/Nota.App/Theme/NotaThemeService.csindex 5b781f3c..f4726419 100644--- a/src/managed/Nota.App/Theme/NotaThemeService.cs+++ b/src/managed/Nota.App/Theme/NotaThemeService.cs@@ -18,6 +18,11 @@//// Custom-drawn Render() overrides read slot colours without subscribing to them, so every// switch forces a repaint of every window.+//+// A theme also carries a typeface and corner radii (spec 087): NotaSkin wears them, and a+// change re-coerces every window. User themes join the list from the themes folder; a reload+// re-wears the active one. A try-on (MCP) is worn without being stored, and RenderScoped+// wears a theme for the length of one call — the skin previews — and puts the live one back.using System;using System.Collections.Generic;@@ -39,6 +44,7 @@ internal static class NotaThemeServiceprivate static AppearanceChoice _choice = new(false, Appearance.StudioDark, Appearance.StudioDark, Appearance.StudioLight);private static AccentChoice _accent = AccentChoice.Default;+ private static NotaColourTheme? _tryOn;/// <summary>The appearance being followed.</summary>public static AppearanceChoice Choice => _choice;@@ -61,9 +67,73 @@ internal static class NotaThemeServiceApplyActive();}- /// <summary>Every loaded theme id → whether it is dark — what <see cref="Appearance.Resolve"/> needs.</summary>+ /// <summary>Every loaded theme id (built-in and user) → whether it is dark — what+ /// <see cref="Appearance.Resolve"/> needs.</summary>public static IReadOnlyDictionary<string, bool> KnownThemes =>- NotaThemes.BuiltIn.ToDictionary(t => t.Id, t => t.IsDark);+ NotaThemes.All.ToDictionary(t => t.Id, t => t.IsDark);++ /// <summary>The choice the settings hold, resolved against the themes loaded now. Set by the+ /// app at startup; read again after each reload of the themes folder.</summary>+ public static Func<AppearanceChoice>? StoredChoice { get; set; }++ /// <summary>The theme being tried on (not stored), if any.</summary>+ public static NotaColourTheme? TryOnTheme => _tryOn;++ /// <summary>The theme the window wears now, accent included.</summary>+ public static NotaColourTheme? WornTheme => NotaPalette.Theme;++ /// <summary>Wear <paramref name="theme"/> live without storing it, until <see cref="RevertTryOn"/>,+ /// a <see cref="Set"/> (a pick in Preferences) or a restart.</summary>+ public static void TryOn(NotaColourTheme theme)+ {+ _tryOn = theme;+ ApplyActive();+ }++ /// <summary>End a try-on: back to the stored choice. No-op without one.</summary>+ public static void RevertTryOn()+ {+ if (_tryOn is null) return;+ _tryOn = null;+ ApplyActive();+ }++ /// <summary>Wear <paramref name="theme"/> (with the user's accent, or the theme's own) for the+ /// length of <paramref name="render"/>, then put the live theme back — all inside the caller's+ /// UI-thread job, so the compositor never sends a frame of it to the screen. Live windows are+ /// neither repainted nor re-coerced; <paramref name="render"/> re-coerces its own trees.</summary>+ public static void RenderScoped(NotaColourTheme theme, bool themeAccent, Action render)+ {+ var app = Avalonia.Application.Current;+ if (app is null) { render(); return; }+ var live = NotaPalette.Theme;+ var liveGeometry = NotaSkin.Geometry;+ var scoped = themeAccent ? theme : Worn(theme);+ InScope = true;+ try+ {+ NotaPalette.Apply(scoped);+ ApplyResources(app, scoped);+ NotaSkin.Set(scoped.Geometry);+ render();+ }+ finally+ {+ if (live is not null)+ {+ NotaPalette.Apply(live);+ ApplyResources(app, live);+ }+ // Resource changes inside the scope make live controls re-evaluate their typeface and+ // radii against the scoped skin; give every live window its own skin back.+ if (NotaSkin.Set(liveGeometry)) NotaSkin.Reapply();+ InScope = false;+ }+ }++ /// <summary>True while <see cref="RenderScoped"/> wears a theme for a picture: views built+ /// then must not reload or re-wear themes (that would put the live theme back mid-picture).</summary>+ public static bool InScope { get; private set; }/// <summary>Wear <paramref name="choice"/> and keep following it. Safe to call repeatedly.</summary>public static void Set(AppearanceChoice choice)@@ -73,9 +143,19 @@ internal static class NotaThemeServicePublish(app);_choice = choice;+ _tryOn = null; // a pick replaces a try-on+if (!_hooked){app.ActualThemeVariantChanged += (_, _) => { if (_choice.FollowSystem) ApplyActive(); };+ // The folder changed under the worn theme: wear what it holds now (or the fallback).+ NotaThemes.ThemesChanged += () =>+ {+ // Re-resolve from the settings: a stored theme that had fallen back comes back+ // once its file loads again (the fallback was never stored).+ if (StoredChoice?.Invoke() is { } stored) _choice = stored;+ ApplyActive();+ };_hooked = true;}@@ -92,18 +172,30 @@ internal static class NotaThemeServiceif (app is null) return;// With no OS signal Avalonia reports Light, which is the spec's fallback too.bool osDark = app.ActualThemeVariant == ThemeVariant.Dark;- var theme = Worn(NotaThemes.Find(_choice.Active(osDark)) ?? NotaThemes.Default);+ var theme = _tryOn is not null ? Worn(_tryOn) : Worn(NotaThemes.Find(_choice.Active(osDark)) ?? FallbackFor(osDark));- if (!_choice.FollowSystem)+ if (!_choice.FollowSystem || _tryOn is not null)app.RequestedThemeVariant = theme.IsDark ? ThemeVariant.Dark : ThemeVariant.Light;+ else+ app.RequestedThemeVariant = ThemeVariant.Default;if (ReferenceEquals(NotaPalette.Theme, theme)) return;NotaPalette.Apply(theme);ApplyResources(app, theme);+ if (NotaSkin.Set(theme.Geometry)) NotaSkin.Reapply();RepaintEverything();Changed?.Invoke();}+ // A stored theme that is gone (a user file removed or broken): the default for that mode,+ // as Appearance.Resolve falls back. The stored choice is kept, so fixing the file brings it back.+ private static NotaColourTheme FallbackFor(bool osDark)+ {+ bool dark = _choice.FollowSystem ? osDark : true;+ return dark ? NotaThemes.Default+ : NotaThemes.BuiltIn.FirstOrDefault(t => t.Id == Appearance.StudioLight) ?? NotaThemes.Default;+ }+// Put the slot brushes into the application resources once. They are re-tinted in// place afterwards, so the resource entries never need replacing.private static void Publish(Avalonia.Application app)diff --git a/src/managed/Nota.App/Theme/token-roles.json b/src/managed/Nota.App/Theme/token-roles.jsonnew file mode 100644index 00000000..930d948b--- /dev/null+++ b/src/managed/Nota.App/Theme/token-roles.json@@ -0,0 +1,612 @@+[+ {+ "name": "SurfaceAbyss",+ "group": "Surfaces",+ "role": "well: the transport console recess"+ },+ {+ "name": "BgApp",+ "group": "Surfaces",+ "role": "ground: window, arrangement, plugin body"+ },+ {+ "name": "Gutter",+ "group": "Surfaces",+ "role": "the seam the docked panels meet on"+ },+ {+ "name": "BgSunken",+ "group": "Surfaces",+ "role": "well: the recess behind sunken controls (chrome background)"+ },+ {+ "name": "CanvasBg",+ "group": "Surfaces",+ "role": "modular canvas, just above the well"+ },+ {+ "name": "SurfaceDeep",+ "group": "Surfaces",+ "role": "step-sequencer ground"+ },+ {+ "name": "LaneB",+ "group": "Surfaces",+ "role": "alternating lane"+ },+ {+ "name": "Panel",+ "group": "Surfaces",+ "role": "browser, headers, inspector"+ },+ {+ "name": "SurfaceCard",+ "group": "Surfaces",+ "role": "a section inside a device (panel tone; divided by rules)"+ },+ {+ "name": "SurfaceInset",+ "group": "Surfaces",+ "role": "rail, sunken chip, hovered well"+ },+ {+ "name": "SurfaceRaised",+ "group": "Surfaces",+ "role": "button at rest"+ },+ {+ "name": "SurfaceHover",+ "group": "Surfaces",+ "role": "a raised button under the pointer"+ },+ {+ "name": "TrackOff",+ "group": "Surfaces",+ "role": "track of an off toggle"+ },+ {+ "name": "SurfaceActive",+ "group": "Surfaces",+ "role": "a raised button while pressed or on"+ },+ {+ "name": "GridSubBeat",+ "group": "Grid + graph lines",+ "role": "finer than a beat"+ },+ {+ "name": "GridBeat",+ "group": "Grid + graph lines",+ "role": "grid inside graphs, zero axis"+ },+ {+ "name": "GridRow",+ "group": "Grid + graph lines",+ "role": "piano-roll row divider"+ },+ {+ "name": "GridBar",+ "group": "Grid + graph lines",+ "role": "bar lines in the arrangement and editors"+ },+ {+ "name": "GraphBorder",+ "group": "Grid + graph lines",+ "role": "inner border of a visualiser well"+ },+ {+ "name": "WellGrid",+ "group": "Grid + graph lines",+ "role": "grid drawn inside a well"+ },+ {+ "name": "PadGrid",+ "group": "Grid + graph lines",+ "role": "XY-pad grid"+ },+ {+ "name": "TextHeading",+ "group": "Text",+ "role": "Ink 0 — page titles, project name. Rare."+ },+ {+ "name": "TextPrimary",+ "group": "Text",+ "role": "Ink 1 — device/track/preset names, values"+ },+ {+ "name": "TextStrong",+ "group": "Text",+ "role": "Ink 2 — button text, transport readouts"+ },+ {+ "name": "TextSecondary",+ "group": "Text",+ "role": "Ink 3 — inactive but readable, metadata"+ },+ {+ "name": "TextMuted",+ "group": "Text",+ "role": "Ink 4 — explanations, units, hints"+ },+ {+ "name": "TextTertiary",+ "group": "Text",+ "role": "Ink 5 — caps labels above parameters"+ },+ {+ "name": "TextDisabled",+ "group": "Text",+ "role": "Ink 6 — placeholder, disabled action"+ },+ {+ "name": "TextAxis",+ "group": "Text",+ "role": "Ink 7 — axis labels inside graphs only"+ },+ {+ "name": "TextOnAccent",+ "group": "Text",+ "role": "text and glyphs on an accent fill"+ },+ {+ "name": "TextFaint",+ "group": "Text",+ "role": "disabled controls only"+ },+ {+ "name": "VizInk",+ "group": "Text",+ "role": "lines and fills drawn inside visualisers"+ },+ {+ "name": "VizGrid",+ "group": "Text",+ "role": "grid inside a well"+ },+ {+ "name": "BorderDefault",+ "group": "Borders",+ "role": "the border of fields, buttons and cards"+ },+ {+ "name": "BorderStrong",+ "group": "Borders",+ "role": "knob cap, hovered border"+ },+ {+ "name": "BorderBrass",+ "group": "Borders",+ "role": "accent line: 70% accent over panel"+ },+ {+ "name": "Seam",+ "group": "Borders",+ "role": "the 1 px line where panels meet"+ },+ {+ "name": "Rule",+ "group": "Borders",+ "role": "divider lines inside a panel"+ },+ {+ "name": "Accent",+ "group": "Accent",+ "role": "playhead, selection, toggled-on fill"+ },+ {+ "name": "AccentBright",+ "group": "Accent",+ "role": "accent glow: the line/ink variant"+ },+ {+ "name": "AccentHover",+ "group": "Accent",+ "role": "accent text on hover"+ },+ {+ "name": "AccentDeep",+ "group": "Accent",+ "role": "press, left half of the loop"+ },+ {+ "name": "AccentDim",+ "group": "Accent",+ "role": "the soft/pressed accent"+ },+ {+ "name": "AccentEdge",+ "group": "Accent",+ "role": "chip border, link underline"+ },+ {+ "name": "AccentMute",+ "group": "Accent",+ "role": "a muted accent; nothing at rest uses it any more"+ },+ {+ "name": "AccentPale",+ "group": "Accent",+ "role": "hot edge highlight"+ },+ {+ "name": "AccentSubtle",+ "group": "Accent",+ "role": "accent-soft wash"+ },+ {+ "name": "Record",+ "group": "Status",+ "role": "active recording, the only claim on red"+ },+ {+ "name": "RecordInk",+ "group": "Status",+ "role": "disc on an engaged record button"+ },+ {+ "name": "Success",+ "group": "Status",+ "role": "Signal, working meter zone"+ },+ {+ "name": "SuccessInk",+ "group": "Status",+ "role": "ink on a Success fill (Session play)"+ },+ {+ "name": "SuccessDim",+ "group": "Status",+ "role": "transport input, metronome"+ },+ {+ "name": "Warning",+ "group": "Status",+ "role": "Caution, −6..0 dB"+ },+ {+ "name": "Mute",+ "group": "Status",+ "role": "mute button when on, muted state"+ },+ {+ "name": "Solo",+ "group": "Status",+ "role": "solo button when on"+ },+ {+ "name": "Danger",+ "group": "Status",+ "role": "Alert, overload / clipping"+ },+ {+ "name": "DangerHover",+ "group": "Status",+ "role": "a destructive button under the pointer"+ },+ {+ "name": "DangerBright",+ "group": "Status",+ "role": "Alert Light, readout text"+ },+ {+ "name": "DangerDeep",+ "group": "Status",+ "role": "over-threshold fill, below Alert"+ },+ {+ "name": "DangerPale",+ "group": "Status",+ "role": "live-take waveform / label"+ },+ {+ "name": "Teal",+ "group": "Data + modulation",+ "role": "2nd layer; also the modulation accent"+ },+ {+ "name": "TealBright",+ "group": "Data + modulation",+ "role": "light variant of Teal, for lines and text"+ },+ {+ "name": "Rose",+ "group": "Data + modulation",+ "role": "3rd layer: right channel, highs, tail"+ },+ {+ "name": "RoseBright",+ "group": "Data + modulation",+ "role": "light variant of Rose, for lines and text"+ },+ {+ "name": "Steel",+ "group": "Data + modulation",+ "role": "4th layer, used rarely"+ },+ {+ "name": "Sage",+ "group": "Data + modulation",+ "role": "standalone hue (no longer a track slot)"+ },+ {+ "name": "Threshold",+ "group": "Data + modulation",+ "role": "threshold markers"+ },+ {+ "name": "Marker",+ "group": "Data + modulation",+ "role": "clip markers / brackets"+ },+ {+ "name": "MarkerHot",+ "group": "Data + modulation",+ "role": "resize-edge affordance"+ },+ {+ "name": "Frozen",+ "group": "Data + modulation",+ "role": "frozen-track ice"+ },+ {+ "name": "SignalIn",+ "group": "Data + modulation",+ "role": "ghost \"input\" trace label"+ },+ {+ "name": "SignalInFill",+ "group": "Data + modulation",+ "role": "fill under the ghost input trace"+ },+ {+ "name": "HandleSel",+ "group": "Data + modulation",+ "role": "selected graph handle"+ },+ {+ "name": "SelHeaderBg",+ "group": "Tinted chrome",+ "role": "selected track header — raised hover (the accent tick marks it)"+ },+ {+ "name": "FrozenHeaderBg",+ "group": "Tinted chrome",+ "role": "frozen track header"+ },+ {+ "name": "MuteTint",+ "group": "Tinted chrome",+ "role": "muted band"+ },+ {+ "name": "Veil",+ "group": "Tinted chrome",+ "role": "deactivated-clip scrim base"+ },+ {+ "name": "TooltipBg",+ "group": "Tinted chrome",+ "role": "tooltip: a raised popover"+ },+ {+ "name": "TooltipText",+ "group": "Tinted chrome",+ "role": "tooltip text"+ },+ {+ "name": "Well",+ "group": "Wells and depth",+ "role": "behind a button, field or menu at rest"+ },+ {+ "name": "WellTrack",+ "group": "Wells and depth",+ "role": "switch and slider track"+ },+ {+ "name": "KnobTrack",+ "group": "Wells and depth",+ "role": "the arc a knob's value runs on"+ },+ {+ "name": "Groove",+ "group": "Wells and depth",+ "role": "device controls sit in one"+ },+ {+ "name": "DeviceSection",+ "group": "Wells and depth",+ "role": "a pressed-in section inside a device"+ },+ {+ "name": "DeviceSectionEdge",+ "group": "Wells and depth",+ "role": "that section's inner edge"+ },+ {+ "name": "DeviceHeader",+ "group": "Wells and depth",+ "role": "device card header"+ },+ {+ "name": "Bevel",+ "group": "Wells and depth",+ "role": "light top edge on raised parts"+ },+ {+ "name": "KnobCap",+ "group": "Wells and depth",+ "role": "knob centre cap (devices only)"+ },+ {+ "name": "AccentSoft",+ "group": "Wells and depth",+ "role": "behind something picked"+ },+ {+ "name": "MeterSafe",+ "group": "Wells and depth",+ "role": "meter fill in the working range"+ },+ {+ "name": "MeterHot",+ "group": "Wells and depth",+ "role": "meter fill near the top (−6..0 dB)"+ },+ {+ "name": "MeterOver",+ "group": "Wells and depth",+ "role": "meter fill over 0 dB"+ },+ {+ "name": "TrackHeaderSelected",+ "group": "Wells and depth",+ "role": "the selected track's header"+ },+ {+ "name": "LaneSelected",+ "group": "Wells and depth",+ "role": "the selected track's lane"+ },+ {+ "name": "KeyWhite",+ "group": "Piano keys",+ "role": "piano-roll keys: dark, never the brightest thing"+ },+ {+ "name": "KeyBlack",+ "group": "Piano keys",+ "role": "black keys and their lanes"+ },+ {+ "name": "MiniKeyWhite",+ "group": "Piano keys",+ "role": "device-card mini keyboards"+ },+ {+ "name": "MiniKeyBlack",+ "group": "Piano keys",+ "role": "black keys of device-card mini keyboards"+ },+ {+ "name": "ShadeUp",+ "group": "Track-shade mix targets",+ "role": "\"lighter\" shade"+ },+ {+ "name": "ShadeDown",+ "group": "Track-shade mix targets",+ "role": "\"darker\" shade"+ },+ {+ "name": "Track1",+ "group": "Track palette",+ "role": "track colour 1 (Drums by default)"+ },+ {+ "name": "Track2",+ "group": "Track palette",+ "role": "track colour 2 (Perc by default)"+ },+ {+ "name": "Track3",+ "group": "Track palette",+ "role": "track colour 3 (Bass by default)"+ },+ {+ "name": "Track4",+ "group": "Track palette",+ "role": "track colour 4 (Keys by default)"+ },+ {+ "name": "Track5",+ "group": "Track palette",+ "role": "track colour 5 (Texture by default)"+ },+ {+ "name": "Track6",+ "group": "Track palette",+ "role": "track colour 6 (FX by default)"+ },+ {+ "name": "Track7",+ "group": "Track palette",+ "role": "track colour 7 (Brass by default)"+ },+ {+ "name": "Track8",+ "group": "Track palette",+ "role": "track colour 8 (Vox by default)"+ },+ {+ "name": "Track9",+ "group": "Track palette",+ "role": "track colour 9 (Return by default)"+ },+ {+ "name": "Master",+ "group": "Track palette",+ "role": "the master track's colour"+ },+ {+ "name": "ReturnA",+ "group": "Track palette",+ "role": "return track A's colour"+ },+ {+ "name": "ReturnB",+ "group": "Track palette",+ "role": "return track B's colour"+ },+ {+ "name": "SystemAccent",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentLight1",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentLight2",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentLight3",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentDark1",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentDark2",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "SystemAccentDark3",+ "group": "Fluent accent ramp",+ "role": "the accent ramp Avalonia's own controls read"+ },+ {+ "name": "ShadowBevel",+ "group": "Shadows",+ "role": "light top edge of raised parts (translucent)"+ },+ {+ "name": "ShadowPopover",+ "group": "Shadows",+ "role": "drop shadow under menus and popovers (translucent)"+ },+ {+ "name": "ShadowModal",+ "group": "Shadows",+ "role": "drop shadow under dialogs (translucent)"+ }+]diff --git a/src/managed/Nota.Application/Localization/en.json b/src/managed/Nota.Application/Localization/en.jsonindex 647cae81..c0733450 100644--- a/src/managed/Nota.Application/Localization/en.json+++ b/src/managed/Nota.Application/Localization/en.json@@ -540,9 +540,14 @@"commands.settings_appearance": "Settings: Appearance","commands.settings_audio": "Settings: Audio","commands.settings_downloads": "Settings: Downloads",+ "commands.settings_editing": "Settings: Editing","commands.settings_gamepads": "Settings: Gamepads",+ "commands.settings_inputs": "Settings: Inputs",+ "commands.settings_language": "Settings: Language","commands.settings_library": "Settings: Library",+ "commands.settings_mcp": "Settings: AI control (MCP)","commands.settings_midi": "Settings: MIDI",+ "commands.settings_outputs": "Settings: Outputs","commands.settings_plug_ins": "Settings: Plug-ins","commands.settings_remote": "Settings: Remote","commands.settings_shortcuts": "Settings: Shortcuts",@@ -2565,8 +2570,8 @@"main.mosaic.created_the_preset": "Created the preset {0}","main.narrow_grid": "Narrow grid","main.new": "New",- "main.no_audio_output_could_be": "No audio output could be opened — Nota runs without sound. Choose a device in Settings → Audio",- "main.no_audio_output_device_opened": "No audio output device opened — Nota runs silently. Choose a device in Settings → Audio",+ "main.no_audio_output_could_be_opened_outputs": "No audio output could be opened — Nota runs without sound. Choose a device in Settings → Outputs",+ "main.no_audio_output_device_opened_outputs": "No audio output device opened — Nota runs silently. Choose a device in Settings → Outputs","main.no_key": "No key","main.no_project_key": "No project key","main.not_now": "Not now",@@ -3284,10 +3289,13 @@"preferences.any_button": "Any button","preferences.any_button_can_be_mapped": "Any button can be mapped to a control instead: click MIDI in the top-right, click the control, then press the button. A mapped button drives that control and stops playing its note; the rest of the pad keeps the layout above. The sticks and the trigger travel map the same way and are continuous, so they suit a knob or a fader — they play no notes, and do nothing until mapped. Mappings are listed in the browser's MIDI Map tab and travel with the project.","preferences.appearance": "Appearance",+ "preferences.appearance_subtitle": "Theme, scale, text and waveforms","preferences.apply_and_keep_the_palette": "Apply and keep the palette open for the next device","preferences.apply_where_the_palette_was": "Apply where the palette was opened (the target shows in the field)",+ "preferences.arrangement": "Arrangement","preferences.arrangement_editing": "Arrangement & editing","preferences.asio_caps": "ASIO",+ "preferences.asio_device_on_audio": "{0} — the ASIO driver is both input and output.","preferences.asio_frames": "ASIO · {0} frames @ {1}{2}","preferences.asio_unavailable_wasapi": "ASIO unavailable ({0}) → WASAPI","preferences.audio_clip_editor": "Audio clip editor",@@ -3295,6 +3303,7 @@"preferences.audio_device": "Audio device","preferences.audio_device_not_running": "Audio device not running.","preferences.audio_settings_are_unavailable_in": "Audio settings are unavailable in this window.",+ "preferences.audio_subtitle": "Sample rate, buffer and latency","preferences.audio_system": "Audio system","preferences.back_to_the_standard_height": "Back to the standard height","preferences.bars": "Bars",@@ -3306,6 +3315,7 @@"preferences.cancel_the_current_gesture_clear": "Cancel the current gesture / clear the selection · close the patch-bay overlay","preferences.change_a_device_value_hold": "Change a device value · hold ⌘ or ⇧ for fine steps","preferences.change_its_velocity_the_whole": "Change its velocity · the whole selection's when the note is selected · elsewhere scroll sideways",+ "preferences.change_on_audio_page": "Change on the Audio page","preferences.change_the_notes_start_or": "Change the note's start or end","preferences.channels_2_16_each_carry": "Channels 2–16 each carry one note with its own pitch bend, pressure and slide (CC74). A controller that announces its range overrides this one. Channel 1 plays as an ordinary keyboard, its pitch wheel and aftertouch moving the whole instrument. ","preferences.choose": "Choose…",@@ -3375,7 +3385,6 @@"preferences.deselect_moved_or_pasted_notes": "Deselect · moved or pasted notes replace the notes under them","preferences.detail_panel": "Detail panel","preferences.device_default": "Device default",- "preferences.device_sample_rate_and_buffer": "Device, sample rate and buffer","preferences.devices_after_a_click_on": "Devices (after a click on a device)","preferences.devices_settings": "Devices","preferences.direction": "Direction",@@ -3454,6 +3463,8 @@"preferences.duplicate_the_selection_replaces_the": "Duplicate the selection · replaces the notes it lands on","preferences.duplicate_time_insert_a_copy": "Duplicate time · insert a copy of the time range after it, pushing everything later right","preferences.edit_the_clip_an_empty": "Edit the clip · an empty MIDI slot gets a new clip",+ "preferences.editing": "Editing",+ "preferences.editing_subtitle": "Piano roll, arrangement and the detail panel","preferences.enable_mcp_server_let_an": "Enable MCP server (let an AI drive Nota)","preferences.end_macro_mapping_map_on": "End macro mapping (Map on the rack card)","preferences.enter_leave_full_screen_the": "Enter / leave full screen — the title bar hides in full screen",@@ -3496,6 +3507,7 @@"preferences.inputs_hint": "Switch off the inputs you don't use and name the rest: track input menus list only the inputs that are on, under these names. Kept for this device.","preferences.inputs_no_device": "No input device: choose one above, or connect one.","preferences.inputs_pairs": "Stereo pairs",+ "preferences.inputs_subtitle": "What Nota records from, and what each input is called","preferences.inputs_switch_tip": "Off: tracks can't pick this input, and a track set to it records nothing","preferences.insert_a_scene_below_the": "Insert a scene below the selection","preferences.insert_silence_push_everything_from": "Insert silence · push everything from the range start right by its length",@@ -3532,6 +3544,7 @@"preferences.language.unreadable": "unreadable","preferences.language.update": "Update","preferences.language.will_be_downloaded_when_online": "{0} isn't installed yet — Nota downloads it when it's online",+ "preferences.language_subtitle": "The language of menus and panels","preferences.last": "Last","preferences.last_check_average_peak": "Last check: {0:0} % average, {1:0} % peak · {2} — {3}.","preferences.latency": "Latency",@@ -3556,6 +3569,7 @@"preferences.mappable_as_continuous_controls_a": "Mappable as continuous controls (a knob, a fader); they play no notes","preferences.mappable_through_midi_learn_a": "Mappable through MIDI Learn — a mapped button drives the control instead","preferences.mark_a_new_section_over": "Mark a new section over the dragged bars",+ "preferences.mcp_subtitle": "Let an AI assistant work in Nota","preferences.measures_audio_thread_load_for": "Measures audio-thread load for 5 s — play your project for a real-world figure.","preferences.measuring": "Measuring…","preferences.measuring_5_s_left_play": "Measuring… 5 s left — play your project for a real-world figure.",@@ -3612,6 +3626,8 @@"preferences.open_plug_in_window_on": "Open plug-in window on insert","preferences.open_the_detail_panel_when": "Open the detail panel when you select a track or clip","preferences.output_check": "Output check",+ "preferences.outputs": "Outputs",+ "preferences.outputs_subtitle": "Where Nota plays, and the test tone","preferences.overloaded_raise_the_buffer_size": "overloaded — raise the buffer size","preferences.paste_the_last_range_as": "Paste the last range as audio rendered through its devices","preferences.patch_a_cable_in_nota": "Patch a cable in Nota Consort · ⌥-click a jack to pull its cables",@@ -3670,6 +3686,7 @@"preferences.remote.usb_caps": "USB ","preferences.remote.when_you_turn_this_on": "When you turn this on, Windows asks whether Nota may use the network. Allow private networks, or phones can't reach Nota.","preferences.remote.when_you_turn_this_on_2": "When you turn this on, macOS asks whether Nota may find devices on the local network. Allow it, or phones can't reach Nota.",+ "preferences.remote_control": "Remote control","preferences.remove": "Remove","preferences.remove_the_selected_device_the": "Remove the selected device — the header no longer carries a close button","preferences.removing": "Removing {0}…",@@ -3760,6 +3777,18 @@"preferences.show_playhead_scroll_the_arrangement": "Show playhead · scroll the Arrangement to it without moving it · picks up a paused Follow","preferences.show_primary_controller_lane": "Show the primary MIDI controller lane","preferences.shows_every_note_name_c": "Shows every note name (C, D, E…) on the piano roll's keys instead of only C. Helpful when learning notes.",+ "preferences.skins.cant_save": "Couldn't save the theme: {0}",+ "preferences.skins.copy_name": "{0} copy",+ "preferences.skins.duplicate": "Duplicate",+ "preferences.skins.fallback_note": "“{0}” could not be loaded — showing {1}",+ "preferences.skins.follow_system_hint": "Built-in themes change colours only; a user theme can also change the typeface and the corners. Follow system switches between your dark-mode and light-mode theme with the OS appearance.",+ "preferences.skins.hint": "Themes you put in the themes folder appear here. A theme file sets the colours, and can also set a typeface and how round the corners are.",+ "preferences.skins.more": "+{0} more",+ "preferences.skins.open_folder": "Open themes folder",+ "preferences.skins.problems_heading": "Some theme files could not be loaded",+ "preferences.skins.reload": "Reload",+ "preferences.skins.user_tag": "User theme",+ "preferences.skins.warnings": {"one": "{0} warning", "other": "{0} warnings"},"preferences.smooth": "Smooth","preferences.snap_to_grid_on_off": "Snap to grid on / off","preferences.solid": "Solid",@@ -3814,8 +3843,6 @@"preferences.the_driver_didnt_start": "the driver didn't start","preferences.the_driver_doesnt_support": "The driver doesn't support {0}","preferences.the_language_of_menus_panels": "The language of menus, panels and messages. It changes when Nota restarts. Project files and the names you type are never translated.",- "preferences.theme_scale_waveforms_and_ai": "Theme, scale, waveforms and AI control",- "preferences.themes_change_colours_only_follow": "Themes change colours only. Follow system switches between your dark-mode and light-mode theme with the OS appearance.","preferences.this_erases_the_version_history": "This erases the version history of the open project now, and of any other project the next time you save it. Older versions can't be brought back.","preferences.toggle_automation_mode": "Toggle automation mode","preferences.toggle_the_mixer_view": "Toggle the Mixer view",@@ -4116,6 +4143,38 @@"tag_editor.no_tags_yet_add_one": "No tags yet — add one below.","tag_editor.tags_title_colour": "Tags — title & colour","text_prompt.ok_caps": "OK",+ "themes.problem.and_more": "{0}; +{1} more",+ "themes.problem.bad_colour": "token “{0}” has an invalid colour “{1}” (use #RRGGBB or #AARRGGBB)",+ "themes.problem.builtin_id": "id “{0}” belongs to a built-in theme — give the theme its own id",+ "themes.problem.colors_missing": "colors is missing: an object with one colour per token",+ "themes.problem.duplicate_id": "duplicate id “{0}” — another file in the folder already uses it",+ "themes.problem.file_unreadable": "the file cannot be read: {0}",+ "themes.problem.folder_unreadable": "the folder cannot be read: {0}",+ "themes.problem.font_family": "font.family must be a font name of 1–{0} characters",+ "themes.problem.font_object": "font must be an object with a “family”: the name of an installed font",+ "themes.problem.format_version": "formatVersion must be 1 or 2",+ "themes.problem.id": "invalid id “{0}”: use lower-case letters, digits and single hyphens (not “system”)",+ "themes.problem.kind": "kind must be dark or light, not “{0}”",+ "themes.problem.missing_token": "missing token “{0}”",+ "themes.problem.name": "name must be 1–{0} characters",+ "themes.problem.needs_v2": "“{0}” needs formatVersion 2",+ "themes.problem.not_json": "not valid JSON: {0}",+ "themes.problem.not_object": "the file must hold one JSON object",+ "themes.problem.opaque": "token “{0}” must be opaque",+ "themes.problem.radius_object": "radius must be an object with “scale” and/or “steps”",+ "themes.problem.radius_scale": "radius.scale must be a number from {0} to {1}",+ "themes.problem.radius_step_range": "radius.steps.{0} must be a number from {1} to {2}",+ "themes.problem.radius_step_unknown": "unknown radius step “{0}” (use {1})",+ "themes.problem.radius_steps": "radius.steps must be an object",+ "themes.problem.too_large": "the file is larger than {0} KB",+ "themes.problem.unknown_key": "unknown key “{0}”",+ "themes.problem.unknown_token": "unknown token “{0}”",+ "themes.warning.contrast": "{0}: contrast {1}, needs {2}",+ "themes.warning.distance": "{0}: colour distance {1}, needs {2} (hard to tell apart)",+ "themes.warning.font_missing": "font “{0}” is not installed — Geist is used instead",+ "themes.warning.on": "{0} on {1}",+ "themes.warning.text_on": "text on {0}",+ "themes.warning.vs": "{0} vs {1}","track_arming.arm_for_recording_click_to": "Arm for recording · ⌘-click to arm several tracks · ⌥-click to arm one track of a linked group","track_inspector.arm": "Arm","track_inspector.audio_track": "Audio track",diff --git a/src/managed/Nota.Application/Palette/CommandCatalog.cs b/src/managed/Nota.Application/Palette/CommandCatalog.csindex aa71e186..ababac3a 100644--- a/src/managed/Nota.Application/Palette/CommandCatalog.cs+++ b/src/managed/Nota.Application/Palette/CommandCatalog.cs@@ -124,14 +124,19 @@ public static class CommandCatalog// ---- Settings ---------------------------------------------------------------------C("prefs.open", Loc.T("common.settings"), Loc.T("common.settings"), Shortcut.Cmd(','), "preferences options"),- C("prefs.audio", Loc.T("commands.settings_audio"), Loc.T("common.settings"), "", "preferences device driver sample rate buffer"),+ C("prefs.audio", Loc.T("commands.settings_audio"), Loc.T("common.settings"), "", "preferences driver asio sample rate buffer latency cpu"),+ C("prefs.outputs", Loc.T("commands.settings_outputs"), Loc.T("common.settings"), "", "preferences output device speakers headphones test tone"),+ C("prefs.inputs", Loc.T("commands.settings_inputs"), Loc.T("common.settings"), "", "preferences input device channels microphone names stereo pairs"),C("prefs.midi", Loc.T("commands.settings_midi"), Loc.T("common.settings"), "", "preferences controller keyboard"),C("prefs.gamepads", Loc.T("commands.settings_gamepads"), Loc.T("common.settings"), "", "preferences joystick controller"),C("prefs.remote", Loc.T("commands.settings_remote"), Loc.T("common.settings"), "", "preferences phone"),+ C("prefs.mcp", Loc.T("commands.settings_mcp"), Loc.T("common.settings"), "", "preferences ai mcp claude assistant server port"),C("prefs.plugins", Loc.T("commands.settings_plug_ins"), Loc.T("common.settings"), "", "preferences vst3 au scan folders"),C("prefs.downloads", Loc.T("commands.settings_downloads"), Loc.T("common.settings"), "", "preferences store models sample packs"),C("prefs.library", Loc.T("commands.settings_library"), Loc.T("common.settings"), "", "preferences folders"),- C("prefs.appearance", Loc.T("commands.settings_appearance"), Loc.T("common.settings"), "", "preferences theme dark light language langue francais english"),+ C("prefs.appearance", Loc.T("commands.settings_appearance"), Loc.T("common.settings"), "", "preferences theme dark light skin accent scale text size waveform"),+ C("prefs.language", Loc.T("commands.settings_language"), Loc.T("common.settings"), "", "preferences language langue francais english russian"),+ C("prefs.editing", Loc.T("commands.settings_editing"), Loc.T("common.settings"), "", "preferences piano roll note names labels split fades detail panel"),C("prefs.shortcuts", Loc.T("commands.settings_shortcuts"), Loc.T("common.settings"), "", "preferences hotkeys keys keyboard"),C("prefs.updates", Loc.T("commands.settings_updates"), Loc.T("common.settings"), "", "preferences update automatic check version"),diff --git a/src/managed/Nota.Application/Themes/SkinGeometry.cs b/src/managed/Nota.Application/Themes/SkinGeometry.csnew file mode 100644index 00000000..bcd912f2--- /dev/null+++ b/src/managed/Nota.Application/Themes/SkinGeometry.cs@@ -0,0 +1,69 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// What a skin does to type and corners (spec 087): an optional system typeface and a corner+// roundness over the style guide's radius scale (spec 038). The design scale stays the base+// every control is written against; MapRadius turns a design value into the skin's value, so+// mapping never compounds and the default geometry is an exact no-op.++namespace Nota.Application.Themes;++/// <summary>The steps of the style guide's radius scale, largest first. Docked panels (0) are+/// not a step: they meet their neighbours on a seam and never round.</summary>+public enum RadiusStep { Card, Group, Field, Cell, ValueBar, Switch, Fine }++public sealed record SkinGeometry(string? FontFamily, double Roundness, IReadOnlyDictionary<RadiusStep, double> StepOverrides)+{+ public const double MinRoundness = 0, MaxRoundness = 2, MinStep = 0, MaxStep = 24;+ public const int MaxFamilyLength = 100;++ /// <summary>Geist and the design scale — every built-in theme and every format-1 file.</summary>+ public static readonly SkinGeometry Default = new(null, 1, new Dictionary<RadiusStep, double>());++ /// <summary>The style guide's value for each step (NotaRadius in the app mirrors these).</summary>+ public static double Design(RadiusStep step) => step switch+ {+ RadiusStep.Card => 9,+ RadiusStep.Group => 7,+ RadiusStep.Field => 6,+ RadiusStep.Cell => 5,+ RadiusStep.ValueBar => 4,+ RadiusStep.Switch => 3,+ _ => 2,+ };++ /// <summary>The key a step has in a theme file's <c>radius.steps</c>.</summary>+ public static string Key(RadiusStep step) => step switch+ {+ RadiusStep.ValueBar => "valueBar",+ _ => step.ToString().ToLowerInvariant(),+ };++ public static RadiusStep? FromKey(string key) =>+ Enum.GetValues<RadiusStep>().Cast<RadiusStep?>().FirstOrDefault(s => Key(s!.Value) == key);++ public bool IsDefault => FontFamily is null && Roundness == 1 && StepOverrides.Count == 0;++ /// <summary>The radius this skin gives <paramref name="step"/>, in whole pixels.</summary>+ public double RadiusOf(RadiusStep step) =>+ StepOverrides.TryGetValue(step, out var v) ? v : Math.Round(Design(step) * Roundness, MidpointRounding.AwayFromZero);++ /// <summary>A radius as written in the code (a design value) as this skin draws it: 0 stays+ /// square, a value on the scale takes its step's radius, any other is scaled by roundness.</summary>+ public double MapRadius(double designValue)+ {+ if (designValue <= 0 || IsDefault) return designValue;+ foreach (var step in Enum.GetValues<RadiusStep>())+ if (designValue == Design(step)) return RadiusOf(step);+ return Math.Round(designValue * Roundness, MidpointRounding.AwayFromZero);+ }++ // Records compare dictionaries by reference; two geometries are the same skin when their+ // values are.+ public bool Equals(SkinGeometry? other) =>+ other is not null && FontFamily == other.FontFamily && Roundness == other.Roundness+ && StepOverrides.Count == other.StepOverrides.Count+ && StepOverrides.All(kv => other.StepOverrides.TryGetValue(kv.Key, out var v) && v == kv.Value);++ public override int GetHashCode() => HashCode.Combine(FontFamily, Roundness, StepOverrides.Count);+}diff --git a/src/managed/Nota.Application/Themes/ThemeFile.cs b/src/managed/Nota.Application/Themes/ThemeFile.csnew file mode 100644index 00000000..edea2c13--- /dev/null+++ b/src/managed/Nota.Application/Themes/ThemeFile.cs@@ -0,0 +1,362 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The theme file (spec 011, format 1; spec 087, format 2) as data: one validator for the+// built-in loader, the user themes folder, the MCP tools and the smoke test. It never throws+// and reports every problem it finds, so a hand-written file can be fixed in one pass. The+// readability pairings of spec 011 (T3) are warnings here: a user may choose a low-contrast+// look for themselves; the built-ins are held to them by the smoke test. No Avalonia types —+// colours are ARGB uints — so the MCP project and the tests use it without the UI.++using System.Globalization;+using System.Text;+using System.Text.Json;+using System.Text.RegularExpressions;+using Nota.Application.Localization;++namespace Nota.Application.Themes;++/// <summary>A theme file that validated: everything the app needs to wear it.</summary>+public sealed record ParsedTheme(string Id, string Name, bool IsDark, IReadOnlyDictionary<string, uint> Colors,+ SkinGeometry Geometry, int FormatVersion);++/// <summary>A rule the file breaks. <see cref="Field"/> is the token or key path, when there is one.</summary>+public sealed record ThemeProblem(string Rule, string? Field, string Message);++/// <summary>Something that does not stop the theme loading: a readability pairing below its+/// minimum, or a typeface that is not installed.</summary>+public sealed record ThemeWarning(string Kind, string? Pairing, IReadOnlyList<string> Tokens, double Measured, double Minimum, string Message)+{+ public const string Readability = "readability", FontMissing = "font-missing";+}++public sealed record ThemeValidation(IReadOnlyList<ThemeProblem> Problems, IReadOnlyList<ThemeWarning> Warnings, ParsedTheme? Theme)+{+ public bool IsValid => Problems.Count == 0 && Theme is not null;+}++public static class ThemeFile+{+ public const int MaxNameLength = 40;+ /// <summary>A theme file larger than this is not read (the folder loader's guard).</summary>+ public const int MaxFileBytes = 256 * 1024;++ private static readonly Regex IdPattern = new("^[a-z0-9]+(-[a-z0-9]+)*$", RegexOptions.Compiled);+ private static readonly Regex HexPattern = new("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$", RegexOptions.Compiled);++ /// <summary>Check <paramref name="json"/> against the theme-file rules. <paramref name="catalogue"/>+ /// is every colour token a theme must define, in file order; <paramref name="translucent"/> the+ /// tokens that may carry alpha. <paramref name="fontInstalled"/>, when given, turns a typeface+ /// that is not installed into a warning.</summary>+ public static ThemeValidation Validate(string json, IReadOnlyList<string> catalogue, IReadOnlySet<string> translucent,+ Func<string, bool>? fontInstalled = null)+ {+ var problems = new List<ThemeProblem>();+ var warnings = new List<ThemeWarning>();+ void P(string rule, string? field, string message) => problems.Add(new(rule, field, message));++ JsonDocument doc;+ try { doc = JsonDocument.Parse(json ?? "", new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip }); }+ catch (JsonException e)+ {+ P("JSON", null, Loc.F("themes.problem.not_json", e.Message));+ return new(problems, warnings, null);+ }++ using (doc)+ {+ var root = doc.RootElement;+ if (root.ValueKind != JsonValueKind.Object)+ {+ P("JSON", null, Loc.T("themes.problem.not_object"));+ return new(problems, warnings, null);+ }++ // F1′ — format version 1 (colours) or 2 (colours + typeface + radius).+ int version = 0;+ if (!root.TryGetProperty("formatVersion", out var fv) || fv.ValueKind != JsonValueKind.Number+ || !fv.TryGetInt32(out version) || version is not (1 or 2))+ P("F1", "formatVersion", Loc.T("themes.problem.format_version"));++ static string? Str(JsonElement root, string key) =>+ root.TryGetProperty(key, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() : null;++ // F2 — id.+ var id = Str(root, "id") ?? "";+ if (!IdPattern.IsMatch(id) || id == "system")+ P("F2", "id", Loc.F("themes.problem.id", id));++ // F3 — name.+ var name = Str(root, "name") ?? "";+ if (name.Trim().Length < 1 || name.Length > MaxNameLength)+ P("F3", "name", Loc.F("themes.problem.name", MaxNameLength));++ // F4 — kind.+ var kindText = Str(root, "kind");+ bool isDark = kindText == "dark";+ if (kindText is not ("dark" or "light"))+ P("F4", "kind", Loc.F("themes.problem.kind", kindText ?? ""));++ // F5, F6 — the exact catalogue, valid colours, opaque but the translucent tokens.+ var colors = new Dictionary<string, uint>();+ if (!root.TryGetProperty("colors", out var colorsEl) || colorsEl.ValueKind != JsonValueKind.Object)+ P("F5", "colors", Loc.T("themes.problem.colors_missing"));+ else+ {+ var known = catalogue as IReadOnlySet<string> ?? catalogue.ToHashSet();+ foreach (var p in colorsEl.EnumerateObject())+ {+ if (!known.Contains(p.Name)) { P("F5", $"colors.{p.Name}", Loc.F("themes.problem.unknown_token", p.Name)); continue; }+ var hex = p.Value.ValueKind == JsonValueKind.String ? p.Value.GetString() ?? "" : p.Value.ToString();+ if (!HexPattern.IsMatch(hex)) { P("F6", $"colors.{p.Name}", Loc.F("themes.problem.bad_colour", p.Name, hex)); continue; }+ var argb = ParseHex(hex);+ if (argb >> 24 != 0xFF && !translucent.Contains(p.Name))+ {+ P("F6", $"colors.{p.Name}", Loc.F("themes.problem.opaque", p.Name));+ continue;+ }+ colors[p.Name] = argb;+ }+ var missing = catalogue.Where(t => !colorsEl.TryGetProperty(t, out _)).ToList();+ foreach (var t in missing) P("F5", $"colors.{t}", Loc.F("themes.problem.missing_token", t));+ }++ // V1–V4 — the format-2 parts.+ var geometry = ReadGeometry(root, version, P);++ if (problems.Count > 0) return new(problems, warnings, null);++ var theme = new ParsedTheme(id, name, isDark, colors, geometry, version);+ warnings.AddRange(Readability(colors));+ if (geometry.FontFamily is { } family && fontInstalled is not null && !fontInstalled(family))+ warnings.Add(new(ThemeWarning.FontMissing, null, new[] { family }, 0, 0,+ Loc.F("themes.warning.font_missing", family)));+ return new(problems, warnings, theme);+ }+ }++ private static SkinGeometry ReadGeometry(JsonElement root, int version, Action<string, string?, string> P)+ {+ bool hasFont = root.TryGetProperty("font", out var fontEl);+ bool hasRadius = root.TryGetProperty("radius", out var radiusEl);+ if ((hasFont || hasRadius) && version == 1)+ {+ if (hasFont) P("V1", "font", Loc.F("themes.problem.needs_v2", "font"));+ if (hasRadius) P("V1", "radius", Loc.F("themes.problem.needs_v2", "radius"));+ return SkinGeometry.Default;+ }++ string? family = null;+ if (hasFont)+ {+ if (fontEl.ValueKind != JsonValueKind.Object)+ P("V2", "font", Loc.T("themes.problem.font_object"));+ else+ {+ foreach (var p in fontEl.EnumerateObject())+ if (p.Name != "family") P("V2", $"font.{p.Name}", Loc.F("themes.problem.unknown_key", $"font.{p.Name}"));+ var f = fontEl.TryGetProperty("family", out var fe) && fe.ValueKind == JsonValueKind.String ? fe.GetString()?.Trim() : null;+ if (string.IsNullOrEmpty(f) || f.Length > SkinGeometry.MaxFamilyLength)+ P("V2", "font.family", Loc.F("themes.problem.font_family", SkinGeometry.MaxFamilyLength));+ else family = f;+ }+ }++ double scale = 1;+ var steps = new Dictionary<RadiusStep, double>();+ if (hasRadius)+ {+ if (radiusEl.ValueKind != JsonValueKind.Object)+ P("V3", "radius", Loc.T("themes.problem.radius_object"));+ else+ {+ foreach (var p in radiusEl.EnumerateObject())+ if (p.Name is not ("scale" or "steps")) P("V3", $"radius.{p.Name}", Loc.F("themes.problem.unknown_key", $"radius.{p.Name}"));+ if (radiusEl.TryGetProperty("scale", out var se))+ {+ if (se.ValueKind != JsonValueKind.Number || !se.TryGetDouble(out scale)+ || scale < SkinGeometry.MinRoundness || scale > SkinGeometry.MaxRoundness || double.IsNaN(scale))+ {+ P("V3", "radius.scale", Loc.F("themes.problem.radius_scale", SkinGeometry.MinRoundness, SkinGeometry.MaxRoundness));+ scale = 1;+ }+ }+ if (radiusEl.TryGetProperty("steps", out var st))+ {+ if (st.ValueKind != JsonValueKind.Object) P("V4", "radius.steps", Loc.T("themes.problem.radius_steps"));+ else+ foreach (var p in st.EnumerateObject())+ {+ var step = SkinGeometry.FromKey(p.Name);+ if (step is null)+ {+ P("V4", $"radius.steps.{p.Name}", Loc.F("themes.problem.radius_step_unknown", p.Name,+ string.Join(", ", Enum.GetValues<RadiusStep>().Select(SkinGeometry.Key))));+ continue;+ }+ if (p.Value.ValueKind != JsonValueKind.Number || !p.Value.TryGetDouble(out var v)+ || v < SkinGeometry.MinStep || v > SkinGeometry.MaxStep || double.IsNaN(v))+ {+ P("V4", $"radius.steps.{p.Name}", Loc.F("themes.problem.radius_step_range", p.Name, SkinGeometry.MinStep, SkinGeometry.MaxStep));+ continue;+ }+ steps[step.Value] = v;+ }+ }+ }+ }++ return family is null && scale == 1 && steps.Count == 0 ? SkinGeometry.Default : new SkinGeometry(family, scale, steps);+ }++ /// <summary>The file text for <paramref name="theme"/>: tokens in catalogue order, 2-space+ /// indent, format 1 when it only has colours.</summary>+ public static string Write(ParsedTheme theme, IReadOnlyList<string> catalogue)+ {+ using var ms = new MemoryStream();+ using (var w = new Utf8JsonWriter(ms, new JsonWriterOptions { Indented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }))+ {+ var g = theme.Geometry;+ w.WriteStartObject();+ w.WriteNumber("formatVersion", g.IsDefault ? 1 : 2);+ w.WriteString("id", theme.Id);+ w.WriteString("name", theme.Name);+ w.WriteString("kind", theme.IsDark ? "dark" : "light");+ if (g.FontFamily is { } family)+ {+ w.WriteStartObject("font");+ w.WriteString("family", family);+ w.WriteEndObject();+ }+ if (g.Roundness != 1 || g.StepOverrides.Count > 0)+ {+ w.WriteStartObject("radius");+ if (g.Roundness != 1) w.WriteNumber("scale", g.Roundness);+ if (g.StepOverrides.Count > 0)+ {+ w.WriteStartObject("steps");+ foreach (var step in Enum.GetValues<RadiusStep>())+ if (g.StepOverrides.TryGetValue(step, out var v)) w.WriteNumber(SkinGeometry.Key(step), v);+ w.WriteEndObject();+ }+ w.WriteEndObject();+ }+ w.WriteStartObject("colors");+ foreach (var token in catalogue)+ if (theme.Colors.TryGetValue(token, out var c)) w.WriteString(token, ToHex(c));+ w.WriteEndObject();+ w.WriteEndObject();+ }+ // Utf8JsonWriter indents with two spaces; end with a newline like the built-in files.+ return Encoding.UTF8.GetString(ms.ToArray()) + "\n";+ }++ /// <summary>A theme id made from <paramref name="name"/> that is not in <paramref name="taken"/>:+ /// lower-case, hyphenated, numbered on a clash ("studio-dark-copy", "studio-dark-copy-2").</summary>+ public static string FreeId(string name, Func<string, bool> taken)+ {+ var sb = new StringBuilder();+ foreach (var ch in name.Normalize(NormalizationForm.FormD).ToLowerInvariant())+ {+ if (CharUnicodeInfo.GetUnicodeCategory(ch) == UnicodeCategory.NonSpacingMark) continue;+ if (ch is >= 'a' and <= 'z' or >= '0' and <= '9') sb.Append(ch);+ else if (sb.Length > 0 && sb[^1] != '-') sb.Append('-');+ }+ var slug = sb.ToString().Trim('-');+ if (slug.Length == 0 || slug == "system") slug = "theme";+ if (slug.Length > 60) slug = slug[..60].TrimEnd('-');+ if (!taken(slug)) return slug;+ for (int n = 2; ; n++)+ if (!taken($"{slug}-{n}")) return $"{slug}-{n}";+ }++ public static uint ParseHex(string hex)+ {+ var h = hex.TrimStart('#');+ uint v = uint.Parse(h, NumberStyles.HexNumber, CultureInfo.InvariantCulture);+ return h.Length == 6 ? 0xFF000000 | v : v;+ }++ public static string ToHex(uint argb) =>+ argb >> 24 == 0xFF ? $"#{argb & 0xFFFFFF:X6}" : $"#{argb:X8}";++ // ---- T3: readability pairings (specs/011-colour-themes/contracts/ui-contract.md) -------++ private static readonly string[] FiveSurfaces = { "BgApp", "Panel", "SurfaceRaised", "SurfaceHover", "BgSunken" };++ /// <summary>Every T3 pairing below its minimum, as warnings. Pairings whose tokens the+ /// colours lack are skipped.</summary>+ public static IEnumerable<ThemeWarning> Readability(IReadOnlyDictionary<string, uint> c)+ {+ var list = new List<(string Id, string[] Tokens, string What, double Value, double Min, bool DeltaE)>();+ bool Has(params string[] t) => t.All(c.ContainsKey);+ void Cr(string id, string a, string b, double min)+ {+ if (Has(a, b)) list.Add((id, new[] { a, b }, Loc.F("themes.warning.on", a, b), Contrast(c[a], c[b]), min, false));+ }+ void Ink(string id, string fill, double min)+ {+ if (Has(fill)) list.Add((id, new[] { fill }, Loc.F("themes.warning.text_on", fill), Contrast(ReadableInk(c[fill]), c[fill]), min, false));+ }+ void De(string id, string a, string b, double min)+ {+ if (Has(a, b)) list.Add((id, new[] { a, b }, Loc.F("themes.warning.vs", a, b), DeltaE(c[a], c[b]), min, true));+ }++ foreach (var t in new[] { "TextPrimary", "TextSecondary", "TextMuted" })+ foreach (var s in FiveSurfaces) Cr("T3.1", t, s, 4.5);+ foreach (var s in FiveSurfaces) Cr("T3.2", "TextTertiary", s, 3.0);+ foreach (var t in new[] { "TextFaint", "TextDisabled", "TextAxis" })+ foreach (var s in FiveSurfaces) Cr("T3.3", t, s, 2.5);+ foreach (var s in new[] { "BgApp", "Panel", "BgSunken" }) Cr("T3.4", "AccentBright", s, 2.3);+ foreach (var f in new[] { "Accent", "Mute", "Solo", "Record" }) Ink("T3.5", f, 4.5);+ Cr("T3.9", "RecordInk", "Record", 4.5);+ Cr("T3.9", "SuccessInk", "Success", 4.5);+ foreach (var f in Enumerable.Range(1, 9).Select(i => $"Track{i}").Append("ReturnA").Append("ReturnB")) Ink("T3.6", f, 3.0);+ var tracks = Enumerable.Range(1, 9).Select(i => $"Track{i}").ToArray();+ for (int i = 0; i < tracks.Length; i++)+ for (int j = i + 1; j < tracks.Length; j++) De("T3.7", tracks[i], tracks[j], 12);+ var states = new[] { "Accent", "Mute", "Solo", "Record" };+ for (int i = 0; i < states.Length; i++)+ for (int j = i + 1; j < states.Length; j++) De("T3.8", states[i], states[j], 15);++ foreach (var p in list)+ if (p.Value < p.Min - 1e-9)+ yield return new(ThemeWarning.Readability, p.Id, p.Tokens, Math.Round(p.Value, 2), p.Min,+ p.DeltaE ? Loc.F("themes.warning.distance", p.What, Math.Round(p.Value, 1), p.Min)+ : Loc.F("themes.warning.contrast", p.What, Math.Round(p.Value, 2), p.Min));+ }++ /// <summary>NotaPalette.ReadableInkOn: dark ink or white, whichever reads better on the fill.</summary>+ public static uint ReadableInk(uint fill) =>+ Contrast(0xFF17181A, fill) >= Contrast(0xFFFFFFFF, fill) ? 0xFF17181A : 0xFFFFFFFF;++ /// <summary>WCAG 2.x contrast ratio of two colours (alpha ignored).</summary>+ public static double Contrast(uint a, uint b)+ {+ double la = Luminance(a), lb = Luminance(b);+ return (Math.Max(la, lb) + 0.05) / (Math.Min(la, lb) + 0.05);+ }++ private static double Luminance(uint c)+ {+ static double Ch(double v) { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.Pow((v + 0.055) / 1.055, 2.4); }+ return 0.2126 * Ch((c >> 16) & 0xFF) + 0.7152 * Ch((c >> 8) & 0xFF) + 0.0722 * Ch(c & 0xFF);+ }++ /// <summary>CIE76 colour distance.</summary>+ public static double DeltaE(uint a, uint b)+ {+ static (double L, double A, double B) Lab(uint c)+ {+ static double Lin(double v) { v /= 255; return v <= 0.04045 ? v / 12.92 : Math.Pow((v + 0.055) / 1.055, 2.4); }+ static double F(double t) => t > 0.008856 ? Math.Cbrt(t) : 7.787 * t + 16.0 / 116;+ double r = Lin((c >> 16) & 0xFF), g = Lin((c >> 8) & 0xFF), bl = Lin(c & 0xFF);+ double x = (r * .4124 + g * .3576 + bl * .1805) / .95047, y = r * .2126 + g * .7152 + bl * .0722,+ z = (r * .0193 + g * .1192 + bl * .9505) / 1.08883;+ return (116 * F(y) - 16, 500 * (F(x) - F(y)), 200 * (F(y) - F(z)));+ }+ var (l1, a1, b1) = Lab(a); var (l2, a2, b2) = Lab(b);+ return Math.Sqrt((l1 - l2) * (l1 - l2) + (a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2));+ }+}diff --git a/src/managed/Nota.Application/Themes/ThemeFolder.cs b/src/managed/Nota.Application/Themes/ThemeFolder.csnew file mode 100644index 00000000..52907eb2--- /dev/null+++ b/src/managed/Nota.Application/Themes/ThemeFolder.cs@@ -0,0 +1,85 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The user themes folder (spec 087): every *.json file in it, read in a fixed order and+// validated, with a plain reason for each one that cannot be worn. Never throws — a bad+// file is a line in the problems list, not an error dialog. Pure, so the smoke test checks+// the same rules the app runs.++using Nota.Application.Localization;++namespace Nota.Application.Themes;++public sealed record ThemeFolderEntry(string FileName, string Path, ThemeValidation Validation);++public sealed record ThemeFolderScan(IReadOnlyList<ThemeFolderEntry> Loaded, IReadOnlyList<(string FileName, string Reason)> Problems);++public static class ThemeFolder+{+ /// <summary>Read <paramref name="dir"/>. A file loads when it validates and its id is neither+ /// <paramref name="reservedId"/> (a built-in) nor the id of an earlier file (ordinal file-name+ /// order). A missing folder is an empty one.</summary>+ public static ThemeFolderScan Scan(string dir, IReadOnlyList<string> catalogue, IReadOnlySet<string> translucent,+ Func<string, bool> reservedId, Func<string, bool>? fontInstalled = null)+ {+ var loaded = new List<ThemeFolderEntry>();+ var problems = new List<(string, string)>();+ string[] files;+ try { files = Directory.Exists(dir) ? Directory.GetFiles(dir, "*.json") : Array.Empty<string>(); }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException)+ {+ problems.Add((dir, Loc.F("themes.problem.folder_unreadable", e.Message)));+ return new(loaded, problems);+ }+ Array.Sort(files, StringComparer.Ordinal);++ var ids = new HashSet<string>();+ foreach (var path in files)+ {+ var file = System.IO.Path.GetFileName(path);+ string json;+ try+ {+ var len = new FileInfo(path).Length;+ if (len > ThemeFile.MaxFileBytes)+ {+ problems.Add((file, Loc.F("themes.problem.too_large", ThemeFile.MaxFileBytes / 1024)));+ continue;+ }+ json = File.ReadAllText(path);+ }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException)+ {+ problems.Add((file, Loc.F("themes.problem.file_unreadable", e.Message)));+ continue;+ }++ var v = ThemeFile.Validate(json, catalogue, translucent, fontInstalled);+ if (!v.IsValid)+ {+ problems.Add((file, Describe(v.Problems)));+ continue;+ }+ var id = v.Theme!.Id;+ if (reservedId(id))+ {+ problems.Add((file, Loc.F("themes.problem.builtin_id", id)));+ continue;+ }+ if (!ids.Add(id))+ {+ problems.Add((file, Loc.F("themes.problem.duplicate_id", id)));+ continue;+ }+ loaded.Add(new(file, path, v));+ }+ return new(loaded, problems);+ }++ /// <summary>The first three problems in one line, then how many more.</summary>+ public static string Describe(IReadOnlyList<ThemeProblem> problems)+ {+ var head = string.Join("; ", problems.Take(3).Select(p => p.Message));+ return problems.Count > 3 ? Loc.F("themes.problem.and_more", head, problems.Count - 3) : head;+ }+}diff --git a/src/managed/Nota.Mcp/Abstractions.cs b/src/managed/Nota.Mcp/Abstractions.csindex 9007f4c3..3868f9c4 100644--- a/src/managed/Nota.Mcp/Abstractions.cs+++ b/src/managed/Nota.Mcp/Abstractions.cs@@ -70,3 +70,42 @@ public interface IProjectKeyAccess{int KeyCode { get; set; }}++/// <summary>Facade over the app's colour themes for the theme tools (spec 087): list, read,+/// validate, preview, save, wear and try on themes — without referencing Nota.App. Implemented+/// in Nota.App over NotaThemes / NotaThemeService; every member runs on the UI thread (call it+/// inside <see cref="IEngineDispatch.InvokeAsync{T}"/>).</summary>+public interface IThemeAccess+{+ ThemeListing List();+ /// <summary>A listed theme's file text (format 1 or 2), or null for an unknown id.</summary>+ string? GetFile(string id);+ ThemeCatalogue Catalogue();+ IReadOnlyList<string> SystemFonts();+ Nota.Application.Themes.ThemeValidation Validate(string json);+ /// <summary>Images of <paramref name="json"/> worn on the named surfaces (all when null),+ /// rendered offscreen; the live window does not change. Nothing is rendered for an invalid theme.</summary>+ Task<ThemePreviews> PreviewAsync(string json, IReadOnlyList<string>? surfaces, bool themeAccent);+ ThemeSaveResult Save(string json, bool overwrite);+ /// <summary>Wear a listed theme and store it, as a pick in Preferences. Null, or why not.</summary>+ string? Apply(string id);+ /// <summary>Wear <paramref name="json"/> live without storing it. Whether it is worn.</summary>+ bool TryOn(string json, out Nota.Application.Themes.ThemeValidation validation);+ /// <summary>End a try-on; the id worn afterwards.</summary>+ string RevertTryOn();+}++public sealed record ThemeListing(ThemeListEntry[] Themes, string Worn, bool TryOn, ThemeChoiceInfo Choice, ThemeFileProblem[] Problems);+public sealed record ThemeListEntry(string Id, string Name, string Kind, string Source, int Warnings, bool FontMissing,+ string? FontFamily, double Roundness);+public sealed record ThemeChoiceInfo(bool FollowSystem, string Single, string Dark, string Light);+public sealed record ThemeFileProblem(string File, string Reason);+public sealed record ThemeTokenInfo(string Name, string Group, string Role, bool Translucent);+public sealed record ThemeRadiusStepInfo(string Name, double Design);+/// <summary>The accepted limits, each as [min, max]: radius scale, a radius step in px, the font family name's length.</summary>+public sealed record ThemeRanges(double[] Scale, double[] Step, int[] FontFamilyLength);+public sealed record ThemeCatalogue(ThemeTokenInfo[] Tokens, ThemeRadiusStepInfo[] RadiusSteps, ThemeRanges Ranges, int[] FormatVersions);+public sealed record ThemePreviewImage(string Name, string Description, byte[] Png);+public sealed record ThemePreviews(Nota.Application.Themes.ThemeValidation Validation, ThemePreviewImage[] Images,+ string[] Rendered, string[] Unknown);+public sealed record ThemeSaveResult(Nota.Application.Themes.ThemeValidation Validation, bool Saved, string? File, string? Reason);diff --git a/src/managed/Nota.Mcp/Tools/ThemeTools.cs b/src/managed/Nota.Mcp/Tools/ThemeTools.csnew file mode 100644index 00000000..0360bfbb--- /dev/null+++ b/src/managed/Nota.Mcp/Tools/ThemeTools.cs@@ -0,0 +1,152 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// MCP tools — colour themes and skins (spec 087, issue #336): a client (an AI helping someone+// turn a palette into a usable skin) reads a theme as a template, changes it, validates it,+// gets back one image per part of the app showing how it looks, and saves or wears it. The+// theme travels as the theme file's own JSON text, so what a client sends is exactly what it+// would save. A malformed theme is a validation result, never an error across the transport.++using System.ComponentModel;+using System.Text.Json;+using ModelContextProtocol.Protocol;+using ModelContextProtocol.Server;+using Nota.Application;+using Nota.Application.Themes;++namespace Nota.Mcp.Tools;++[McpServerToolType]+public sealed class ThemeTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh, IThemeAccess themes)+ : EngineTools(engine, dispatch, refresh)+{+ private const string Format =+ "A theme is the JSON text of a theme file: { \"formatVersion\": 1 or 2, \"id\": \"lower-case-hyphenated\", \"name\": \"1–40 chars\", "+ + "\"kind\": \"dark\"|\"light\", \"colors\": { every token: \"#RRGGBB\" (or #AARRGGBB where the catalogue allows translucency) } }. "+ + "Format 2 may add \"font\": { \"family\": \"<installed font>\" } and \"radius\": { \"scale\": 0–2, \"steps\": { \"card\": px, … } }.";++ public sealed record Problem(+ [property: Description("Rule broken: F1–F6 (format, id, name, kind, tokens, colours), V1–V4 (font/radius), JSON")] string Rule,+ [property: Description("Token or key path, e.g. colors.Panel or radius.scale")] string? Field,+ string Message);++ public sealed record Warning(+ [property: Description("readability (a contrast or colour-distance pairing below its minimum) or font-missing")] string Kind,+ [property: Description("Readability pairing id, T3.1–T3.9 (specs/011 ui-contract)")] string? Pairing,+ [property: Description("The tokens involved (for font-missing: the family)")] string[] Tokens,+ [property: Description("WCAG contrast ratio, or CIE76 ΔE for T3.7/T3.8")] double Measured,+ double Minimum, string Message);++ public sealed record ValidationResult(+ [property: Description("True when the theme can be saved and worn (warnings don't block)")] bool Valid,+ Problem[] Problems, Warning[] Warnings);++ public sealed record SaveResult(ValidationResult Validation, bool Saved,+ [property: Description("The file written in Nota's themes folder")] string? File, string? Reason);++ public sealed record TryOnResult(ValidationResult Validation, bool Wearing);++ public sealed record WornResult(string Worn);++ private static ValidationResult Result(ThemeValidation v) => new(+ v.IsValid,+ v.Problems.Select(p => new Problem(p.Rule, p.Field, p.Message)).ToArray(),+ v.Warnings.Select(w => new Warning(w.Kind, w.Pairing, w.Tokens.ToArray(), w.Measured, w.Minimum, w.Message)).ToArray());++ [McpServerTool(Name = "list_themes"), Description(+ "List Nota's colour themes (skins): the built-ins and the user themes in the themes folder, with kind, warnings, "+ + "typeface and roundness; which one is worn now (and whether it is a try-on); the stored Appearance choice; and "+ + "the theme files that could not be loaded, with the reason.")]+ public Task<ThemeListing> ListThemes() => Read(themes.List);++ [McpServerTool(Name = "get_theme"), Description(+ "Read one theme's file (JSON text, tokens in catalogue order). Use a built-in as the template for a new skin: "+ + "change the id and name, then the colours (and, in formatVersion 2, font and radius).")]+ public async Task<string> GetTheme([Description("Theme id from list_themes, e.g. studio-dark")] string id) =>+ await Read(() => themes.GetFile(id)) ?? throw new ArgumentException($"No theme '{id}' — see list_themes.");++ [McpServerTool(Name = "get_theme_catalogue"), Description(+ "The colour tokens every theme must define, in file order, each with its group, what it colours, and whether it may "+ + "be translucent; the radius steps with their design values in px; the accepted ranges ([min, max]) for the radius "+ + "scale, a radius step in px and the font family name's length; the supported format versions. "+ + "Readability is checked on text tokens over the surfaces (contrast ≥ 4.5 for TextPrimary/Secondary/Muted, …), "+ + "on ink over Accent/Mute/Solo/Record and the track colours, and on how distinct the track colours are.")]+ public Task<ThemeCatalogue> GetThemeCatalogue() => Read(themes.Catalogue);++ [McpServerTool(Name = "list_system_fonts"), Description(+ "The font families installed on this computer — a skin's font.family must be one of them, or Nota uses its own Geist.")]+ public async Task<string[]> ListSystemFonts() => (await Read(themes.SystemFonts)).ToArray();++ [McpServerTool(Name = "validate_theme"), Description(+ "Check a theme without saving or showing it: every format problem (each naming the token or key) and every "+ + "readability warning (pairing, tokens, measured vs minimum). Cheap — call it after each change. " + Format)]+ public async Task<ValidationResult> ValidateTheme([Description("The theme file's JSON text")] string theme) =>+ Result(await Read(() => themes.Validate(theme)));++ [McpServerTool(Name = "preview_theme"), Description(+ "Render how Nota looks in a theme: one PNG per part of the app (overview, top-bar, arrangement, mixer, device-rack, "+ + "piano-roll, browser, preferences, menu, dialog), from a fixed sample project, offscreen — the user's window does "+ + "not change and nothing is saved. Takes a few seconds. The first content block is the validation as JSON; then, "+ + "per part, its name and description followed by the image. An invalid theme returns only the validation. " + Format)]+ public async Task<CallToolResult> PreviewTheme(+ [Description("The theme file's JSON text")] string theme,+ [Description("Only these parts (names as listed above); all when omitted")] string[]? surfaces = null,+ [Description("\"user\" (default): with the accent colour the user picked, as the skin would really look; "+ + "\"theme\": with the theme's own accent")] string? accent = null)+ {+ var result = await await Read(() => themes.PreviewAsync(theme, surfaces, string.Equals(accent, "theme", StringComparison.OrdinalIgnoreCase)));+ var head = new+ {+ validation = Result(result.Validation),+ rendered = result.Rendered,+ unknown = result.Unknown,+ };+ var content = new List<ContentBlock>+ {+ new TextContentBlock { Text = JsonSerializer.Serialize(head, JsonOptions) },+ };+ foreach (var image in result.Images)+ {+ content.Add(new TextContentBlock { Text = $"{image.Name} — {image.Description}" });+ content.Add(ImageContentBlock.FromBytes(image.Png, "image/png"));+ }+ return new CallToolResult { Content = content, IsError = false };+ }++ [McpServerTool(Name = "save_theme"), Description(+ "Save a valid theme as a user theme (<id>.json in Nota's themes folder); it appears in Preferences → Appearance "+ + "at once. Refused for an invalid theme, a built-in's id, or an existing user theme unless overwrite is true. "+ + "Saving does not wear it — call apply_theme. " + Format)]+ public async Task<SaveResult> SaveTheme(+ [Description("The theme file's JSON text")] string theme,+ [Description("Replace the user theme with the same id")] bool overwrite = false)+ {+ var r = await Read(() => themes.Save(theme, overwrite));+ return new SaveResult(Result(r.Validation), r.Saved, r.File, r.Reason);+ }++ [McpServerTool(Name = "apply_theme"), Description(+ "Wear a listed theme (built-in or user) and store the choice, as picking it in Preferences → Appearance, in "+ + "single-theme mode (Follow system is turned off, so this theme is the one on screen). "+ + "Ends any try-on.")]+ public async Task<WornResult> ApplyTheme([Description("Theme id from list_themes")] string id)+ {+ var error = await Read(() => themes.Apply(id));+ if (error is not null) throw new ArgumentException(error);+ return new WornResult(id);+ }++ [McpServerTool(Name = "try_on_theme"), Description(+ "Wear a theme live without saving or storing it, so the user can look at the real app. It lasts until "+ + "revert_try_on, a pick in Preferences, apply_theme or a restart. The user sees it — revert it if it isn't kept. " + Format)]+ public async Task<TryOnResult> TryOnTheme([Description("The theme file's JSON text")] string theme)+ {+ var (wearing, v) = await Read(() => (themes.TryOn(theme, out var validation), validation));+ return new TryOnResult(Result(v), wearing);+ }++ [McpServerTool(Name = "revert_try_on"), Description("End a try-on: Nota wears the stored theme again. Does nothing without a try-on.")]+ public async Task<WornResult> RevertTryOn() => new(await Read(themes.RevertTryOn));++ private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);+}diff --git a/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs b/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.csindex 49c49b44..10106c28 100644--- a/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs+++ b/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs@@ -327,8 +327,8 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable/// <summary>Why nothing is heard when no output device opened (the engine runs silently/// or not at all), else null.</summary>public string? NoAudioOutput- => !Engine.IsRunning ? Loc.T("main.no_audio_output_could_be")- : Engine.AudioSilentFallback ? Loc.T("main.no_audio_output_device_opened")+ => !Engine.IsRunning ? Loc.T("main.no_audio_output_could_be_opened_outputs")+ : Engine.AudioSilentFallback ? Loc.T("main.no_audio_output_device_opened_outputs"): null;/// <summary>diff --git a/tests/Nota.SmokeTest/DesignTokenCheck.Skins.cs b/tests/Nota.SmokeTest/DesignTokenCheck.Skins.csnew file mode 100644index 00000000..429ef596--- /dev/null+++ b/tests/Nota.SmokeTest/DesignTokenCheck.Skins.cs@@ -0,0 +1,174 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// User skins (spec 087): the shared theme-file validator (format 1 and 2), the skin+// geometry's radius mapping, and the user themes folder — as data, with no UI. The+// validator must agree with the independent spec-011 checks above on the built-ins, report+// every problem in a broken file naming its field, and never throw.++using System.Text.Json;+using System.Text.Json.Nodes;+using System.Text.RegularExpressions;+using Nota.Application.Themes;++namespace Nota.SmokeTest;++internal static partial class DesignTokenCheck+{+ public static IEnumerable<(bool Ok, string Label)> RunSkins()+ {+ var root = RepoRoot();+ if (root is null) { yield return (false, "repo root located"); yield break; }+ var app = Path.Combine(root, "src/managed/Nota.App");+ var palette = File.ReadAllText(Path.Combine(app, "Theme/NotaPalette.cs"));+ var catalogue = Regex.Matches(palette, @"\bT\((?:nameof\((?<n>\w+)\)|""(?<n>\w+)"")\)").Select(m => m.Groups["n"].Value)+ .Concat(ExtraTokens).ToList();+ var files = Directory.EnumerateFiles(Path.Combine(app, "Theme/Themes"), "*.json").OrderBy(f => f).ToList();++ // ---- the built-ins: valid, and the T3 port agrees with the spec-011 check ----------+ foreach (var file in files)+ {+ var id = Path.GetFileNameWithoutExtension(file);+ var json = File.ReadAllText(file);+ var v = ThemeFile.Validate(json, catalogue, AlphaTokens);+ yield return (v.IsValid && v.Theme!.Id == id && v.Theme.FormatVersion == 1 && v.Theme.Geometry.IsDefault,+ v.IsValid ? $"skins: built-in {id} validates (format 1, default geometry)" : $"skins: built-in {id} — {ThemeFolder.Describe(v.Problems)}");+ if (!v.IsValid) continue;+ var (data, _) = LoadTheme(json, catalogue.ToHashSet());+ int expected = Pairings(data!.Colors).Count(p => p.Value < p.Min - 1e-9);+ int got = v.Warnings.Count(w => w.Kind == ThemeWarning.Readability);+ yield return (got == expected, $"skins: {id} readability warnings match the spec-011 check ({got} = {expected})");++ // A low-contrast copy: both checks see the same failures.+ var node = JsonNode.Parse(json)!;+ node["colors"]!["TextMuted"] = data.Colors["Panel"];+ node["colors"]!["Track2"] = data.Colors["Track1"];+ var mutated = node.ToJsonString();+ var (mData, _) = LoadTheme(mutated, catalogue.ToHashSet());+ int mExpected = Pairings(mData!.Colors).Count(p => p.Value < p.Min - 1e-9);+ var mv = ThemeFile.Validate(mutated, catalogue, AlphaTokens);+ int mGot = mv.Warnings.Count(w => w.Kind == ThemeWarning.Readability);+ yield return (mv.IsValid && mGot == mExpected && mGot > 0+ && mv.Warnings.Any(w => w.Pairing == "T3.1" && w.Tokens.Contains("TextMuted"))+ && mv.Warnings.Any(w => w.Pairing == "T3.7"),+ $"skins: {id} with unreadable text still loads, with {mGot} warnings naming the pairings (spec-011 check: {mExpected})");++ // Write → Validate round-trips, colours and all.+ var back = ThemeFile.Validate(ThemeFile.Write(v.Theme!, catalogue), catalogue, AlphaTokens);+ yield return (back.IsValid && back.Theme!.Colors.Count == v.Theme!.Colors.Count+ && back.Theme.Colors.All(kv => v.Theme.Colors[kv.Key] == kv.Value),+ $"skins: {id} round-trips through the writer");+ }++ // ---- broken files: every problem reported, naming its field ----------------------+ var good = JsonNode.Parse(File.ReadAllText(files.First(f => f.EndsWith("studio-dark.json"))))!;+ JsonNode Copy() => JsonNode.Parse(good.ToJsonString())!;+ string With(Action<JsonNode> edit) { var n = Copy(); n["id"] = "my-skin"; edit(n); return n.ToJsonString(); }++ var cases = new (string What, string Json, string Field)[]+ {+ ("missing token", With(n => n["colors"]!.AsObject().Remove("Panel")), "colors.Panel"),+ ("unknown token", With(n => n["colors"]!["Sparkle"] = "#FFFFFF"), "colors.Sparkle"),+ ("bad hex", With(n => n["colors"]!["Panel"] = "#12345"), "colors.Panel"),+ ("translucent opaque token", With(n => n["colors"]!["Panel"] = "#80141310"), "colors.Panel"),+ ("bad id", With(n => n["id"] = "My Skin"), "id"),+ ("system id", With(n => n["id"] = "system"), "id"),+ ("bad kind", With(n => n["kind"] = "dusk"), "kind"),+ ("long name", With(n => n["name"] = new string('x', 41)), "name"),+ ("format 3", With(n => n["formatVersion"] = 3), "formatVersion"),+ ("v1 with font", With(n => n["font"] = new JsonObject { ["family"] = "Helvetica" }), "font"),+ ("scale 3", With(n => { n["formatVersion"] = 2; n["radius"] = new JsonObject { ["scale"] = 3 }; }), "radius.scale"),+ ("unknown step", With(n => { n["formatVersion"] = 2; n["radius"] = new JsonObject { ["steps"] = new JsonObject { ["huge"] = 4 } }; }), "radius.steps.huge"),+ ("step 30", With(n => { n["formatVersion"] = 2; n["radius"] = new JsonObject { ["steps"] = new JsonObject { ["card"] = 30 } }; }), "radius.steps.card"),+ ("empty family", With(n => { n["formatVersion"] = 2; n["font"] = new JsonObject { ["family"] = " " }; }), "font.family"),+ ("font as string", With(n => { n["formatVersion"] = 2; n["font"] = "Helvetica"; }), "font"),+ };+ foreach (var (what, json, field) in cases)+ {+ var v = ThemeFile.Validate(json, catalogue, AlphaTokens);+ yield return (!v.IsValid && v.Problems.Any(p => p.Field == field),+ $"skins: {what} is rejected naming {field}" + (v.IsValid ? " (but it validated)" : $" — {ThemeFolder.Describe(v.Problems)}"));+ }++ foreach (var (what, json) in new[] { ("invalid JSON", "{ \"formatVersion\": 1, "), ("an array", "[1,2]"), ("empty", "") })+ {+ ThemeValidation? v = null;+ Exception? ex = null;+ try { v = ThemeFile.Validate(json, catalogue, AlphaTokens); } catch (Exception e) { ex = e; }+ yield return (ex is null && v is { IsValid: false } && v.Problems.Count > 0, $"skins: {what} is a problem, not an exception");+ }++ var three = ThemeFile.Validate(With(n => { n["kind"] = "dusk"; n["colors"]!["Panel"] = "red"; n["colors"]!.AsObject().Remove("BgApp"); }), catalogue, AlphaTokens);+ yield return (three.Problems.Count >= 3 && three.Problems.Any(p => p.Field == "kind")+ && three.Problems.Any(p => p.Field == "colors.Panel") && three.Problems.Any(p => p.Field == "colors.BgApp"),+ $"skins: a file with three problems reports all of them ({three.Problems.Count})");++ // ---- format 2 parsed --------------------------------------------------------------+ var v2 = ThemeFile.Validate(With(n =>+ {+ n["formatVersion"] = 2;+ n["font"] = new JsonObject { ["family"] = "Helvetica" };+ n["radius"] = new JsonObject { ["scale"] = 0.5, ["steps"] = new JsonObject { ["card"] = 12, ["valueBar"] = 0 } };+ }), catalogue, AlphaTokens, fontInstalled: f => f == "Helvetica");+ var g = v2.Theme?.Geometry;+ yield return (v2.IsValid && g is not null && g.FontFamily == "Helvetica" && g.Roundness == 0.5+ && g.RadiusOf(RadiusStep.Card) == 12 && g.RadiusOf(RadiusStep.ValueBar) == 0 && g.RadiusOf(RadiusStep.Group) == 4+ && !v2.Warnings.Any(w => w.Kind == ThemeWarning.FontMissing),+ "skins: format 2 reads the typeface, the roundness and step overrides");+ var missingFont = ThemeFile.Validate(With(n => { n["formatVersion"] = 2; n["font"] = new JsonObject { ["family"] = "No Such Font" }; }),+ catalogue, AlphaTokens, fontInstalled: _ => false);+ yield return (missingFont.IsValid && missingFont.Warnings.Any(w => w.Kind == ThemeWarning.FontMissing),+ "skins: a typeface that is not installed is a warning, and the theme still loads");+ var round = ThemeFile.Validate(ThemeFile.Write(v2.Theme!, catalogue), catalogue, AlphaTokens);+ yield return (round.IsValid && round.Theme!.FormatVersion == 2 && round.Theme.Geometry.Equals(g),+ "skins: a format-2 theme round-trips through the writer");++ // ---- geometry ---------------------------------------------------------------------+ var steps = Enum.GetValues<RadiusStep>();+ var square = new SkinGeometry(null, 0, new Dictionary<RadiusStep, double>());+ var double2 = new SkinGeometry(null, 2, new Dictionary<RadiusStep, double> { [RadiusStep.Fine] = 1 });+ yield return (steps.All(s => SkinGeometry.Default.MapRadius(SkinGeometry.Design(s)) == SkinGeometry.Design(s))+ && SkinGeometry.Default.MapRadius(12) == 12,+ "skins: the default geometry maps every radius to itself");+ yield return (steps.All(s => square.MapRadius(SkinGeometry.Design(s)) == 0) && square.MapRadius(12) == 0 && square.MapRadius(0) == 0,+ "skins: roundness 0 squares every corner");+ yield return (double2.MapRadius(9) == 18 && double2.MapRadius(2) == 1 && double2.MapRadius(0) == 0 && double2.MapRadius(11) == 22,+ "skins: roundness 2 doubles the scale; a step override wins; off-scale radii scale");+ yield return (steps.Select(SkinGeometry.Design).Distinct().Count() == steps.Length,+ "skins: the design radius steps are distinct (a value names its step)");+ var geometry = File.ReadAllText(Path.Combine(app, "Theme/NotaGeometry.cs"));+ var mismatch = steps.Where(s => !Regex.IsMatch(geometry, $@"RadiusStep\.{s}\b")).ToArray();+ yield return (mismatch.Length == 0,+ mismatch.Length == 0 ? "skins: NotaRadius reads every step through the skin" : $"skins: NotaRadius does not use step(s) {string.Join(", ", mismatch)}");++ // ---- ids --------------------------------------------------------------------------+ var taken = new HashSet<string> { "studio-dark-copy" };+ yield return (ThemeFile.FreeId("Studio Dark copy", taken.Contains) == "studio-dark-copy-2"+ && ThemeFile.FreeId("Café Noir", _ => false) == "cafe-noir" && ThemeFile.FreeId("???", _ => false) == "theme",+ "skins: a duplicate's id is a free slug of its name");++ // ---- the folder -------------------------------------------------------------------+ var dir = Path.Combine(Path.GetTempPath(), "nota-skins-" + Guid.NewGuid().ToString("N")[..8]);+ Directory.CreateDirectory(dir);+ ThemeFolderScan scan;+ try+ {+ File.WriteAllText(Path.Combine(dir, "a.json"), With(n => n["name"] = "A"));+ File.WriteAllText(Path.Combine(dir, "b.json"), With(n => n["name"] = "B")); // same id as a.json+ File.WriteAllText(Path.Combine(dir, "c.json"), With(n => n["id"] = "studio-dark")); // a built-in id+ File.WriteAllText(Path.Combine(dir, "d.json"), With(n => n["colors"]!["Panel"] = "nope")); // invalid+ File.WriteAllText(Path.Combine(dir, "e.json"), new string(' ', ThemeFile.MaxFileBytes + 1)); // too large+ File.WriteAllText(Path.Combine(dir, "notes.txt"), "not a theme");+ scan = ThemeFolder.Scan(dir, catalogue, AlphaTokens, id => id == "studio-dark");+ }+ finally { Directory.Delete(dir, true); }+ string Reason(string file) => scan.Problems.FirstOrDefault(p => p.FileName == file).Reason ?? "";+ yield return (scan.Loaded.Count == 1 && scan.Loaded[0].FileName == "a.json",+ $"skins: the folder loads the one good file ({string.Join(", ", scan.Loaded.Select(l => l.FileName))})");+ yield return (Reason("b.json").Contains("duplicate id") && Reason("c.json").Contains("built-in")+ && Reason("d.json").Contains("Panel") && Reason("e.json").Contains("larger") && scan.Problems.Count == 4,+ "skins: duplicate, built-in id, invalid and oversized files are reported by name; other files are ignored");+ var none = ThemeFolder.Scan(Path.Combine(dir, "missing"), catalogue, AlphaTokens, _ => false);+ yield return (none.Loaded.Count == 0 && none.Problems.Count == 0, "skins: a missing folder is an empty one");+ }+}diff --git a/tests/Nota.SmokeTest/DesignTokenCheck.cs b/tests/Nota.SmokeTest/DesignTokenCheck.csindex 30e3b27b..75d2abb9 100644--- a/tests/Nota.SmokeTest/DesignTokenCheck.cs+++ b/tests/Nota.SmokeTest/DesignTokenCheck.cs@@ -89,10 +89,13 @@ internal static partial class DesignTokenCheckforeach (Match m in Regex.Matches(theme, """x:Key="(?<key>(?:Radius|Control|Space)\.\w+)">(?<v>[0-9.]+)<"""))xaml[m.Groups["key"].Value] = double.Parse(m.Groups["v"].Value, System.Globalization.CultureInfo.InvariantCulture);- // C# side: NotaRadius.<Name>Value, NotaSize.<Name>, NotaSpace.<Name>+ // C# side: the radius scale (SkinGeometry.Design — spec 087 moved it there so skins can+ // re-round it; NotaRadius.DockedValue stays a constant), NotaSize.<Name>, NotaSpace.<Name>var cs = new Dictionary<string, double>(StringComparer.Ordinal);foreach (Match m in Regex.Matches(geo, @"\b(?<name>\w+)Value\s*=\s*(?<v>[0-9.]+)"))cs["Radius." + m.Groups["name"].Value] = double.Parse(m.Groups["v"].Value, System.Globalization.CultureInfo.InvariantCulture);+ foreach (var step in Enum.GetValues<Nota.Application.Themes.RadiusStep>())+ cs["Radius." + step] = Nota.Application.Themes.SkinGeometry.Design(step);foreach (var (cls, prefix) in new[] { ("NotaSize", "Control."), ("NotaSpace", "Space.") }){var body = Regex.Match(geo, $@"class {cls}\s*\{{(?<b>.*?)\n\}}", RegexOptions.Singleline).Groups["b"].Value;@@ -390,8 +393,10 @@ internal static partial class DesignTokenCheck// Hex strings that are data rather than tokens: tag swatches the library stores, and// two device hue tables. Each is only ever painted through NotaPalette.Ink().var hexData = new[] { "TagEditorWindow.cs", "DeviceCards/Bodies/StrataDeviceBody.cs", "DeviceCards/Instruments/RhythmInstrumentCard.cs" };- // Opacity is allowed for exactly one thing: the ghost of a card being dragged.- var dragGhost = new Regex(@"\b(card|_devDragCard|_rcDragCard)\.Opacity = (0\.55|1\.0);");+ // Opacity is allowed for exactly one thing: the ghost of a card being dragged — and,+ // not being a look at all, the skin previews' host windows (spec 087), shown off screen+ // and fully transparent so their views lay out; only their content is drawn.+ var dragGhost = new Regex(@"\b(card|_devDragCard|_rcDragCard)\.Opacity = (0\.55|1\.0);|^\s*host\.Opacity = 0;");var rules = new (string Name, Regex Re, Func<string, string, bool>? Allow)[]{diff --git a/tests/Nota.SmokeTest/LocalizationAllowList.txt b/tests/Nota.SmokeTest/LocalizationAllowList.txtindex 63352708..a1965fbc 100644--- a/tests/Nota.SmokeTest/LocalizationAllowList.txt+++ b/tests/Nota.SmokeTest/LocalizationAllowList.txt@@ -2131,18 +2131,10 @@ Nota.App/PreferencesWindow.cs Return # data: key name shown on a key cap (the keNota.App/PreferencesWindow.cs Shortcuts # data: stable page id (Page.Id); the shown title is translatedNota.App/PreferencesWindow.cs Updates # data: stable page id (Page.Id); the shown title is translatedNota.App/SessionView.Mixer.cs Ext Out 1/2 # data: hardware output name-Nota.App/Theme/NotaColourTheme.cs $"invalid id '{id}'" # data: diagnostics for people writing a theme file-Nota.App/Theme/NotaColourTheme.cs $"kind must be dark or light, not '{kindText}'" # data: diagnostics for people writing a theme file-Nota.App/Theme/NotaColourTheme.cs $"token '{p.Name}' has invalid colour '{hex}'" # data: diagnostics for people writing a theme file-Nota.App/Theme/NotaColourTheme.cs $"token '{p.Name}' must be opaque" # data: diagnostics for people writing a theme file-Nota.App/Theme/NotaColourTheme.cs $"unknown token '{p.Name}'" # data: diagnostics for people writing a theme fileNota.App/Theme/NotaColourTheme.cs $"{id}: file declares id '{theme.Id}'" # data: diagnostics for people writing a theme fileNota.App/Theme/NotaColourTheme.cs $"{id}: no theme file" # data: diagnostics for people writing a theme fileNota.App/Theme/NotaColourTheme.cs Bevel # data: theme token nameNota.App/Theme/NotaColourTheme.cs Well # data: theme token name-Nota.App/Theme/NotaColourTheme.cs colors missing # data: technical validation message for a theme file-Nota.App/Theme/NotaColourTheme.cs name must be 1–40 characters # data: diagnostics for people writing a theme file-Nota.App/Theme/NotaColourTheme.cs the file must hold one JSON object # data: diagnostics for people writing a theme fileNota.App/Theme/NotaTextSize.cs Fixed # data: attached property nameNota.App/WelcomeWindow.cs $" · {NotaNum.Unit(p.Fraction * 100, " # data: numbers and units onlyNota.App/WelcomeWindow.cs $"{(p.Fraction * size).ToString(" # data: numbers and units only@@ -2522,14 +2514,14 @@ Nota.Application/Palette/CommandCatalog.cs overdub replace take pass loop recordNota.Application/Palette/CommandCatalog.cs pitch shift # data: search keyword or alias of the palette and the browser, not shownNota.Application/Palette/CommandCatalog.cs play row # data: search keyword or alias of the palette and the browser, not shownNota.Application/Palette/CommandCatalog.cs preferences controller keyboard # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)-Nota.Application/Palette/CommandCatalog.cs preferences device driver sample rate buffer # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences driver asio sample rate buffer latency cpu # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs preferences folders # data: search keyword or alias of the palette and the browser, not shownNota.Application/Palette/CommandCatalog.cs preferences hotkeys keys keyboard # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs preferences joystick controller # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs preferences options # data: search keyword or alias of the palette and the browser, not shownNota.Application/Palette/CommandCatalog.cs preferences phone # data: search keyword or alias of the palette and the browser, not shownNota.Application/Palette/CommandCatalog.cs preferences store models sample packs # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)-Nota.Application/Palette/CommandCatalog.cs preferences theme dark light language langue francais english # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences theme dark light skin accent scale text size waveform # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs preferences update automatic check version # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs quantise grid snap align # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)Nota.Application/Palette/CommandCatalog.cs quit close leave # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)@@ -2691,4 +2683,52 @@ Nota.Presentation/ViewModels/BrowserViewModel.cs MIDI Effects # data: identifierNota.Presentation/ViewModels/BrowserViewModel.cs Nota # data: identifier compared in codeNota.App/Controls/ReverbViews.cs Decay # data: device parameter, port and value names and live readouts of their values (FR-004)-Nota.App/Controls/ReverbViews.cs Decay # data: device parameter, port and value names and live readouts of their values (FR-004)\ No newline at end of file+Nota.App/Controls/ReverbViews.cs Decay # data: device parameter, port and value names and live readouts of their values (FR-004)+Nota.App/Mcp/ThemeAccess.cs $"'{id}' is a built-in theme — give the theme its own id" # data: MCP tools are not translated+Nota.App/Mcp/ThemeAccess.cs $"a user theme '{id}' exists — pass overwrite to replace it" # data: MCP tools are not translated+Nota.App/Mcp/ThemeAccess.cs the theme is not valid — see the problems # data: MCP tools are not translated+Nota.App/Skins/SampleScene.cs Bass # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Beat # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Chords # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Drums # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Hook # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Keys # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Lead # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Pad # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Reverb # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SampleScene.cs Texture # data: names in the fixed sample project the skin previews draw+Nota.App/Skins/SkinPreviewRenderer.cs A confirmation dialog with a primary and a secondary button # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs A track context menu: rows with icons and shortcuts, a submenu, a separator # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs Appearance # data: a page id and a control name, not shown+Nota.App/Skins/SkinPreviewRenderer.cs Arrangement: track headers, MIDI and audio clips in the track colours, an automation lane # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs Browser # data: a page id and a control name, not shown+Nota.App/Skins/SkinPreviewRenderer.cs Device rack: an instrument and two audio effects as device cards # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs Mixer: channel strips with sends, a return and the master # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs Piano roll: chords on the keyboard grid with the velocity lane # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs Preferences → Appearance: the theme cards, accent, scale and text size # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs The browser as it is now: categories, the list and the search field (the user's library) # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs The main window as it is now: top bar, browser, arrangement and the detail panel (the user's open project) # data: MCP tools are not translated+Nota.App/Skins/SkinPreviewRenderer.cs The transport row: transport keys, position, tempo, view switches, CPU (live values) # data: MCP tools are not translated+Nota.Application/Themes/ThemeFile.cs Accent # data: theme token name+Nota.Application/Themes/ThemeFile.cs Mute # data: theme token name+Nota.Application/Themes/ThemeFile.cs Panel # data: theme token name+Nota.Application/Themes/ThemeFile.cs Record # data: theme token name+Nota.Application/Themes/ThemeFile.cs Solo # data: theme token name+Nota.Application/Themes/ThemeFile.cs Success # data: theme token name+Nota.App/MainWindow.AudioFormat.cs Inputs # data: page id passed to ShowPreferencesPage+Nota.App/MainWindow.Commands.cs Editing # data: page id passed to ShowPreferencesPage+Nota.App/MainWindow.Commands.cs Inputs # data: page id passed to ShowPreferencesPage+Nota.App/MainWindow.Commands.cs Language # data: page id passed to ShowPreferencesPage+Nota.App/MainWindow.Commands.cs Outputs # data: page id passed to ShowPreferencesPage+Nota.App/PreferencesWindow.AudioIo.cs Audio # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.Downloads.cs Downloads # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.Remote.cs Remote # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.cs Editing # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.cs Inputs # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.cs Language # data: stable page id (Page.Id); the shown title is translated+Nota.App/PreferencesWindow.cs Outputs # data: stable page id (Page.Id); the shown title is translated+Nota.Application/Palette/CommandCatalog.cs preferences ai mcp claude assistant server port # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences input device channels microphone names stereo pairs # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences language langue francais english russian # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences output device speakers headphones test tone # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)+Nota.Application/Palette/CommandCatalog.cs preferences piano roll note names labels split fades detail panel # data: search keywords, device and node names, category ids (FR-004; what is drawn goes through Loc)\ No newline at end of filediff --git a/tests/Nota.SmokeTest/PaletteTests.cs b/tests/Nota.SmokeTest/PaletteTests.csindex 804970c1..472f8f62 100644--- a/tests/Nota.SmokeTest/PaletteTests.cs+++ b/tests/Nota.SmokeTest/PaletteTests.cs@@ -344,6 +344,17 @@ internal static class PaletteTests: $"commands without a handler: {string.Join(", ", unbound)}");var prefs = File.ReadAllText(Path.Combine(app, "PreferencesWindow.cs"));+ // Settings pages are opened by id (specs/088): every prefs.* command names a page in the+ // sidebar, and every page has its command.+ var pageIds = System.Text.RegularExpressions.Regex.Matches(prefs, "new Page\\(\"([^\"]+)\"").Select(m => m.Groups[1].Value).ToHashSet();+ var prefCmds = System.Text.RegularExpressions.Regex.Matches(bindings, "\\(\"(prefs\\.[a-z]+)\", \"([^\"]+)\"\\)")+ .Select(m => (Cmd: m.Groups[1].Value, Page: m.Groups[2].Value)).ToList();+ var badPages = prefCmds.Where(c => !pageIds.Contains(c.Page)).Select(c => $"{c.Cmd} → {c.Page}")+ .Concat(pageIds.Where(id => prefCmds.All(c => c.Page != id)).Select(id => $"no command for {id}")).ToList();+ yield return (pageIds.Count >= 15 && badPages.Count == 0, badPages.Count == 0+ ? $"every Settings page ({pageIds.Count}) has its palette command and every command its page"+ : $"Settings pages and commands disagree: {string.Join(", ", badPages)}");+var listed = System.Text.RegularExpressions.Regex.Matches(prefs, "\\(\"([^\"]+)\",\\s*(?:Loc\\.T\\()?\"").Select(m => m.Groups[1].Value).SelectMany(k => k.Split(' ', StringSplitOptions.RemoveEmptyEntries)).Select(Canon).ToHashSet();var missing = catalog.Where(c => c.Gesture.Length > 0 && !listed.Contains(Canon(c.Gesture))).Select(c => $"{c.Gesture} ({c.Title})").ToList();diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 5e0edffc..f0d4029f 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -97,6 +97,8 @@ if (args.Contains("--hosted-render-pool"))foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunStudio()) Check(ok, label);Console.WriteLine("-- design: themes --");foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunThemes()) Check(ok, label);+ Console.WriteLine("-- design: user skins --");+ foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunSkins()) Check(ok, label);Console.WriteLine("-- design: splash art --");foreach (var (ok, label) in Nota.SmokeTest.SplashArtTests.Run()) Check(ok, label);Console.WriteLine("-- design: appearance --");