Przeglądaj źródła

Playlist and automation editor: design tokens and translatable strings

Clips share one frame: tamed pattern colour, solid title band with contrast-aware
text, red outline when selected. Loop and playhead in red, markers as amber tags
(time signatures in blue), automation in teal. The Picker is a clean list with a
red strip on the current pattern. Menus, tooltips and dialogs go through tr().
Kauan 1 miesiąc temu
rodzic
commit
d5e38936bc
2 zmienionych plików z 219 dodań i 188 usunięć
  1. 44 33
      src/ui/AutomationUi.cpp
  2. 175 155
      src/ui/PlaylistComponent.cpp

+ 44 - 33
src/ui/AutomationUi.cpp

@@ -5,6 +5,7 @@
 
 #include "core/Effects.h"
 #include "engine/Text.h"
+#include "ui/I18n.h"
 #include "ui/Theme.h"
 
 namespace lynx
@@ -53,7 +54,8 @@ public:
 
     void paint (juce::Graphics& g) override
     {
-        g.fillAll (theme::window);
+        using namespace theme;
+        g.fillAll (colour::bg1);
         const auto* a = current();
 
         if (a == nullptr)
@@ -63,7 +65,7 @@ public:
         const auto area = plotArea();
         const auto bar = (std::int64_t) ppq * juce::jmax (1, song.beatsPerBar);
 
-        g.setColour (juce::Colour (0xff262b30));
+        g.setColour (colour::bg0);
         g.fillRect (area);
 
         // grid: beats and bars
@@ -78,20 +80,20 @@ public:
                 continue;
 
             const auto x = (int) tickToX ((double) tick);
-            g.setColour (isBar ? juce::Colour (0xff15181b) : juce::Colour (0xff2c3238));
+            g.setColour (isBar ? colour::gridBar : colour::gridBeat);
             g.drawVerticalLine (x, (float) area.getY(), (float) area.getBottom());
 
             if (isBar)
             {
-                g.setColour (theme::text.withAlpha (0.6f));
-                g.setFont (juce::FontOptions (11.0f));
+                g.setColour (colour::textSecondary);
+                g.setFont (font (type::caption));
                 g.drawText (juce::String (tick / bar + 1), x + 3, 2, 40, 16, juce::Justification::centredLeft);
             }
         }
 
         for (auto v : { 0.25f, 0.5f, 0.75f })
         {
-            g.setColour (juce::Colour (0xff2f353c));
+            g.setColour (colour::gridStep.brighter (0.15f));
             g.drawHorizontalLine ((int) valueToY (v), (float) area.getX(), (float) area.getRight());
         }
 
@@ -109,34 +111,43 @@ public:
                 curve.lineTo ((float) x, y);
         }
 
