Przeglądaj źródła

UI: design tokens, LookAndFeel, icon set and translation infrastructure

Theme.h is the single source of colours (backgrounds by elevation, text, red
accent, semantic colours), type sizes, spacing and radii; Theme.cpp draws every
stock JUCE widget with them. Icons.cpp holds LYNX's own juce::Path icons and an
IconButton. I18n.cpp adds tr() over JUCE LocalisedStrings with tables embedded
from resources/i18n (tools/make_i18n.py), plus tools/i18n_keys.py.
Kauan 1 miesiąc temu
rodzic
commit
ff9ddcbfdb
12 zmienionych plików z 1858 dodań i 37 usunięć
  1. 4 1
      CMakeLists.txt
  2. 11 0
      resources/i18n/pt-BR.txt
  3. 1 1
      scripts/build-windows-zig.sh
  4. 94 0
      src/ui/I18n.cpp
  5. 45 0
      src/ui/I18n.h
  6. 39 0
      src/ui/I18nData.h
  7. 463 0
      src/ui/Icons.cpp
  8. 58 0
      src/ui/Icons.h
  9. 851 0
      src/ui/Theme.cpp
  10. 199 35
      src/ui/Theme.h
  11. 72 0
      tools/i18n_keys.py
  12. 21 0
      tools/make_i18n.py

+ 4 - 1
CMakeLists.txt

@@ -105,7 +105,10 @@ if(LYNX_BUILD_APP)
         src/ui/ExportDialog.cpp
         src/ui/AutomationUi.cpp
         src/ui/ChannelSettings.cpp
-        src/ui/BrowserComponent.cpp)
+        src/ui/BrowserComponent.cpp
+        src/ui/Theme.cpp
+        src/ui/Icons.cpp
+        src/ui/I18n.cpp)
 
     target_include_directories(LYNX PRIVATE third_party/asiosdk/common)
 

+ 11 - 0
resources/i18n/pt-BR.txt

@@ -0,0 +1,11 @@
+language: Português (Brasil)
+countries: br
+
+# LYNX interface in Brazilian Portuguese (JUCE LocalisedStrings format).
+# One line per string: "English text" = "Texto em português"  (escapes: \n \t \" \\)
+# English is the source language; tools/i18n_keys.py --missing lists strings still untranslated.
+# After editing, run: python3 tools/make_i18n.py  (embeds this file in src/ui/I18nData.h)
+#
+# Glossary: Channel Rack, Piano Roll, Playlist, Mixer and Browser are proper names (not translated);
+# pattern, sample, plugin, preset, insert, send, step, slot, loop, stem, velocity stay as Brazilian
+# producers say them; track = faixa, bar = compasso, clip = clipe, automation = automação.

+ 1 - 1
scripts/build-windows-zig.sh

@@ -73,7 +73,7 @@ fi
 APP_SOURCES=(src/Main.cpp
              src/engine/AudioEngine.cpp src/engine/ChannelRackProcessor.cpp src/engine/Metronome.cpp
              src/engine/SampleLibrary.cpp src/engine/WavPackFormat.cpp src/engine/ProjectFile.cpp src/engine/PluginHost.cpp src/engine/PluginSandbox.cpp src/engine/Exporter.cpp src/engine/StreamPrefetcher.cpp src/engine/ClapFormat.cpp src/engine/MidiFileIo.cpp src/engine/PreviewPlayer.cpp
-             src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp
+             src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp src/ui/Theme.cpp src/ui/Icons.cpp src/ui/I18n.cpp
              src/core/Song.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp
              src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Vocodex.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/Harmless.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
              src/platform/MingwFixes.cpp)

+ 94 - 0
src/ui/I18n.cpp

@@ -0,0 +1,94 @@
+#include "ui/I18n.h"
+
+#include "engine/PluginHost.h"
+#include "ui/I18nData.h"
+
+namespace lynx
+{
+namespace
+{
+juce::String& currentId()
+{
+    static juce::String id { "en" };
+    return id;
+}
+
+juce::File settingsFile()
+{
+    return PluginHost::settingsFolder().getChildFile ("language.txt");
+}
+
+bool isKnown (const juce::String& id)
+{
+    for (const auto& l : i18n::languages())
+        if (id == l.id)
+            return true;
+    return false;
+}
+} // namespace
+
+juce::String tr (const juce::String& english)
+{
+    return juce::translate (english);
+}
+
+juce::String tr (const char* englishUtf8)
+{
+    return juce::translate (juce::String::fromUTF8 (englishUtf8));
+}
+
+juce::String tr (const char* englishUtf8, std::initializer_list<juce::String> args)
+{
+    auto text = tr (englishUtf8);
+    int i = 0;
+    for (const auto& a : args)
+        text = text.replace ("{" + juce::String (i++) + "}", a);
+    return text;
+}
+
+namespace i18n
+{
+const std::vector<Language>& languages()
+{
+    static const std::vector<Language> list { { "en", "English" }, { "pt-BR", "Portugu\xc3\xaas (Brasil)" } };
+    return list;
+}
+
+juce::String current()
+{
+    return currentId();
+}
+
+juce::String saved()
+{
+    const auto id = settingsFile().loadFileAsString().trim();
+    return isKnown (id) ? id : juce::String ("en");
+}
+
+void save (const juce::String& id)
+{
+    if (isKnown (id))
+        settingsFile().replaceWithText (id);
+}
+
+juce::String tableText (const juce::String& id)
+{
+    if (id == "pt-BR")
+        return juce::String::fromUTF8 ((const char*) data::ptBR, (int) sizeof (data::ptBR));
+    return {};
+}
+
+void initialise (const juce::StringArray& args)
+{
+    auto id = saved();
+    const auto flag = args.indexOf ("--lang");
+
+    if (flag >= 0 && isKnown (args[flag + 1].unquoted()))
+        id = args[flag + 1].unquoted();
+
+    currentId() = id;
+    const auto table = tableText (id);
+    juce::LocalisedStrings::setCurrentMappings (table.isEmpty() ? nullptr : new juce::LocalisedStrings (table, false));
+}
+} // namespace i18n
+} // namespace lynx

+ 45 - 0
src/ui/I18n.h

@@ -0,0 +1,45 @@
+#pragma once
+
+#include <initializer_list>
+#include <vector>
+
+#include <juce_core/juce_core.h>
+
+// Interface languages. English is the source language: every user-visible string is written in
+// English in the code and wrapped in tr(); the other languages are JUCE LocalisedStrings tables
+// embedded in the executable (resources/i18n/*.txt -> ui/I18nData.h, see tools/make_i18n.py).
+//
+// The tests scan the sources for string literals passed to tr() / TR_NOOP() and check that every one
+// has a non-empty entry in each translation file.
+
+// Marks a literal for translation without translating it (for tables translated later with tr()).
+#define TR_NOOP(text) text
+
+namespace lynx
+{
+// Translates an English UI string (UTF-8) into the current language.
+juce::String tr (const char* englishUtf8);
+juce::String tr (const juce::String& english);
+
+// Same, then replaces {0}, {1}... with `args` (the translation may reorder them).
+juce::String tr (const char* englishUtf8, std::initializer_list<juce::String> args);
+
+namespace i18n
+{
+struct Language
+{
+    const char* id;         // "en", "pt-BR"
+    const char* nativeName; // as shown in the Language menu
+};
+
+const std::vector<Language>& languages();
+
+juce::String current();                       // id of the language in use
+juce::String saved();                         // id stored in the settings (default "en")
+void save (const juce::String& id);           // applied at the next start
+void initialise (const juce::StringArray& commandLine); // --lang <id> overrides the saved setting
+
+// The embedded table for a language id (empty for English).
+juce::String tableText (const juce::String& id);
+} // namespace i18n
+} // namespace lynx

+ 39 - 0
src/ui/I18nData.h

@@ -0,0 +1,39 @@
+#pragma once
+
+// Generated by tools/make_i18n.py from resources/i18n/*.txt - do not edit by hand.
+
+namespace lynx::i18n::data
+{
+// resources/i18n/pt-BR.txt
+inline constexpr unsigned char ptBR[] = {
+108, 97, 110, 103, 117, 97, 103, 101, 58, 32, 80, 111, 114, 116, 117, 103, 117, 195, 170, 115, 32, 40, 66, 114,
+97, 115, 105, 108, 41, 10, 99, 111, 117, 110, 116, 114, 105, 101, 115, 58, 32, 98, 114, 10, 10, 35, 32, 76,
+89, 78, 88, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 32, 105, 110, 32, 66, 114, 97, 122, 105, 108, 105,
+97, 110, 32, 80, 111, 114, 116, 117, 103, 117, 101, 115, 101, 32, 40, 74, 85, 67, 69, 32, 76, 111, 99, 97,
+108, 105, 115, 101, 100, 83, 116, 114, 105, 110, 103, 115, 32, 102, 111, 114, 109, 97, 116, 41, 46, 10, 35, 32,
+79, 110, 101, 32, 108, 105, 110, 101, 32, 112, 101, 114, 32, 115, 116, 114, 105, 110, 103, 58, 32, 34, 69, 110,
+103, 108, 105, 115, 104, 32, 116, 101, 120, 116, 34, 32, 61, 32, 34, 84, 101, 120, 116, 111, 32, 101, 109, 32,
+112, 111, 114, 116, 117, 103, 117, 195, 170, 115, 34, 32, 32, 40, 101, 115, 99, 97, 112, 101, 115, 58, 32, 92,
+110, 32, 92, 116, 32, 92, 34, 32, 92, 92, 41, 10, 35, 32, 69, 110, 103, 108, 105, 115, 104, 32, 105, 115,
+32, 116, 104, 101, 32, 115, 111, 117, 114, 99, 101, 32, 108, 97, 110, 103, 117, 97, 103, 101, 59, 32, 116, 111,
+111, 108, 115, 47, 105, 49, 56, 110, 95, 107, 101, 121, 115, 46, 112, 121, 32, 45, 45, 109, 105, 115, 115, 105,
+110, 103, 32, 108, 105, 115, 116, 115, 32, 115, 116, 114, 105, 110, 103, 115, 32, 115, 116, 105, 108, 108, 32, 117,
+110, 116, 114, 97, 110, 115, 108, 97, 116, 101, 100, 46, 10, 35, 32, 65, 102, 116, 101, 114, 32, 101, 100, 105,
+116, 105, 110, 103, 44, 32, 114, 117, 110, 58, 32, 112, 121, 116, 104, 111, 110, 51, 32, 116, 111, 111, 108, 115,
+47, 109, 97, 107, 101, 95, 105, 49, 56, 110, 46, 112, 121, 32, 32, 40, 101, 109, 98, 101, 100, 115, 32, 116,
+104, 105, 115, 32, 102, 105, 108, 101, 32, 105, 110, 32, 115, 114, 99, 47, 117, 105, 47, 73, 49, 56, 110, 68,
+97, 116, 97, 46, 104, 41, 10, 35, 10, 35, 32, 71, 108, 111, 115, 115, 97, 114, 121, 58, 32, 67, 104, 97,
+110, 110, 101, 108, 32, 82, 97, 99, 107, 44, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 44, 32, 80,
+108, 97, 121, 108, 105, 115, 116, 44, 32, 77, 105, 120, 101, 114, 32, 97, 110, 100, 32, 66, 114, 111, 119, 115,
+101, 114, 32, 97, 114, 101, 32, 112, 114, 111, 112, 101, 114, 32, 110, 97, 109, 101, 115, 32, 40, 110, 111, 116,
+32, 116, 114, 97, 110, 115, 108, 97, 116, 101, 100, 41, 59, 10, 35, 32, 112, 97, 116, 116, 101, 114, 110, 44,
+32, 115, 97, 109, 112, 108, 101, 44, 32, 112, 108, 117, 103, 105, 110, 44, 32, 112, 114, 101, 115, 101, 116, 44,
+32, 105, 110, 115, 101, 114, 116, 44, 32, 115, 101, 110, 100, 44, 32, 115, 116, 101, 112, 44, 32, 115, 108, 111,
+116, 44, 32, 108, 111, 111, 112, 44, 32, 115, 116, 101, 109, 44, 32, 118, 101, 108, 111, 99, 105, 116, 121, 32,
+115, 116, 97, 121, 32, 97, 115, 32, 66, 114, 97, 122, 105, 108, 105, 97, 110, 10, 35, 32, 112, 114, 111, 100,
+117, 99, 101, 114, 115, 32, 115, 97, 121, 32, 116, 104, 101, 109, 59, 32, 116, 114, 97, 99, 107, 32, 61, 32,
+102, 97, 105, 120, 97, 44, 32, 98, 97, 114, 32, 61, 32, 99, 111, 109, 112, 97, 115, 115, 111, 44, 32, 99,
+108, 105, 112, 32, 61, 32, 99, 108, 105, 112, 101, 44, 32, 97, 117, 116, 111, 109, 97, 116, 105, 111, 110, 32,
+61, 32, 97, 117, 116, 111, 109, 97, 195, 167, 195, 163, 111, 46, 10,
+};
+} // namespace lynx::i18n::data

