4
0

Feel190qeTest.inc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. // LYNX --feel190qetest <report.txt> [<shot prefix> [project.(flp|lynx)]] (round 190qe, TOP-NEXT R1 "Feel 1"): off screen
  2. // through the real components:
  3. // - the edge scroll (core/EditorFeel.h): a clip dragged past the Playlist's right edge runs the view at FL's measured
  4. // speed in the Pattern layout (≈ 223 px/s 20 px out), flat over time, the clip kept at the edge, stopped by the
  5. // release; never before bar 1; a selection box grows into what comes in; the Clip-launch layout's Live-like zone;
  6. // the Piano roll's notes (sideways and up), its velocity lane stroke;
  7. // - the view stack ("Zoom to the selection" again = back, "Previous view"), the zoom glide (150 ms, ease-out), the
  8. // zoom keys' anchor (the selection's centre stays), "Restore selection";
  9. // - FL's "Keep labels on screen": a clip whose start is scrolled off has its label at the left edge (on) or none
  10. // (off), in the three layouts.
  11. // With a shot prefix: the Playlist with Keep labels on and off (FL's verify_190qc shots 06 / 07 are the reference), on
  12. // the project when one is given; @150 with LYNX_SHOT_SCALE=1.5 LYNX_SHOT_SUFFIX=@150. Included in the app class of
  13. // Main.cpp. Returns true when every check passes; `summary` gets "OK" or the first failure (for --selftest).
  14. bool runFeel190qeTest (const juce::String& reportPath, const juce::String& prefix, const juce::String& projectPath, juce::String* summary = nullptr)
  15. {
  16. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  17. const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
  18. using namespace lynx;
  19. const juce::ScopedValueSetter<bool> held (edgescroll::buttonHeldForTests, true);
  20. const auto motionBefore = ui::motion::enabled();
  21. const auto keepBefore = keeplabels::on;
  22. const auto layoutBefore = layoutstyle::current();
  23. ui::motion::enabled() = false;
  24. juce::String text, firstFailure;
  25. bool allOk = true;
  26. const auto check = [&] (const juce::String& what, bool ok) {
  27. text << (ok ? "ok " : "FAIL ") << what << "\n";
  28. if (! ok && firstFailure.isEmpty())
  29. firstFailure = what;
  30. allOk = allOk && ok;
  31. };
  32. // a press, a drag (from the press) and a release, as JUCE delivers them to the component
  33. const auto event = [] (juce::Component& target, juce::Point<int> p, juce::Point<int> down, juce::ModifierKeys mods, bool dragged) {
  34. auto source = juce::Desktop::getInstance().getMainMouseSource();
  35. const auto now = juce::Time::getCurrentTime();
  36. return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &target, &target, now, down.toFloat(), now, 1, dragged);
  37. };
  38. const auto left = juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier);
  39. const auto px = [] (double v) { return juce::String (v, 1); };
  40. // 64 bars; tracks 1-4: one-bar pattern clips every other bar; track 6: a 32-bar clip ("Long lead") from bar 3
  41. const auto bar = (std::int64_t) 4 * ppq;
  42. auto song = Song::makeDefault();
  43. song.mode = PlayMode::song;
  44. song.patterns.resize (3);
  45. song.patterns[0].name = "Beat";
  46. song.patterns[1].name = "Long lead";
  47. song.patterns[2].name = "Notes";
  48. for (int k = 0; k < 16; ++k)
  49. {
  50. Note n;
  51. n.channel = 0;
  52. n.start = k * ppq;
  53. n.length = ppq / 2;
  54. n.key = 60 + (k * 5) % 12;
  55. song.patterns[2].notes.push_back (n);
  56. song.patterns[0].notes.push_back (n);
  57. }
  58. song.playlist.clear();
  59. for (int t = 1; t <= 4; ++t)
  60. for (int b = 0; b < 64; b += 2)
  61. {
  62. Clip c;
  63. c.pattern = 0;
  64. c.track = t;
  65. c.start = b * bar;
  66. c.length = bar;
  67. song.playlist.push_back (c);
  68. }
  69. {
  70. Clip c;
  71. c.pattern = 1;
  72. c.track = 6;
  73. c.start = 3 * bar;
  74. c.length = 32 * bar;
  75. song.playlist.push_back (c);
  76. }
  77. AudioEngine offline (false);
  78. offline.setSong (song);
  79. MainComponent ui (offline, false);
  80. ui.setSize (1920, 1080);
  81. offline.dispatchPendingMessages();
  82. ui.setLayoutStyle (layoutstyle::Style::pattern);
  83. ui.selectTabForSnapshot (2);
  84. offline.dispatchPendingMessages();
  85. auto& pl = ui.getPlaylistForSnapshot();
  86. const auto ppt = [&pl] { return pl.viewNowForTests().pixelsPerUnit; };
  87. const auto clipOf = [&offline] (int track, std::int64_t start) {
  88. const auto& list = offline.getSong().playlist;
  89. for (int i = 0; i < (int) list.size(); ++i)
  90. if (list[(std::size_t) i].track == track && list[(std::size_t) i].start == start)
  91. return i;
  92. return -1;
  93. };
  94. // runs the view's frames for `ms` at 60 Hz from `t0`, returns the end time
  95. const auto frames = [] (auto& view, double t0, double ms) {
  96. for (double t = t0; t <= t0 + ms + 0.01; t += 1000.0 / 60.0)
  97. view.feelFrameForTests (t);
  98. return t0 + ms;
  99. };
  100. // ---- A. the Playlist, Pattern layout: FL's law ------------------------------------------------------------
  101. {
  102. pl.setViewForSnapshot (64.0, 0, 0);
  103. const auto grid = pl.gridAreaForSnapshot();
  104. const auto index = clipOf (2, 4 * bar);
  105. const auto box = pl.clipBoundsForSnapshot (index);
  106. const auto press = juce::Point<int> (box.getCentreX(), box.getBottom() - 4);
  107. pl.mouseDown (event (pl, press, press, left, false));
  108. const auto out = juce::Point<int> (grid.getRight() - 1 + 20, press.y); // 20 px past the right edge
  109. pl.mouseDrag (event (pl, out.withX (out.x - 200), press, left, true));
  110. pl.mouseDrag (event (pl, out, press, left, true));
  111. const auto s0 = pl.viewNowForTests().scroll;
  112. auto t = frames (pl, 0.0, 1000.0);
  113. const auto s1 = pl.viewNowForTests().scroll;
  114. t = frames (pl, t + 1000.0 / 60.0, 1000.0);
  115. const auto s2 = pl.viewNowForTests().scroll;
  116. const auto first = (s1 - s0) * ppt(), second = (s2 - s1) * ppt();
  117. check ("Playlist (Pattern): 20 px past the right edge runs " + px (first) + " px in the first second (FL: 223)", std::abs (first - 223.0) <= 6.0);
  118. check ("Playlist (Pattern): the same speed in the next second (" + px (second) + " px; FL: no acceleration over time)", std::abs (second - first) <= 6.0);
  119. // the dragged clip stays at the edge: its grabbed point at the view's right edge (within a snap step)
  120. const auto& moved = offline.getSong().playlist[(std::size_t) index];
  121. const auto grabbedX = pl.clipBoundsForSnapshot (index).getX() + (press.x - box.getX());
  122. check ("Playlist (Pattern): the dragged clip moved with the view and stays at the edge (its grip at " + juce::String (grabbedX) + ", edge "
  123. + juce::String (grid.getRight() - 1) + ", clip at bar " + juce::String ((double) moved.start / (double) bar + 1.0, 2) + ")",
  124. std::abs (grabbedX - (grid.getRight() - 1)) <= (int) std::ceil (16.0) + 1 && moved.start > 4 * bar);
  125. pl.mouseUp (event (pl, out, press, {}, true));
  126. const auto s3 = pl.viewNowForTests().scroll;
  127. frames (pl, t + 100.0, 500.0);
  128. check ("Playlist (Pattern): the release stops it", pl.viewNowForTests().scroll == s3 && ! pl.edgeScrollRunning());
  129. offline.undo();
  130. offline.dispatchPendingMessages();
  131. // 3 px inside the edge: still (FL); 1 px past the left edge at bar 1: still (FL stops at the song's start)
  132. pl.setViewForSnapshot (64.0, 0, 0);
  133. const auto box2 = pl.clipBoundsForSnapshot (clipOf (1, 2 * bar));
  134. const auto press2 = juce::Point<int> (box2.getCentreX(), box2.getBottom() - 4);
  135. pl.mouseDown (event (pl, press2, press2, left, false));
  136. pl.mouseDrag (event (pl, { grid.getRight() - 4, press2.y }, press2, left, true));
  137. frames (pl, 10000.0, 500.0);
  138. check ("Playlist (Pattern): 3 px inside the edge does not scroll (FL)", pl.viewNowForTests().scroll == 0.0);
  139. pl.mouseDrag (event (pl, { grid.getX() - 30, press2.y }, press2, left, true));
  140. frames (pl, 11000.0, 500.0);
  141. check ("Playlist (Pattern): past the left edge at bar 1 the view stays (FL stops at the song's start)", pl.viewNowForTests().scroll == 0.0);
  142. pl.mouseUp (event (pl, { grid.getX() - 30, press2.y }, press2, {}, true));
  143. offline.undo();
  144. offline.dispatchPendingMessages();
  145. // a selection box (Select tool) dragged past the right edge selects what comes into view
  146. pl.setViewForSnapshot (64.0, 0, 0);
  147. pl.selectClipsForSnapshot ({});
  148. pl.setToolForSnapshot (EditTool::lasso);
  149. const auto boxFrom = juce::Point<int> (grid.getX() + 96, pl.trackRowForSnapshot (1).getY() + 3); // (bar 2.5: empty)
  150. pl.mouseDown (event (pl, boxFrom, boxFrom, left, false));
  151. const auto boxTo = juce::Point<int> (grid.getRight() - 1 + 40, pl.trackRowForSnapshot (2).getBottom() - 3);
  152. pl.mouseDrag (event (pl, boxTo.withX (grid.getCentreX()), boxFrom, left, true));
  153. pl.mouseDrag (event (pl, boxTo, boxFrom, left, true));
  154. frames (pl, 20000.0, 1500.0);
  155. const auto visibleBars = (double) grid.getWidth() / 64.0;
  156. const auto farClip = clipOf (2, (std::int64_t) std::ceil (visibleBars / 2.0 + 1.0) * 2 * bar);
  157. const auto sel = pl.clipSelectionForSnapshot();
  158. const auto first0 = clipOf (1, 2 * bar);
  159. check ("Playlist (Pattern): a selection box past the edge selects the clips that came into view (" + juce::String ((int) sel.size())
  160. + " clips) and keeps its corner at bar 2.5",
  161. farClip >= 0 && std::find (sel.begin(), sel.end(), farClip) != sel.end() && std::find (sel.begin(), sel.end(), first0) != sel.end());
  162. pl.mouseUp (event (pl, boxTo, boxFrom, {}, true));
  163. pl.setToolForSnapshot (EditTool::pencil);
  164. // "Restore selection": the box's selection, then a click on an empty spot clears it, then Restore brings it back
  165. const auto before = pl.clipSelectionForSnapshot();
  166. pl.setViewForSnapshot (64.0, 0, 0);
  167. const auto empty = juce::Point<int> (grid.getX() + 100, pl.trackRowForSnapshot (9).getCentreY());
  168. pl.setToolForSnapshot (EditTool::lasso);
  169. pl.mouseDown (event (pl, empty, empty, left, false));
  170. pl.mouseUp (event (pl, empty, empty, {}, false));
  171. const auto cleared = pl.clipSelectionForSnapshot().empty();
  172. pl.runAction ("playlist.restoreSelection");
  173. check ("Playlist: a click cleared the selection (" + juce::String (cleared ? "yes" : "no") + ") and \"Restore selection\" brings back its "
  174. + juce::String ((int) before.size()) + " clips",
  175. cleared && ! before.empty() && pl.clipSelectionForSnapshot() == before);
  176. pl.setToolForSnapshot (EditTool::pencil);
  177. }
  178. // ---- B. the view stack, the zoom keys' anchor and the glide (Playlist) --------------------------------------
  179. {
  180. pl.setViewForSnapshot (32.0, 8, 0);
  181. const auto start = pl.viewNowForTests();
  182. const auto one = clipOf (6, 3 * bar);
  183. pl.selectClipsForSnapshot ({ one });
  184. pl.runAction ("playlist.zoomSelection");
  185. const auto zoomed = pl.viewNowForTests();
  186. check ("Playlist: \"Zoom to the selection\" shows the clip (" + juce::String (zoomed.pixelsPerUnit * (double) bar, 1) + " px a bar)",
  187. zoomed.pixelsPerUnit > start.pixelsPerUnit && pl.viewStackDepth() == 1);
  188. pl.runAction ("playlist.zoomSelection");
  189. check ("Playlist: the same key again goes back to the view before", viewstack::same (pl.viewNowForTests(), start) && pl.viewStackDepth() == 0);
  190. pl.runAction ("playlist.zoomSelection");
  191. pl.setScrollTickForSnapshot (pl.viewNowForTests().scroll + (double) bar); // (moved by hand: the key zooms again)
  192. pl.runAction ("playlist.previousView");
  193. check ("Playlist: \"Previous view\" goes back whatever the view is now", viewstack::same (pl.viewNowForTests(), start));
  194. // UX-A2: stopped, the zoom keys keep the selection's centre in place
  195. pl.setViewForSnapshot (32.0, 0, 0);
  196. const auto bounds = pl.clipBoundsForSnapshot (one);
  197. const auto centre = bounds.getX() + bounds.getWidth() * 0.5;
  198. const auto tickAt = [&pl] (double x) { const auto v = pl.viewNowForTests(); return v.scroll + (x - pl.gridAreaForSnapshot().getX()) / v.pixelsPerUnit; };
  199. const auto anchorTick = tickAt (centre);
  200. pl.runAction ("playlist.zoomIn");
  201. const auto v = pl.viewNowForTests();
  202. const auto after = pl.gridAreaForSnapshot().getX() + (anchorTick - v.scroll) * v.pixelsPerUnit;
  203. check ("Playlist: PageUp zooms around the selection's centre (it moved " + px (after - centre) + " px)", std::abs (after - centre) < 1.0);
  204. // UX-A3: with Animations on the zoom glides over 150 ms, ease-out, and lands on the key's view
  205. ui::motion::enabled() = true;
  206. const juce::ScopedValueSetter<bool> glides (glide::inTests, true);
  207. pl.setViewForSnapshot (32.0, 0, 0);
  208. pl.selectClipsForSnapshot ({});
  209. const auto from = pl.viewNowForTests();
  210. pl.runAction ("playlist.zoomIn");
  211. const auto running = pl.viewGlideRunning();
  212. const auto t0 = juce::Time::getMillisecondCounterHiRes();
  213. pl.feelFrameForTests (t0 + 40.0);
  214. const auto mid = pl.viewNowForTests().pixelsPerUnit;
  215. pl.feelFrameForTests (t0 + 80.0);
  216. const auto later = pl.viewNowForTests().pixelsPerUnit;
  217. pl.feelFrameForTests (t0 + 200.0);
  218. const auto landed = pl.viewNowForTests().pixelsPerUnit;
  219. check ("Playlist: the zoom key glides (" + juce::String (from.pixelsPerUnit * (double) bar, 2) + " -> " + juce::String (mid * (double) bar, 2) + " -> "
  220. + juce::String (later * (double) bar, 2) + " -> " + juce::String (landed * (double) bar, 2) + " px a bar)",
  221. running && mid > from.pixelsPerUnit && later > mid && landed > later && std::abs (landed - from.pixelsPerUnit * 1.25) < 1.0e-9
  222. && ! pl.viewGlideRunning());
  223. ui::motion::enabled() = false;
  224. pl.runAction ("playlist.zoomOut");
  225. check ("Playlist: with Animations off the zoom key jumps", ! pl.viewGlideRunning() && std::abs (pl.viewNowForTests().pixelsPerUnit - from.pixelsPerUnit) < 1.0e-9);
  226. }
  227. // ---- C. FL's "Keep labels on screen", three layouts -----------------------------------------------------------
  228. const auto labelStrip = [&pl, &offline, bar] {
  229. // the left 120 px of the long clip's row with its start 2 bars left of the view
  230. pl.setViewForSnapshot (48.0, 5, 0);
  231. offline.dispatchPendingMessages();
  232. const auto grid = pl.gridAreaForSnapshot();
  233. const auto row = pl.trackRowForSnapshot (6);
  234. juce::ignoreUnused (bar);
  235. return pl.createComponentSnapshot ({ grid.getX(), row.getY(), 120, row.getHeight() }, true, 1.0f);
  236. };
  237. const auto differs = [] (const juce::Image& a, const juce::Image& b) {
  238. if (a.getBounds() != b.getBounds())
  239. return true;
  240. int n = 0;
  241. for (int y = 0; y < a.getHeight(); ++y)
  242. for (int x = 0; x < a.getWidth(); ++x)
  243. n += a.getPixelAt (x, y) != b.getPixelAt (x, y) ? 1 : 0;
  244. return n > 20;
  245. };
  246. for (const auto layout : { layoutstyle::Style::pattern, layoutstyle::Style::clipLaunch, layoutstyle::Style::simple })
  247. {
  248. ui.setLayoutStyle (layout);
  249. if (layout == layoutstyle::Style::clipLaunch)
  250. {
  251. ui.showPanelsForSnapshot ({ workspace::Panel::playlist });
  252. ui.setClipGridView (PlaylistArea::GridView::song);
  253. }
  254. offline.dispatchPendingMessages();
  255. const juce::String name = layout == layoutstyle::Style::pattern ? "Pattern" : layout == layoutstyle::Style::clipLaunch ? "Clip-launch" : "Simple";
  256. keeplabels::on = true;
  257. const auto on = labelStrip();
  258. keeplabels::on = false;
  259. pl.repaint();
  260. const auto off = labelStrip();
  261. keeplabels::on = true;
  262. check ("Keep labels on screen (" + name + "): the label of a clip scrolled off shows at the left edge, and not with the option off", differs (on, off));
  263. }
  264. ui.setLayoutStyle (layoutstyle::Style::pattern);
  265. ui.selectTabForSnapshot (2);
  266. offline.dispatchPendingMessages();
  267. // ---- D. the Clip-launch layout: the Live-like zone (10 px inside the edge already runs; the Pattern law does not)
  268. {
  269. ui.setLayoutStyle (layoutstyle::Style::clipLaunch);
  270. ui.showPanelsForSnapshot ({ workspace::Panel::playlist });
  271. ui.setClipGridView (PlaylistArea::GridView::song);
  272. offline.dispatchPendingMessages();
  273. auto& p2 = ui.getPlaylistForSnapshot();
  274. p2.setViewForSnapshot (64.0, 0, 0);
  275. const auto grid = p2.gridAreaForSnapshot();
  276. const auto index = clipOf (2, 4 * bar);
  277. const auto box = p2.clipBoundsForSnapshot (index);
  278. const auto press = juce::Point<int> (box.getCentreX(), box.getBottom() - 4);
  279. p2.mouseDown (event (p2, press, press, left, false));
  280. p2.mouseDrag (event (p2, { grid.getRight() - 11, press.y }, press, left, true));
  281. frames (p2, 30000.0, 1000.0);
  282. const auto ran = p2.viewNowForTests().scroll * p2.viewNowForTests().pixelsPerUnit;
  283. check ("Playlist (Clip-launch): 10 px inside the edge runs (Live-like zone): " + px (ran) + " px in 1 s, between 0.5 and 4 screens",
  284. ran >= 0.5 * grid.getWidth() - 2.0 && ran <= 4.0 * grid.getWidth() + 2.0);
  285. p2.mouseUp (event (p2, { grid.getRight() - 11, press.y }, press, {}, true));
  286. offline.undo();
  287. offline.dispatchPendingMessages();
  288. ui.setLayoutStyle (layoutstyle::Style::pattern);
  289. ui.selectTabForSnapshot (2);
  290. offline.dispatchPendingMessages();
  291. }
  292. // ---- E. the Piano roll (Pattern layout): notes sideways and up, the velocity lane ---------------------------
  293. {
  294. offline.editSong ([] (Song& s) { s.currentPattern = 2; }, false);
  295. offline.dispatchPendingMessages();
  296. ui.selectTabForSnapshot (1);
  297. offline.dispatchPendingMessages();
  298. auto& roll = ui.getPianoRollForSnapshot();
  299. roll.resized();
  300. const auto grid = roll.gridAreaForSnapshot();
  301. const auto note = offline.getSong().patterns[2].notes[1];
  302. const auto at = roll.pointForSnapshot (note.key, note.start);
  303. roll.mouseDown (event (roll, at, at, left, false));
  304. roll.mouseDrag (event (roll, { grid.getRight() - 1 + 20, at.y }, at, left, true));
  305. const auto s0 = roll.viewNowForTests().scroll;
  306. frames (roll, 40000.0, 1000.0);
  307. const auto ran = (roll.viewNowForTests().scroll - s0) * roll.viewNowForTests().pixelsPerUnit;
  308. check ("Piano roll (Pattern): a note 20 px past the right edge runs " + px (ran) + " px in 1 s (FL: 183 at 16 px, 223 at 20 px)", std::abs (ran - 223.0) <= 6.0);
  309. roll.mouseUp (event (roll, { grid.getRight() - 1 + 20, at.y }, at, {}, true));
  310. offline.undo();
  311. offline.dispatchPendingMessages();
  312. // up: a note dragged 37 px above the grid (FL: 396 px/s)
  313. const auto y0 = roll.viewNowForTests().scrollY;
  314. roll.mouseDown (event (roll, at, at, left, false));
  315. roll.mouseDrag (event (roll, { at.x, grid.getY() - 37 }, at, left, true));
  316. frames (roll, 50000.0, 250.0);
  317. const auto up = y0 - roll.viewNowForTests().scrollY;
  318. check ("Piano roll (Pattern): a note 37 px above the grid runs up " + px (up * 4.0) + " px/s (FL: 396)", y0 < 1.0 || std::abs (up * 4.0 - 396.0) <= 30.0);
  319. roll.mouseUp (event (roll, { at.x, grid.getY() - 37 }, at, {}, true));
  320. offline.undo();
  321. offline.dispatchPendingMessages();
  322. // the velocity lane: a stroke 16 px past the right edge (FL: 176 px/s)
  323. const auto lane = roll.laneAreaForSnapshot();
  324. if (! lane.isEmpty())
  325. {
  326. const auto from = juce::Point<int> (grid.getX() + 40, lane.getCentreY());
  327. const auto l0 = roll.viewNowForTests().scroll;
  328. roll.mouseDown (event (roll, from, from, left, false));
  329. roll.mouseDrag (event (roll, { grid.getRight() - 1 + 16, lane.getCentreY() }, from, left, true));
  330. frames (roll, 60000.0, 1000.0);
  331. const auto laneRan = (roll.viewNowForTests().scroll - l0) * roll.viewNowForTests().pixelsPerUnit;
  332. check ("Piano roll (Pattern): a velocity lane stroke 16 px past the edge runs " + px (laneRan) + " px in 1 s (FL: 176)", std::abs (laneRan - 186.7) <= 8.0);
  333. roll.mouseUp (event (roll, { grid.getRight() - 1 + 16, lane.getCentreY() }, from, {}, true));
  334. offline.undo();
  335. offline.dispatchPendingMessages();
  336. }
  337. else
  338. check ("Piano roll: the velocity lane is shown", false);
  339. ui.selectTabForSnapshot (2);
  340. offline.dispatchPendingMessages();
  341. }
  342. // ---- shots: Keep labels on screen on / off (the reference: FL 2026, verify_190qc shots 06 / 07) ---------------
  343. if (prefix.isNotEmpty())
  344. {
  345. if (projectPath.isNotEmpty())
  346. {
  347. juce::String error;
  348. const juce::File project (projectPath);
  349. const auto ok = project.hasFileExtension ("flp") ? offline.importFlpFile (project, error) : [&] {
  350. if (auto s = ProjectFile::load (project, error))
  351. {
  352. offline.setSong (std::move (*s));
  353. return true;
  354. }
  355. return false;
  356. }();
  357. check ("shots: the project " + project.getFileName() + " loads " + error, ok);
  358. offline.dispatchPendingMessages();
  359. }
  360. ui.setLayoutStyle (layoutstyle::Style::pattern);
  361. ui.selectTabForSnapshot (2);
  362. offline.dispatchPendingMessages();
  363. auto& p3 = ui.getPlaylistForSnapshot();
  364. const auto firstBar = juce::SystemStats::getEnvironmentVariable ("LYNX_FEEL_BAR", projectPath.isNotEmpty() ? "41" : "5").getIntValue();
  365. const auto perBar = juce::SystemStats::getEnvironmentVariable ("LYNX_FEEL_PPB", "58").getDoubleValue();
  366. const auto firstTrack = juce::SystemStats::getEnvironmentVariable ("LYNX_FEEL_TRACK", "0").getIntValue();
  367. for (const auto on : { true, false })
  368. {
  369. keeplabels::on = on;
  370. p3.setViewForSnapshot (perBar, firstBar, firstTrack);
  371. p3.repaint();
  372. offline.dispatchPendingMessages();
  373. p3.resized();
  374. savePng (shot::snapshot (p3), prefix + (on ? "-keep-labels-on" : "-keep-labels-off") + ".png");
  375. const auto grid = p3.gridAreaForSnapshot();
  376. savePng (p3.createComponentSnapshot (juce::Rectangle<int> (grid.getX() - 8, grid.getY(), 420, 400).getIntersection (p3.getLocalBounds()), true,
  377. 2.0f * shot::scale()),
  378. prefix + (on ? "-keep-labels-on-zoom" : "-keep-labels-off-zoom") + ".png");
  379. }
  380. keeplabels::on = true;
  381. // the Playlist menu's View submenu (FL 2026: Grid / Content / Time / Track headers, verify_190qc shot 05)
  382. {
  383. const auto menu = ui.getPanelMenuForSnapshot (workspace::Panel::playlist);
  384. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  385. if (it.getItem().text == tr ("View") && it.getItem().subMenu != nullptr)
  386. {
  387. auto hasKeep = false;
  388. for (juce::PopupMenu::MenuItemIterator v (*it.getItem().subMenu); v.next();)
  389. hasKeep = hasKeep || (v.getItem().text == tr ("Keep labels on screen") && v.getItem().isTicked);
  390. check ("Playlist menu › View › Content › Keep labels on screen, ticked", hasKeep);
  391. saveMenus ({ tr ("View") }, { *it.getItem().subMenu }, prefix + "-view-menu.png");
  392. }
  393. }
  394. text << "shots: " << prefix << "-keep-labels-on / -off (+ -zoom), first bar " << firstBar << ", " << perBar << " px a bar\n";
  395. }
  396. keeplabels::on = keepBefore;
  397. ui::motion::enabled() = motionBefore;
  398. layoutstyle::setCurrent (layoutBefore);
  399. text << "result=" << (allOk ? "OK" : "FAIL") << "\n";
  400. if (reportPath.isNotEmpty())
  401. juce::File (reportPath).replaceWithText (text);
  402. if (summary != nullptr)
  403. *summary = allOk ? juce::String ("OK") : "ERROR " + firstFailure;
  404. return allOk;
  405. }