Просмотр исходного кода

Round 170a: FL-like rack playhead strip and hits, red-tinted beat groups, FL wheel/drag direction, first-match mnemonics

Ka1-S 1 месяц назад
Родитель
Сommit
aefdf14b11

+ 3 - 3
cmake/LynxPatchJuce.cmake

@@ -48,8 +48,8 @@
 #    main window opens), so the menu closed at once. Only a window that really moved or changed size dismisses now.
 # 12. Every platform, juce_PopupMenu.cpp (round 170a): menu accelerator letters like FL's ('&' letters, e.g. D = Delete).
 #    An item whose text has the mark U+0001 before a character (core/MenuMnemonic.h) is picked by typing that key
-#    while the menu is open: the only enabled item with that key runs (a submenu opens, its first item highlighted);
-#    when several items share the key, each press highlights the next of them (Return runs it), as Windows menus do.
+#    while the menu is open: the first enabled item with that key runs (a submenu opens, its first item highlighted),
+#    as in FL (round 170a [SHOT]: "Cu&t itself" and "Cu&t" share T in the channel menu; T runs "Cut itself").
 #
 # Used by CMake (lynx_patch_juce on the fetched JUCE) and by scripts/build-windows-zig.sh, which runs this file with
 # `cmake -DJUCE_DIR=<a copy of JUCE's juce_gui_basics module> -P cmake/LynxPatchJuce.cmake`.
@@ -111,7 +111,7 @@ function(lynx_patch_juce_file file)
             "    bool doesAnyJuceCompHaveFocus()|NL|    {|NL|       #if JUCE_LINUX || JUCE_BSD|NL|        // LYNX patch (issue #45): the mouse over one of our windows = still ours (X focus moving between them)|NL|        {|NL|            const auto mousePos = Desktop::getInstance().getMainMouseSource().getScreenPosition();|NL||NL|            for (int i = ComponentPeer::getNumPeers(); --i >= 0;)|NL|            {|NL|                auto& comp = ComponentPeer::getPeer (i)->getComponent();|NL||NL|                if (comp.isShowing() && comp.getLocalBounds().toFloat().contains (comp.getLocalPoint (nullptr, mousePos)))|NL|                    return true;|NL|            }|NL|        }|NL|       #endif|NL||NL|")
         lynx_juce_fix("menu accelerator letters" "LYNX patch (round 170a): menu accelerator letters"
             "    bool keyPressed (const KeyPress& key) override|NL|    {|NL|        if (key.isKeyCode (KeyPress::downKey))"
-            "    // LYNX patch (round 170a): menu accelerator letters (core/MenuMnemonic.h marks the letter with U+0001)|NL|    bool lynxMenuMnemonic (const KeyPress& key)|NL|    {|NL|        const auto mods = key.getModifiers();|NL|        const auto typed = CharacterFunctions::toLowerCase (key.getTextCharacter());|NL|        if (typed <= 32 || mods.isCtrlDown() || mods.isCommandDown() || mods.isAltDown())|NL|            return false;|NL||NL|        Array<ItemComponent*> matches;|NL|        for (auto* child : items)|NL|        {|NL|            const auto& text = child->item.text;|NL|            const auto at = text.indexOfChar ((juce_wchar) 1);|NL|            if (at >= 0 && CharacterFunctions::toLowerCase (text[at + 1]) == typed|NL|                && (canBeTriggered (child->item) || hasActiveSubMenu (child->item)))|NL|                matches.add (child);|NL|        }|NL||NL|        if (matches.isEmpty())|NL|            return false;|NL||NL|        disableTimerUntilMouseMoves();|NL||NL|        if (matches.size() > 1)|NL|        {|NL|            setCurrentlyHighlightedChild (matches[(matches.indexOf (currentChild.getComponent()) + 1) % matches.size()]);|NL|            return true;|NL|        }|NL||NL|        auto* only = matches.getFirst();|NL|        setCurrentlyHighlightedChild (only);|NL||NL|        if (hasActiveSubMenu (only->item))|NL|        {|NL|            if (showSubMenuFor (only) && isSubMenuVisible())|NL|                activeSubMenu->selectNextItem (MenuSelectionDirection::current);|NL|        }|NL|        else|NL|        {|NL|            triggerCurrentlyHighlightedItem();|NL|        }|NL||NL|        return true;|NL|    }|NL||NL|    bool keyPressed (const KeyPress& key) override|NL|    {|NL|        if (key.isKeyCode (KeyPress::downKey))")
+            "    // LYNX patch (round 170a): menu accelerator letters (core/MenuMnemonic.h marks the letter with U+0001)|NL|    bool lynxMenuMnemonic (const KeyPress& key)|NL|    {|NL|        const auto mods = key.getModifiers();|NL|        const auto typed = CharacterFunctions::toLowerCase (key.getTextCharacter());|NL|        if (typed <= 32 || mods.isCtrlDown() || mods.isCommandDown() || mods.isAltDown())|NL|            return false;|NL||NL|        Array<ItemComponent*> matches;|NL|        for (auto* child : items)|NL|        {|NL|            const auto& text = child->item.text;|NL|            const auto at = text.indexOfChar ((juce_wchar) 1);|NL|            if (at >= 0 && CharacterFunctions::toLowerCase (text[at + 1]) == typed|NL|                && (canBeTriggered (child->item) || hasActiveSubMenu (child->item)))|NL|                matches.add (child);|NL|        }|NL||NL|        if (matches.isEmpty())|NL|            return false;|NL||NL|        disableTimerUntilMouseMoves();|NL||NL|        // FL: the first item with the key (in menu order) runs, even when another one has the same key|NL|        auto* only = matches.getFirst();|NL|        setCurrentlyHighlightedChild (only);|NL||NL|        if (hasActiveSubMenu (only->item))|NL|        {|NL|            if (showSubMenuFor (only) && isSubMenuVisible())|NL|                activeSubMenu->selectNextItem (MenuSelectionDirection::current);|NL|        }|NL|        else|NL|        {|NL|            triggerCurrentlyHighlightedItem();|NL|        }|NL||NL|        return true;|NL|    }|NL||NL|    bool keyPressed (const KeyPress& key) override|NL|    {|NL|        if (key.isKeyCode (KeyPress::downKey))")
         lynx_juce_fix("menu accelerator keys" "LYNX patch (round 170a): accelerator letters"
             "            dismissMenu (nullptr);|NL|        }|NL|        else|NL|        {|NL|            return false;|NL|        }"
             "            dismissMenu (nullptr);|NL|        }|NL|        else if (! lynxMenuMnemonic (key)) // LYNX patch (round 170a): accelerator letters|NL|        {|NL|            return false;|NL|        }")