+ 463 - 0
src/ui/Icons.cpp

@@ -0,0 +1,463 @@
+#include "ui/Icons.h"
+
+#include <map>
+
+#include "ui/Theme.h"
+
+namespace lynx
+{
+namespace icons
+{
+namespace
+{
+constexpr float pi = juce::MathConstants<float>::pi;
+
+void line (juce::Path& p, float x1, float y1, float x2, float y2)
+{
+    p.startNewSubPath (x1, y1);
+    p.lineTo (x2, y2);
+}
+
+void roundRect (juce::Path& p, float x, float y, float w, float h, float r)
+{
+    p.addRoundedRectangle (x, y, w, h, r);
+}
+
+void polyline (juce::Path& p, std::initializer_list<juce::Point<float>> points, bool close = false)
+{
+    bool first = true;
+    for (auto pt : points)
+    {
+        if (first)
+            p.startNewSubPath (pt);
+        else
+            p.lineTo (pt);
+        first = false;
+    }
+    if (close)
+        p.closeSubPath();
+}
+
+Shape make (Icon icon)
+{
+    Shape s;
+    auto& st = s.stroke;
+    auto& fi = s.fill;
+
+    switch (icon)
+    {
+        case Icon::none:
+            break;
+
+        // --- transport (solid) ---
+        case Icon::play:
+        {
+            juce::Path tri;
+            tri.addTriangle (7.5f, 5.0f, 7.5f, 19.0f, 19.0f, 12.0f);
+            fi = tri.createPathWithRoundedCorners (1.6f);
+            break;
+        }
+        case Icon::pause:
+            fi.addRoundedRectangle (6.5f, 5.0f, 4.0f, 14.0f, 1.2f);
+            fi.addRoundedRectangle (13.5f, 5.0f, 4.0f, 14.0f, 1.2f);
+            break;
+        case Icon::stop:
+            fi.addRoundedRectangle (6.0f, 6.0f, 12.0f, 12.0f, 2.0f);
+            break;
+        case Icon::record:
+            fi.addEllipse (6.0f, 6.0f, 12.0f, 12.0f);
+            break;
+
+        // --- small glyphs ---
+        case Icon::chevronDown:
+            polyline (st, { { 7.0f, 10.0f }, { 12.0f, 15.0f }, { 17.0f, 10.0f } });
+            break;
+        case Icon::more:
+            for (float x : { 6.0f, 12.0f, 18.0f })
+                fi.addEllipse (x - 1.6f, 10.4f, 3.2f, 3.2f);
+            break;
+        case Icon::plus:
+            line (st, 12.0f, 6.0f, 12.0f, 18.0f);
+            line (st, 6.0f, 12.0f, 18.0f, 12.0f);
+            break;
+        case Icon::check:
+            polyline (st, { { 6.0f, 12.5f }, { 10.0f, 16.5f }, { 18.0f, 8.0f } });
+            break;
+        case Icon::close:
+            line (st, 7.0f, 7.0f, 17.0f, 17.0f);
+            line (st, 17.0f, 7.0f, 7.0f, 17.0f);
+            break;
+        case Icon::minimise:
+            line (st, 7.0f, 12.5f, 17.0f, 12.5f);
+            break;
+        case Icon::maximise:
+            roundRect (st, 7.0f, 7.0f, 10.0f, 10.0f, 1.5f);
+            break;
+
+        // --- modes ---
+        case Icon::pattern: // a 2x2 step block, one lit
+            roundRect (st, 5.0f, 5.0f, 6.0f, 6.0f, 1.2f);
+            roundRect (st, 13.0f, 13.0f, 6.0f, 6.0f, 1.2f);
+            roundRect (st, 5.0f, 13.0f, 6.0f, 6.0f, 1.2f);
+            fi.addRoundedRectangle (13.0f, 5.0f, 6.0f, 6.0f, 1.2f);
+            break;
+        case Icon::song: // arrangement lanes
+            line (st, 4.5f, 7.0f, 13.0f, 7.0f);
+            line (st, 9.0f, 12.0f, 19.5f, 12.0f);
+            line (st, 4.5f, 17.0f, 16.0f, 17.0f);
+            break;
+        case Icon::metronome:
+        {
+            juce::Path body;
+            body.startNewSubPath (9.5f, 4.5f);
+            body.lineTo (14.5f, 4.5f);
+            body.lineTo (18.5f, 19.5f);
+            body.lineTo (5.5f, 19.5f);
+            body.closeSubPath();
+            st.addPath (body.createPathWithRoundedCorners (1.5f));
+            line (st, 12.0f, 16.0f, 17.5f, 7.0f);
+            line (st, 7.0f, 15.5f, 17.0f, 15.5f);
+            break;
+        }
+
+        // --- file ---
+        case Icon::newFile:
+        case Icon::file:
+        {
+            juce::Path page;
+            polyline (page, { { 6.0f, 3.5f }, { 13.5f, 3.5f }, { 18.0f, 8.0f }, { 18.0f, 20.5f }, { 6.0f, 20.5f } }, true);
+            st.addPath (page.createPathWithRoundedCorners (1.5f));
+            polyline (st, { { 13.5f, 3.5f }, { 13.5f, 8.0f }, { 18.0f, 8.0f } });
+            if (icon == Icon::newFile)
+            {
+                line (st, 12.0f, 11.0f, 12.0f, 17.0f);
+                line (st, 9.0f, 14.0f, 15.0f, 14.0f);
+            }
+            break;
+        }
+        case Icon::open:
+        case Icon::folder:
+        {
+            juce::Path f;
+            polyline (f, { { 3.5f, 6.0f }, { 9.0f, 6.0f }, { 11.0f, 8.0f }, { 20.5f, 8.0f }, { 20.5f, 18.5f }, { 3.5f, 18.5f } }, true);
+            st.addPath (f.createPathWithRoundedCorners (1.5f));
+            if (icon == Icon::open)
+                line (st, 3.5f, 11.5f, 20.5f, 11.5f);
+            break;
+        }
+        case Icon::save:
+        {
+            juce::Path body;
+            polyline (body, { { 4.5f, 4.5f }, { 16.0f, 4.5f }, { 19.5f, 8.0f }, { 19.5f, 19.5f }, { 4.5f, 19.5f } }, true);
+            st.addPath (body.createPathWithRoundedCorners (1.5f));
+            polyline (st, { { 8.0f, 4.5f }, { 8.0f, 9.0f }, { 15.0f, 9.0f }, { 15.0f, 4.5f } });
+            roundRect (st, 8.0f, 13.5f, 8.0f, 6.0f, 1.0f);
+            break;
+        }
+        case Icon::exportAudio: // waveform leaving a box
+            polyline (st, { { 12.0f, 3.5f }, { 12.0f, 14.0f } });
+            polyline (st, { { 8.0f, 7.5f }, { 12.0f, 3.5f }, { 16.0f, 7.5f } });
+            polyline (st, { { 4.5f, 13.0f }, { 4.5f, 19.5f }, { 19.5f, 19.5f }, { 19.5f, 13.0f } });
+            break;
+        case Icon::settings: // three sliders
+            line (st, 5.0f, 7.0f, 19.0f, 7.0f);
+            line (st, 5.0f, 12.0f, 19.0f, 12.0f);
+            line (st, 5.0f, 17.0f, 19.0f, 17.0f);
+            fi.addEllipse (7.0f, 4.8f, 4.4f, 4.4f);
+            fi.addEllipse (13.6f, 9.8f, 4.4f, 4.4f);
+            fi.addEllipse (9.0f, 14.8f, 4.4f, 4.4f);
+            break;
+        case Icon::help:
+            st.addCentredArc (12.0f, 9.5f, 3.5f, 3.5f, 0.0f, -pi * 0.5f, pi * 0.75f, true);
+            st.lineTo (12.0f, 14.5f);
+            fi.addEllipse (10.9f, 17.0f, 2.2f, 2.2f);
+            break;
+        case Icon::undo:
+        case Icon::redo:
+        {
+            juce::Path p;
+            p.startNewSubPath (6.0f, 10.0f);
+            p.lineTo (14.0f, 10.0f);
+            p.addCentredArc (14.0f, 14.0f, 4.0f, 4.0f, 0.0f, 0.0f, pi, false);
+            p.lineTo (9.0f, 18.0f);
+            polyline (p, { { 9.5f, 6.5f }, { 6.0f, 10.0f }, { 9.5f, 13.5f } });
+            if (icon == Icon::redo)
+                p.applyTransform (juce::AffineTransform::scale (-1.0f, 1.0f, 12.0f, 12.0f));
+            st.addPath (p);
+            break;
+        }
+
+        // --- views ---
+        case Icon::channelRack: // rows of steps
+            for (int r = 0; r < 3; ++r)
+            {
+                const auto y = 5.5f + (float) r * 5.0f;
+                fi.addRoundedRectangle (4.0f, y, 4.0f, 3.0f, 0.8f);
+                for (int c = 0; c < 3; ++c)
+                {
+                    juce::Path cell;
+                    cell.addRoundedRectangle (10.0f + (float) c * 3.6f, y, 2.6f, 3.0f, 0.6f);
+                    if ((r + c) % 2 == 0)
+                        fi.addPath (cell);
+                    else
+                        st.addPath (cell);
+                }
+            }
+            break;
+        case Icon::pianoRoll: // keys + notes
+            roundRect (st, 4.0f, 4.5f, 16.0f, 15.0f, 1.5f);
+            line (st, 8.5f, 4.5f, 8.5f, 19.5f);
+            fi.addRoundedRectangle (10.5f, 7.0f, 4.0f, 2.4f, 0.8f);
+            fi.addRoundedRectangle (13.0f, 11.0f, 5.0f, 2.4f, 0.8f);
+            fi.addRoundedRectangle (11.0f, 15.0f, 3.5f, 2.4f, 0.8f);
+            break;
+        case Icon::playlist: // clips on lanes
+            fi.addRoundedRectangle (4.0f, 5.0f, 9.0f, 3.5f, 1.0f);
+            fi.addRoundedRectangle (9.0f, 10.3f, 11.0f, 3.5f, 1.0f);
+            fi.addRoundedRectangle (4.0f, 15.6f, 6.0f, 3.5f, 1.0f);
+            fi.addRoundedRectangle (12.0f, 15.6f, 6.0f, 3.5f, 1.0f);
+            break;
+        case Icon::mixer: // three faders
+            for (int i = 0; i < 3; ++i)
+            {
+                const auto x = 6.5f + (float) i * 5.5f;
+                line (st, x, 4.5f, x, 19.5f);
+            }
+            fi.addRoundedRectangle (4.5f, 12.0f, 4.0f, 3.0f, 0.8f);
+            fi.addRoundedRectangle (10.0f, 7.0f, 4.0f, 3.0f, 0.8f);
+            fi.addRoundedRectangle (15.5f, 14.5f, 4.0f, 3.0f, 0.8f);
+            break;
+        case Icon::browser: // sidebar
+            roundRect (st, 4.0f, 4.5f, 16.0f, 15.0f, 1.5f);
+            line (st, 9.5f, 4.5f, 9.5f, 19.5f);
+            line (st, 12.5f, 9.0f, 17.0f, 9.0f);
+            line (st, 12.5f, 12.5f, 17.0f, 12.5f);
+            line (st, 12.5f, 16.0f, 15.0f, 16.0f);
+            break;
+
+        // --- content ---
+        case Icon::audioFile:
+            for (int i = 0; i < 5; ++i)
+            {
+                const float heights[] = { 5.0f, 11.0f, 15.0f, 9.0f, 4.0f };
+                const auto x = 6.0f + (float) i * 3.0f;
+                line (st, x, 12.0f - heights[i] / 2.0f, x, 12.0f + heights[i] / 2.0f);
+            }
+            break;
+        case Icon::plugin: // a module with a jack
+            roundRect (st, 5.0f, 6.5f, 14.0f, 11.0f, 2.0f);
+            line (st, 9.0f, 3.5f, 9.0f, 6.5f);
+            line (st, 15.0f, 3.5f, 15.0f, 6.5f);
+            fi.addEllipse (10.0f, 10.0f, 4.0f, 4.0f);
+            break;
+        case Icon::preset: // a knob
+            st.addCentredArc (12.0f, 12.0f, 7.0f, 7.0f, 0.0f, -pi * 0.75f, pi * 0.75f, true);
+            line (st, 12.0f, 12.0f, 15.5f, 8.5f);
+            break;
+        case Icon::project: // the LYNX "spark": a diamond
+        {
+            juce::Path d;
+            polyline (d, { { 12.0f, 3.5f }, { 19.0f, 12.0f }, { 12.0f, 20.5f }, { 5.0f, 12.0f } }, true);
+            st.addPath (d.createPathWithRoundedCorners (2.0f));
+            fi.addEllipse (10.0f, 10.0f, 4.0f, 4.0f);
+            break;
+        }
+
+        // --- tools ---
+        case Icon::draw: // pencil
+        {
+            juce::Path p;
+            polyline (p, { { 15.5f, 4.5f }, { 19.5f, 8.5f }, { 9.0f, 19.0f }, { 4.5f, 19.5f }, { 5.0f, 15.0f } }, true);
+            st.addPath (p.createPathWithRoundedCorners (1.0f));
+            line (st, 13.0f, 7.0f, 17.0f, 11.0f);
+            break;
+        }
+        case Icon::erase:
+        {
+            juce::Path p;
+            polyline (p, { { 13.0f, 4.5f }, { 19.5f, 11.0f }, { 11.5f, 19.0f }, { 7.5f, 19.0f }, { 4.5f, 16.0f } }, true);
+            st.addPath (p.createPathWithRoundedCorners (1.0f));
+            line (st, 9.0f, 9.0f, 15.0f, 15.0f);
+            line (st, 11.5f, 19.0f, 19.5f, 19.0f);
+            break;
+        }
+        case Icon::select:
+        {
+            const float dash[] = { 2.5f, 2.0f };
+            juce::Path box;
+            box.addRectangle (4.5f, 4.5f, 15.0f, 15.0f);
+            juce::PathStrokeType (1.0f).createDashedStroke (fi, box, dash, 2);
+            break;
+        }
+        case Icon::slice:
+        case Icon::scissors:
+            st.addEllipse (4.5f, 13.5f, 5.0f, 5.0f);
+            st.addEllipse (14.5f, 13.5f, 5.0f, 5.0f);
+            line (st, 8.5f, 14.5f, 17.0f, 4.5f);
+            line (st, 15.5f, 14.5f, 7.0f, 4.5f);
+            break;
+        case Icon::mute: // speaker with a cross
+        {
+            juce::Path sp;
+            polyline (sp, { { 4.5f, 9.5f }, { 8.0f, 9.5f }, { 12.0f, 5.5f }, { 12.0f, 18.5f }, { 8.0f, 14.5f }, { 4.5f, 14.5f } }, true);
+            st.addPath (sp.createPathWithRoundedCorners (1.0f));
+            line (st, 15.5f, 9.5f, 20.0f, 14.5f);
+            line (st, 20.0f, 9.5f, 15.5f, 14.5f);
+            break;
+        }
+        case Icon::link:
+            st.addRoundedRectangle (3.5f, 9.0f, 10.0f, 6.0f, 3.0f);
+            st.addRoundedRectangle (10.5f, 9.0f, 10.0f, 6.0f, 3.0f);
+            break;
+        case Icon::magnet:
+        {
+            juce::Path m;
+            m.startNewSubPath (6.0f, 5.0f);
+            m.lineTo (6.0f, 12.0f);
+            m.addCentredArc (12.0f, 12.0f, 6.0f, 6.0f, 0.0f, -pi * 0.5f, pi * 0.5f, false);
+            m.lineTo (18.0f, 5.0f);
+            st.addPath (m);
+            line (st, 6.0f, 8.0f, 9.5f, 8.0f);
+            line (st, 14.5f, 8.0f, 18.0f, 8.0f);
+            break;
+        }
+    }
+
+    return s;
+}
+} // namespace
+
+const Shape& get (Icon icon)
+{
+    static std::map<Icon, Shape> cache;
+    auto it = cache.find (icon);
+    if (it == cache.end())
+        it = cache.emplace (icon, make (icon)).first;
+    return it->second;
+}
+
+void draw (juce::Graphics& g, Icon icon, juce::Rectangle<float> area, juce::Colour colour)
+{
+    if (icon == Icon::none || area.isEmpty())
+        return;
+
+    const auto size = juce::jmin (area.getWidth(), area.getHeight());
+    const auto box = area.withSizeKeepingCentre (size, size);
+    const auto scale = size / 24.0f;
+    const auto transform = juce::AffineTransform::scale (scale).translated (box.getX(), box.getY());
+    const auto& shape = get (icon);
+
+    g.setColour (colour);
+
+    if (! shape.fill.isEmpty())
+        g.fillPath (shape.fill, transform);
+
+    if (! shape.stroke.isEmpty())
+        g.strokePath (shape.stroke,
+                      juce::PathStrokeType (juce::jlimit (1.2f, 2.4f, 1.7f * scale), juce::PathStrokeType::curved, juce::PathStrokeType::rounded),
+                      transform);
+}
+} // namespace icons
+
+IconButton::IconButton (const juce::String& name, Icon i, const juce::String& t)
+    : juce::Button (name), icon (i), text (t), onColour (theme::colour::accent), iconOnColour (theme::colour::onAccent)
+{
+    setMouseCursor (juce::MouseCursor::PointingHandCursor);
+}
+
+void IconButton::setIcon (Icon newIcon)
+{
+    if (icon != newIcon)
+    {
+        icon = newIcon;
+        repaint();
+    }
+}
+
+void IconButton::setText (const juce::String& newText)
+{
+    if (text != newText)
+    {
+        text = newText;
+        repaint();
+    }
+}
+
+void IconButton::setPrimary (bool b) { primary = b; repaint(); }
+void IconButton::setOnColour (juce::Colour c) { onColour = c; repaint(); }
+void IconButton::setIconColourWhenOn (juce::Colour c) { iconOnColour = c; repaint(); }
+void IconButton::setFlat (bool b) { flat = b; repaint(); }
+
+void IconButton::setCorners (bool left, bool right)
+{
+    roundLeft = left;
+    roundRight = right;
+    repaint();
+}
+
+int IconButton::getIdealWidth (int height) const
+{
+    const auto iconSize = icon == Icon::none ? 0 : juce::roundToInt (height * 0.55f);
+    const auto textWidth = text.isEmpty() ? 0
+                                          : juce::roundToInt (juce::GlyphArrangement::getStringWidth (juce::Font (theme::font (theme::type::body)), text));
+    const auto gap = iconSize > 0 && textWidth > 0 ? 6 : 0;
+    return juce::jmax (height, iconSize + gap + textWidth + (textWidth > 0 ? 20 : 0));
+}
+
+void IconButton::paintButton (juce::Graphics& g, bool highlighted, bool down)
+{
+    using namespace theme;
+    const auto bounds = getLocalBounds().toFloat().reduced (0.5f);
+    const auto on = getToggleState();
+    const auto enabled = isEnabled();
+
+    juce::Colour bg;
+    if (on || primary)
+        bg = down ? colour::accentPressed : highlighted ? onColour.brighter (0.12f) : onColour;
+    else if (down)
+        bg = colour::bg6;
+    else if (highlighted)
+        bg = colour::bg5;
+    else
+        bg = flat ? juce::Colours::transparentBlack : colour::bg4;
+
+    if (! enabled)
+        bg = bg.withMultipliedAlpha (0.5f);
+
+    if (! bg.isTransparent())
+    {
+        juce::Path p;
+        p.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md,
+                               roundLeft, roundRight, roundLeft, roundRight);
+        g.setColour (bg);
+        g.fillPath (p);
+    }
+
+    auto fg = (on || primary) ? iconOnColour : (highlighted ? colour::textPrimary : colour::textSecondary.brighter (0.25f));
+    if (! enabled)
+        fg = colour::textDisabled;
+
+    auto area = getLocalBounds().toFloat();
+    const auto iconSize = juce::jmin (area.getHeight() * 0.6f, 20.0f);
+
+    if (text.isEmpty())
+    {
+        icons::draw (g, icon, area.withSizeKeepingCentre (iconSize, iconSize), fg);
+        return;
+    }
+
+    const auto font = juce::Font (theme::font (type::body));
+    const auto textWidth = juce::GlyphArrangement::getStringWidth (font, text);
+    const auto gap = icon == Icon::none ? 0.0f : 6.0f;
+    const auto contentWidth = juce::jmin (area.getWidth() - 12.0f, (icon == Icon::none ? 0.0f : iconSize) + gap + textWidth);
+    auto content = area.withSizeKeepingCentre (contentWidth, area.getHeight());
+
+    if (icon != Icon::none)
+        icons::draw (g, icon, content.removeFromLeft (iconSize).withSizeKeepingCentre (iconSize, iconSize), fg);
+
+    content.removeFromLeft (gap);
+    g.setColour (fg);
+    g.setFont (font);
+    g.drawFittedText (text, content.toNearestInt(), juce::Justification::centredLeft, 1, 0.85f);
+}
+} // namespace lynx

