WorkflowShot190iu.inc 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. // --workflowshot190iu <prefix> (round 190iu, issues #186 and #191): the wheel zones, temporary tools, MIDI files
  2. // dropped on the Playlist / the Clip-launch arrangement / the clip grid, automation clips moved into lanes, Track-only
  3. // mode and the picker's clean-up, driven through the real components offscreen; prefix-checks.txt. Included in the app
  4. // class of Main.cpp (it uses savePng / saveMenus / lookAndFeel).
  5. bool runWorkflowShot190iu (const juce::String& prefix)
  6. {
  7. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  8. juce::StringArray report;
  9. bool allOk = true;
  10. const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
  11. report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
  12. allOk = allOk && ok;
  13. };
  14. using namespace lynx;
  15. // a .mid file as drum / instrument plugins hand one over: two tracks ("Bass" and an unnamed drum track)
  16. const auto midiFile = juce::File (prefix + "-groove.mid");
  17. {
  18. juce::MidiFile file;
  19. file.setTicksPerQuarterNote (960);
  20. juce::MidiMessageSequence bass, drums;
  21. bass.addEvent (juce::MidiMessage::textMetaEvent (3, "Bass"), 0);
  22. for (int beat = 0; beat < 8; beat += 2)
  23. {
  24. bass.addEvent (juce::MidiMessage::noteOn (1, 36 + (beat % 4 == 0 ? 0 : 7), (juce::uint8) 100), beat * 960);
  25. bass.addEvent (juce::MidiMessage::noteOff (1, 36 + (beat % 4 == 0 ? 0 : 7)), beat * 960 + 1800);
  26. }
  27. for (int step = 0; step < 32; ++step)
  28. {
  29. const auto key = step % 8 == 0 ? 36 : step % 8 == 4 ? 38 : 42;
  30. drums.addEvent (juce::MidiMessage::noteOn (10, key, (juce::uint8) 90), step * 240);
  31. drums.addEvent (juce::MidiMessage::noteOff (10, key), step * 240 + 120);
  32. }
  33. bass.updateMatchedPairs();
  34. drums.updateMatchedPairs();
  35. file.addTrack (bass);
  36. file.addTrack (drums);
  37. midiFile.deleteFile();
  38. if (auto out = midiFile.createOutputStream())
  39. file.writeTo (*out, 1);
  40. }
  41. check ("midi_file_written", midiFile.existsAsFile(), midiFile.getFullPathName());
  42. ui::motion::enabled() = false; // (the wheel's glide lands at once)
  43. AudioEngine engine (false);
  44. MainComponent ui (engine, false);
  45. ui.setSize (1600, 900);
  46. {
  47. auto song = Song::makeDefault();
  48. song.playlist.clear();
  49. // Kick on track 1, a "Lead" instrument track on track 3, two takes and two recorded envelopes
  50. auto& p = song.patterns.front();
  51. p.name = "Beat";
  52. for (int step : { 0, 4, 8, 12 })
  53. p.toggleStep (0, step);
  54. Clip beat;
  55. beat.kind = ClipKind::pattern;
  56. beat.pattern = 0;
  57. beat.track = 0;
  58. beat.length = 4 * ppq;
  59. for (int bar = 0; bar < 4; ++bar)
  60. {
  61. beat.start = (std::int64_t) bar * 4 * ppq;
  62. song.playlist.push_back (beat);
  63. }
  64. song.playlistTracks.resize (10);
  65. const auto lead = trackmodes::addInstrumentTrack (song, mididrop::newChannel ("Lead"), 2);
  66. for (const char* take : { "Vocal take 1", "Vocal take 2" })
  67. {
  68. ChannelDef c;
  69. c.name = take;
  70. c.instrument = InstrumentKind::audioClip;
  71. c.samplePath = std::string ("/shots/") + take + ".wav";
  72. song.channels.push_back (c);
  73. }
  74. Clip t1;
  75. t1.kind = ClipKind::audio;
  76. t1.channel = (int) song.channels.size() - 2;
  77. t1.track = 4;
  78. t1.start = 4 * ppq;
  79. t1.length = 8 * ppq;
  80. song.playlist.push_back (t1);
  81. Automation env;
  82. env.name = "Lead - Volume";
  83. env.target = { AutomationTargetKind::channelVolume, lead, 0, 0 };
  84. env.points = { { 0, 0.2f, 0.0f }, { 4 * ppq, 0.9f, 0.0f }, { 8 * ppq, 0.4f, 0.0f } };
  85. song.automations.push_back (env);
  86. Automation spare;
  87. spare.name = "Cutoff (unused take)";
  88. spare.target = { AutomationTargetKind::channelPan, 0, 0, 0 };
  89. song.automations.push_back (spare);
  90. Clip a;
  91. a.kind = ClipKind::automation;
  92. a.automation = 0;
  93. a.track = 6;
  94. a.start = 0;
  95. a.length = 8 * ppq;
  96. song.playlist.push_back (a);
  97. engine.setSong (std::move (song));
  98. }
  99. engine.dispatchPendingMessages();
  100. ui.selectTabForSnapshot (2);
  101. engine.dispatchPendingMessages();
  102. auto& pl = ui.getPlaylistForSnapshot();
  103. pl.setSize (juce::jmax (pl.getWidth(), 1100), juce::jmax (pl.getHeight(), 640));
  104. pl.setViewForSnapshot (120.0, 1, 0);
  105. const auto& song = [&]() -> const Song& { return engine.getSong(); };
  106. const auto snap = [&] (const juce::String& name, int rows) {
  107. const auto bottom = pl.trackRowForSnapshot (juce::jmin (rows, pl.numTracksForSnapshot() - 1)).getY();
  108. savePng (shot::snapshot (pl, juce::Rectangle<int> (0, 0, juce::jmin (pl.getWidth(), 1000), juce::jmin (pl.getHeight(), bottom + 12))), prefix + name);
  109. };
  110. snap ("-start.png", 9);
  111. auto source = juce::Desktop::getInstance().getMainMouseSource();
  112. const auto now = juce::Time::getCurrentTime();
  113. const auto wheelAt = [&] (juce::Point<int> p, juce::ModifierKeys mods, float dy) {
  114. juce::MouseWheelDetails w;
  115. w.deltaX = 0.0f;
  116. w.deltaY = dy;
  117. w.isReversed = false;
  118. w.isSmooth = false;
  119. w.isInertial = false;
  120. pl.mouseWheelMove (juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &pl, &pl, now, p.toFloat(), now, 0, false), w);
  121. };
  122. const int ctrl = juce::ModifierKeys::commandModifier;
  123. const auto header = juce::Point<int> (pl.headerWidthForSnapshot() / 2, pl.trackRowForSnapshot (2).getCentreY());
  124. const auto grid = juce::Point<int> (pl.headerWidthForSnapshot() + 300, pl.trackRowForSnapshot (2).getCentreY());
  125. const auto zoomNow = [&] { return pl.xOfTickForSnapshot (16.0 * ppq) - pl.xOfTickForSnapshot (0.0); };
  126. const auto rowY = [&] { return pl.trackRowForSnapshot (3).getY(); };
  127. // ---- 1. #186 wheel zones: off = FL (plain wheel scrolls everywhere, Ctrl zooms)
  128. {
  129. const auto z0 = zoomNow();
  130. wheelAt (grid, {}, -0.5f);
  131. check ("off_plain_wheel_on_arrangement_keeps_zoom", std::abs (zoomNow() - z0) < 0.5, juce::String (z0) + " " + juce::String (zoomNow()));
  132. wheelAt (grid, ctrl, 0.5f);
  133. check ("off_ctrl_wheel_zooms", zoomNow() > z0 + 1.0, juce::String (zoomNow()));
  134. pl.setViewForSnapshot (120.0, 1, 0);
  135. }
  136. workflowextras::setExtra ("playlist.wheelZones", true);
  137. {
  138. const auto z0 = zoomNow();
  139. const auto y0 = rowY();
  140. wheelAt (grid, {}, 0.5f);
  141. const auto z1 = zoomNow();
  142. check ("on_plain_wheel_on_arrangement_zooms", z1 > z0 + 1.0 && rowY() == y0, juce::String (z0) + " -> " + juce::String (z1));
  143. snap ("-wheel-zoomed.png", 9);
  144. wheelAt (header, {}, -0.5f);
  145. const auto y1 = rowY();
  146. check ("on_plain_wheel_on_headers_scrolls", y1 < y0 && std::abs (zoomNow() - z1) < 0.5, juce::String (y0) + " -> " + juce::String (y1));
  147. wheelAt (grid, ctrl, 0.5f);
  148. check ("on_ctrl_wheel_on_arrangement_scrolls", std::abs (zoomNow() - z1) < 0.5 && rowY() >= y1, juce::String (rowY()));
  149. wheelAt (header, ctrl, 0.5f);
  150. check ("on_ctrl_wheel_on_headers_zooms", zoomNow() > z1 + 1.0, juce::String (zoomNow()));
  151. pl.setViewForSnapshot (120.0, 1, 0);
  152. }
  153. workflowextras::setExtra ("playlist.wheelZones", false);
  154. check ("wheel_zones_off_again", ! wheelzones::enabled());
  155. // ---- 2. #191.1 temporary tools: off by default (FL's keys only select)
  156. auto& hold = workflowextras::tempTools();
  157. const auto toolKey = [&] (int code, const char* action) {
  158. const auto before = pl.currentTool();
  159. pl.runKeyAction (action);
  160. hold.toolKey (temptool::Editor::playlist, code, before, pl.currentTool(), [&pl] { return pl.currentTool(); },
  161. [&pl] (EditTool t) { pl.setToolForSnapshot (t); });
  162. };
  163. pl.setToolForSnapshot (EditTool::pencil);
  164. toolKey ('C', "playlist.tool.knife");
  165. hold.releaseNow (juce::Time::getMillisecondCounter() + 2000);
  166. check ("temp_tools_off_tool_stays", pl.currentTool() == EditTool::knife);
  167. workflowextras::setExtra ("editing.tempTools", true);
  168. pl.setToolForSnapshot (EditTool::pencil);
  169. toolKey ('C', "playlist.tool.knife");
  170. check ("held_c_is_the_knife", pl.currentTool() == EditTool::knife && hold.holding());
  171. {
  172. const auto area = ui.getToolStripAreaForSnapshot (true);
  173. if (! area.isEmpty())
  174. savePng (shot::snapshot (ui, area.expanded (4)), prefix + "-temptool-held.png");
  175. }
  176. hold.releaseNow (juce::Time::getMillisecondCounter() + 2000);
  177. check ("released_back_to_pencil", pl.currentTool() == EditTool::pencil && ! hold.holding());
  178. toolKey ('C', "playlist.tool.knife");
  179. hold.releaseNow (juce::Time::getMillisecondCounter()); // (a tap)
  180. check ("tap_keeps_the_knife", pl.currentTool() == EditTool::knife);
  181. pl.setToolForSnapshot (EditTool::pencil);
  182. workflowextras::setExtra ("editing.tempTools", false);
  183. // ---- 3. #191.2 MIDI files: the Pattern layout takes them while the extra is on
  184. const juce::StringArray files { midiFile.getFullPathName() };
  185. const auto dropX = (int) pl.xOfTickForSnapshot (8.0 * ppq) + 2, dropY = pl.trackRowForSnapshot (7).getCentreY();
  186. // (on by default since 0.1.31.2, the owner's choice on #287; off, the Pattern layout refuses them as FL Studio ignores them)
  187. check ("pattern_layout_takes_mid_by_default", pl.isInterestedInFileDrag (files));
  188. workflowextras::setExtra ("playlist.midiDrop", false);
  189. check ("pattern_layout_refuses_mid_with_the_extra_off", ! pl.isInterestedInFileDrag (files));
  190. workflowextras::setExtra ("playlist.midiDrop", true);
  191. check ("pattern_layout_takes_mid_with_the_extra", pl.isInterestedInFileDrag (files));
  192. {
  193. const auto patterns = song().patterns.size(), channels = song().channels.size(), clips = song().playlist.size();
  194. pl.filesDropped (files, dropX, dropY);
  195. engine.dispatchPendingMessages();
  196. const auto& last = song().playlist.back();
  197. check ("mid_drop_makes_a_pattern_clip", song().patterns.size() == patterns + 1 && song().playlist.size() == clips + 1
  198. && last.kind == ClipKind::pattern && last.track == 7 && last.start == 8 * ppq,
  199. juce::String (last.track) + " " + juce::String (last.start));
  200. check ("mid_drop_two_new_channels", song().channels.size() == channels + 2
  201. && song().channels[channels].name == "Bass",
  202. juce::String ((int) song().channels.size()));
  203. check ("mid_drop_pattern_named_after_file", song().patterns.back().name == "workflow-groove" || song().patterns.back().name.find ("groove") != std::string::npos,
  204. juce::String::fromUTF8 (song().patterns.back().name.c_str()));
  205. snap ("-mid-dropped.png", 9);
  206. // on the Lead instrument track: the notes go to its channel
  207. const auto leadTrack = 2;
  208. const auto leadChannel = song().playlistTracks[leadTrack].channel;
  209. const auto before = song().channels.size();
  210. pl.filesDropped (files, (int) pl.xOfTickForSnapshot (16.0 * ppq) + 2, pl.trackRowForSnapshot (leadTrack).getCentreY());
  211. engine.dispatchPendingMessages();
  212. const auto& p = song().patterns.back();
  213. check ("mid_drop_on_instrument_track_uses_its_channel", song().channels.size() == before && ! p.notes.empty()
  214. && std::all_of (p.notes.begin(), p.notes.end(), [leadChannel] (const Note& n) { return n.channel == leadChannel; }));
  215. engine.undo();
  216. engine.dispatchPendingMessages();
  217. check ("mid_drop_is_one_undo_step", song().channels.size() == before);
  218. }
  219. workflowextras::setExtra ("playlist.midiDrop", false);
  220. // ---- 3b. the same .mid dropped on the Channel Rack (PR #262, FL 2026 as seen in round 190qj): on a channel's row
  221. // FL's "Import MIDI data" window for that channel opens (Shift: at once, the window's last choices) and the notes go
  222. // into it; below the channels FL's full window (new channels). While dragging, FL outlines the target channel's
  223. // name button, or draws a line under the last channel for a new one.
  224. {
  225. auto& rack = ui.getRackForSnapshot();
  226. auto& ws = ui.workspaceForTest();
  227. const auto pumpUi = [&engine] {
  228. #if JUCE_LINUX || JUCE_WINDOWS
  229. for (int i = 0; i < 256 && juce::detail::dispatchNextMessageOnSystemQueue (true); ++i) {}
  230. #endif
  231. engine.dispatchPendingMessages();
  232. };
  233. const auto modals = [] { return juce::ModalComponentManager::getInstance()->getNumModalComponents(); };
  234. const auto leadChannel = song().playlistTracks[2].channel;
  235. const auto pattern = song().currentPattern;
  236. const auto noteCount = [&] (int channel) {
  237. const auto& notes = song().patterns[(std::size_t) pattern].notes;
  238. return (int) std::count_if (notes.begin(), notes.end(), [channel] (const Note& n) { return n.channel == channel; });
  239. };
  240. ui.showPanelsForSnapshot ({ workspace::Panel::channelRack });
  241. pumpUi();
  242. const auto rowCentre = rack.rowTopForSnapshot (leadChannel) + ChannelRackComponent::rowHeight / 2;
  243. const auto shotArea = juce::Rectangle<int> (0, 0, juce::jmin (rack.getWidth(), 1000), rack.getHeight());
  244. rack.fileDragEnter (files, 10, rowCentre);
  245. check ("rack_mid_drag_marks_the_channel", rack.fileDropRowForSnapshot() == leadChannel, juce::String (rack.fileDropRowForSnapshot()));
  246. savePng (shot::snapshot (rack, shotArea), prefix + "-mid-drag-over-rack.png");
  247. savePng (rack.createComponentSnapshot (shotArea, true, 1.5f), prefix + "-mid-drag-over-rack@150.png");
  248. const auto belowY = rack.rowTopForSnapshot ((int) song().channels.size() - 1) + 3 * ChannelRackComponent::rowHeight;
  249. rack.fileDragMove (files, 10, belowY);
  250. check ("rack_mid_drag_below_marks_a_new_channel", rack.fileDropRowForSnapshot() == ChannelRackComponent::newChannelDrop);
  251. savePng (shot::snapshot (rack, shotArea), prefix + "-mid-drag-below-rack.png");
  252. rack.fileDragExit (files);
  253. check ("rack_mid_drag_mark_goes_away", rack.fileDropRowForSnapshot() == ChannelRackComponent::noDrop);
  254. check ("rack_takes_mid", rack.isInterestedInFileDrag (files));
  255. const auto before = noteCount (leadChannel);
  256. const auto othersBefore = (int) song().patterns[(std::size_t) pattern].notes.size() - before;
  257. const auto panelsBefore = ws.isPanelVisible (workspace::Panel::pianoRoll);
  258. // a plain drop: FL's window first, nothing imported until Accept
  259. rack.filesDropped (files, 10, rowCentre);
  260. pumpUi();
  261. auto* window = juce::Component::getCurrentlyModalComponent();
  262. check ("rack_drop_opens_the_import_window", modals() > 0 && window != nullptr && noteCount (leadChannel) == before);
  263. if (window != nullptr)
  264. {
  265. savePng (window->createComponentSnapshot (window->getLocalBounds(), true, 1.0f), prefix + "-mid-drop-window.png");
  266. window->exitModalState (1); // (Accept)
  267. }
  268. pumpUi();
  269. // (the file's 4 bass and 32 drum notes, both tracks merged into the channel it was dropped on)
  270. check ("rack_drop_puts_the_notes_in_that_channel", noteCount (leadChannel) == 36, juce::String (noteCount (leadChannel)));
  271. check ("rack_drop_keeps_the_other_channels", (int) song().patterns[(std::size_t) pattern].notes.size() - noteCount (leadChannel) == othersBefore);
  272. check ("rack_drop_selects_the_channel", engine.getSelectedChannel() == leadChannel, juce::String (engine.getSelectedChannel()));
  273. check ("rack_drop_leaves_the_panels_as_fl", ws.isPanelVisible (workspace::Panel::pianoRoll) == panelsBefore);
  274. engine.undo();
  275. pumpUi();
  276. check ("rack_drop_is_one_undo_step", noteCount (leadChannel) == before, juce::String (noteCount (leadChannel)));
  277. // Cancel: nothing changes
  278. rack.filesDropped (files, 10, rowCentre);
  279. pumpUi();
  280. if (auto* w = juce::Component::getCurrentlyModalComponent())
  281. w->exitModalState (0);
  282. pumpUi();
  283. check ("rack_drop_cancelled_changes_nothing", noteCount (leadChannel) == before && modals() == 0);
  284. // Shift held (FL): at once, without the window
  285. rack.shiftDropForTests = true;
  286. rack.filesDropped (files, 10, rowCentre);
  287. pumpUi();
  288. rack.shiftDropForTests = false;
  289. check ("rack_shift_drop_imports_without_the_window", modals() == 0 && noteCount (leadChannel) == 36, juce::String (noteCount (leadChannel)));
  290. engine.undo();
  291. pumpUi();
  292. // below the channels: FL's full window (new channels); Cancel leaves the rack as it was
  293. const auto channels = song().channels.size();
  294. rack.filesDropped (files, 10, belowY);
  295. pumpUi();
  296. check ("rack_drop_below_opens_the_full_window", modals() > 0);
  297. if (auto* w = juce::Component::getCurrentlyModalComponent())
  298. w->exitModalState (0);
  299. pumpUi();
  300. check ("rack_drop_below_cancelled_adds_nothing", song().channels.size() == channels && modals() == 0);
  301. ui.selectTabForSnapshot (2); // (the Playlist again, as the rest of this shot expects it)
  302. pumpUi();
  303. }
  304. // ---- 3c. PR #266 (FL 2026's Save as window for a new project, round 190qj): the name is filled in as "Project_N"
  305. {
  306. auto panel = makeNewProjectPanelAsShown();
  307. panel->setSize (700, 540);
  308. std::function<juce::String (juce::Component&)> filled = [&filled] (juce::Component& c) -> juce::String {
  309. if (auto* e = dynamic_cast<juce::TextEditor*> (&c); e != nullptr && e->getText().startsWith ("Project_"))
  310. return e->getText();
  311. for (auto* child : c.getChildren())
  312. if (const auto t = filled (*child); t.isNotEmpty())
  313. return t;
  314. return {};
  315. };
  316. const auto name = filled (*panel);
  317. check ("new_project_name_is_filled_in_as_fl", name.matchesWildcard ("Project_*", false) && name.substring (8).getIntValue() >= 1, name);
  318. savePng (panel->createComponentSnapshot (panel->getLocalBounds(), true, 1.0f), prefix + "-new-project-name.png");
  319. savePng (panel->createComponentSnapshot (panel->getLocalBounds(), true, 1.5f), prefix + "-new-project-name@150.png");
  320. }
  321. // ---- 4. #191.6 the picker's takes and envelopes: the Playlist menu (the Picker panel submenu holds the clean-up)
  322. {
  323. const auto menu = ui.getPanelMenuForSnapshot (workspace::Panel::playlist);
  324. saveMenus (juce::StringArray { "Playlist" }, std::vector<juce::PopupMenu> { menu }, prefix + "-playlist-menu.png");
  325. const juce::PopupMenu* pickerMenu = nullptr;
  326. juce::StringArray texts;
  327. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  328. {
  329. texts.add (it.getItem().text);
  330. if (it.getItem().text == tr ("Picker panel"))
  331. pickerMenu = it.getItem().subMenu.get();
  332. }
  333. check ("menu_has_the_switches", texts.contains (tr ("Wheel: scroll over the track headers, zoom over the arrangement"))
  334. && texts.contains (tr ("Hold a tool key for a temporary tool"))
  335. && texts.contains (tr ("MIDI files dropped on the Playlist become pattern clips")));
  336. if (pickerMenu != nullptr)
  337. saveMenus (juce::StringArray { "Picker panel" }, std::vector<juce::PopupMenu> { *pickerMenu }, prefix + "-picker-menu.png");
  338. bool purge = false, unused = false;
  339. if (pickerMenu != nullptr)
  340. for (juce::PopupMenu::MenuItemIterator it (*pickerMenu); it.next();)
  341. {
  342. purge = purge || it.getItem().text.startsWith (tr ("Purge unused audio clips"));
  343. unused = unused || it.getItem().text.startsWith (tr ("Delete unused automation clips ({0})", { "1" }));
  344. }
  345. check ("picker_menu_clean_up_items", purge && unused);
  346. const auto automations = song().automations.size(), channels = song().channels.size();
  347. engine.editSong ([] (Song& s) { takecleanup::deleteUnusedAutomations (s); });
  348. engine.editSong ([] (Song& s) { pltracks::purgeUnusedAudioClips (s); });
  349. check ("unused_envelope_and_take_deleted", song().automations.size() == automations - 1 && song().channels.size() == channels - 1,
  350. juce::String ((int) song().automations.size()) + " " + juce::String ((int) song().channels.size()));
  351. }
  352. // ---- 5. #191.3 automation clips into their tracks' lanes (shown while the lanes are on)
  353. autolanes::setShown (true);
  354. pl.repaint();
  355. snap ("-lanes-before.png", 9);
  356. check ("lanes_movable_clip", laneview::movableClips (song()).size() == 1);
  357. saveMenus (juce::StringArray { "Playlist" }, std::vector<juce::PopupMenu> { ui.getPanelMenuForSnapshot (workspace::Panel::playlist) },
  358. prefix + "-playlist-menu-lanes.png");
  359. workflowextras::runAction ("playlist.clipsToLanes");
  360. engine.dispatchPendingMessages();
  361. check ("lanes_clip_moved_under_lead", song().playlistTracks[2].lanes.size() == 1
  362. && std::none_of (song().playlist.begin(), song().playlist.end(), [] (const Clip& c) { return c.kind == ClipKind::automation; }));
  363. snap ("-lanes-after.png", 9);
  364. engine.undo();
  365. engine.dispatchPendingMessages();
  366. check ("lanes_undo", song().playlistTracks[2].lanes.empty());
  367. autolanes::setShown (false);
  368. // ---- 6. #191.5 Track-only mode: the rack hidden, every new instrument on its own track
  369. ui.showDesktopForSnapshot (false);
  370. trackonly::setEnabled (true);
  371. if (workflowextras::onChanged)
  372. workflowextras::onChanged();
  373. // (issue #246, round 190oq: the rack is hidden when the mode comes on and opens again on request, as FL keeps an
  374. // instrument track's channel in its Channel rack)
  375. check ("track_only_hides_the_rack_when_it_comes_on", ! ui.workspaceForTest().isPanelVisible (workspace::Panel::channelRack));
  376. {
  377. const auto channels = song().channels.size();
  378. engine.editSong ([] (Song& s) { s.channels.push_back (mididrop::newChannel ("Strings")); });
  379. engine.dispatchPendingMessages();
  380. check ("track_only_new_instrument_gets_a_track", ! trackmodes::instrumentTracksOf (song(), (int) channels).empty());
  381. }
  382. savePng (shot::snapshot (ui, ui.getLocalBounds()), prefix + "-track-only.png");
  383. trackonly::setEnabled (false);
  384. // ---- 7. the Clip-launch layout: MIDI files on its arrangement and its grid (Live: always)
  385. ui.setLayoutStyle (layoutstyle::Style::clipLaunch, false);
  386. engine.dispatchPendingMessages();
  387. check ("clip_launch_takes_mid", pl.isInterestedInFileDrag (files));
  388. {
  389. const auto free = trackmodes::firstFreeTrack (song());
  390. pl.filesDropped (files, (int) pl.xOfTickForSnapshot (0.0) + 2, pl.trackRowForSnapshot (free).getCentreY());
  391. engine.dispatchPendingMessages();
  392. check ("clip_launch_arrangement_drop_makes_instrument_tracks",
  393. free >= 0 && free < (int) song().playlistTracks.size() && song().playlistTracks[(std::size_t) free].mode == PlaylistTrackMode::instrument,
  394. juce::String (free));
  395. if (auto* gridView = ui.getClipGridForSnapshot())
  396. {
  397. if (auto* target = dynamic_cast<juce::FileDragAndDropTarget*> (gridView))
  398. check ("grid_takes_mid", target->isInterestedInFileDrag (files));
  399. const auto ok = workflowextras::dropMidiOnSlot (engine, files, free, 1);
  400. engine.dispatchPendingMessages();
  401. check ("grid_slot_drop", ok && song().clipGrid.has_value() && launcher::clipAt (*song().clipGrid, free, 1) != nullptr);
  402. gridView->setSize (juce::jmax (gridView->getWidth(), 900), juce::jmax (gridView->getHeight(), 420));
  403. savePng (shot::snapshot (*gridView, gridView->getLocalBounds()), prefix + "-grid-mid.png");
  404. }
  405. snap ("-cliplaunch-mid.png", 9);
  406. }
  407. ui.setLayoutStyle (layoutstyle::Style::pattern, false);
  408. // ---- 7b. FL's Playlist: with a track selected, the other tracks step back (a dark veil over their rows)
  409. {
  410. const auto bar = song().barTicks();
  411. pl.setViewForSnapshot (60.0, 1, 0);
  412. engine.dispatchPendingMessages();
  413. int selected = -1, other = -1;
  414. for (int t = 0; t < pl.numTracksForSnapshot(); ++t)
  415. {
  416. const auto row = pl.trackRowForSnapshot (t);
  417. if (row.getHeight() < 8 || row.getBottom() > pl.getHeight())
  418. continue;
  419. const auto empty = std::none_of (song().playlist.begin(), song().playlist.end(), [t] (const Clip& c) { return c.track == t; })
  420. && (t >= (int) song().playlistTracks.size() || song().playlistTracks[(std::size_t) t].lanes.empty());
  421. if (! empty)
  422. continue;
  423. if (selected < 0)
  424. selected = t;
  425. else if ((t % 2) == (selected % 2)) // (the lanes alternate by row: same shade before the veil)
  426. {
  427. other = t;
  428. break;
  429. }
  430. }
  431. check ("playlist_dim_has_two_empty_tracks", selected >= 0 && other >= 0, juce::String (selected) + " " + juce::String (other));
  432. if (selected >= 0 && other >= 0)
  433. {
  434. pl.selectTrack (selected);
  435. engine.dispatchPendingMessages();
  436. const auto x = juce::jlimit (0, pl.getWidth() - 1, (int) pl.xOfTickForSnapshot (5.0 * bar) + 8);
  437. const auto brightness = [&] (const juce::Image& image, int t) { return image.getPixelAt (x, pl.trackRowForSnapshot (t).getCentreY()).getBrightness(); };
  438. // the LYNX extra (Playlist › View › Dim unselected tracks; off by default since round 190ro): the others step back
  439. PlaylistComponent::dimUnselectedTracks = true;
  440. pl.repaint();
  441. {
  442. const auto image = shot::snapshot (pl);
  443. const auto lit = brightness (image, selected), dark = brightness (image, other);
  444. check ("playlist_selected_track_leaves_the_others_darker", lit > dark + 0.005f, juce::String (lit, 4) + " / " + juce::String (dark, 4));
  445. savePng (image, prefix + "-playlist-selected-track.png");
  446. savePng (pl.createComponentSnapshot (pl.getLocalBounds(), true, 1.5f), prefix + "-playlist-selected-track@150.png");
  447. }
  448. // switched off: FL-exact (FL 2026 marks a selected track in its header only)
  449. PlaylistComponent::dimUnselectedTracks = false;
  450. pl.repaint();
  451. {
  452. const auto image = shot::snapshot (pl);
  453. check ("playlist_selection_dims_nothing_when_off_as_fl", std::abs (brightness (image, selected) - brightness (image, other)) < 0.002f,
  454. juce::String (brightness (image, selected), 4) + " / " + juce::String (brightness (image, other), 4));
  455. savePng (image, prefix + "-playlist-selected-track-fl.png");
  456. }
  457. PlaylistComponent::dimUnselectedTracks = false; // (its default since round 190ro)
  458. }
  459. }
  460. // ---- 7c. PR #268 (a LYNX extra since round 190qm, on by default): a track switched off (its LED dark) goes dark as a
  461. // whole; the others stay light
  462. {
  463. const auto bar = song().barTicks();
  464. pl.setViewForSnapshot (60.0, 1, 0);
  465. engine.dispatchPendingMessages();
  466. int muted = -1, other = -1;
  467. for (int t = 0; t < (int) song().playlistTracks.size() && t < pl.numTracksForSnapshot(); ++t)
  468. {
  469. const auto row = pl.trackRowForSnapshot (t);
  470. if (row.getHeight() < 8 || row.getBottom() > pl.getHeight())
  471. continue;
  472. const auto empty = std::none_of (song().playlist.begin(), song().playlist.end(), [t] (const Clip& c) { return c.track == t; })
  473. && song().playlistTracks[(std::size_t) t].lanes.empty();
  474. if (! empty)
  475. continue;
  476. if (muted < 0)
  477. muted = t;
  478. else if ((t % 2) == (muted % 2)) // (the lanes alternate by row: same shade before the veil)
  479. {
  480. other = t;
  481. break;
  482. }
  483. }
  484. check ("playlist_mute_has_two_empty_tracks", muted >= 0 && other >= 0, juce::String (muted) + " " + juce::String (other));
  485. if (muted >= 0 && other >= 0)
  486. {
  487. const auto before = shot::snapshot (pl);
  488. engine.editSong ([muted] (Song& s) { s.playlistTracks[(std::size_t) muted].muted = true; });
  489. engine.dispatchPendingMessages();
  490. const auto image = shot::snapshot (pl);
  491. const auto x = juce::jlimit (0, image.getWidth() - 1, (int) pl.xOfTickForSnapshot (5.0 * bar) + 8);
  492. const auto lit = before.getPixelAt (x, pl.trackRowForSnapshot (muted).getCentreY()).getBrightness();
  493. const auto dark = image.getPixelAt (x, pl.trackRowForSnapshot (muted).getCentreY()).getBrightness();
  494. const auto otherBefore = before.getPixelAt (x, pl.trackRowForSnapshot (other).getCentreY()).getBrightness();
  495. const auto otherAfter = image.getPixelAt (x, pl.trackRowForSnapshot (other).getCentreY()).getBrightness();
  496. check ("playlist_muted_track_goes_dark", dark < lit * 0.75f, juce::String (lit, 4) + " -> " + juce::String (dark, 4));
  497. check ("playlist_track_left_on_stays_light", std::abs (otherBefore - otherAfter) < 0.004f,
  498. juce::String (otherBefore, 4) + " -> " + juce::String (otherAfter, 4));
  499. savePng (image, prefix + "-playlist-muted-track.png");
  500. // round 190qm: the row veil is a LYNX extra (FL 2026 leaves a switched-off track's lane as it is: Thief,
  501. // shots/fl/fl3-*); switched off, the empty lane is as before the mute (FL-exact)
  502. PlaylistComponent::darkenMutedTracks = false;
  503. pl.repaint();
  504. {
  505. const auto fl = shot::snapshot (pl);
  506. const auto lane = fl.getPixelAt (x, pl.trackRowForSnapshot (muted).getCentreY()).getBrightness();
  507. check ("playlist_muted_track_lane_unchanged_without_the_extra_as_fl", std::abs (lane - lit) < 0.004f,
  508. juce::String (lit, 4) + " -> " + juce::String (lane, 4));
  509. savePng (fl, prefix + "-playlist-muted-track-fl.png");
  510. }
  511. PlaylistComponent::darkenMutedTracks = true;
  512. pl.repaint();
  513. engine.undo(); // (leaves the song as it was)
  514. engine.dispatchPendingMessages();
  515. }
  516. }
  517. // ---- 7d. round 190qm (PR #268, FL 2026 checked on Thief): a switched-off track's clips are drawn as muted clips
  518. // (the veil, the X in the glyph's place), with or without the LYNX row veil
  519. {
  520. const auto saved = PlaylistComponent::darkenMutedTracks;
  521. PlaylistComponent::darkenMutedTracks = false; // (only the FL part: the clip's own veil)
  522. pl.repaint();
  523. int track = -1;
  524. juce::Point<int> at;
  525. for (const auto& c : song().playlist)
  526. {
  527. if (c.muted || c.track < 0 || c.kind != ClipKind::pattern || song().isTrackMuted (c.track))
  528. continue;
  529. const auto row = pl.trackRowForSnapshot (c.track);
  530. const auto x = (int) pl.xOfTickForSnapshot ((double) c.start + (double) c.length * 0.5);
  531. if (row.getHeight() >= 12 && row.getY() >= 0 && row.getBottom() <= pl.getHeight() && x > 0 && x < pl.getWidth() - 1
  532. && (int) (pl.xOfTickForSnapshot ((double) c.end()) - pl.xOfTickForSnapshot ((double) c.start)) >= 24)
  533. {
  534. track = c.track;
  535. at = { x, row.getY() + row.getHeight() * 2 / 3 };
  536. break;
  537. }
  538. }
  539. check ("playlist_has_a_pattern_clip_in_view", track >= 0, juce::String (track));
  540. if (track >= 0)
  541. {
  542. const auto before = shot::snapshot (pl);
  543. engine.editSong ([track] (Song& s) { s.playlistTracks[(std::size_t) track].muted = true; });
  544. engine.dispatchPendingMessages();
  545. pl.repaint();
  546. const auto after = shot::snapshot (pl);
  547. const auto b = before.getPixelAt (at.x, at.y), a = after.getPixelAt (at.x, at.y);
  548. // the veil (bg1 at 55 %) takes the clip's colour away, as FL greys the clips of a track switched off
  549. check ("playlist_switched_off_track_greys_its_clips_as_fl", std::abs (b.getSaturation() - a.getSaturation()) > 0.05f
  550. || std::abs (b.getBrightness() - a.getBrightness()) > 0.05f,
  551. b.toDisplayString (false) + " -> " + a.toDisplayString (false));
  552. savePng (after, prefix + "-playlist-muted-track-clips.png");
  553. engine.undo();
  554. engine.dispatchPendingMessages();
  555. }
  556. PlaylistComponent::darkenMutedTracks = saved;
  557. pl.repaint();
  558. }
  559. // ---- 8. Settings › LYNX extras with the new switches
  560. {
  561. auto page = makeSettingsPanel (engine, SettingsPage::extras);
  562. page->setSize (juce::jmax (page->getWidth(), 760), 1600);
  563. juce::Component frame;
  564. frame.setSize (page->getWidth(), page->getHeight());
  565. frame.setOpaque (true);
  566. frame.addAndMakeVisible (*page);
  567. savePng (shot::paint (frame, theme::panel), prefix + "-settings-extras.png");
  568. }
  569. // ---- 9. FL's Playlist: bars in groups of 4, every other group a shade apart (with the lanes' row shades)
  570. {
  571. const auto bar = song().barTicks();
  572. engine.editSong ([bar] (Song& s) { // a clip far out: the end-of-song veil starts past the bars compared
  573. Clip far;
  574. far.kind = ClipKind::pattern;
  575. far.pattern = 0;
  576. far.track = 0;
  577. far.start = 40 * 4 * bar;
  578. far.length = 4 * bar;
  579. s.playlist.push_back (far);
  580. });
  581. pl.setViewForSnapshot (60.0, 1, 0); // (60 px a bar: bars 1 to 8 fit the view)
  582. engine.dispatchPendingMessages();
  583. const auto image = shot::snapshot (pl);
  584. int track = -1; // (an empty lane: its own shade, no clips)
  585. for (int t = 0; t < pl.numTracksForSnapshot(); ++t)
  586. {
  587. const auto row = pl.trackRowForSnapshot (t);
  588. if (row.getCentreY() >= image.getHeight() - 4 || row.getHeight() < 8)
  589. continue;
  590. const auto empty = std::none_of (song().playlist.begin(), song().playlist.end(), [t] (const Clip& c) { return c.track == t; })
  591. && (t >= (int) song().playlistTracks.size() || song().playlistTracks[(std::size_t) t].lanes.empty());
  592. if (empty)
  593. {
  594. track = t;
  595. break;
  596. }
  597. }
  598. check ("playlist_four_bar_shading_finds_an_empty_lane", track >= 0, juce::String (track));
  599. if (track >= 0)
  600. {
  601. const auto y = pl.trackRowForSnapshot (track).getCentreY();
  602. const auto at = [&] (double bars) { return juce::jlimit (0, image.getWidth() - 1, (int) std::lround (pl.xOfTickForSnapshot (bars * bar) + 8.0)); };
  603. const auto first = image.getPixelAt (at (1.4), y).getBrightness(); // bars 1-4 (the untinted group)
  604. const auto second = image.getPixelAt (at (5.4), y).getBrightness(); // bars 5-8 (the tinted one)
  605. check ("playlist_four_bar_groups_are_a_shade_apart", std::abs (first - second) > 0.003f,
  606. juce::String (first, 4) + " / " + juce::String (second, 4));
  607. }
  608. savePng (image, prefix + "-playlist-four-bar-groups.png");
  609. engine.undo();
  610. engine.dispatchPendingMessages();
  611. }
  612. midiFile.deleteFile();
  613. juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
  614. return allOk;
  615. }