+ 75 - 0
docs/analise/REA_rodada170a.md

@@ -0,0 +1,75 @@
+# REA round 170a — Channel Rack and pattern workflow (Busy Works Beats' video)
+
+Source: Busy Works Beats, "Making a Beat on the 'Open Source' FL STUDIO..." (2026-11-03, macOS, LYNX 0.1.22/0.1.23),
+items #1 #4 #6 #7 #8 #9 of coord/busyworks-0.1.24.md. FL evidence from FL Studio 2026's own binaries (FLEngine_x64.dll
+in the round 167g Ghidra project, headless decompilation; DFM resources dumped in round 165) and, where marked
+[SHOT], one driven FL session. Clean-room: behaviour only, no code or art.
+
+| # | Reporter's words | FL evidence | LYNX before | LYNX now |
+|---|---|---|---|---|
+| 1 | 00:18 "Control X doesn't work on the channel rack" | §1 | Ctrl+X/C/V did nothing in the rack | Ctrl+X/C/V cut / copy / paste the selected channels' steps and notes, as FL |
+| 4 | 03:50 "by default we should have every key labeled" | FL labels the Cs (LYNX extra) | Cs only (white keys too when rows ≥ 16 px) | every key named (≥ 8 px rows), on by default; Settings › General + Piano roll menu switch |
+| 6 | 09:57 "in FL Studio you can left click and drag ... dropdowns take a long time" | §3 | dropdown; rack selector had arrows + wheel | left-drag up/down and the wheel step the patterns on the toolbar box and the rack selector; a click still opens the list |
+| 7 | 12:41 "too close of a color ... dramatically different" | §5 | groups 0x2a2d34 / 0x33363f | see §5 |
+| 8 | 13:18, 20:48 "can't see where the playhead is", "the sound lighting up when it hits" | §2 | playhead only in Pattern mode, a 28 % tint | see §2 |
+| 9 | 11:43 "right clicking and hitting shortcut key like D" | §4 | no letters | FL's letters in the Channel Rack, Playlist and Piano roll menus |
+
+## 1. Ctrl+X / C / V in the Channel Rack
+
+- [DECOMP 0xf20030 EditCutActionExecute / 0xf1ffe0 EditCopyActionExecute / 0xf20080 EditPasteActionExecute]: when no
+  Playlist / Piano roll editor has the focus (FUN_011e9220 false) they call FUN_011e87b0(cut, 0) / FUN_011e8cf0.
+  The channel menu's Cut / Copy / Paste (CutMenuClick 0x11e9650, CopyMenuClick 0x11e96a0) call the same functions.
+- FUN_011e87b0: first = the first selected channel (FUN_011e82c0); the clipboard holds one slot per channel from
+  `first` to the last channel; a channel that is not selected (+0x32c) is marked 0xFF (a gap), a selected one gets its
+  step data for the current pattern (0xFE when it has none) and its per-pattern record (the loop point, 0x14 bytes).
+  With cut = 1 it clears the selected channels' steps (FUN_012d3000) and deletes their notes (FUN_012def00). An undo
+  step is saved.
+- FUN_011e8cf0 (paste): from the first selected channel, slot k → channel first + k (stops at the last channel); a gap
+  is skipped, a 0xFE slot clears the channel, otherwise its steps are replaced and its notes deleted then the copied
+  ones added; the loop record is set from the slot or reset when the slot had none. Undo entry "paste".
+- So FL's Ctrl+X cuts the selected channels' steps/notes (not the channels: deleting channels is Alt+Del). LYNX:
+  core `copyChannelSteps` / `clearChannelSteps` / `pasteChannelSteps` (RackOps), keys rack.cut / rack.copy /
+  rack.paste, the channel menu's Cut / Copy / Paste act on the selection the same way.
+
+## 2. The Channel Rack playhead
+
+- [DFM TStepSeqForm] `PosLEDPanel: TQuickPaintBox`, 8 px high, hint "Playing step", in the rack's bottom panel under
+  the steps. [DECOMP 0x1039610 PosLEDPanelPaint]: the strip alternates beat groups and, while a step plays
+  (global ≥ 0), fills that step's cell.
+- LYNX before: the step was only computed in Pattern mode (`song.mode == PlayMode::pattern`) — in Song mode
+  (Busy Works' case) the rack never showed a playhead even while the shown pattern played in the Playlist.
+- LYNX now: `transportedit::patternPlayhead` (the Piano roll's rule since round 162): Pattern mode, or a clip of the
+  shown pattern playing in Song mode.
+
+## 3. The pattern selector
+
+- [DFM TToolbarForm] `PatSelect: TVectorDigiWheel` (Min 1, Max 999, MoveSpeed 2, Options wwIncMode), hint
+  "^?172^^d^^+- ^Pattern selector", OnDblClick → rename (FUN_012d2920), OnGetText → the pattern's name when wide
+  enough. A digiwheel: left-drag up/down and the wheel change the value.
+
+## 4. Menu accelerator letters
+
+- [DFM TFruityLoopsMainForm] the channel menu: "&Rename, color and icon...", "&Load sample...", "Cu&t itself",
+  "&Insert", "&Clone", "Clone &with links", "&Delete...", "Cu&t", "C&opy", "&Paste", "Fill each &2 / &4 / &8 steps",
+  "Advanced &fill...", "Receive &notes from" (› "&Unlock"), "Burn MIDI to" › "&Current pattern" / "&New pattern",
+  "&Group selected...". The Playlist track menu: "&Rename, color and icon...", "&Auto name", "&Track mode"
+  (› "&Unassigned", "&Audio track", "&Instrument track"), "&Performance settings", "&Size", "&Lock to this size",
+  "&Group with above track", "U&ngroup", "C&onsolidate this track" (› "&From track start", "From &song start"),
+  "&Insert one", "Cl&one...", "D&elete", "Move &up", "Move &down". [DFM TShortcutsModule] the editors' Edit actions:
+  "Cu&t", "&Copy", "&Paste", "D&uplicate", "&Delete", "Delete &all"; Select: "&Deselect", "Select &all",
+  "Select one at &random", "Select more at &random", "Select by &color", "Select &odd", "Select &muted",
+  "&Invert selection"; the Piano roll's menu: "&File" ("&Open score...", "&Browse scores", "&Save score as...",
+  "&Import MIDI file...", "&Export as MIDI file...", "&Paste from MIDI clipboard...", "&Copy to MIDI clipboard..."),
+  "&Edit", "&Tools", "&View", "&Select".
+- LYNX: core/MenuMnemonic.h marks the letter (U+0001) in the translated caption (a translation without the letter
+  gets " (D)"), the LookAndFeel underlines it, JUCE fix 12 (cmake/LynxPatchJuce.cmake) picks the item on the key:
+  one item runs (a submenu opens), several items with the key are highlighted in turn.
+
+## 5. Step colours
+
+(see the driven session below)
+
+## Where I stopped
+
+- done: §1, §2 (Song mode), §3 (drag + wheel), §4, note names; tests tests/Rack170aTests.inc.
+- in progress: FL session (shots), playhead/step look, beat-group colours, Windows screenshots.

+ 16 - 0
src/core/RackOps.cpp

@@ -934,4 +934,20 @@ bool pasteChannelSteps (Pattern& pattern, const ChannelStepsClipboard& clipboard
     return true;
 }
 
+int stepPatternCreating (Song& song, int delta)
+{
+    if (song.patterns.empty())
+        return 0;
+    const auto last = (int) song.patterns.size() - 1;
+    const auto target = song.currentPattern + delta;
+    if (delta > 0 && target > last && ! isPatternEmpty (song.patterns[(std::size_t) last]))
+    {
+        Pattern p;
+        p.name = newPatternName (song);
+        song.patterns.push_back (std::move (p));
+        return last + 1;
+    }
+    return std::clamp (target, 0, last);
+}
+
 } // namespace lynx