+ 58 - 0
src/ui/Icons.h

@@ -0,0 +1,58 @@
+#pragma once
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+// LYNX's own vector icons, drawn with juce::Path on a 24x24 grid (line icons with rounded
+// joins; transport symbols are solid). Original designs.
+namespace lynx
+{
+enum class Icon
+{
+    none,
+    play, pause, stop, record, chevronDown, more, plus, check, close, minimise, maximise,
+    pattern, song, metronome,
+    newFile, open, save, exportAudio, settings, help, undo, redo,
+    channelRack, pianoRoll, playlist, mixer, browser,
+    folder, file, audioFile, plugin, preset, project,
+    draw, erase, select, slice, mute, link, magnet, scissors
+};
+
+namespace icons
+{
+struct Shape
+{
+    juce::Path stroke; // drawn with a line (stroke width scales with the size)
+    juce::Path fill;   // solid parts
+};
+
+const Shape& get (Icon icon);
+
+// Draws `icon` fitted (centred, square) into `area`.
+void draw (juce::Graphics& g, Icon icon, juce::Rectangle<float> area, juce::Colour colour);
+} // namespace icons
+
+// A flat button that shows an icon, optionally followed by text. Uses the theme colours:
+// neutral at rest, red accent when toggled on (or when `primary`).
+class IconButton : public juce::Button
+{
+public:
+    IconButton (const juce::String& name, Icon icon, const juce::String& text = {});
+
+    void setIcon (Icon newIcon);
+    void setText (const juce::String& newText);
+    void setPrimary (bool shouldBePrimary);              // filled with the accent even when off
+    void setOnColour (juce::Colour colour);              // background when toggled on (default: accent)
+    void setIconColourWhenOn (juce::Colour colour);      // icon/text colour when on (default: white)
+    void setFlat (bool shouldBeFlat);                    // no background at rest (toolbar style)
+    void setCorners (bool roundLeft, bool roundRight);   // for segmented groups
+    int getIdealWidth (int height) const;
+
+    void paintButton (juce::Graphics&, bool highlighted, bool down) override;
+
+private:
+    Icon icon;
+    juce::String text;
+    bool primary = false, flat = false, roundLeft = true, roundRight = true;
+    juce::Colour onColour, iconOnColour;
+};
+} // namespace lynx

+ 851 - 0
src/ui/Theme.cpp