-        g.setColour (theme::accentGreen);
-        g.strokePath (curve, juce::PathStrokeType (2.0f));
+        // soft fill under the curve, then the line
+        auto fill = curve;
+        fill.lineTo ((float) area.getRight(), (float) area.getBottom());
+        fill.lineTo ((float) area.getX(), (float) area.getBottom());
+        fill.closeSubPath();
+        g.setColour (colour::automation.withAlpha (0.10f));
+        g.fillPath (fill);
+        g.setColour (colour::automation);
+        g.strokePath (curve, juce::PathStrokeType (2.0f, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
 
         for (std::size_t i = 0; i < points.size(); ++i)
         {
             const auto p = pointPosition (points[i]);
-            g.setColour ((int) i == hoverPoint || (int) i == dragPoint ? juce::Colours::white : theme::accentGreen);
-            g.fillEllipse (p.x - 5.0f, p.y - 5.0f, 10.0f, 10.0f);
-            g.setColour (juce::Colours::black.withAlpha (0.6f));
-            g.drawEllipse (p.x - 5.0f, p.y - 5.0f, 10.0f, 10.0f, 1.0f);
+            const auto active = (int) i == hoverPoint || (int) i == dragPoint;
+            g.setColour (colour::bg0);
+            g.fillEllipse (p.x - 6.0f, p.y - 6.0f, 12.0f, 12.0f);
+            g.setColour (active ? colour::textPrimary : colour::automation);
+            g.fillEllipse (p.x - 4.5f, p.y - 4.5f, 9.0f, 9.0f);
         }
 
         // playback cursor (at the position of the clip currently playing)
         if (playhead >= 0.0)
         {
-            g.setColour (theme::playhead);
+            g.setColour (colour::playhead);
             g.drawVerticalLine ((int) tickToX (playhead), (float) area.getY(), (float) area.getBottom());
         }
 
-        g.setColour (theme::text.withAlpha (0.45f));
-        g.setFont (juce::FontOptions (11.0f));
-        g.drawText (utf8 ("Click: new point · drag: move · right-click: delete · Alt+drag: curve · Ctrl+wheel: zoom"),
+        g.setColour (colour::textSecondary);
+        g.setFont (font (type::caption));
+        g.drawText (tr ("Click: new point · drag: move · right-click: delete · Alt+drag: curve · Ctrl+wheel: zoom"),
                     area.getX(), getHeight() - 18, area.getWidth(), 16, juce::Justification::centredLeft);
 
         if (hoverPoint >= 0 && hoverPoint < (int) points.size())
         {
             const auto p = pointPosition (points[(std::size_t) hoverPoint]);
-            g.setColour (theme::text);
+            g.setColour (colour::textPrimary);
+            g.setFont (font (type::small));
             const auto value = points[(std::size_t) hoverPoint].value;
             g.drawText (a->target.kind == AutomationTargetKind::tempo ? juce::String (tempoFromValue (value), 1) + " BPM"
                                                                        : juce::String (juce::roundToInt (value * 100.0f)) + "%",
@@ -311,7 +322,7 @@ private:
         }
 
         if (auto* w = findParentComponentOfClass<juce::DocumentWindow>())
-            w->setName (utf8 ("Automation - ") + juce::String::fromUTF8 (current()->name.c_str()));
+            w->setName (tr ("Automation - {0}", { juce::String::fromUTF8 (current()->name.c_str()) }));
 
         repaint();
     }
@@ -351,7 +362,7 @@ class AutomationWindow final : public juce::DocumentWindow
 {
 public:
     AutomationWindow (AudioEngine& engine, int index, const juce::String& title)
-        : juce::DocumentWindow (title, theme::window, DocumentWindow::closeButton)
+        : juce::DocumentWindow (title, theme::colour::bg1, DocumentWindow::closeButton)
     {
         setUsingNativeTitleBar (true);
         setContentOwned (new AutomationEditor (engine, index), true);
@@ -391,15 +402,15 @@ juce::String describeAutomationTarget (AudioEngine& engine, const AutomationTarg
 
     switch (t.kind)
     {
-        case AutomationTargetKind::channelVolume: return channelName + " - Volume";
-        case AutomationTargetKind::channelPan: return channelName + " - Pan";
-        case AutomationTargetKind::mixerVolume: return trackName + " - Volume";
-        case AutomationTargetKind::mixerPan: return trackName + " - Pan";
+        case AutomationTargetKind::channelVolume: return channelName + " - " + tr ("Volume");
+        case AutomationTargetKind::channelPan: return channelName + " - " + tr ("Pan");
+        case AutomationTargetKind::mixerVolume: return trackName + " - " + tr ("Volume");
+        case AutomationTargetKind::mixerPan: return trackName + " - " + tr ("Pan");
 
         case AutomationTargetKind::channelParam:
         case AutomationTargetKind::effectParam:
         {
-            juce::String param = juce::String ("Param ") + juce::String (t.param + 1);
+            juce::String param = tr ("Param {0}", { juce::String (t.param + 1) });
 
             if (auto* plugin = pluginFor (engine, t))
             {
@@ -418,18 +429,18 @@ juce::String describeAutomationTarget (AudioEngine& engine, const AutomationTarg
             return (t.kind == AutomationTargetKind::channelParam ? channelName : trackName) + " - " + param;
         }
 
-        case AutomationTargetKind::tempo: return "Tempo";
+        case AutomationTargetKind::tempo: return tr ("Tempo");
         case AutomationTargetKind::effectMix:
         {
             juce::String effect = "FX " + juce::String (t.slot + 1);
             if (t.index < (int) song.mixer.size() && t.slot >= 0 && t.slot < (int) song.mixer[(std::size_t) t.index].effects.size())
                 effect = utf8 (effectInfo (song.mixer[(std::size_t) t.index].effects[(std::size_t) t.slot].kind).name);
-            return trackName + " - " + effect + " - Mix";
+            return trackName + " - " + effect + " - " + tr ("Mix");
         }
         case AutomationTargetKind::none: break;
     }
 
-    return utf8 ("(no target)");
+    return tr ("(no target)");
 }
 
 void createAutomationClip (AudioEngine& engine, const AutomationTarget& target)
@@ -482,7 +493,7 @@ void openAutomationEditor (AudioEngine& engine, int index)
         }
 
     windows().push_back (std::make_unique<AutomationWindow> (
-        engine, index, utf8 ("Automation - ") + nameOf (engine.getSong().automations[(std::size_t) index].name)));
+        engine, index, tr ("Automation - {0}", { nameOf (engine.getSong().automations[(std::size_t) index].name) })));
 }
 
 void closeAutomationEditors()
@@ -497,8 +508,8 @@ std::unique_ptr<juce::Component> makeAutomationEditor (AudioEngine& engine, int
 
 void addAutomationItem (juce::PopupMenu& menu, AudioEngine& engine, const AutomationTarget& target)
 {
-    menu.addItem (utf8 ("Create automation clip"), [&engine, target] { createAutomationClip (engine, target); });
-    menu.addItem (utf8 ("Link to MIDI controller (move a knob on the controller)"), [&engine, target] {
+    menu.addItem (tr ("Create automation clip"), [&engine, target] { createAutomationClip (engine, target); });
+    menu.addItem (tr ("Link to MIDI controller (move a knob on the controller)"), [&engine, target] {
         engine.learnMidiController (target);
     });
 
@@ -506,7 +517,7 @@ void addAutomationItem (juce::PopupMenu& menu, AudioEngine& engine, const Automa
     const auto linked = std::find_if (links.begin(), links.end(), [&] (const MidiLink& l) { return l.target == target; });
 
     if (linked != links.end())
-        menu.addItem (utf8 ("Unlink controller (CC ") + juce::String (linked->cc) + ")", [&engine, target] {
+        menu.addItem (tr ("Unlink controller (CC {0})", { juce::String (linked->cc) }), [&engine, target] {
             engine.editSong ([target] (Song& s) {
                 s.midiLinks.erase (std::remove_if (s.midiLinks.begin(), s.midiLinks.end(), [&] (const MidiLink& l) { return l.target == target; }),
                                    s.midiLinks.end());
@@ -530,8 +541,8 @@ void addPluginParameterItems (juce::PopupMenu& menu, AudioEngine& engine, juce::
     }
 
     if (list.isEmpty())
-        params.addItem (utf8 ("(the plugin exposes no parameters)"), false, false, [] {});
+        params.addItem (tr ("(the plugin exposes no parameters)"), false, false, [] {});
 
-    menu.addSubMenu (utf8 ("Automate plugin parameter"), params);
+    menu.addSubMenu (tr ("Automate plugin parameter"), params);
 }
 } // namespace lynx

+ 175 - 155
src/ui/PlaylistComponent.cpp

@@ -4,11 +4,62 @@
 #include "engine/Text.h"
 #include "ui/BrowserComponent.h"
 #include "ui/AutomationUi.h"
-
+#include "ui/I18n.h"
 #include "ui/Theme.h"
 
 namespace lynx
 {
+namespace
+{
+constexpr float clipTitleHeight = 14.0f;
+
+// Text colour readable on a clip's title band.
+juce::Colour clipTitleText (juce::Colour band)
+{
+    return band.getPerceivedBrightness() > 0.62f ? theme::colour::bg0 : theme::colour::textPrimary;
+}
+
+// Clip body (dark tint of the clip colour) with a solid title band; returns the body below the band.
+juce::Rectangle<float> paintClipFrame (juce::Graphics& g, juce::Rectangle<float> r, juce::Colour base, const juce::String& name)
+{
+    using namespace theme;
+    g.setColour (base.interpolatedWith (colour::bg1, 0.62f));
+    g.fillRoundedRectangle (r, radius::sm);
+
+    const auto title = r.withHeight (juce::jmin (clipTitleHeight, r.getHeight()));
+    juce::Path band;
+    band.addRoundedRectangle (title.getX(), title.getY(), title.getWidth(), title.getHeight(), radius::sm, radius::sm, true, true, false, false);
+    g.setColour (base);
+    g.fillPath (band);
+
+    if (r.getWidth() > 24.0f)
+    {
+        g.setColour (clipTitleText (base));
+        g.setFont (font (type::caption, true));
+        g.drawText (name, title.reduced (4.0f, 0.0f).toNearestInt(), juce::Justification::centredLeft, true);
+    }
+
+    return r.withTrimmedTop (title.getHeight());
+}
+
+void paintClipOutline (juce::Graphics& g, juce::Rectangle<float> r, juce::Colour base, bool selected, bool current)
+{
+    using namespace theme;
+    if (selected)
+    {
+        g.setColour (colour::selection);
+        g.drawRoundedRectangle (r.reduced (0.5f), radius::sm, 2.0f);
+    }
+    else
+    {
+        g.setColour (current ? colour::textPrimary.withAlpha (0.55f) : base.darker (0.3f));
+        g.drawRoundedRectangle (r.reduced (0.5f), radius::sm, current ? 1.2f : 1.0f);
+    }
+}
+
+const char* const snapNames[] = { TR_NOOP ("No snap"), TR_NOOP ("1/4 step"), TR_NOOP ("1/2 step"), TR_NOOP ("Step"), TR_NOOP ("Beat"), TR_NOOP ("Bar") };
+} // namespace
+
 PlaylistComponent::PlaylistComponent (AudioEngine& e)
     : engine (e)
 {
@@ -22,14 +73,15 @@ PlaylistComponent::PlaylistComponent (AudioEngine& e)
         addAndMakeVisible (bar);
     }
 
-    snapBox.addItemList ({ "No snap", "1/4 step", "1/2 step", "Step", "Beat", "Bar" }, 1);
+    for (int i = 0; i < (int) std::size (snapNames); ++i)
+        snapBox.addItem (tr (snapNames[i]), i + 1);
     snapBox.setSelectedId (5, juce::dontSendNotification);
-    snapBox.setTooltip ("Playlist snap (grid); hold Alt while dragging to disable");
+    snapBox.setTooltip (tr ("Playlist snap (grid); hold Alt while dragging to disable"));
     snapBox.setWantsKeyboardFocus (false);
     snapBox.setMouseClickGrabsKeyboardFocus (false);
     addAndMakeVisible (snapBox);
 
-    arrangementBox.setTooltip (utf8 ("Arrangement (as in FL, a project can have several)"));
+    arrangementBox.setTooltip (tr ("Arrangement (as in FL, a project can have several)"));
     arrangementBox.setWantsKeyboardFocus (false);
     arrangementBox.setMouseClickGrabsKeyboardFocus (false);
     arrangementBox.onChange = [this] { arrangementChosen(); };
@@ -72,10 +124,10 @@ void PlaylistComponent::refreshArrangementBox()
             arrangementBox.addItem (names[i], i + 1);
 
         arrangementBox.addSeparator();
-        arrangementBox.addItem (utf8 ("New arrangement"), newArrangement);
-        arrangementBox.addItem (utf8 ("Clone this one"), cloneArrangement);
-        arrangementBox.addItem (utf8 ("Rename..."), renameArrangementAction);
-        arrangementBox.addItem (utf8 ("Remove this one"), removeArrangementAction);
+        arrangementBox.addItem (tr ("New arrangement"), newArrangement);
+        arrangementBox.addItem (tr ("Clone this one"), cloneArrangement);
+        arrangementBox.addItem (tr ("Rename..."), renameArrangementAction);
+        arrangementBox.addItem (tr ("Remove this one"), removeArrangementAction);
         arrangementBox.setItemEnabled (removeArrangementAction, names.size() > 1);
     }
 
@@ -121,10 +173,10 @@ void PlaylistComponent::arrangementChosen()
 void PlaylistComponent::renameArrangement()
 {
     const auto index = engine.getSong().currentArrangement;
-    auto* window = new juce::AlertWindow ("Rename arrangement", {}, juce::MessageBoxIconType::NoIcon);
+    auto* window = new juce::AlertWindow (tr ("Rename arrangement"), {}, juce::MessageBoxIconType::NoIcon);
     window->addTextEditor ("name", juce::String::fromUTF8 (engine.getSong().arrangements[(std::size_t) index].name.c_str()));
-    window->addButton ("OK", 1, juce::KeyPress (juce::KeyPress::returnKey));
-    window->addButton ("Cancel", 0, juce::KeyPress (juce::KeyPress::escapeKey));
+    window->addButton (tr ("OK"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+    window->addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
     window->enterModalState (true, juce::ModalCallbackFunction::create ([this, index, window] (int result) {
                                  const auto name = window->getTextEditorContents ("name").trim().toStdString();
 
@@ -219,7 +271,8 @@ void PlaylistComponent::paint (juce::Graphics& g)
     const auto bar = (std::int64_t) ppq * song.beatsPerBar;
     const auto tracks = numTracks();
 
-    g.fillAll (theme::window);
+    using namespace theme;
+    g.fillAll (colour::bg1);
 
     // --- tracks and grid ---------------------------------------------------
     {
@@ -233,9 +286,9 @@ void PlaylistComponent::paint (juce::Graphics& g)
             if (y > grid.getBottom() || y + trackHeight < grid.getY())
                 continue;
 
-            g.setColour (t % 2 == 0 ? juce::Colour (0xff2c3238) : juce::Colour (0xff292e34));
+            g.setColour (t % 2 == 0 ? colour::bg2 : colour::bg2.interpolatedWith (colour::bg1, 0.5f));
             g.fillRect (grid.getX(), y, grid.getWidth(), trackHeight);
-            g.setColour (juce::Colour (0xff1d2125));
+            g.setColour (colour::bg0);
             g.drawHorizontalLine (y + trackHeight - 1, (float) grid.getX(), (float) grid.getRight());
         }
 
@@ -243,13 +296,13 @@ void PlaylistComponent::paint (juce::Graphics& g)
 
         for (const auto& b : song.barsBetween ((std::int64_t) std::max (0.0, scrollTicks), (std::int64_t) xToTick (grid.getRight()) + 1))
         {
-            g.setColour (juce::Colour (0xff181b1f));
+            g.setColour (colour::gridBar);
             g.drawVerticalLine ((int) tickToX ((double) b.tick), (float) grid.getY(), (float) grid.getBottom());
 
             if (beatPixels < 8.0)
                 continue; // zoomed far out: bar lines only
 
-            g.setColour (juce::Colour (0xff24292e));
+            g.setColour (colour::gridBeat);
             for (auto tick = b.tick + ppq; tick < b.tick + b.length; tick += ppq)
                 g.drawVerticalLine ((int) tickToX ((double) tick), (float) grid.getY(), (float) grid.getBottom());
         }
@@ -258,9 +311,9 @@ void PlaylistComponent::paint (juce::Graphics& g)
         if (song.hasLoop())
         {
             const auto lx0 = (float) tickToX ((double) song.loopStart), lx1 = (float) tickToX ((double) song.loopEnd);
-            g.setColour (theme::accentGreen.withAlpha (0.05f));
+            g.setColour (colour::accent.withAlpha (0.06f));
             g.fillRect (juce::Rectangle<float> (lx0, (float) grid.getY(), lx1 - lx0, (float) grid.getHeight()));
-            g.setColour (theme::accentGreen.withAlpha (0.35f));
+            g.setColour (colour::accent.withAlpha (0.45f));
             g.drawVerticalLine ((int) lx0, (float) grid.getY(), (float) grid.getBottom());
             g.drawVerticalLine ((int) lx1, (float) grid.getY(), (float) grid.getBottom());
         }
@@ -269,11 +322,11 @@ void PlaylistComponent::paint (juce::Graphics& g)
         if (! song.playlist.empty())
         {
             const auto endX = (float) tickToX ((double) song.songLength());
-            g.setColour (juce::Colours::black.withAlpha (0.25f));
+            g.setColour (colour::bg0.withAlpha (0.45f));
             g.fillRect (juce::Rectangle<float> (endX, (float) grid.getY(), (float) grid.getRight() - endX, (float) grid.getHeight()));
         }
 
-        g.setFont (juce::FontOptions (11.0f));
+        g.setFont (font (type::caption));
 
         for (int i = 0; i < (int) song.playlist.size(); ++i)
         {
@@ -295,10 +348,7 @@ void PlaylistComponent::paint (juce::Graphics& g)
                 paintAutomationClip (g, c, r);
 
                 if (isSelected (i))
-                {
-                    g.setColour (juce::Colour (0xffff6f6f));
-                    g.drawRoundedRectangle (r, 3.0f, 2.0f);
-                }
+                    paintClipOutline (g, r, colour::automation, true, false);
                 continue;
             }
 
@@ -307,33 +357,16 @@ void PlaylistComponent::paint (juce::Graphics& g)
                 paintAudioClip (g, c, r);
 
                 if (isSelected (i))
-                {
-                    g.setColour (juce::Colour (0xffff6f6f));
-                    g.drawRoundedRectangle (r, 3.0f, 2.0f);
-                }
+                    paintClipOutline (g, r, colour::audioClip, true, false);
                 continue;
             }
 
-            const auto colour = patternColour (song, c.pattern);
+            const auto base = tame (patternColour (song, c.pattern));
             const auto current = c.pattern == song.currentPattern;
             const auto selected = isSelected (i);
 
-            g.setColour (colour.withAlpha (0.85f));
-            g.fillRoundedRectangle (r, 3.0f);
-            g.setColour (selected ? juce::Colour (0xffff6f6f) : current ? juce::Colours::white : colour.darker (0.6f));
-            g.drawRoundedRectangle (r, 3.0f, selected ? 2.0f : current ? 1.5f : 1.0f);
-
-            // name strip
-            const auto title = r.withHeight (13.0f);
-            g.setColour (colour.darker (0.4f));
-            g.fillRoundedRectangle (title, 3.0f);
-
-            if (r.getWidth() > 24)
-            {
-                g.setColour (juce::Colours::white);
-                g.drawText (juce::String::fromUTF8 (song.patterns[(std::size_t) c.pattern].name.c_str()),
-                            title.reduced (3, 0).toNearestInt(), juce::Justification::centredLeft, true);
-            }
+            // body + name strip
+            const auto clipBody = paintClipFrame (g, r, base, juce::String::fromUTF8 (song.patterns[(std::size_t) c.pattern].name.c_str()));
 
             // note thumbnail
             const auto& notes = song.patterns[(std::size_t) c.pattern].notes;
@@ -347,9 +380,9 @@ void PlaylistComponent::paint (juce::Graphics& g)
                     high = juce::jmax (high, n.key);
                 }
 
-                const auto body = r.withTrimmedTop (15.0f).reduced (2.0f, 2.0f);
+                const auto body = clipBody.reduced (2.0f, 3.0f);
                 const auto keySpan = (float) juce::jmax (1, high - low);
-                g.setColour (colour.darker (0.75f));
+                g.setColour (base.brighter (0.25f));
 
                 for (const auto& n : notes)
                 {
@@ -362,37 +395,41 @@ void PlaylistComponent::paint (juce::Graphics& g)
                     g.fillRect (nx, ny, nw, 2.0f);
                 }
             }
+
+            paintClipOutline (g, r, base, selected, current);
         }
 
         if (! rubberBand.isEmpty())
         {
-            g.setColour (theme::accentBlue.withAlpha (0.15f));
+            g.setColour (colour::selectionFill);
             g.fillRect (rubberBand);
-            g.setColour (theme::accentBlue);
+            g.setColour (colour::selection);
             g.drawRect (rubberBand);
         }
 
         if (playheadTick >= 0.0)
         {
-            g.setColour (theme::playhead);
-            g.drawVerticalLine ((int) tickToX (playheadTick), (float) grid.getY(), (float) grid.getBottom());
+            g.setColour (colour::playhead);
+            g.fillRect (juce::Rectangle<float> ((float) tickToX (playheadTick) - 0.5f, (float) grid.getY(), 1.5f, (float) grid.getHeight()));
         }
     }
 
     // --- ruler ---------------------------------------------------------------
     {
         const auto ruler = juce::Rectangle<int> (headerWidth, 0, grid.getWidth(), timelineHeight);
-        g.setColour (theme::toolbar);
+        g.setColour (colour::bg3);
         g.fillRect (ruler);
+        g.setColour (colour::border);
+        g.fillRect (ruler.withTop (ruler.getBottom() - 1));
         juce::Graphics::ScopedSaveState state (g);
         g.reduceClipRegion (ruler);
-        g.setFont (juce::FontOptions (12.0f));
+        g.setFont (font (type::small));
 
         if (song.hasLoop())
         {
             const auto lx0 = (float) tickToX ((double) song.loopStart), lx1 = (float) tickToX ((double) song.loopEnd);
-            g.setColour (theme::accentGreen.withAlpha (0.55f));
-            g.fillRect (juce::Rectangle<float> (lx0, 0.0f, lx1 - lx0, 6.0f));
+            g.setColour (colour::accent.withAlpha (0.75f));
+            g.fillRect (juce::Rectangle<float> (lx0, 0.0f, lx1 - lx0, 4.0f));
         }
 
         const auto barPixels = bar * pixelsPerTick;
@@ -404,13 +441,14 @@ void PlaylistComponent::paint (juce::Graphics& g)
                 continue;
 
             const auto x = (int) tickToX ((double) b.tick);
-            g.setColour (theme::text.withAlpha (0.7f));
+            g.setColour (colour::textDisabled);
             g.drawVerticalLine (x, 12.0f, (float) timelineHeight);
+            g.setColour (colour::textSecondary);
             g.drawText (juce::String (b.number), x + 3, 2, 40, timelineHeight - 4, juce::Justification::centredLeft);
         }
 
         // markers: small flag with the name; time signature changes show the fraction
-        g.setFont (juce::FontOptions (11.0f));
+        g.setFont (font (type::caption, true));
 
         for (const auto& m : song.markers())
         {
@@ -427,10 +465,10 @@ void PlaylistComponent::paint (juce::Graphics& g)
 
             const auto width = (float) juce::GlyphArrangement::getStringWidthInt (g.getCurrentFont(), label) + 8.0f;
             const auto tag = juce::Rectangle<float> (x, (float) timelineHeight - 11.0f, width, 11.0f);
-            g.setColour ((m.isSignature() ? theme::accentGreen : juce::Colour (0xffe0b050)).withAlpha (0.85f));
-            g.fillRect (tag);
+            g.setColour (m.isSignature() ? colour::info : colour::warning);
+            g.fillRoundedRectangle (tag, 2.0f);
             g.drawVerticalLine ((int) x, 0.0f, (float) timelineHeight);
-            g.setColour (juce::Colours::black);
+            g.setColour (colour::bg0);
             g.drawText (label, tag.reduced (3.0f, 0.0f), juce::Justification::centredLeft, false);
         }
 
@@ -439,7 +477,7 @@ void PlaylistComponent::paint (juce::Graphics& g)
             const auto x = (float) tickToX (playheadTick);
             juce::Path tri;
             tri.addTriangle (x - 6, 0, x + 6, 0, x, 9);
-            g.setColour (theme::playhead);
+            g.setColour (colour::playhead);
             g.fillPath (tri);
         }
     }
@@ -449,7 +487,9 @@ void PlaylistComponent::paint (juce::Graphics& g)
         const auto headers = juce::Rectangle<int> (0, timelineHeight, headerWidth, grid.getHeight());
         juce::Graphics::ScopedSaveState state (g);
         g.reduceClipRegion (headers);
-        g.setFont (juce::FontOptions (12.0f));
+        g.setColour (colour::bg2);
+        g.fillRect (headers);
+        g.setFont (font (type::small));
 
         for (int t = 0; t < tracks; ++t)
         {
@@ -460,19 +500,22 @@ void PlaylistComponent::paint (juce::Graphics& g)
 
             const auto muted = song.isTrackMuted (t);
             const auto custom = t < (int) song.playlistTracks.size() && ! song.playlistTracks[(std::size_t) t].name.empty();
-            g.setColour (theme::channelButton.darker (muted ? 0.4f : 0.0f));
-            g.fillRect (2, y + 1, headerWidth - 4, trackHeight - 3);
-            g.setColour (theme::muteLed (muted));
-            g.fillEllipse (6.0f, (float) y + trackHeight / 2.0f - 5.0f, 10.0f, 10.0f);
-            g.setColour (theme::text.withAlpha (muted ? 0.4f : 0.8f));
+            g.setColour (muted ? colour::bg2 : colour::bg3);
+            g.fillRoundedRectangle (juce::Rectangle<float> (2.0f, (float) y + 1.0f, (float) headerWidth - 4.0f, (float) trackHeight - 3.0f), radius::sm);
+            g.setColour (muteLed (muted));
+            g.fillEllipse (7.0f, (float) y + trackHeight / 2.0f - 4.0f, 8.0f, 8.0f);
+            g.setColour (muted ? colour::textDisabled : (custom ? colour::textPrimary : colour::textSecondary));
             g.drawFittedText (custom ? juce::String::fromUTF8 (song.playlistTracks[(std::size_t) t].name.c_str())
-                                     : "Track " + juce::String (t + 1),
+                                     : tr ("Track {0}", { juce::String (t + 1) }),
                               20, y, headerWidth - 24, trackHeight, juce::Justification::centredLeft, 2, 0.8f);
         }
     }
 
-    g.setColour (theme::toolbar);
+    g.setColour (colour::bg3);
     g.fillRect (0, 0, headerWidth, timelineHeight);
+    g.setColour (colour::border);
+    g.fillRect (0, timelineHeight - 1, headerWidth, 1);
+    g.fillRect (headerWidth - 1, 0, 1, getHeight());
 }
 
 const std::vector<float>* PlaylistComponent::waveformFor (const std::string& path)
@@ -516,29 +559,15 @@ void PlaylistComponent::paintAudioClip (juce::Graphics& g, const Clip& c, juce::
         return;
 
     const auto& channel = song.channels[(std::size_t) c.channel];
-    const auto colour = juce::Colour (0xff4f7f9f); // audio clips in blue, as a highlight
-
-    g.setColour (colour.withAlpha (0.85f));
-    g.fillRoundedRectangle (r, 3.0f);
-    g.setColour (colour.darker (0.6f));
-    g.drawRoundedRectangle (r, 3.0f, 1.0f);
-
-    const auto title = r.withHeight (13.0f);
-    g.setColour (colour.darker (0.4f));
-    g.fillRoundedRectangle (title, 3.0f);
-
-    if (r.getWidth() > 24)
-    {
-        g.setColour (juce::Colours::white);
-        g.drawText (juce::String::fromUTF8 (channel.name.c_str()), title.reduced (3, 0).toNearestInt(),
-                    juce::Justification::centredLeft, true);
-    }
+    const auto colour = theme::colour::audioClip;
+    paintClipFrame (g, r, colour, juce::String::fromUTF8 (channel.name.c_str()));
+    paintClipOutline (g, r, colour, false, false);
 
     // fades: ramps and handles at the top corners
     {
         const auto inX = r.getX() + (float) (c.fadeIn * pixelsPerTick);
         const auto outX = r.getRight() - (float) (c.fadeOut * pixelsPerTick);
-        g.setColour (juce::Colours::white.withAlpha (0.8f));
+        g.setColour (theme::colour::textPrimary.withAlpha (0.8f));
 
         if (c.fadeIn > 0)
             g.drawLine (r.getX(), r.getBottom(), inX, r.getY() + 14.0f, 1.2f);
@@ -564,7 +593,7 @@ void PlaylistComponent::paintAudioClip (juce::Graphics& g, const Clip& c, juce::
     const auto centreY = body.getCentreY();
     const auto halfHeight = body.getHeight() / 2.0f;
     const auto clip = g.getClipBounds().toFloat();
-    g.setColour (colour.darker (0.8f).withAlpha (0.9f));
+    g.setColour (colour.brighter (0.2f));
 
     for (auto x = std::max (body.getX(), clip.getX()); x < std::min (body.getRight(), clip.getRight()); x += 1.0f)
     {
@@ -594,22 +623,10 @@ void PlaylistComponent::paintAutomationClip (juce::Graphics& g, const Clip& c, j
         return;
 
     const auto& automation = song.automations[(std::size_t) c.automation];
-    const auto colour = automation.target.kind == AutomationTargetKind::none ? juce::Colour (0xff555555) : juce::Colour (0xff5f7a5a);
-
-    g.setColour (colour.withAlpha (0.55f));
-    g.fillRoundedRectangle (r, 3.0f);
-    g.setColour (colour.darker (0.6f));
-    g.drawRoundedRectangle (r, 3.0f, 1.0f);
-
-    const auto title = r.withHeight (13.0f);
-    g.setColour (colour.darker (0.4f));
-    g.fillRoundedRectangle (title, 3.0f);
-
-    if (r.getWidth() > 24)
-    {
-        g.setColour (juce::Colours::white);
-        g.drawText (juce::String::fromUTF8 (automation.name.c_str()), title.reduced (3, 0).toNearestInt(), juce::Justification::centredLeft, true);
-    }
+    const auto colour = automation.target.kind == AutomationTargetKind::none ? theme::colour::textDisabled
+                                                                              : theme::colour::automation.withMultipliedSaturation (0.75f).withMultipliedBrightness (0.8f);
+    paintClipFrame (g, r, colour, juce::String::fromUTF8 (automation.name.c_str()));
+    paintClipOutline (g, r, colour, false, false);
 
     // automation curve over the clip's range
     const auto body = r.withTrimmedTop (14.0f).reduced (1.0f, 2.0f);
@@ -630,7 +647,7 @@ void PlaylistComponent::paintAutomationClip (juce::Graphics& g, const Clip& c, j
         started = true;
     }
 
-    g.setColour (juce::Colour (0xffb8f0a8));
+    g.setColour (automation.target.kind == AutomationTargetKind::none ? theme::colour::textSecondary : theme::colour::automation.brighter (0.3f));
     g.strokePath (curve, juce::PathStrokeType (1.5f));
 }
 
@@ -1028,10 +1045,10 @@ void PlaylistComponent::renameTrack (int track)
 {
     const auto& tracks = engine.getSong().playlistTracks;
     const auto current = track < (int) tracks.size() ? juce::String::fromUTF8 (tracks[(std::size_t) track].name.c_str()) : juce::String();
-    auto* window = new juce::AlertWindow ("Rename track", {}, juce::MessageBoxIconType::NoIcon);
-    window->addTextEditor ("name", current.isNotEmpty() ? current : "Track " + juce::String (track + 1));
-    window->addButton ("OK", 1, juce::KeyPress (juce::KeyPress::returnKey));
-    window->addButton ("Cancel", 0, juce::KeyPress (juce::KeyPress::escapeKey));
+    auto* window = new juce::AlertWindow (tr ("Rename track"), {}, juce::MessageBoxIconType::NoIcon);
+    window->addTextEditor ("name", current.isNotEmpty() ? current : tr ("Track {0}", { juce::String (track + 1) }));
+    window->addButton (tr ("OK"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+    window->addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
     window->enterModalState (true, juce::ModalCallbackFunction::create ([this, track, window] (int result) {
                                  if (result != 1)
                                      return;
@@ -1058,20 +1075,20 @@ void PlaylistComponent::showRulerMenu (int x)
             near = i;
 
     juce::PopupMenu menu;
-    menu.addItem ("Add marker here...", [this, tick] { editMarkerName (tick, -1); });
+    menu.addItem (tr ("Add marker here..."), [this, tick] { editMarkerName (tick, -1); });
 
     juce::PopupMenu signatures;
     for (auto [n, d] : { std::pair { 2, 4 }, { 3, 4 }, { 4, 4 }, { 5, 4 }, { 6, 4 }, { 7, 4 }, { 6, 8 }, { 7, 8 }, { 9, 8 }, { 12, 8 } })
         signatures.addItem (juce::String (n) + "/" + juce::String (d), [this, tick, n = n, d = d] {
             engine.editSong ([tick, n, d] (Song& s) { s.addMarker ({ tick, {}, n, d }); });
         });
-    menu.addSubMenu (utf8 ("Time signature change here"), signatures);
+    menu.addSubMenu (tr ("Time signature change here"), signatures);
 
     if (near >= 0)
     {
         menu.addSeparator();
-        menu.addItem ("Rename marker...", [this, near] { editMarkerName (0, near); });
-        menu.addItem ("Remove marker", [this, near] {
+        menu.addItem (tr ("Rename marker..."), [this, near] { editMarkerName (0, near); });
+        menu.addItem (tr ("Remove marker"), [this, near] {
             engine.editSong ([near] (Song& s) {
                 if (near < (int) s.markers().size())
                     s.markers().erase (s.markers().begin() + near);
@@ -1082,7 +1099,7 @@ void PlaylistComponent::showRulerMenu (int x)
     if (song.hasLoop())
     {
         menu.addSeparator();
-        menu.addItem ("Remove loop", [this] { engine.editSong ([] (Song& s) { s.loopStart = s.loopEnd = 0; }, false); });
+        menu.addItem (tr ("Remove loop"), [this] { engine.editSong ([] (Song& s) { s.loopStart = s.loopEnd = 0; }, false); });
     }
 
     menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
@@ -1092,11 +1109,11 @@ void PlaylistComponent::editMarkerName (std::int64_t tick, int existing)
 {
     const auto& markers = engine.getSong().markers();
     const auto current = existing >= 0 && existing < (int) markers.size() ? juce::String::fromUTF8 (markers[(std::size_t) existing].name.c_str())
-                                                                          : juce::String ("Marker");
-    auto* window = new juce::AlertWindow (existing >= 0 ? "Rename marker" : "New marker", {}, juce::MessageBoxIconType::NoIcon);
+                                                                          : tr ("Marker");
+    auto* window = new juce::AlertWindow (existing >= 0 ? tr ("Rename marker") : tr ("New marker"), {}, juce::MessageBoxIconType::NoIcon);
     window->addTextEditor ("name", current);
-    window->addButton ("OK", 1, juce::KeyPress (juce::KeyPress::returnKey));
-    window->addButton ("Cancel", 0, juce::KeyPress (juce::KeyPress::escapeKey));
+    window->addButton (tr ("OK"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+    window->addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
     window->enterModalState (true, juce::ModalCallbackFunction::create ([this, tick, existing, window] (int result) {
                                  if (result != 1)
                                      return;
@@ -1122,7 +1139,7 @@ void PlaylistComponent::showClipMenu (int index)
     const auto splitAt = snap (xToTick (getMouseXYRelative().x) + ppq / 2.0, true);
 
     if (splitAt > clip.start && splitAt < clip.end())
-        menu.addItem (utf8 ("Split here"), [this, index, splitAt] {
+        menu.addItem (tr ("Split here"), [this, index, splitAt] {
             setSelection ({});
             engine.editSong ([index, splitAt] (Song& s) {
                 auto rest = splitClip (s.playlist[(std::size_t) index], splitAt);
@@ -1135,7 +1152,7 @@ void PlaylistComponent::showClipMenu (int index)
     {
         menu.addSectionHeader (juce::String::fromUTF8 (engine.getSong().patterns[(std::size_t) clip.pattern].name.c_str()));
         // like FL's "Make unique": the chosen clips switch to using a copy of the pattern
-        menu.addItem (utf8 ("Make unique"), [this, targets] {
+        menu.addItem (tr ("Make unique"), [this, targets] {
             engine.editSong ([targets] (Song& s) {
                 std::map<int, int> copies; // original pattern -> copy
 
@@ -1160,7 +1177,7 @@ void PlaylistComponent::showClipMenu (int index)
                 s.currentPattern = copies.empty() ? s.currentPattern : copies.begin()->second;
             });
         });
-        menu.addItem ("Select all of this pattern", [this, p = clip.pattern] {
+        menu.addItem (tr ("Select all of this pattern"), [this, p = clip.pattern] {
             std::vector<int> same;
             const auto& playlist = engine.getSong().playlist;
 
@@ -1170,7 +1187,7 @@ void PlaylistComponent::showClipMenu (int index)
 
             setSelection (same);
         });
-        menu.addItem ("Open in Channel Rack", [this] {
+        menu.addItem (tr ("Open in Channel Rack"), [this] {
             if (onOpenPattern)
                 onOpenPattern();
         });
@@ -1192,9 +1209,9 @@ void PlaylistComponent::showClipMenu (int index)
             });
         }
 
-        menu.addSubMenu ("Clip volume", gains);
+        menu.addSubMenu (tr ("Clip volume"), gains);
 
-        menu.addItem ("Normalize", [this, targets] {
+        menu.addItem (tr ("Normalize"), [this, targets] {
             // clip gain so that the peak of the played segment reaches 0 dB (at most +24 dB)
             const auto& song = engine.getSong();
             const auto secondsPerTick = 60.0 / (juce::jmax (1.0, song.bpm) * ppq);
@@ -1235,7 +1252,7 @@ void PlaylistComponent::showClipMenu (int index)
         });
 
         if (clip.fadeIn > 0 || clip.fadeOut > 0)
-            menu.addItem ("Remove fades", [this, targets] {
+            menu.addItem (tr ("Remove fades"), [this, targets] {
                 engine.editSong ([targets] (Song& s) {
                     for (auto i : targets)
                         s.playlist[(std::size_t) i].fadeIn = s.playlist[(std::size_t) i].fadeOut = 0;
@@ -1246,8 +1263,8 @@ void PlaylistComponent::showClipMenu (int index)
     if (clip.kind == ClipKind::automation && clip.automation >= 0 && clip.automation < (int) engine.getSong().automations.size())
     {
         menu.addSectionHeader (juce::String::fromUTF8 (engine.getSong().automations[(std::size_t) clip.automation].name.c_str()));
-        menu.addItem (utf8 ("Edit points..."), [this, a = clip.automation] { openAutomationEditor (engine, a); });
-        menu.addItem (utf8 ("Make unique"), [this, index] {
+        menu.addItem (tr ("Edit points..."), [this, a = clip.automation] { openAutomationEditor (engine, a); });
+        menu.addItem (tr ("Make unique"), [this, index] {
             engine.editSong ([index] (Song& s) {
                 auto& c = s.playlist[(std::size_t) index];
                 auto copy = s.automations[(std::size_t) c.automation];
@@ -1256,13 +1273,13 @@ void PlaylistComponent::showClipMenu (int index)
                 c.automation = (int) s.automations.size() - 1;
             });
         });
-        menu.addItem (utf8 ("Delete automation (all of its clips)"), [this, a = clip.automation] {
+        menu.addItem (tr ("Delete automation (all of its clips)"), [this, a = clip.automation] {
             setSelection ({});
             engine.editSong ([a] (Song& s) { s.removeAutomation (a); });
         });
     }
 
-    menu.addItem (targets.size() > 1 ? "Delete selected" : "Delete", [this, targets] {
+    menu.addItem (targets.size() > 1 ? tr ("Delete selected") : tr ("Delete"), [this, targets] {
         setSelection ({});
         engine.editSong ([targets] (Song& s) {
             auto sorted = targets;
@@ -1622,7 +1639,7 @@ std::vector<PatternPicker::Row> PatternPicker::rows() const
 {
     const auto& song = engine.getSong();
     std::vector<Row> list;
-    list.push_back ({ ClipKind::pattern, -1, "Patterns", {} });
+    list.push_back ({ ClipKind::pattern, -1, tr ("Patterns"), {} });
 
     for (int i = 0; i < (int) song.patterns.size(); ++i)
         list.push_back ({ ClipKind::pattern, i, juce::String::fromUTF8 (song.patterns[(std::size_t) i].name.c_str()),
@@ -1633,15 +1650,15 @@ std::vector<PatternPicker::Row> PatternPicker::rows() const
         if (song.channels[(std::size_t) c].instrument == InstrumentKind::audioClip)
         {
             if (! audioHeader)
-                list.push_back ({ ClipKind::audio, -1, utf8 ("Audio"), {} });
+                list.push_back ({ ClipKind::audio, -1, tr ("Audio"), {} });
             audioHeader = true;
-            list.push_back ({ ClipKind::audio, c, juce::String::fromUTF8 (song.channels[(std::size_t) c].name.c_str()), juce::Colour (0xff4f7fa6) });
+            list.push_back ({ ClipKind::audio, c, juce::String::fromUTF8 (song.channels[(std::size_t) c].name.c_str()), theme::colour::audioClip });
         }
 
     if (! song.automations.empty())
-        list.push_back ({ ClipKind::automation, -1, utf8 ("Automation"), {} });
+        list.push_back ({ ClipKind::automation, -1, tr ("Automation"), {} });
     for (int a = 0; a < (int) song.automations.size(); ++a)
-        list.push_back ({ ClipKind::automation, a, juce::String::fromUTF8 (song.automations[(std::size_t) a].name.c_str()), juce::Colour (0xff6f8f5f) });
+        list.push_back ({ ClipKind::automation, a, juce::String::fromUTF8 (song.automations[(std::size_t) a].name.c_str()), theme::colour::automation });
 
     return list;
 }
@@ -1659,12 +1676,15 @@ void PatternPicker::paint (juce::Graphics& g)
 {
     const auto& song = engine.getSong();
     const auto list = rows();
-    g.fillAll (theme::panel);
-    g.setColour (theme::toolbar);
+    using namespace theme;
+    g.fillAll (colour::bg2);
+    g.setColour (colour::bg3);
     g.fillRect (0, 0, getWidth(), headerHeight);
-    g.setColour (theme::text.withAlpha (0.8f));
-    g.setFont (juce::FontOptions (12.0f));
-    g.drawText ("Picker", 8, 0, getWidth() - 16, headerHeight, juce::Justification::centredLeft);
+    g.setColour (colour::border);
+    g.fillRect (0, headerHeight - 1, getWidth(), 1);
+    g.setColour (colour::textSecondary);
+    g.setFont (font (type::small, true));
+    g.drawText (theme::caps (tr ("Picker")), 10, 0, getWidth() - 20, headerHeight, juce::Justification::centredLeft);
 
     for (int i = scroll; i < (int) list.size(); ++i)
     {
@@ -1677,30 +1697,30 @@ void PatternPicker::paint (juce::Graphics& g)
 
         if (row.index < 0) // section title
         {
-            g.setColour (theme::text.withAlpha (0.5f));
-            g.setFont (juce::FontOptions (11.0f));
-            g.drawText (row.name, 8, y, getWidth() - 16, rowHeight, juce::Justification::bottomLeft);
+            g.setColour (colour::textDisabled);
+            g.setFont (font (type::caption, true));
+            g.drawText (theme::caps (row.name), 10, y, getWidth() - 20, rowHeight - 3, juce::Justification::bottomLeft);
             continue;
         }
 
         const auto r = juce::Rectangle<int> (4, y + 2, getWidth() - 8, rowHeight - 4);
         const auto current = row.kind == ClipKind::pattern ? (playlist.brush.kind == ClipKind::pattern && row.index == song.currentPattern)
                                                            : (playlist.brush.kind == row.kind && playlist.brush.index == row.index);
-        g.setColour (current ? row.colour.withAlpha (0.9f) : row.colour.withAlpha (0.35f));
-        g.fillRoundedRectangle (r.toFloat(), 3.0f);
-
-        if (current)
-        {
-            g.setColour (juce::Colours::white);
-            g.drawRoundedRectangle (r.toFloat(), 3.0f, 1.2f);
-        }
-
-        g.setColour (current ? juce::Colours::white : theme::text.withAlpha (0.85f));
-        g.setFont (juce::FontOptions (12.0f));
-        g.drawText (row.name, r.reduced (6, 0), juce::Justification::centredLeft, true);
+        const auto rowColour = tame (row.colour);
+        const auto box = r.toFloat();
+        g.setColour (current ? rowColour.interpolatedWith (colour::bg3, 0.35f) : colour::bg3);
+        g.fillRoundedRectangle (box, radius::sm);
+
+        // colour swatch on the left; the current row gets the accent strip instead
+        g.setColour (current ? colour::accent : rowColour);
+        g.fillRoundedRectangle (box.withWidth (3.0f), 1.5f);
+
+        g.setColour (current ? clipTitleText (rowColour.interpolatedWith (colour::bg3, 0.35f)) : colour::textPrimary.withAlpha (0.85f));
+        g.setFont (font (type::small, current));
+        g.drawText (row.name, r.withTrimmedLeft (10).withTrimmedRight (4), juce::Justification::centredLeft, true);
     }
 
-    g.setColour (theme::window);
+    g.setColour (colour::border);
     g.drawVerticalLine (getWidth() - 1, 0.0f, (float) getHeight());
 }