+ 9 - 4
src/core/RackOps.h

@@ -36,8 +36,8 @@ inline constexpr int threshold = 3;              // px a press moves before it i
 inline constexpr float pixelsPerPattern = 10.0f; // drag distance per pattern
 // Patterns stepped by a drag `dragY` px from where it started (screen y grows downwards): up = the next patterns.
 inline int steps (float dragY) noexcept { return (int) (-dragY / pixelsPerPattern); }
-// The wheel: one pattern per notch (a trackpad's small deltas add up to a notch); up = the previous pattern, as a
-// list scrolls.
+// The wheel: one pattern per notch (a trackpad's small deltas add up to a notch); up = the next pattern, as FL's
+// selector ([SHOT] round 170a: a notch up on "Pattern 769" gave "Pattern 770").
 struct Wheel
 {
     float pending = 0.0f;
@@ -47,14 +47,14 @@ struct Wheel
         if (delta >= notch || delta <= -notch) // a mouse wheel's notch (JUCE: 0.23 on Windows): one pattern
         {
             pending = 0.0f;
-            return delta > 0.0f ? -1 : 1;
+            return delta > 0.0f ? 1 : -1;
         }
         if ((delta > 0.0f) != (pending > 0.0f) && pending != 0.0f)
             pending = 0.0f; // a turn the other way starts over
         pending += delta;
         if (pending >= notch || pending <= -notch)
         {
-            const auto n = pending > 0.0f ? -1 : 1;
+            const auto n = pending > 0.0f ? 1 : -1;
             pending = 0.0f;
             return n;
         }
@@ -63,6 +63,11 @@ struct Wheel
 };
 } // namespace patterndrag
 