@@ -0,0 +1,851 @@
+#include "ui/Theme.h"
+
+#include "ui/Icons.h"
+
+namespace lynx::theme
+{
+using namespace colour;
+
+namespace
+{
+constexpr float pi = juce::MathConstants<float>::pi;
+
+juce::Font uiFont (float size, bool bold = false)
+{
+    return juce::Font (font (size, bold));
+}
+
+void fillRounded (juce::Graphics& g, juce::Rectangle<float> r, float corner, juce::Colour c)
+{
+    g.setColour (c);
+    g.fillRoundedRectangle (r, corner);
+}
+
+void outlineRounded (juce::Graphics& g, juce::Rectangle<float> r, float corner, juce::Colour c, float thickness = 1.0f)
+{
+    g.setColour (c);
+    g.drawRoundedRectangle (r.reduced (thickness * 0.5f), corner, thickness);
+}
+
+// Window caption buttons (only used for non-native title bars).
+class CaptionButton final : public juce::Button
+{
+public:
+    CaptionButton (const juce::String& name, Icon i, bool isClose) : juce::Button (name), icon (i), close (isClose) {}
+
+    void paintButton (juce::Graphics& g, bool highlighted, bool down) override
+    {
+        if (highlighted || down)
+            g.fillAll (close ? (down ? accentPressed : accent) : (down ? bg6 : bg5));
+
+        icons::draw (g, icon, getLocalBounds().toFloat().withSizeKeepingCentre (16.0f, 16.0f),
+                     highlighted || down ? textPrimary : textSecondary);
+    }
+
+private:
+    Icon icon;
+    bool close;
+};
+} // namespace
+
+void drawKnob (juce::Graphics& g, juce::Rectangle<float> bounds, float value01, bool bipolar, juce::Colour arcColour, bool hover)
+{
+    const auto size = juce::jmin (bounds.getWidth(), bounds.getHeight()) - 2.0f;
+    if (size <= 4.0f)
+        return;
+
+    const auto area = bounds.withSizeKeepingCentre (size, size);
+    const auto centre = area.getCentre();
+    const auto thickness = juce::jlimit (2.0f, 4.0f, size * 0.09f);
+    const auto arcRadius = size / 2.0f - thickness / 2.0f;
+    constexpr auto start = -pi * 0.75f;
+    constexpr auto range = pi * 1.5f;
+    const auto value = juce::jlimit (0.0f, 1.0f, value01);
+
+    // track
+    juce::Path track;
+    track.addCentredArc (centre.x, centre.y, arcRadius, arcRadius, 0.0f, start, start + range, true);
+    g.setColour (bg0);
+    g.strokePath (track, juce::PathStrokeType (thickness, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+
+    // value arc
+    const auto from = bipolar ? start + range * 0.5f : start;
+    const auto to = start + range * value;
+
+    if (std::abs (to - from) > 0.001f)
+    {
+        juce::Path arc;
+        arc.addCentredArc (centre.x, centre.y, arcRadius, arcRadius, 0.0f, juce::jmin (from, to), juce::jmax (from, to), true);
+        g.setColour (arcColour);
+        g.strokePath (arc, juce::PathStrokeType (thickness, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+    }
+
+    // body
+    const auto bodyRadius = arcRadius - thickness * 0.5f - juce::jmax (1.5f, size * 0.06f);
+    if (bodyRadius > 2.0f)
+    {
+        g.setColour (hover ? bg6 : bg5);
+        g.fillEllipse (centre.x - bodyRadius, centre.y - bodyRadius, bodyRadius * 2.0f, bodyRadius * 2.0f);
+
+        // pointer
+        const auto inner = bodyRadius * 0.25f;
+        const auto outer = bodyRadius * 0.92f;
+        g.setColour (textPrimary);
+        g.drawLine (centre.x + std::sin (to) * inner, centre.y - std::cos (to) * inner, centre.x + std::sin (to) * outer,
+                    centre.y - std::cos (to) * outer, juce::jmax (1.5f, size * 0.06f));
+    }
+}
+
+LookAndFeel::LookAndFeel()
+    : juce::LookAndFeel_V4 (juce::LookAndFeel_V4::ColourScheme { bg1, bg2, bg3, borderStrong, textPrimary, bg4, onAccent, accent, textPrimary })
+{
+    // Segoe UI on Windows (the JUCE default there is Verdana, wider and dated)
+   #if JUCE_WINDOWS
+    setDefaultSansSerifTypefaceName ("Segoe UI");
+   #endif
+
+    setColour (juce::ResizableWindow::backgroundColourId, bg1);
+    setColour (juce::DocumentWindow::textColourId, textPrimary);
+
+    setColour (juce::TextButton::buttonColourId, bg4);
+    setColour (juce::TextButton::buttonOnColourId, accent);
+    setColour (juce::TextButton::textColourOffId, textPrimary);
+    setColour (juce::TextButton::textColourOnId, onAccent);
+    setColour (juce::ToggleButton::textColourId, textPrimary);
+    setColour (juce::ToggleButton::tickColourId, onAccent);
+    setColour (juce::ToggleButton::tickDisabledColourId, textDisabled);
+
+    setColour (juce::ComboBox::backgroundColourId, bg4);
+    setColour (juce::ComboBox::outlineColourId, juce::Colours::transparentBlack);
+    setColour (juce::ComboBox::textColourId, textPrimary);
+    setColour (juce::ComboBox::arrowColourId, textSecondary);
+    setColour (juce::ComboBox::buttonColourId, bg4);
+    setColour (juce::ComboBox::focusedOutlineColourId, accent);
+
+    setColour (juce::PopupMenu::backgroundColourId, bg3);
+    setColour (juce::PopupMenu::textColourId, textPrimary);
+    setColour (juce::PopupMenu::headerTextColourId, textSecondary);
+    setColour (juce::PopupMenu::highlightedBackgroundColourId, bg5);
+    setColour (juce::PopupMenu::highlightedTextColourId, textPrimary);
+
+    setColour (juce::Label::textColourId, textPrimary);
+    setColour (juce::Label::backgroundColourId, juce::Colours::transparentBlack);
+    setColour (juce::Label::outlineColourId, juce::Colours::transparentBlack);
+    setColour (juce::Label::textWhenEditingColourId, textPrimary);
+    setColour (juce::Label::backgroundWhenEditingColourId, bg0);
+    setColour (juce::Label::outlineWhenEditingColourId, accent);
+
+    setColour (juce::TextEditor::backgroundColourId, bg0);
+    setColour (juce::TextEditor::textColourId, textPrimary);
+    setColour (juce::TextEditor::highlightColourId, accent.withAlpha (0.35f));
+    setColour (juce::TextEditor::highlightedTextColourId, textPrimary);
+    setColour (juce::TextEditor::outlineColourId, border);
+    setColour (juce::TextEditor::focusedOutlineColourId, accent);
+    setColour (juce::TextEditor::shadowColourId, juce::Colours::transparentBlack);
+    setColour (juce::CaretComponent::caretColourId, accent);
+
+    setColour (juce::Slider::backgroundColourId, bg0);
+    setColour (juce::Slider::trackColourId, accent);
+    setColour (juce::Slider::thumbColourId, textPrimary);
+    setColour (juce::Slider::rotarySliderFillColourId, accent);
+    setColour (juce::Slider::rotarySliderOutlineColourId, bg0);
+    setColour (juce::Slider::textBoxTextColourId, textPrimary);
+    setColour (juce::Slider::textBoxBackgroundColourId, bg0);
+    setColour (juce::Slider::textBoxHighlightColourId, accent.withAlpha (0.35f));
+    setColour (juce::Slider::textBoxOutlineColourId, juce::Colours::transparentBlack);
+
+    setColour (juce::ScrollBar::thumbColourId, bg6);
+    setColour (juce::ScrollBar::trackColourId, juce::Colours::transparentBlack);
+    setColour (juce::ScrollBar::backgroundColourId, juce::Colours::transparentBlack);
+
+    setColour (juce::TabbedButtonBar::tabOutlineColourId, juce::Colours::transparentBlack);
+    setColour (juce::TabbedButtonBar::frontOutlineColourId, juce::Colours::transparentBlack);
+    setColour (juce::TabbedComponent::outlineColourId, juce::Colours::transparentBlack);
+    setColour (juce::TabbedComponent::backgroundColourId, bg2);
+    setColour (juce::TabbedButtonBar::tabTextColourId, textSecondary);
+    setColour (juce::TabbedButtonBar::frontTextColourId, textPrimary);
+
+    setColour (juce::TooltipWindow::backgroundColourId, bg3);
+    setColour (juce::TooltipWindow::textColourId, textPrimary);
+    setColour (juce::TooltipWindow::outlineColourId, borderStrong);
+
+    setColour (juce::AlertWindow::backgroundColourId, bg3);
+    setColour (juce::AlertWindow::textColourId, textPrimary);
+    setColour (juce::AlertWindow::outlineColourId, borderStrong);
+
+    setColour (juce::TreeView::backgroundColourId, bg2);
+    setColour (juce::TreeView::linesColourId, border);
+    setColour (juce::TreeView::selectedItemBackgroundColourId, accentMuted);
+    setColour (juce::TreeView::oddItemsColourId, juce::Colours::transparentBlack);
+    setColour (juce::TreeView::evenItemsColourId, juce::Colours::transparentBlack);
+    setColour (juce::DirectoryContentsDisplayComponent::highlightColourId, accentMuted);
+    setColour (juce::DirectoryContentsDisplayComponent::textColourId, textPrimary);
+    setColour (juce::DirectoryContentsDisplayComponent::highlightedTextColourId, textPrimary);
+    setColour (juce::ListBox::backgroundColourId, bg2);
+    setColour (juce::ListBox::outlineColourId, border);
+    setColour (juce::ListBox::textColourId, textPrimary);
+
+    setColour (juce::GroupComponent::outlineColourId, border);
+    setColour (juce::GroupComponent::textColourId, textSecondary);
+    setColour (juce::ProgressBar::backgroundColourId, bg0);
+    setColour (juce::ProgressBar::foregroundColourId, accent);
+    setColour (juce::HyperlinkButton::textColourId, info);
+    setColour (juce::BubbleComponent::backgroundColourId, bg3);
+    setColour (juce::BubbleComponent::outlineColourId, borderStrong);
+}
+
+// --- buttons ---------------------------------------------------------------------------------------
+
+void LookAndFeel::drawButtonBackground (juce::Graphics& g, juce::Button& button, const juce::Colour& backgroundColour, bool highlighted,
+                                        bool down)
+{
+    auto bounds = button.getLocalBounds().toFloat().reduced (0.5f);
+    const auto on = button.getToggleState();
+    auto base = backgroundColour; // already buttonOnColour when toggled
+
+    if (down)
+        base = on ? accentPressed : (base == bg4 ? bg6 : base.brighter (0.18f));
+    else if (highlighted)
+        base = on ? accentHover : (base == bg4 ? bg5 : base.brighter (0.1f));
+
+    if (! button.isEnabled())
+        base = base.withMultipliedAlpha (0.5f);
+
+    const auto flatLeft = button.isConnectedOnLeft(), flatRight = button.isConnectedOnRight();
+    juce::Path p;
+    p.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md, ! flatLeft,
+                           ! flatRight, ! flatLeft, ! flatRight);
+    g.setColour (base);
+    g.fillPath (p);
+
+    if (button.hasKeyboardFocus (false) && button.getWantsKeyboardFocus())
+    {
+        g.setColour (accent.withAlpha (0.6f));
+        g.strokePath (p, juce::PathStrokeType (1.0f));
+    }
+}
+
+juce::Font LookAndFeel::getTextButtonFont (juce::TextButton&, int buttonHeight)
+{
+    return uiFont (juce::jmin ((float) type::body, (float) buttonHeight * 0.6f));
+}
+
+void LookAndFeel::drawButtonText (juce::Graphics& g, juce::TextButton& button, bool, bool)
+{
+    const auto font = getTextButtonFont (button, button.getHeight());
+    g.setFont (font);
+    const auto fg = button.findColour (button.getToggleState() ? juce::TextButton::textColourOnId : juce::TextButton::textColourOffId)
+                        .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.45f);
+    g.setColour (fg);
+
+    auto area = button.getLocalBounds().reduced (juce::jmin (8, button.getWidth() / 6), 0);
+    const auto iconId = (int) button.getProperties().getWithDefault (iconProperty, 0);
+
+    if (iconId != 0)
+    {
+        const auto iconSize = juce::jmin (16.0f, (float) button.getHeight() * 0.6f);
+        const auto textWidth = button.getButtonText().isEmpty() ? 0.0f : juce::GlyphArrangement::getStringWidth (font, button.getButtonText()) + 6.0f;
+        auto content = area.toFloat().withSizeKeepingCentre (juce::jmin ((float) area.getWidth(), iconSize + textWidth), (float) area.getHeight());
+        icons::draw (g, (Icon) iconId, content.removeFromLeft (iconSize), fg);
+        g.setColour (fg);
+        content.removeFromLeft (6.0f);
+        g.drawFittedText (button.getButtonText(), content.toNearestInt(), juce::Justification::centredLeft, 1, 0.85f);
+        return;
+    }
+
+    g.drawFittedText (button.getButtonText(), area, juce::Justification::centred, 2, 0.85f);
+}
+
+void LookAndFeel::drawTickBox (juce::Graphics& g, juce::Component& component, float x, float y, float w, float h, bool ticked, bool enabled,
+                               bool highlighted, bool)
+{
+    juce::ignoreUnused (component);
+    const auto box = juce::Rectangle<float> (x, y, w, h).reduced (0.5f);
+
+    if (ticked)
+        fillRounded (g, box, radius::sm, enabled ? (highlighted ? accentHover : accent) : accentMuted);
+    else
+    {
+        fillRounded (g, box, radius::sm, bg0);
+        outlineRounded (g, box, radius::sm, highlighted ? textSecondary : borderStrong);
+    }
+
+    if (ticked)
+        icons::draw (g, Icon::check, box.reduced (box.getWidth() * 0.05f), enabled ? onAccent : textDisabled);
+}
+
+void LookAndFeel::drawToggleButton (juce::Graphics& g, juce::ToggleButton& button, bool highlighted, bool down)
+{
+    const auto fontSize = juce::jmin ((float) type::body, (float) button.getHeight() * 0.75f);
+    const auto tickSize = juce::jmin (16.0f, (float) button.getHeight() - 4.0f);
+
+    drawTickBox (g, button, 2.0f, ((float) button.getHeight() - tickSize) * 0.5f, tickSize, tickSize, button.getToggleState(),
+                 button.isEnabled(), highlighted, down);
+
+    g.setColour (button.findColour (juce::ToggleButton::textColourId).withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
+    g.setFont (uiFont (fontSize));
+    g.drawFittedText (button.getButtonText(),
+                      button.getLocalBounds().withTrimmedLeft (juce::roundToInt (tickSize) + 8).withTrimmedRight (2),
+                      juce::Justification::centredLeft, 2, 0.85f);
+}
+
+// --- combo boxes and menus -------------------------------------------------------------------------
+
+void LookAndFeel::drawComboBox (juce::Graphics& g, int width, int height, bool, int, int, int, int, juce::ComboBox& box)
+{
+    const auto bounds = juce::Rectangle<float> (0.0f, 0.0f, (float) width, (float) height).reduced (0.5f);
+    const auto hover = box.isMouseOver (true) && box.isEnabled();
+    fillRounded (g, bounds, radius::md, hover ? bg5 : box.findColour (juce::ComboBox::backgroundColourId));
+
+    if (box.hasKeyboardFocus (true) && box.getWantsKeyboardFocus())
+        outlineRounded (g, bounds, radius::md, accent.withAlpha (0.7f));
+    else if (! box.findColour (juce::ComboBox::outlineColourId).isTransparent())
+        outlineRounded (g, bounds, radius::md, box.findColour (juce::ComboBox::outlineColourId));
+
+    const auto arrowSize = juce::jmin (14.0f, (float) height * 0.6f);
+    const auto arrowArea = juce::Rectangle<float> ((float) width - arrowSize - 7.0f, ((float) height - arrowSize) * 0.5f, arrowSize, arrowSize);
+    icons::draw (g, Icon::chevronDown, arrowArea, (hover ? textPrimary : textSecondary).withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.4f));
+}
+
+juce::Font LookAndFeel::getComboBoxFont (juce::ComboBox& box)
+{
+    return uiFont (juce::jmin ((float) type::body, (float) box.getHeight() * 0.62f));
+}
+
+void LookAndFeel::positionComboBoxText (juce::ComboBox& box, juce::Label& label)
+{
+    const auto arrowSize = juce::jmin (14, juce::roundToInt ((float) box.getHeight() * 0.6f));
+    label.setBounds (2, 1, box.getWidth() - arrowSize - 12, box.getHeight() - 2);
+    label.setFont (getComboBoxFont (box));
+    label.setColour (juce::Label::textColourId, box.findColour (juce::ComboBox::textColourId).withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f));
+}
+
+void LookAndFeel::drawPopupMenuBackground (juce::Graphics& g, int width, int height)
+{
+    const auto bounds = juce::Rectangle<float> (0.0f, 0.0f, (float) width, (float) height);
+    g.fillAll (bg3);
+    g.setColour (borderStrong);
+    g.drawRect (bounds, 1.0f);
+}
+
+juce::Font LookAndFeel::getPopupMenuFont()
+{
+    return uiFont (type::body);
+}
+
+void LookAndFeel::getIdealPopupMenuItemSize (const juce::String& text, bool isSeparator, int standardMenuItemHeight, int& idealWidth,
+                                             int& idealHeight)
+{
+    if (isSeparator)
+    {
+        idealWidth = 50;
+        idealHeight = 9;
+        return;
+    }
+
+    const auto font = getPopupMenuFont();
+    idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : 26;
+    idealWidth = juce::roundToInt (juce::GlyphArrangement::getStringWidth (font, text)) + idealHeight * 2 + 8;
+}
+
+void LookAndFeel::drawPopupMenuItem (juce::Graphics& g, const juce::Rectangle<int>& area, bool isSeparator, bool isActive, bool isHighlighted,
+                                     bool isTicked, bool hasSubMenu, const juce::String& text, const juce::String& shortcutKeyText,
+                                     const juce::Drawable* icon, const juce::Colour* textColourToUse)
+{
+    if (isSeparator)
+    {
+        g.setColour (border.brighter (0.1f));
+        g.fillRect (area.reduced (8, 0).withHeight (1).withY (area.getCentreY()));
+        return;
+    }
+
+    auto r = area.reduced (4, 1);
+
+    if (isHighlighted && isActive)
+    {
+        fillRounded (g, r.toFloat(), radius::sm, bg5);
+        g.setColour (accent);
+        g.fillRoundedRectangle (r.toFloat().withWidth (3.0f).reduced (0.0f, 4.0f), 1.5f);
+    }
+
+    auto textColour = textColourToUse != nullptr ? *textColourToUse : textPrimary;
+    if (! isActive)
+        textColour = textDisabled;
+
+    auto content = r.reduced (8, 0);
+    auto iconArea = content.removeFromLeft (juce::roundToInt ((float) r.getHeight() * 0.8f)).toFloat();
+
+    if (icon != nullptr)
+        icon->drawWithin (g, iconArea.withSizeKeepingCentre (14.0f, 14.0f), juce::RectanglePlacement::centred, isActive ? 1.0f : 0.4f);
+    else if (isTicked)
+        icons::draw (g, Icon::check, iconArea.withSizeKeepingCentre (16.0f, 16.0f), isActive ? accent : textDisabled);
+
+    if (hasSubMenu)
+    {
+        const auto arrow = content.removeFromRight (14).toFloat().withSizeKeepingCentre (12.0f, 12.0f);
+        juce::Graphics::ScopedSaveState state (g);
+        g.addTransform (juce::AffineTransform::rotation (-pi * 0.5f, arrow.getCentreX(), arrow.getCentreY()));
+        icons::draw (g, Icon::chevronDown, arrow, isHighlighted ? textPrimary : textSecondary);
+    }
+
+    content.removeFromLeft (4);
+    const auto font = getPopupMenuFont();
+    g.setFont (font);
+
+    if (shortcutKeyText.isNotEmpty())
+    {
+        g.setColour (textSecondary.withMultipliedAlpha (isActive ? 1.0f : 0.6f));
+        g.setFont (uiFont (type::small));
+        g.drawText (shortcutKeyText, content.removeFromRight (juce::roundToInt (juce::GlyphArrangement::getStringWidth (uiFont (type::small), shortcutKeyText)) + 4),
+                    juce::Justification::centredRight, false);
+        g.setFont (font);
+    }
+
+    g.setColour (textColour);
+    g.drawFittedText (text, content, juce::Justification::centredLeft, 1, 0.9f);
+}
+
+void LookAndFeel::drawPopupMenuSectionHeader (juce::Graphics& g, const juce::Rectangle<int>& area, const juce::String& sectionName)
+{
+    g.setFont (uiFont (type::small, true));
+    g.setColour (textSecondary);
+    g.drawFittedText (sectionName.toUpperCase(), area.reduced (14, 0).withTrimmedTop (4), juce::Justification::centredLeft, 1);
+}
+
+void LookAndFeel::drawMenuBarBackground (juce::Graphics& g, int width, int height, bool, juce::MenuBarComponent&)
+{
+    g.fillAll (bg1);
+    g.setColour (border);
+    g.fillRect (0, height - 1, width, 1);
+}
+
+juce::Font LookAndFeel::getMenuBarFont (juce::MenuBarComponent&, int, const juce::String&)
+{
+    return uiFont (type::body);
+}
+
+int LookAndFeel::getMenuBarItemWidth (juce::MenuBarComponent& bar, int itemIndex, const juce::String& itemText)
+{
+    return juce::roundToInt (juce::GlyphArrangement::getStringWidth (getMenuBarFont (bar, itemIndex, itemText), itemText)) + 22;
+}
+
+void LookAndFeel::drawMenuBarItem (juce::Graphics& g, int width, int height, int itemIndex, const juce::String& itemText, bool isMouseOverItem,
+                                   bool isMenuOpen, bool isMouseOverBar, juce::MenuBarComponent& bar)
+{
+    juce::ignoreUnused (isMouseOverBar);
+    const auto active = isMenuOpen || isMouseOverItem;
+
+    if (active)
+        fillRounded (g, juce::Rectangle<float> (0.0f, 2.0f, (float) width, (float) height - 4.0f).reduced (1.0f, 0.0f), radius::sm,
+                     isMenuOpen ? bg4 : bg3);
+
+    g.setColour (active ? textPrimary : textSecondary.brighter (0.2f));
+    g.setFont (getMenuBarFont (bar, itemIndex, itemText));
+    g.drawFittedText (itemText, 0, 0, width, height, juce::Justification::centred, 1);
+}
+
+// --- sliders ---------------------------------------------------------------------------------------
+
+void LookAndFeel::drawRotarySlider (juce::Graphics& g, int x, int y, int width, int height, float pos, float, float, juce::Slider& slider)
+{
+    const auto bipolar = slider.getMinimum() < 0.0 && slider.getMaximum() > 0.0
+                         && std::abs (slider.getMinimum() + slider.getMaximum()) < 1e-6 * (slider.getMaximum() - slider.getMinimum());
+    auto arc = slider.findColour (juce::Slider::rotarySliderFillColourId);
+    if (! slider.isEnabled())
+        arc = textDisabled;
+    drawKnob (g, juce::Rectangle<int> (x, y, width, height).toFloat(), pos, bipolar, arc, slider.isMouseOverOrDragging());
+}
+
+void LookAndFeel::drawLinearSlider (juce::Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos,
+                                    float maxSliderPos, juce::Slider::SliderStyle style, juce::Slider& slider)
+{
+    if (slider.isBar())
+    {
+        const auto bounds = juce::Rectangle<int> (x, y, width, height).toFloat();
+        fillRounded (g, bounds, radius::sm, bg0);
+        auto fill = slider.isHorizontal() ? bounds.withRight (sliderPos) : bounds.withTop (sliderPos);
+        fillRounded (g, fill, radius::sm, slider.findColour (juce::Slider::trackColourId).withAlpha (0.7f));
+        return;
+    }
+
+    if (style == juce::Slider::TwoValueHorizontal || style == juce::Slider::TwoValueVertical || style == juce::Slider::ThreeValueHorizontal
+        || style == juce::Slider::ThreeValueVertical)
+    {
+        juce::LookAndFeel_V4::drawLinearSlider (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
+        return;
+    }
+
+    const auto vertical = slider.isVertical();
+    const auto bounds = juce::Rectangle<int> (x, y, width, height).toFloat();
+    const auto trackWidth = 4.0f;
+    const auto active = slider.isMouseOverOrDragging();
+    const auto trackColour = slider.isEnabled() ? slider.findColour (juce::Slider::trackColourId) : textDisabled;
+
+    if (vertical)
+    {
+        const auto track = juce::Rectangle<float> (bounds.getCentreX() - trackWidth / 2, bounds.getY(), trackWidth, bounds.getHeight());
+        fillRounded (g, track, trackWidth / 2, bg0);
+        fillRounded (g, track.withTop (sliderPos), trackWidth / 2, trackColour.withAlpha (0.85f));
+
+        // fader cap
+        const auto capWidth = juce::jmin (bounds.getWidth() - 2.0f, 26.0f);
+        const auto cap = juce::Rectangle<float> (capWidth, 12.0f).withCentre ({ bounds.getCentreX(), sliderPos });
+        fillRounded (g, cap.translated (0.0f, 1.5f), radius::sm, juce::Colours::black.withAlpha (0.35f));
+        fillRounded (g, cap, radius::sm, active ? juce::Colour (0xfff4f5f7) : juce::Colour (0xffd4d7dd));
+        g.setColour (bg0.withAlpha (0.8f));
+        g.fillRect (cap.withSizeKeepingCentre (capWidth - 8.0f, 1.5f));
+    }
+    else
+    {
+        const auto track = juce::Rectangle<float> (bounds.getX(), bounds.getCentreY() - trackWidth / 2, bounds.getWidth(), trackWidth);
+        fillRounded (g, track, trackWidth / 2, bg0);
+        fillRounded (g, track.withRight (sliderPos), trackWidth / 2, trackColour.withAlpha (0.85f));
+
+        const auto thumb = juce::Rectangle<float> (12.0f, 12.0f).withCentre ({ sliderPos, bounds.getCentreY() });
+        g.setColour (active ? juce::Colour (0xfff4f5f7) : juce::Colour (0xffd4d7dd));
+        g.fillEllipse (thumb);
+    }
+}
+
+juce::Label* LookAndFeel::createSliderTextBox (juce::Slider& slider)
+{
+    auto* label = juce::LookAndFeel_V4::createSliderTextBox (slider);
+    label->setFont (uiFont (type::small));
+    label->setColour (juce::Label::outlineColourId, juce::Colours::transparentBlack);
+    label->setColour (juce::TextEditor::outlineColourId, juce::Colours::transparentBlack);
+    label->setColour (juce::TextEditor::focusedOutlineColourId, accent);
+    label->setColour (juce::Label::backgroundColourId,
+                      slider.isBar() ? juce::Colours::transparentBlack : slider.findColour (juce::Slider::textBoxBackgroundColourId));
+    return label;
+}
+
+juce::Button* LookAndFeel::createSliderButton (juce::Slider&, bool isIncrement)
+{
+    auto* b = new IconButton (isIncrement ? "+" : "-", isIncrement ? Icon::plus : Icon::minimise);
+    return b;
+}
+
+juce::Slider::SliderLayout LookAndFeel::getSliderLayout (juce::Slider& slider)
+{
+    auto layout = juce::LookAndFeel_V4::getSliderLayout (slider);
+
+    // rotary with a text box below: leave a small gap between the knob and the value
+    if (slider.isRotary() && slider.getTextBoxPosition() == juce::Slider::TextBoxBelow)
+        layout.sliderBounds = layout.sliderBounds.withTrimmedBottom (2);
+
+    return layout;
+}
+
+// --- scrollbars ------------------------------------------------------------------------------------
+
+void LookAndFeel::drawScrollbar (juce::Graphics& g, juce::ScrollBar&, int x, int y, int width, int height, bool vertical, int thumbStart,
+                                 int thumbSize, bool isMouseOver, bool isMouseDown)
+{
+    if (thumbSize <= 0)
+        return;
+
+    auto thumb = vertical ? juce::Rectangle<int> (x, thumbStart, width, thumbSize) : juce::Rectangle<int> (thumbStart, y, thumbSize, height);
+    const auto thickness = isMouseOver || isMouseDown ? 6.0f : 4.0f;
+    auto r = thumb.toFloat().reduced (vertical ? 0.0f : 2.0f, vertical ? 2.0f : 0.0f);
+    r = vertical ? r.withSizeKeepingCentre (thickness, r.getHeight()) : r.withSizeKeepingCentre (r.getWidth(), thickness);
+    fillRounded (g, r, thickness / 2, isMouseDown ? textSecondary : isMouseOver ? bg6.brighter (0.25f) : bg6);
+}
+
+// --- tabs ------------------------------------------------------------------------------------------
+
+int LookAndFeel::getTabButtonBestWidth (juce::TabBarButton& button, int tabDepth)
+{
+    const auto hasIcon = (int) button.getProperties().getWithDefault (iconProperty, 0) != 0;
+    return juce::roundToInt (juce::GlyphArrangement::getStringWidth (uiFont (type::body), button.getButtonText())) + (hasIcon ? tabDepth : 0) + 24;
+}
+
+void LookAndFeel::drawTabbedButtonBarBackground (juce::TabbedButtonBar& bar, juce::Graphics& g)
+{
+    g.fillAll (bg1);
+    g.setColour (border);
+    g.fillRect (0, bar.getHeight() - 1, bar.getWidth(), 1);
+}
+
+void LookAndFeel::drawTabAreaBehindFrontButton (juce::TabbedButtonBar&, juce::Graphics&, int, int) {}
+
+void LookAndFeel::drawTabButton (juce::TabBarButton& button, juce::Graphics& g, bool isMouseOver, bool isMouseDown)
+{
+    const auto front = button.isFrontTab();
+    auto area = button.getActiveArea().toFloat();
+
+    if (front)
+        fillRounded (g, area.reduced (2.0f, 4.0f), radius::md, bg3);
+    else if (isMouseOver || isMouseDown)
+        fillRounded (g, area.reduced (2.0f, 4.0f), radius::md, bg2);
+
+    if (front)
+    {
+        g.setColour (accent);
+        g.fillRoundedRectangle (area.removeFromBottom (2.0f).reduced (10.0f, 0.0f), 1.0f);
+    }
+
+    const auto fg = front ? textPrimary : isMouseOver ? textPrimary.withAlpha (0.85f) : textSecondary;
+    const auto iconId = (int) button.getProperties().getWithDefault (iconProperty, 0);
+    const auto font = uiFont (type::body, false);
+    const auto textWidth = juce::GlyphArrangement::getStringWidth (font, button.getButtonText());
+    const auto iconSize = 16.0f;
+    auto content = button.getActiveArea().toFloat();
+    content = content.withSizeKeepingCentre (juce::jmin (content.getWidth() - 8.0f, textWidth + (iconId != 0 ? iconSize + 7.0f : 0.0f)),
+                                             content.getHeight());
+
+    if (iconId != 0)
+        icons::draw (g, (Icon) iconId, content.removeFromLeft (iconSize).withSizeKeepingCentre (iconSize, iconSize), front ? accent : fg);
+
+    content.removeFromLeft (iconId != 0 ? 7.0f : 0.0f);
+    g.setColour (fg);
+    g.setFont (font);
+    g.drawFittedText (button.getButtonText(), content.toNearestInt(), juce::Justification::centredLeft, 1, 0.9f);
+}
+
+// --- text ------------------------------------------------------------------------------------------
+
+void LookAndFeel::fillTextEditorBackground (juce::Graphics& g, int width, int height, juce::TextEditor& editor)
+{
+    if (dynamic_cast<juce::AlertWindow*> (editor.getParentComponent()) != nullptr)
+    {
+        fillRounded (g, juce::Rectangle<int> (width, height).toFloat(), radius::md, bg0);
+        return;
+    }
+
+    g.setColour (editor.findColour (juce::TextEditor::backgroundColourId));
+    g.fillRoundedRectangle (juce::Rectangle<int> (width, height).toFloat(), radius::sm);
+}
+
+void LookAndFeel::drawTextEditorOutline (juce::Graphics& g, int width, int height, juce::TextEditor& editor)
+{
+    if (! editor.isEnabled())
+        return;
+
+    const auto r = juce::Rectangle<int> (width, height).toFloat();
+
+    if (editor.hasKeyboardFocus (true) && ! editor.isReadOnly())
+        outlineRounded (g, r, radius::sm, editor.findColour (juce::TextEditor::focusedOutlineColourId));
+    else if (! editor.findColour (juce::TextEditor::outlineColourId).isTransparent())
+        outlineRounded (g, r, radius::sm, editor.findColour (juce::TextEditor::outlineColourId));
+}
+
+void LookAndFeel::drawLabel (juce::Graphics& g, juce::Label& label)
+{
+    const auto background = label.findColour (juce::Label::backgroundColourId);
+    if (! background.isTransparent())
+        fillRounded (g, label.getLocalBounds().toFloat(), radius::sm, background);
+
+    if (! label.isBeingEdited())
+    {
+        const auto alpha = label.isEnabled() ? 1.0f : 0.5f;
+        const auto font = getLabelFont (label);
+        g.setColour (label.findColour (juce::Label::textColourId).withMultipliedAlpha (alpha));
+        g.setFont (font);
+        const auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
+        g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
+                          juce::jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())), label.getMinimumHorizontalScale());
+    }
+
+    const auto outline = label.findColour (juce::Label::outlineColourId);
+    if (! outline.isTransparent())
+        outlineRounded (g, label.getLocalBounds().toFloat(), radius::sm, outline);
+}
+
+// --- tooltips, alerts, windows ---------------------------------------------------------------------
+
+juce::Rectangle<int> LookAndFeel::getTooltipBounds (const juce::String& tipText, juce::Point<int> screenPos, juce::Rectangle<int> parentArea)
+{
+    juce::TextLayout layout;
+    juce::AttributedString s;
+    s.append (tipText, uiFont (type::small), textPrimary);
+    layout.createLayoutWithBalancedLineLengths (s, 360.0f);
+    const auto w = (int) (layout.getWidth() + 18.0f), h = (int) (layout.getHeight() + 12.0f);
+    return juce::Rectangle<int> (screenPos.x > parentArea.getCentreX() ? screenPos.x - (w + 12) : screenPos.x + 24,
+                                 screenPos.y > parentArea.getCentreY() ? screenPos.y - (h + 6) : screenPos.y + 6, w, h)
+        .constrainedWithin (parentArea);
+}
+
+void LookAndFeel::drawTooltip (juce::Graphics& g, const juce::String& text, int width, int height)
+{
+    const auto bounds = juce::Rectangle<int> (width, height).toFloat();
+    g.fillAll (bg3);
+    g.setColour (borderStrong);
+    g.drawRect (bounds, 1.0f);
+
+    juce::AttributedString s;
+    s.setJustification (juce::Justification::centredLeft);
+    s.append (text, uiFont (type::small), textPrimary);
+    juce::TextLayout layout;
+    layout.createLayoutWithBalancedLineLengths (s, 360.0f);
+    layout.draw (g, bounds.reduced (9.0f, 6.0f));
+}
+
+juce::Font LookAndFeel::getAlertWindowTitleFont() { return uiFont (type::title, true); }
+juce::Font LookAndFeel::getAlertWindowMessageFont() { return uiFont (type::body); }
+juce::Font LookAndFeel::getAlertWindowFont() { return uiFont (type::body); }
+
+void LookAndFeel::drawAlertBox (juce::Graphics& g, juce::AlertWindow& alert, const juce::Rectangle<int>& textArea, juce::TextLayout& textLayout)
+{
+    auto bounds = alert.getLocalBounds().toFloat();
+    g.fillAll (bg3);
+    g.setColour (borderStrong);
+    g.drawRect (bounds, 1.0f);
+    g.setColour (accent);
+    g.fillRect (bounds.removeFromTop (3.0f));
+
+    auto iconSpace = 0;
+    const auto type = alert.getAlertType();
+
+    if (type != juce::MessageBoxIconType::NoIcon)
+    {
+        iconSpace = 46;
+        const auto iconArea = juce::Rectangle<float> ((float) textArea.getX() - 2.0f, (float) textArea.getY() + 2.0f, 30.0f, 30.0f);
+        const auto tint = type == juce::MessageBoxIconType::WarningIcon ? warning : type == juce::MessageBoxIconType::InfoIcon ? info : accent;
+        g.setColour (tint.withAlpha (0.16f));
+        g.fillEllipse (iconArea);
+        g.setColour (tint);
+        g.setFont (uiFont (18.0f, true));
+        g.drawText (type == juce::MessageBoxIconType::QuestionIcon ? "?" : type == juce::MessageBoxIconType::InfoIcon ? "i" : "!",
+                    iconArea, juce::Justification::centred);
+    }
+
+    g.setColour (alert.findColour (juce::AlertWindow::textColourId));
+    textLayout.draw (g, textArea.withTrimmedLeft (iconSpace).toFloat());
+}
+
+void LookAndFeel::drawDocumentWindowTitleBar (juce::DocumentWindow& window, juce::Graphics& g, int w, int h, int titleSpaceX, int titleSpaceW,
+                                              const juce::Image* icon, bool drawTitleTextOnLeft)
+{
+    if (w * h == 0)
+        return;
+
+    g.fillAll (bg1);
+    g.setColour (border);
+    g.fillRect (0, h - 1, w, 1);
+
+    const auto font = uiFont (type::body);
+    g.setFont (font);
+    auto textW = juce::GlyphArrangement::getStringWidthInt (font, window.getName());
+    auto iconW = 0;
+
+    if (icon != nullptr)
+        iconW = h - 10 + 6;
+
+    textW = juce::jmin (titleSpaceW, textW + iconW);
+    auto textX = drawTitleTextOnLeft ? titleSpaceX + 4 : juce::jmax (titleSpaceX, (w - textW) / 2);
+
+    if (icon != nullptr)
+    {
+        g.setOpacity (window.isActiveWindow() ? 1.0f : 0.6f);
+        g.drawImageWithin (*icon, textX, 5, h - 10, h - 10, juce::RectanglePlacement::centred, false);
+        textX += iconW;
+        textW -= iconW;
+    }
+
+    g.setColour (window.isActiveWindow() ? textPrimary : textSecondary);
+    g.drawText (window.getName(), textX, 0, textW, h, juce::Justification::centredLeft, true);
+}
+
+juce::Button* LookAndFeel::createDocumentWindowButton (int buttonType)
+{
+    if (buttonType == juce::DocumentWindow::closeButton)
+        return new CaptionButton ("close", Icon::close, true);
+    if (buttonType == juce::DocumentWindow::minimiseButton)
+        return new CaptionButton ("minimise", Icon::minimise, false);
+    return new CaptionButton ("maximise", Icon::maximise, false);
+}
+
+void LookAndFeel::drawCornerResizer (juce::Graphics& g, int w, int h, bool isMouseOver, bool isMouseDragging)
+{
+    g.setColour (isMouseOver || isMouseDragging ? textSecondary : textDisabled);
+    for (float i = 0.3f; i < 1.0f; i += 0.3f)
+        g.drawLine ((float) w * i, (float) h + 1.0f, (float) w + 1.0f, (float) h * i, 1.0f);
+}
+
+void LookAndFeel::drawProgressBar (juce::Graphics& g, juce::ProgressBar& bar, int width, int height, double progress, const juce::String& textToShow)
+{
+    juce::ignoreUnused (bar);
+    const auto r = juce::Rectangle<int> (width, height).toFloat();
+    fillRounded (g, r, r.getHeight() / 2, bg0);
+
+    if (progress >= 0.0 && progress <= 1.0)
+        fillRounded (g, r.withWidth (juce::jmax (r.getHeight(), (float) (r.getWidth() * progress))), r.getHeight() / 2, accent);
+    else // indeterminate: a sliding segment
+    {
+        const auto t = (float) std::fmod (juce::Time::getMillisecondCounterHiRes() / 1200.0, 1.0);
+        fillRounded (g, r.withWidth (r.getWidth() * 0.3f).withX (r.getX() + (r.getWidth() * 1.3f) * t - r.getWidth() * 0.3f), r.getHeight() / 2,
+                     accent.withAlpha (0.8f));
+    }
+
+    if (textToShow.isNotEmpty())
+    {
+        g.setColour (textPrimary);
+        g.setFont (uiFont (type::small));
+        g.drawText (textToShow, r, juce::Justification::centred, false);
+    }
+}
+
+void LookAndFeel::drawGroupComponentOutline (juce::Graphics& g, int w, int h, const juce::String& text, const juce::Justification&,
+                                             juce::GroupComponent&)
+{
+    const auto r = juce::Rectangle<float> (0.5f, 8.5f, (float) w - 1.0f, (float) h - 9.0f);
+    outlineRounded (g, r, radius::lg, border);
+
+    if (text.isNotEmpty())
+    {
+        const auto font = uiFont (type::small, true);
+        const auto tw = juce::GlyphArrangement::getStringWidth (font, text) + 10.0f;
+        g.setColour (bg2);
+        g.fillRect (12.0f, 0.0f, tw, 16.0f);
+        g.setColour (textSecondary);
+        g.setFont (font);
+        g.drawText (text, juce::Rectangle<float> (12.0f, 0.0f, tw, 16.0f), juce::Justification::centred, false);
+    }
+}
+
+// --- file browser ----------------------------------------------------------------------------------
+
+void LookAndFeel::drawFileBrowserRow (juce::Graphics& g, int width, int height, const juce::File& file, const juce::String& filename,
+                                      juce::Image*, const juce::String&, const juce::String&, bool isDirectory, bool isItemSelected, int,
+                                      juce::DirectoryContentsDisplayComponent&)
+{
+    const auto r = juce::Rectangle<int> (width, height).toFloat();
+
+    if (isItemSelected)
+    {
+        fillRounded (g, r.reduced (1.0f, 0.5f), radius::sm, accentMuted);
+        g.setColour (accent);
+        g.fillRoundedRectangle (r.withWidth (2.5f).reduced (0.0f, 3.0f), 1.0f);
+    }
+
+    auto iconKind = Icon::file;
+    if (isDirectory)
+        iconKind = Icon::folder;
+    else if (file.hasFileExtension ("wav;aif;aiff;flac;ogg;mp3;wv"))
+        iconKind = Icon::audioFile;
+    else if (file.hasFileExtension ("lynx;flp;dawproj"))
+        iconKind = Icon::project;
+    else if (file.hasFileExtension ("mid;midi"))
+        iconKind = Icon::pianoRoll;
+    else if (file.hasFileExtension ("fst;lynxpreset"))
+        iconKind = Icon::preset;
+
+    const auto iconSize = juce::jmin (16.0f, (float) height - 4.0f);
+    icons::draw (g, iconKind, juce::Rectangle<float> (4.0f, ((float) height - iconSize) / 2.0f, iconSize, iconSize),
+                 isDirectory ? textSecondary.brighter (0.15f) : (iconKind == Icon::audioFile ? info : textSecondary));
+
+    g.setColour (isItemSelected ? textPrimary : (isDirectory ? textPrimary : textPrimary.withAlpha (0.88f)));
+    g.setFont (uiFont (type::body, false));
+    g.drawFittedText (filename, juce::Rectangle<int> (juce::roundToInt (iconSize) + 10, 0, width - juce::roundToInt (iconSize) - 12, height),
+                      juce::Justification::centredLeft, 1, 0.9f);
+}
+
+void LookAndFeel::drawTreeviewPlusMinusBox (juce::Graphics& g, const juce::Rectangle<float>& area, juce::Colour, bool isOpen, bool isMouseOver)
+{
+    const auto r = area.withSizeKeepingCentre (12.0f, 12.0f);
+    juce::Graphics::ScopedSaveState state (g);
+    if (! isOpen)
+        g.addTransform (juce::AffineTransform::rotation (-pi * 0.5f, r.getCentreX(), r.getCentreY()));
+    icons::draw (g, Icon::chevronDown, r, isMouseOver ? textPrimary : textSecondary);
+}
+} // namespace lynx::theme

