Quellcode durchsuchen

Round 170f: pattern blocks default height, 5-row snapshot, test fixes

Ka1-S vor 1 Monat
Ursprung
Commit
4765eb2801

+ 3 - 3
docs/analise/REA_rodada170f.md

@@ -37,8 +37,8 @@ grows, a block row's header gestures, and the conversion's target tracks.
 
 ## 3. Design (LYNX)
 
-**Option.** `Song::patternBlocks` (bool, saved in .lynx) — Playlist menu *Pattern blocks (current project)*, key-map
-action `playlist.patternBlocks`, and Options › Project. Turning it on shows the blocks section; turning it off while
+**Option.** `Song::patternBlocksOn` (bool, saved in .lynx) — the Playlist's right-click menu and its panel options menu
+*Pattern blocks (current project)*, key-map action `playlist.patternBlocks` (no default key; assignable). Turning it on shows the blocks section; turning it off while
 blocks exist asks: *Turn them into clips* / *Delete them* / *Cancel* (LYNX: hidden blocks that still play would be
 confusing). Off by default (as FL 10).
 
@@ -80,7 +80,7 @@ host's blocks travel with the project).
 
 | Item | FL evidence | LYNX before | LYNX now |
 |---|---|---|---|
-| Opt-in block playlist | E1, E4 | none | per-project option, Playlist menu + Options › Project |
+| Opt-in block playlist | E1, E4 | none | per-project option in the Playlist menus (+ key-map action) |
 | Row = pattern, one click paints | E3, E5 | Picker + pencil (pick a pattern first) | block rows, left-click / drag paints |
 | Whole-pattern blocks on the bar grid | E3 | clips can be trimmed/slipped/moved | blocks = pattern length at bar starts, no move/resize |
 | Minimal display | E3 | clip previews | solid colour blocks |

+ 2 - 0
src/Main.cpp

@@ -8123,6 +8123,8 @@ private:
                 const auto saved = offline.getSong();
                 offline.editSong ([] (lynx::Song& s) {
                     s.patternBlocksOn = true;
+                    while (s.patterns.size() < 5) // a few rows to show (Drums, Bass...: copies of the demo's pattern)
+                        lynx::clonePattern (s, (int) s.patterns.size() - 1);
                     const auto rows = juce::jmin (6, (int) s.patterns.size());
                     for (int r = 0; r < rows; ++r)
                         lynx::patternblocks::paintRange (s, r, (std::int64_t) (r % 3) * 4 * lynx::ppq * 2,

+ 1 - 1
src/core/Song.h

@@ -1404,7 +1404,7 @@ struct Arrangement
     std::int64_t loopStart = 0, loopEnd = 0;
     std::vector<Marker> markers;           // sorted by tick (stay here even for the current arrangement)
     std::uint64_t uid = 0;                 // stable id (Online Sessions, round 168a)
-    std::vector<PatternBlock> blocks;      // Pattern Blocks (round 170f); empty for the current one: Song::blocks
+    std::vector<PatternBlock> blocks {};   // Pattern Blocks (round 170f); empty for the current one: Song::blocks
     bool operator== (const Arrangement&) const = default;
 };
 

+ 3 - 1
src/ui/PlaylistComponent.cpp

@@ -433,7 +433,9 @@ int PlaylistComponent::blocksSectionHeight() const
     const auto available = getHeight() - headerHeight;
     const auto least = PatternBlocksView::dividerHeight + 3 * PatternBlocksView::rowHeight;
     const auto most = juce::jmax (least, available - 2 * trackHeight); // the clip tracks keep two rows
-    const auto wanted = blocksHeight > 0 ? blocksHeight : available / 3;
+    // by default a third of the grid, or less when every row (and a spare one) fits in less
+    const auto rows = PatternBlocksView::dividerHeight + ((int) engine.getSong().patterns.size() + 1) * PatternBlocksView::rowHeight;
+    const auto wanted = blocksHeight > 0 ? blocksHeight : juce::jmin (available / 3, rows);
     return juce::jlimit (least, most, wanted);
 }
 

+ 8 - 2
tests/PatternBlocks170fTests.inc

@@ -225,9 +225,15 @@ TEST (pb170f_turn_blocks_into_clips_one_locked_track_per_pattern)
     for (const auto& clip : s.playlist)
     {
         if (clip.track == 2)
-            ++onTrack2, CHECK (clip.pattern == 0 && clip.length == bar);
+        {
+            ++onTrack2;
+            CHECK (clip.pattern == 0 && clip.length == bar);
+        }
         if (clip.track == 3)
-            ++onTrack3, CHECK (clip.pattern == 1 && clip.start == 2 * bar && clip.length == 2 * bar);
+        {
+            ++onTrack3;
+            CHECK (clip.pattern == 1 && clip.start == 2 * bar && clip.length == 2 * bar);
+        }
     }
     CHECK (onTrack2 == 2 && onTrack3 == 1);
     CHECK (s.playlistTracks.size() >= 4 && s.playlistTracks[2].name == "P1" && s.playlistTracks[3].name == "P2");