+// The pattern selector's step (drag / wheel): FL's selector goes on past the last pattern and creates the one it lands
+// on ([SHOT] round 170a: a drag up from "Pattern 1" made "Pattern 769"). LYNX creates at most one: stepping forward
+// from the last pattern appends a new empty one unless the last one is already empty. Returns the index to select.
+int stepPatternCreating (Song& song, int delta);
+
 // The first empty pattern after `from` (wrapping around, never `from` itself); -1 if there is none.
 int findNextEmptyPattern (const Song& song, int from) noexcept;
 

+ 5 - 2
src/core/ThemePalette.cpp

@@ -24,7 +24,7 @@ constexpr Palette builtIn {
     0xff2a2d34, 0xff3b3f48,                                                             // border, borderStrong
     0xffeceef2, 0xffa1a6b0, 0xff60656f,                                                 // text
     0xffe5383b, 0xfff2545a, 0xffc12a30, 0xff5c1f24, 0xffffffff, 0x2ee5383b,             // accent family
-    0xffc5c9d1, 0xff444955, 0xff2a2d34, 0xff33363f, 0xffe8a3a6,                         // knobs, steps
+    0xffc5c9d1, 0xff444955, 0xff2a2d34, 0xff573036, 0xffe8a3a6,                         // knobs, steps (alt: stepOffAlt below)
     0xff3a3e47, 0xff262930, 0xff1d1f24, 0xff17181c, 0xff1c1e23, 0xff16171b,             // grids, keys, rows
     0xffb3545a, 0xffff6b6e, 0xff4a4e57, 0xff3a3e47                                      // notes, LED
 };