+ 199 - 35
src/ui/Theme.h

@@ -2,58 +2,222 @@
 
 #include <juce_gui_basics/juce_gui_basics.h>
 
-// Palette and LookAndFeel: dark bluish-grey tones, accents in orange,
-// green and blue, in the spirit of FL Studio.
+// LYNX design tokens: the single source of colours, type sizes, spacing and radii for the whole UI,
+// plus the LookAndFeel that draws every stock JUCE widget with them.
+//
+// Identity: dark, flat, high contrast, with one red accent used sparingly (selection, active
+// states, playhead/record, primary actions). Surfaces get lighter as they rise ("elevation").
 namespace lynx::theme
 {
-inline const juce::Colour window { 0xff1e2226 };
-inline const juce::Colour panel { 0xff2b3036 };
-inline const juce::Colour toolbar { 0xff32383f };
-inline const juce::Colour channelButton { 0xff434a52 };
-inline const juce::Colour channelButtonSelected { 0xff56606b };
-inline const juce::Colour knobBackground { 0xff1b1e22 };
-inline const juce::Colour stepOn { 0xffe8e8e8 };
-inline const juce::Colour stepOnOffGrid { 0xff9fd3ff };
-inline const juce::Colour accentOrange { 0xffff9a3c };
-inline const juce::Colour accentGreen { 0xff7ed957 };
-inline const juce::Colour accentBlue { 0xff58b7ff };
-inline const juce::Colour playhead { 0xff30c0ff };
-inline const juce::Colour text { 0xffe6e6e6 };
+// --- colours -----------------------------------------------------------------------------------
+namespace colour
+{
+// backgrounds by elevation (0 = deepest)
+inline const juce::Colour bg0 { 0xff0e0f12 };   // editor canvases, insets, meter wells
+inline const juce::Colour bg1 { 0xff15161a };   // app background, menu bar, status bar
+inline const juce::Colour bg2 { 0xff1b1d22 };   // panels (browser, rack, mixer strips)
+inline const juce::Colour bg3 { 0xff23262c };   // raised surfaces: toolbar, headers, popups
+inline const juce::Colour bg4 { 0xff2c2f37 };   // controls at rest
+inline const juce::Colour bg5 { 0xff363a43 };   // controls hovered
+inline const juce::Colour bg6 { 0xff434852 };   // controls pressed / neutral "on"
+
+inline const juce::Colour border { 0xff2a2d34 };       // hairlines between areas
+inline const juce::Colour borderStrong { 0xff3b3f48 }; // control outlines
+
+inline const juce::Colour textPrimary { 0xffeceef2 };
+inline const juce::Colour textSecondary { 0xffa1a6b0 };
+inline const juce::Colour textDisabled { 0xff60656f };
+
+// the red accent
+inline const juce::Colour accent { 0xffe5383b };
+inline const juce::Colour accentHover { 0xfff2545a };
+inline const juce::Colour accentPressed { 0xffc12a30 };
+inline const juce::Colour accentMuted { 0xff5c1f24 };  // tinted backgrounds (armed, selected rows)
+inline const juce::Colour onAccent { 0xffffffff };     // text/icons drawn on the accent
+
+// semantic
+inline const juce::Colour selection { accent };                       // selected notes/clips outline
+inline const juce::Colour selectionFill { 0x2ee5383b };               // selection rectangles
+inline const juce::Colour playhead { accent };
+inline const juce::Colour record { 0xffff3b3f };
+inline const juce::Colour automation { 0xff4cc9c0 };                   // automation curves and clips
+inline const juce::Colour info { 0xff6ea8fe };                         // secondary values (pan, links)
+inline const juce::Colour ledOn { 0xff3ddc84 };                        // "active/unmuted" LEDs
+inline const juce::Colour ledOff { 0xff3a3e47 };
+inline const juce::Colour warning { 0xfff5b942 };                      // markers, missing items
+inline const juce::Colour meterLow { 0xff3ddc84 };
+inline const juce::Colour meterMid { 0xfff5c542 };
+inline const juce::Colour meterClip { 0xffff3b3f };
+
+// step sequencer / editors
+inline const juce::Colour stepOff { 0xff2a2d34 };
+inline const juce::Colour stepOffAlt { 0xff33363f };   // every other group of 4 steps
+inline const juce::Colour stepOn { accent };
+inline const juce::Colour stepNote { 0xffe8a3a6 };     // a step that only has a Piano Roll note
+inline const juce::Colour gridBar { 0xff3a3e47 };      // bar lines
+inline const juce::Colour gridBeat { 0xff262930 };     // beat lines
+inline const juce::Colour gridStep { 0xff1d1f24 };     // step lines
+inline const juce::Colour keyWhite { 0xffd9dbe0 };
+inline const juce::Colour keyBlack { 0xff17181c };
+inline const juce::Colour rowWhite { 0xff1c1e23 };     // Piano Roll rows of white keys
+inline const juce::Colour rowBlack { 0xff16171b };     // rows of black keys
+inline const juce::Colour noteSoft { 0xffb3545a };     // note colour at velocity 0
+inline const juce::Colour noteHard { 0xffff6b6e };     // note colour at velocity 1
+inline const juce::Colour noteMuted { 0xff4a4e57 };
+inline const juce::Colour audioClip { 0xff5a87b8 };
+} // namespace colour
+
+// --- typography ----------------------------------------------------------------------------------
+namespace type
+{
+inline constexpr float caption = 11.0f;  // grid numbers, small captions
+inline constexpr float small = 12.0f;    // secondary labels, status bar, tooltips
+inline constexpr float body = 13.0f;     // default control text
+inline constexpr float title = 15.0f;    // panel titles
+inline constexpr float display = 20.0f;  // the transport position
+} // namespace type
+
+inline juce::FontOptions font (float size, bool bold = false)
+{
+    return juce::FontOptions (size, bold ? juce::Font::bold : juce::Font::plain);
+}
+
+inline juce::FontOptions monoFont (float size)
+{
+    return juce::FontOptions (juce::Font::getDefaultMonospacedFontName(), size, juce::Font::plain);
+}
+
+// --- spacing and radii ---------------------------------------------------------------------------
+namespace space
+{
+inline constexpr int xs = 2, sm = 4, md = 8, lg = 12, xl = 16;
+}
 
+namespace radius
+{
+inline constexpr float sm = 3.0f, md = 4.0f, lg = 6.0f;
+}
+
+// --- helpers -------------------------------------------------------------------------------------
 inline juce::Colour stepOff (int step)
 {
-    return (step / 4) % 2 == 0 ? juce::Colour (0xff4a525b) : juce::Colour (0xff5b4f4f); // alternating groups of 4
+    return (step / 4) % 2 == 0 ? colour::stepOff : colour::stepOffAlt; // alternating groups of 4
 }
 
 inline juce::Colour muteLed (bool muted)
 {
-    return muted ? juce::Colour (0xff505050) : accentGreen;
+    return muted ? colour::ledOff : colour::ledOn;
 }
 
-// Piano Roll note colour by velocity (soft = greenish, hard = orange).
+// Piano Roll note colour by velocity (soft = dark rose, hard = bright red).
 inline juce::Colour noteColour (float velocity)
 {
-    return juce::Colour (0xff7ed957).interpolatedWith (accentOrange, juce::jlimit (0.0f, 1.0f, velocity));
+    return colour::noteSoft.interpolatedWith (colour::noteHard, juce::jlimit (0.0f, 1.0f, velocity));
 }
 
+// A user/channel colour toned down to sit on the dark surfaces without shouting.
+inline juce::Colour tame (juce::Colour c)
+{
+    return c.withMultipliedSaturation (0.8f).withBrightness (juce::jmin (c.getBrightness(), 0.72f));
+}
+
+// Draws a rotary value arc in the LYNX style (used by custom-painted knobs too).
+void drawKnob (juce::Graphics& g, juce::Rectangle<float> bounds, float value01, bool bipolar, juce::Colour arc, bool hover = false);
+
+// --- legacy names (kept so code written against the old palette keeps compiling) ---------------
+inline const juce::Colour window { colour::bg1 };
+inline const juce::Colour panel { colour::bg2 };
+inline const juce::Colour toolbar { colour::bg3 };
+inline const juce::Colour channelButton { colour::bg4 };
+inline const juce::Colour channelButtonSelected { colour::bg6 };
+inline const juce::Colour knobBackground { colour::bg0 };
+inline const juce::Colour stepOn { colour::stepOn };
+inline const juce::Colour stepOnOffGrid { colour::stepNote };
+inline const juce::Colour accentOrange { colour::accent };
+inline const juce::Colour accentGreen { colour::ledOn };
+inline const juce::Colour accentBlue { colour::info };
+inline const juce::Colour playhead { colour::playhead };
+inline const juce::Colour text { colour::textPrimary };
+
+// --- LookAndFeel ---------------------------------------------------------------------------------
 class LookAndFeel final : public juce::LookAndFeel_V4
 {
 public:
-    LookAndFeel()
-        : juce::LookAndFeel_V4 (juce::LookAndFeel_V4::ColourScheme {
-              window, panel, toolbar, juce::Colour (0xff4d5560), text, toolbar, juce::Colours::white, accentOrange,
-              text })
-    {
-        setColour (juce::TextButton::buttonOnColourId, accentOrange.darker (0.3f));
-        setColour (juce::ComboBox::backgroundColourId, panel);
-        setColour (juce::TabbedButtonBar::tabOutlineColourId, juce::Colours::transparentBlack);
-        setColour (juce::TabbedButtonBar::frontOutlineColourId, juce::Colours::transparentBlack);
-        setColour (juce::TabbedComponent::outlineColourId, juce::Colours::transparentBlack);
-        setColour (juce::TabbedButtonBar::tabTextColourId, text.withAlpha (0.6f));
-        setColour (juce::TabbedButtonBar::frontTextColourId, accentOrange);
-        setColour (juce::Slider::rotarySliderFillColourId, accentOrange);
-        setColour (juce::Slider::rotarySliderOutlineColourId, juce::Colour (0xff4a525b));
-        setColour (juce::Slider::thumbColourId, juce::Colours::white);
-    }
+    LookAndFeel();
+
+    // property set on a Button / TabBarButton to draw one of lynx::Icon next to (or instead of) its text
+    static constexpr const char* iconProperty = "lynxIcon";
+
+    // buttons
+    void drawButtonBackground (juce::Graphics&, juce::Button&, const juce::Colour& backgroundColour, bool highlighted, bool down) override;
+    void drawButtonText (juce::Graphics&, juce::TextButton&, bool highlighted, bool down) override;
+    juce::Font getTextButtonFont (juce::TextButton&, int buttonHeight) override;
+    void drawToggleButton (juce::Graphics&, juce::ToggleButton&, bool highlighted, bool down) override;
+    void drawTickBox (juce::Graphics&, juce::Component&, float x, float y, float w, float h, bool ticked, bool enabled, bool highlighted, bool down) override;
+
+    // combo boxes and menus
+    void drawComboBox (juce::Graphics&, int width, int height, bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, juce::ComboBox&) override;
+    juce::Font getComboBoxFont (juce::ComboBox&) override;
+    void positionComboBoxText (juce::ComboBox&, juce::Label&) override;
+    void drawPopupMenuBackground (juce::Graphics&, int width, int height) override;
+    void drawPopupMenuItem (juce::Graphics&, const juce::Rectangle<int>& area, bool isSeparator, bool isActive, bool isHighlighted,
+                            bool isTicked, bool hasSubMenu, const juce::String& text, const juce::String& shortcutKeyText,
+                            const juce::Drawable* icon, const juce::Colour* textColour) override;
+    void drawPopupMenuSectionHeader (juce::Graphics&, const juce::Rectangle<int>& area, const juce::String& sectionName) override;
+    juce::Font getPopupMenuFont() override;
+    void getIdealPopupMenuItemSize (const juce::String& text, bool isSeparator, int standardMenuItemHeight, int& idealWidth, int& idealHeight) override;
+    int getPopupMenuBorderSize() override { return 4; }
+    void drawMenuBarBackground (juce::Graphics&, int width, int height, bool isMouseOverBar, juce::MenuBarComponent&) override;
+    void drawMenuBarItem (juce::Graphics&, int width, int height, int itemIndex, const juce::String& itemText, bool isMouseOverItem,
+                          bool isMenuOpen, bool isMouseOverBar, juce::MenuBarComponent&) override;
+    juce::Font getMenuBarFont (juce::MenuBarComponent&, int itemIndex, const juce::String& itemText) override;
+    int getMenuBarItemWidth (juce::MenuBarComponent&, int itemIndex, const juce::String& itemText) override;
+
+    // sliders
+    void drawRotarySlider (juce::Graphics&, int x, int y, int width, int height, float sliderPosProportional, float rotaryStartAngle,
+                           float rotaryEndAngle, juce::Slider&) override;
+    void drawLinearSlider (juce::Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos,
+                           juce::Slider::SliderStyle, juce::Slider&) override;
+    juce::Label* createSliderTextBox (juce::Slider&) override;
+    juce::Button* createSliderButton (juce::Slider&, bool isIncrement) override;
+    juce::Slider::SliderLayout getSliderLayout (juce::Slider&) override;
+
+    // scrollbars
+    void drawScrollbar (juce::Graphics&, juce::ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical, int thumbStartPosition,
+                        int thumbSize, bool isMouseOver, bool isMouseDown) override;
+    int getDefaultScrollbarWidth() override { return 10; }
+    bool areScrollbarButtonsVisible() override { return false; }
+
+    // tabs
+    int getTabButtonBestWidth (juce::TabBarButton&, int tabDepth) override;
+    void drawTabButton (juce::TabBarButton&, juce::Graphics&, bool isMouseOver, bool isMouseDown) override;
+    void drawTabbedButtonBarBackground (juce::TabbedButtonBar&, juce::Graphics&) override;
+    void drawTabAreaBehindFrontButton (juce::TabbedButtonBar&, juce::Graphics&, int w, int h) override;
+
+    // text
+    void fillTextEditorBackground (juce::Graphics&, int width, int height, juce::TextEditor&) override;
+    void drawTextEditorOutline (juce::Graphics&, int width, int height, juce::TextEditor&) override;
+    void drawLabel (juce::Graphics&, juce::Label&) override;
+
+    // tooltips, alerts, windows
+    juce::Rectangle<int> getTooltipBounds (const juce::String& tipText, juce::Point<int> screenPos, juce::Rectangle<int> parentArea) override;
+    void drawTooltip (juce::Graphics&, const juce::String& text, int width, int height) override;
+    void drawAlertBox (juce::Graphics&, juce::AlertWindow&, const juce::Rectangle<int>& textArea, juce::TextLayout&) override;
+    int getAlertWindowButtonHeight() override { return 30; }
+    juce::Font getAlertWindowTitleFont() override;
+    juce::Font getAlertWindowMessageFont() override;
+    juce::Font getAlertWindowFont() override;
+    void drawDocumentWindowTitleBar (juce::DocumentWindow&, juce::Graphics&, int w, int h, int titleSpaceX, int titleSpaceW,
+                                     const juce::Image* icon, bool drawTitleTextOnLeft) override;
+    juce::Button* createDocumentWindowButton (int buttonType) override;
+    void drawCornerResizer (juce::Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) override;
+    void drawProgressBar (juce::Graphics&, juce::ProgressBar&, int width, int height, double progress, const juce::String& textToShow) override;
+    void drawGroupComponentOutline (juce::Graphics&, int w, int h, const juce::String& text, const juce::Justification&, juce::GroupComponent&) override;
+
+    // file browser (the LYNX browser panel is a FileTreeComponent)
+    void drawFileBrowserRow (juce::Graphics&, int width, int height, const juce::File& file, const juce::String& filename, juce::Image* icon,
+                             const juce::String& fileSizeDescription, const juce::String& fileTimeDescription, bool isDirectory,
+                             bool isItemSelected, int itemIndex, juce::DirectoryContentsDisplayComponent&) override;
+    void drawTreeviewPlusMinusBox (juce::Graphics&, const juce::Rectangle<float>& area, juce::Colour backgroundColour, bool isOpen, bool isMouseOver) override;
 };
 } // namespace lynx::theme