@@ -81,7 +81,7 @@ Palette derivePalette (std::uint32_t accentIn, std::uint32_t backgroundIn)
 
     // surfaces, hairlines, grids: the built-in steps from the background
     for (auto* token : { &p.bg0, &p.bg1, &p.bg2, &p.bg3, &p.bg4, &p.bg5, &p.bg6, &p.border, &p.borderStrong, &p.knobTrack, &p.stepOff,
-                         &p.stepOffAlt, &p.gridBar, &p.gridBeat, &p.gridStep, &p.keyBlack, &p.rowWhite, &p.rowBlack, &p.noteMuted, &p.ledOff })
+                         &p.gridBar, &p.gridBeat, &p.gridStep, &p.keyBlack, &p.rowWhite, &p.rowBlack, &p.noteMuted, &p.ledOff })
         *token = surface (*token, background, light);
 
     if (light)
@@ -112,6 +112,9 @@ Palette derivePalette (std::uint32_t accentIn, std::uint32_t backgroundIn)
         p.noteHard = mix (accent, 0xffffffff, 0.26);
         p.noteSoft = mix (accent, 0xff808080, 0.42);
     }
+    // the Channel Rack's every-other beat group: the off step tinted with the accent, clearly apart at a glance like
+    // FL's grey / red groups (Busy Works Beats' video, round 170a: "too close of a color")
+    p.stepOffAlt = mix (p.stepOff, p.accent, stepGroupTint);
     return p;
 }
 

+ 3 - 0
src/core/ThemePalette.h

@@ -40,6 +40,9 @@ DigitDisplayColours<C> digitDisplayColours (C bg0, C border, C accent, C accentH
     return { bg0, hot ? accent : border, hot ? accentHover : dimmed ? textDisabled : textPrimary };
 }
 
+// How much of the accent tints the Channel Rack's every-other beat group of steps (Palette::stepOffAlt).
+constexpr double stepGroupTint = 0.24;
+
 // The palette for an accent and a background (alpha is ignored: both are opaque).
 Palette derivePalette (std::uint32_t accent, std::uint32_t background);
 // LYNX's built-in palette (= derivePalette (defaultAccent, defaultBackground)).

+ 45 - 3
src/ui/ChannelRackComponent.cpp

@@ -693,6 +693,24 @@ bool ChannelRackComponent::cellHasNote (int channel, int step) const
     return false;
 }
 
+bool ChannelRackComponent::channelHitsNow (int row) const
+{
+    if (playheadStep < 0 || playheadStep >= numSteps())
+        return false;
+    const auto& song = engine.getSong();
+    const auto& p = song.patterns[(std::size_t) song.currentPattern];
+    const auto loopSteps = loopStepsOf (row);
+    const auto step = loopSteps > 0 && playheadStep >= loopSteps ? playheadStep % loopSteps : playheadStep;
+    return p.hasStep (row, step) || cellHasNote (row, step);
+}
+
+void ChannelRackComponent::paintStepHit (juce::Graphics& g, juce::Rectangle<float> r)
+{
+    theme::fillRoundRect (g, r, theme::radius::sm, juce::Colours::white.withAlpha (0.55f));
+    g.setColour (theme::colour::playhead);
+    g.drawRoundedRectangle (r.reduced (0.75f), theme::radius::sm, 1.5f);
+}
+
 void ChannelRackComponent::paint (juce::Graphics& g)
 {
     const uitrace::Scope trace ("ChannelRackComponent paint", true, g.getClipBounds());
@@ -767,6 +785,8 @@ void ChannelRackComponent::paint (juce::Graphics& g)
                 const auto repeated = pattern.hasStep (row, source) || cellHasNote (row, source);
                 auto fill = repeated ? stepOn : theme::stepOff (step);
                 theme::fillRoundRect (g, r.toFloat(), theme::radius::sm, fill.withMultipliedAlpha (hoverStepHere ? 0.75f : repeated ? 0.45f : 0.3f));
+                if (repeated && step == playheadStep) // the repeat plays: lit as a hit (below)
+                    paintStepHit (g, r.toFloat());
                 if (any)
                 {
                     g.setColour (textDisabled);
@@ -790,6 +810,10 @@ void ChannelRackComponent::paint (juce::Graphics& g)
             else
                 theme::fillRoundRect (g, r.toFloat(), theme::radius::sm, hoverStepHere ? fill.brighter (any ? 0.15f : 0.35f) : fill);
 
+            // FL lights the step as the playhead hits it (its LED turns red, round 170a [SHOT]): a step that plays now glows
+            if (any && step == playheadStep && step < realSteps)
+                paintStepHit (g, r.toFloat());
+
             if (hoverStepHere)
             {
                 g.setColour (textSecondary.withAlpha (0.7f));
@@ -808,12 +832,26 @@ void ChannelRackComponent::paint (juce::Graphics& g)
     const auto addY = rowY ((int) song.channels.size());
     g.setColour (textDisabled);
     g.setFont (theme::font (theme::type::small));
-    textcache::drawText (g, tr ("or drop an audio file here"), gridLeft() + 4, addY, 400, rowHeight, juce::Justification::centredLeft);
+    textcache::drawText (g, tr ("or drop an audio file here"), gridLeft() + 4, addY + positionStripHeight, 400, rowHeight - positionStripHeight,
+                         juce::Justification::centredLeft);
+
+    // FL's "Playing step" strip (PosLEDPanel, REA round 170a §2): a slim LED row under the steps, beat groups
+    // alternating, the playing step lit — in Pattern mode and whenever the shown pattern plays in Song mode
+    for (int step = 0; step < realSteps; ++step)
+    {
+        const auto cell = juce::Rectangle<float> ((float) (gridLeft() + step * stepWidth) + 1.0f, (float) addY + 2.0f, (float) stepWidth - 4.0f,
+                                                  (float) positionStripHeight - 3.0f);
+        if (cell.getRight() < (float) clip.getX() || cell.getX() > (float) clip.getRight())
+            continue;
+        theme::fillRoundRect (g, cell, 1.5f, step == playheadStep ? playhead : theme::stepOff (step).brighter (0.12f));
+    }
 
-    if (playheadStep >= 0 && playheadStep < steps)
+    if (playheadStep >= 0 && playheadStep < steps) // the playing column, over every row
     {
         theme::fillRoundRect (g, juce::Rectangle<float> ((float) (gridLeft() + playheadStep * stepWidth), 2.0f, (float) stepWidth - 2.0f,
-                                                        (float) addY - 2.0f), theme::radius::sm, playhead.withAlpha (0.28f));
+                                                        (float) addY - 2.0f), theme::radius::sm, playhead.withAlpha (0.2f));
+        g.setColour (playhead.withAlpha (0.85f));
+        g.fillRect ((float) (gridLeft() + playheadStep * stepWidth), 2.0f, (float) stepWidth - 2.0f, 2.0f);
     }
 
     // the controls column stays put while the steps scroll sideways (FL's rack keeps the channel buttons in
@@ -928,6 +966,9 @@ void ChannelRackComponent::paint (juce::Graphics& g)
             // selector: a slim pill, lit when the row is selected
             const auto pill = juce::Rectangle<float> ((float) selectLeft() + 3.0f, (float) y + 7.0f, (float) selectWidth - 6.0f, (float) rowHeight - 14.0f);
             theme::fillRoundRect (g, pill, 3.0f, selected ? (hovered (Area::select) ? accentHover : accent) : hovered (Area::select) ? textDisabled : ledOff);
+            // FL flashes the channel's selector as its note plays (round 170a [SHOT]): the "sound lighting up when it hits"
+            if (! channel.muted && channelHitsNow (row))
+                theme::fillRoundRect (g, pill.expanded (1.0f, 0.0f), 3.0f, juce::Colours::white.withAlpha (selected ? 0.75f : 0.9f));
         }
 
         paintLane (g);