+ 72 - 0
tools/i18n_keys.py

@@ -0,0 +1,72 @@
+# Lists the translatable strings of the UI (string literals passed to tr() / TR_NOOP()) and
+# checks them against a translation table.
+# Usage: python3 tools/i18n_keys.py [resources/i18n/pt-BR.txt] [--missing] [--unused]
+#   --missing  print the keys with no translation, as lines ready to paste into the table
+#   --unused   print table entries no source uses (JUCE's own strings are expected here)
+import pathlib, re, sys
+
+root = pathlib.Path(__file__).resolve().parent.parent
+
+def unescape(s):
+    out, i = [], 0
+    while i < len(s):
+        c = s[i]
+        if c == "\\" and i + 1 < len(s):
+            n = s[i + 1]
+            out.append({"n": "\n", "t": "\t", '"': '"', "\\": "\\", "'": "'"}.get(n, n))
+            i += 2
+        else:
+            out.append(c)
+            i += 1
+    return "".join(out)
+
+def escape(s):
+    return s.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n").replace("\t", "\\t")
+
+def source_keys():
+    keys = {}
+    call = re.compile(r'(?<![A-Za-z0-9_])(tr|TR_NOOP)\s*\(\s*')
+    literal = re.compile(r'"((?:[^"\\\n]|\\.)*)"\s*')
+    for path in sorted(list((root / "src").rglob("*.cpp")) + list((root / "src").rglob("*.h"))):
+        text = path.read_text(encoding="utf-8", errors="replace")
+        text = "\n".join("" if l.strip().startswith("//") else l for l in text.split("\n"))
+        for m in call.finditer(text):
+            pos, parts = m.end(), []
+            while True:
+                lm = literal.match(text, pos)
+                if not lm:
+                    break
+                parts.append(lm.group(1))
+                pos = lm.end()
+            if parts:
+                keys.setdefault(unescape("".join(parts)), str(path.relative_to(root)))
+    return keys
+
+def table(path):
+    entries = {}
+    pair = re.compile(r'^"((?:[^"\\]|\\.)*)"\s*=\s*"((?:[^"\\]|\\.)*)"\s*$')
+    for line in pathlib.Path(path).read_text(encoding="utf-8").split("\n"):
+        m = pair.match(line.strip())
+        if m:
+            entries[unescape(m.group(1))] = unescape(m.group(2))
+    return entries
+
+if __name__ == "__main__":
+    args = [a for a in sys.argv[1:] if not a.startswith("--")]
+    path = args[0] if args else root / "resources/i18n/pt-BR.txt"
+    keys = source_keys()
+    entries = table(path) if pathlib.Path(path).exists() else {}
+    missing = [k for k in keys if not entries.get(k)]
+    if "--missing" in sys.argv:
+        last = None
+        for k in missing:
+            if keys[k] != last:
+                print(f"\n# {keys[k]}")
+                last = keys[k]
+            print(f'"{escape(k)}" = ""')
+    elif "--unused" in sys.argv:
+        for k in entries:
+            if k not in keys:
+                print(f'"{escape(k)}"')
+    else:
+        print(f"{len(keys)} keys in the sources, {len(entries)} entries in {path}, {len(missing)} missing")

+ 21 - 0
tools/make_i18n.py

@@ -0,0 +1,21 @@
+# Embeds the translation tables in the executable.
+# Usage: python3 tools/make_i18n.py   (from the repository root)
+# Reads resources/i18n/pt-BR.txt and writes src/ui/I18nData.h.
+import pathlib
+
+root = pathlib.Path(__file__).resolve().parent.parent
+tables = [("ptBR", "resources/i18n/pt-BR.txt")]
+
+out = ["#pragma once", "",
+       "// Generated by tools/make_i18n.py from resources/i18n/*.txt - do not edit by hand.", "",
+       "namespace lynx::i18n::data", "{"]
+for name, path in tables:
+    data = (root / path).read_bytes()
+    out.append(f"// {path}")
+    out.append(f"inline constexpr unsigned char {name}[] = {{")
+    for i in range(0, len(data), 24):
+        out.append(", ".join(str(b) for b in data[i:i + 24]) + ",")
+    out.append("};")
+out.append("} // namespace lynx::i18n::data")
+out.append("")
+(root / "src/ui/I18nData.h").write_text("\n".join(out))