@@ -2851,6 +2892,7 @@ void ChannelRackComponent::timerCallback()
         dirty (playheadStep);
         playheadStep = step;
         dirty (playheadStep);
+        repaint (stickyX + selectLeft(), 0, selectWidth, getHeight()); // the selectors flash with the hits
         followPlayhead();
     }
 }

+ 3 - 0
src/ui/ChannelRackComponent.h

@@ -240,6 +240,9 @@ private:
 
     AudioEngine& engine;
     int playheadStep = -1;
+    static constexpr int positionStripHeight = 9; // FL's "Playing step" LED strip, at the top of the add row
+    bool channelHitsNow (int row) const;
+    static void paintStepHit (juce::Graphics&, juce::Rectangle<float>);
 
     enum class PaintMode { none, add, remove } paintMode = PaintMode::none;
     int lastPaintedRow = -1, lastPaintedStep = -1;

+ 13 - 2
src/ui/MainComponent.cpp

@@ -274,7 +274,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     }
 
     patternBox.setTooltip (tr ("Current pattern (Numpad +/-: next/previous, F4: next empty, F2: rename)"));
-    patternBox.onStep = [this] (int delta) { selectPattern (stepPattern (engine.getSong(), delta)); };
+    patternBox.onStep = [this] (int delta) { stepPatternFromSelector (delta); };
     gridBox.setScrollWheelEnabled (true);
     patternBox.onChange = [this]
     {
@@ -378,7 +378,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     ui::setHint (rackLoopStarterButton, tr ("Loop Starter: pick a genre and get a drum loop (kit channels with steps) to re-roll and send to the Playlist"));
     rackTitleTools.addAndMakeVisible (rackLoopStarterButton);
     // the pattern selector (issue #9): change the pattern the rack edits right from its title bar
-    rackPatternSelector.onStep = [this] (int delta) { selectPattern (stepPattern (engine.getSong(), delta)); };
+    rackPatternSelector.onStep = [this] (int delta) { stepPatternFromSelector (delta); };
     rackPatternSelector.onMenu = [this] { showRackPatternList(); };
     ui::setHint (rackPatternSelector, tr ("Pattern the Channel Rack edits: [LMB] on the name: the list of patterns, on the arrows: previous / next  [Wheel] step") + "  " + tr ("[LMB] drag up / down: step through the patterns"));
     rackTitleTools.addAndMakeVisible (rackPatternSelector);
@@ -2090,6 +2090,17 @@ void MainComponent::selectPattern (int index)
         engine.editSong ([index] (Song& s) { s.currentPattern = index; }, false);
 }
 
+void MainComponent::stepPatternFromSelector (int delta)
+{
+    // FL's selector goes on past the last pattern (rack ops stepPatternCreating: one new empty pattern at most)
+    const auto& song = engine.getSong();
+    const auto last = (int) song.patterns.size() - 1;
+    if (delta > 0 && last >= 0 && song.currentPattern + delta > last && ! isPatternEmpty (song.patterns[(std::size_t) last]))
+        engine.editSong ([delta] (Song& s) { s.currentPattern = stepPatternCreating (s, delta); });
+    else
+        selectPattern (stepPattern (song, delta));
+}
+
 void MainComponent::nextEmptyPattern()
 {
     engine.editSong ([] (Song& s) { gotoNextEmptyPattern (s); });

+ 1 - 0
src/ui/MainComponent.h

@@ -398,6 +398,7 @@ private:
     };
     PatternSelector rackPatternSelector;
     void showRackPatternList();
+    void stepPatternFromSelector (int delta); // drag / wheel on the toolbar box or the rack selector
     void refreshRackPatternSelector();
     // The current pattern's length in bars next to the swing knob (issue #12; drawn like the rack's insert number
     // box): drag up / down or the wheel changes it, double-click = automatic (from the notes), right-click = menu.

+ 1 - 1
src/ui/Theme.h

@@ -57,7 +57,7 @@ inline juce::Colour meterClip { 0xffff3b3f };
 inline juce::Colour knobArc { 0xffc5c9d1 };     // rotary value arcs at rest (accent while touched)
 inline juce::Colour knobTrack { 0xff444955 };   // the unlit part of a knob's ring (reads on every panel surface)
 inline juce::Colour stepOff { 0xff2a2d34 };
-inline juce::Colour stepOffAlt { 0xff33363f };   // every other group of 4 steps
+inline juce::Colour stepOffAlt { 0xff573036 };   // every other group of 4 steps (accent-tinted, round 170a)
 inline juce::Colour stepOn { 0xffe5383b }; // = accent
 inline juce::Colour stepNote { 0xffe8a3a6 };     // a step that only has a Piano Roll note
 inline juce::Colour gridBar { 0xff3a3e47 };      // bar lines

+ 44 - 3
tests/Rack170aTests.inc

@@ -100,12 +100,31 @@ TEST (rack170a_pattern_selector_drag_and_wheel)
     CHECK (steps (-3.0f * pixelsPerPattern) == 3);
     CHECK (steps (2.0f * pixelsPerPattern) == -2); // down: the previous ones
     Wheel w;
-    CHECK (w.take (0.23f) == -1);  // a mouse notch up: the previous pattern
-    CHECK (w.take (-0.23f) == 1);
-    CHECK (w.take (0.04f) == 0 && w.take (0.04f) == 0 && w.take (0.04f) == -1); // trackpad deltas add up
+    CHECK (w.take (0.23f) == 1);  // a mouse notch up: the next pattern (FL)
+    CHECK (w.take (-0.23f) == -1);
+    CHECK (w.take (0.04f) == 0 && w.take (0.04f) == 0 && w.take (0.04f) == 1); // trackpad deltas add up
     CHECK (w.take (0.05f) == 0 && w.take (-0.05f) == 0); // the other way starts over
 }
 
+TEST (rack170a_pattern_selector_past_the_last)
+{
+    using namespace lynx;
+    Song s;
+    s.patterns.resize (2);
+    s.patterns[0].name = "Pattern 1";
+    s.patterns[1].name = "Pattern 2";
+    s.currentPattern = 1;
+    // the last pattern is empty: no new one
+    CHECK (stepPatternCreating (s, 1) == 1 && s.patterns.size() == 2);
+    Note n;
+    s.patterns[1].notes.push_back (n);
+    // with notes: one new empty pattern, named after the others
+    CHECK (stepPatternCreating (s, 3) == 2 && s.patterns.size() == 3 && s.patterns[2].name == "Pattern 3");
+    s.currentPattern = 2;
+    CHECK (stepPatternCreating (s, 1) == 2 && s.patterns.size() == 3);
+    CHECK (stepPatternCreating (s, -5) == 0);
+}
+
 TEST (rack170a_playhead_in_song_mode_and_note_names)
 {
     using namespace lynx;
@@ -126,3 +145,25 @@ TEST (rack170a_playhead_in_song_mode_and_note_names)
     // every Piano roll key is named by default (LYNX)
     CHECK (notenames::everyKey.load());
 }
+
+TEST (rack170a_step_groups_clearly_apart)
+{
+    using namespace lynx::themes;
+    // Busy Works Beats: "too close of a color ... dramatically different" — FL's groups are grey / red-tinted
+    const auto& d = defaultPalette();
+    CHECK (d.stepOffAlt != d.stepOff);
+    const auto r = [] (std::uint32_t c) { return (int) ((c >> 16) & 255); };
+    const auto gch = [] (std::uint32_t c) { return (int) ((c >> 8) & 255); };
+    CHECK (r (d.stepOffAlt) - r (d.stepOff) >= 30);              // clearly redder
+    CHECK (r (d.stepOffAlt) - gch (d.stepOffAlt) >= 25);         // a tint, not a lighter grey
+    // every theme (light ones too, and other accents) keeps the groups apart
+    for (const auto bg : { 0xff1c1e23u, 0xfff2f3f5u, 0xff3a3d44u })
+        for (const auto accent : { 0xffe5383bu, 0xff3a8ee5u })
+        {
+            const auto p = derivePalette (accent, bg);
+            int diff = 0;
+            for (const int shift : { 16, 8, 0 })
+                diff += std::abs ((int) ((p.stepOffAlt >> shift) & 255) - (int) ((p.stepOff >> shift) & 255));
+            CHECK (diff >= 45);
+        }
+}