| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- // Round 190ta (the 0.1.33 REA gap-hunt of FL Studio 2026 and Live 12; docs/analise/COVERAGE-0.1.33-TECH.md): the small
- // FL-exact gaps it fixed, through the real components, off screen. Included in the app class of Main.cpp;
- // --rea190tatest <report> and --selftest "rea190ta".
- // `shots` (optional, --rea190tatest <report> <prefix>): the changed menus as pictures, <prefix>-<name>.png (@150 with
- // LYNX_SHOT_SCALE=1.5 LYNX_SHOT_SUFFIX=@150, as the other shot routes)
- juce::String rea190taCheck (juce::String& log, const juce::String& shots = {})
- {
- using namespace lynx;
- juce::String result = "OK";
- const auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
- log << (ok ? "ok " : "FAIL ") << what << (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()) << "\n";
- if (! ok && result == "OK")
- result = "ERROR " + what;
- };
- #if JUCE_MAC
- // (as 190sk's checks: the selftest has no message pump on macOS)
- log << "skipped on macOS (the selftest has no message pump there)\n";
- return result;
- #else
- const auto settle = [] (int ms) {
- const auto end = juce::Time::getMillisecondCounter() + (juce::uint32) ms;
- while (juce::Time::getMillisecondCounter() < end)
- {
- for (int i = 0; i < 256 && juce::detail::dispatchNextMessageOnSystemQueue (true); ++i) {}
- juce::Thread::sleep (2);
- }
- };
- const auto closeModals = [&settle] {
- for (int k = 0; k < 20; ++k)
- if (auto* modal = juce::Component::getCurrentlyModalComponent())
- modal->exitModalState (0);
- settle (50);
- };
- // (theme::mnemonic marks the accelerator letter with \x01, core/MenuMnemonic.h)
- const auto plain = [] (juce::String t) { return t.upToFirstOccurrenceOf ("\t", false, false).removeCharacters ("&").removeCharacters (juce::String::charToString (1)); };
- // the menu's rows in order (separators as "-", headers as "#<text>"), one level
- const auto rows = [&plain] (const juce::PopupMenu& menu) {
- juce::StringArray out;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- const auto& item = it.getItem();
- out.add (item.isSeparator ? juce::String ("-") : item.isSectionHeader ? "#" + plain (item.text) : plain (item.text));
- }
- return out;
- };
- const auto find = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu::Item* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == text)
- return &it.getItem();
- return nullptr;
- };
- const auto run = [&find, &settle] (const juce::PopupMenu& menu, const juce::String& text) {
- const auto* item = find (menu, text);
- if (item == nullptr || item->action == nullptr || ! item->isEnabled)
- return false;
- item->action();
- settle (30);
- return true;
- };
- const auto before = [] (const juce::StringArray& list, const juce::String& a, const juce::String& b) {
- const auto i = list.indexOf (a), j = list.indexOf (b);
- return i >= 0 && j >= 0 && i < j;
- };
- const auto shootMenu = [&shots] (const juce::String& name, const juce::PopupMenu& menu) {
- if (shots.isNotEmpty()) // (the PNG writer adds LYNX_SHOT_SUFFIX itself, ui/ShotScale.h)
- saveMenus (juce::StringArray { name }, std::vector<juce::PopupMenu> { menu }, shots + "-" + name + ".png");
- };
- const auto layoutBefore = layoutstyle::current();
- layoutstyle::setCurrent (layoutstyle::Style::pattern);
- const juce::ScopedValueSetter<bool> shown (ui::showingForShots(), true);
- AudioEngine offline (false);
- {
- auto song = Song::makeDefault();
- song.patterns.resize (1);
- song.currentPattern = 0;
- const auto bar = song.barTicks();
- auto& p = song.patterns[0];
- p.lengthTicks = 8 * bar;
- p.notes.clear();
- for (int k = 0; k < 4; ++k)
- {
- Note n;
- n.channel = 0;
- n.key = 60 + k;
- n.start = k * bar;
- n.length = bar / 2;
- p.notes.push_back (n);
- }
- offline.setSong (std::move (song));
- }
- offline.setSelectedChannel (0);
- MainComponent mainUi (offline, false);
- mainUi.setSize (1600, 900);
- closeModals();
- const auto bar = offline.getSong().barTicks();
- // ---- the Piano roll's Time markers: FL's "Add one every" (after Add auto) and "Delete" (FL's EEMenu order)
- {
- auto& roll = mainUi.getPianoRollForSnapshot();
- roll.setBounds (0, 0, 1200, 700);
- settle (30);
- const auto marker = roll.getPatternMarkerMenuForSnapshot (-1);
- const auto* sub = find (marker, tr ("Time markers"));
- check ("PR Time markers submenu is there", sub != nullptr && sub->subMenu != nullptr);
- if (sub != nullptr && sub->subMenu != nullptr)
- {
- const auto& markers = *sub->subMenu;
- shootMenu ("pianoroll-time-markers", markers);
- const auto list = rows (markers);
- log << " Time markers: " << list.joinIntoString (" | ") << "\n";
- check ("PR Time markers: Add auto, Add two..., Add one every, then Add time signature change... (FL's EEMenu)",
- before (list, tr ("Add auto"), tr ("Add two...")) && before (list, tr ("Add two..."), tr ("Add one every"))
- && before (list, tr ("Add one every"), tr ("Add time signature change...")));
- const auto* two = find (markers, tr ("Add two..."));
- check ("PR Add two... is greyed without a time selection (FL)", two != nullptr && ! two->isEnabled);
- check ("PR Time markers: Delete after Add key marker", before (list, tr ("Add key marker"), tr ("Delete")));
- check ("PR Time markers: LYNX's key region and Delete all markers after FL's items",
- before (list, tr ("Delete"), tr ("Key region for the time selection")) && before (list, tr ("Delete"), tr ("Delete all markers")));
- const auto* every = find (markers, tr ("Add one every"));
- check ("PR Add one every lists Bar / 2 / 4 / 8 bars",
- every != nullptr && every->subMenu != nullptr && rows (*every->subMenu).joinIntoString ("|") == tr ("Bar") + "|" + tr ("2 bars") + "|" + tr ("4 bars") + "|" + tr ("8 bars"));
- if (every != nullptr && every->subMenu != nullptr)
- {
- run (*every->subMenu, tr ("2 bars"));
- const auto& m = offline.getSong().patterns[0].markers;
- check ("PR Add one every 2 bars on an 8-bar pattern: bars 1, 3, 5, 7",
- m.size() == 4u && m[0].tick == 0 && m[3].tick == 6 * bar && m[3].name == "7", juce::String ((int) m.size()));
- }
- roll.setTimeSelectionForTests (2 * bar, 5 * bar);
- const auto again = roll.getPatternMarkerMenuForSnapshot (-1);
- if (const auto* s2 = find (again, tr ("Time markers")); s2 != nullptr && s2->subMenu != nullptr)
- {
- shootMenu ("pianoroll-time-markers-selection", *s2->subMenu);
- const auto* two = find (*s2->subMenu, tr ("Add two..."));
- check ("PR Add two... is enabled with a time selection (FL)", two != nullptr && two->isEnabled);
- }
- if (const auto* s2 = find (again, tr ("Time markers")); s2 != nullptr && s2->subMenu != nullptr)
- run (*s2->subMenu, tr ("Delete"));
- const auto& m = offline.getSong().patterns[0].markers;
- check ("PR Delete with a time selection [bar 3, bar 6): only the bar 3 and 5 markers go",
- m.size() == 2u && m[0].tick == 0 && m[1].tick == 6 * bar, juce::String ((int) m.size()));
- roll.setTimeSelectionForTests (-1, -1);
- }
- // ---- the Piano roll's Select › Select time around selection / previous time / next time (Ctrl+Enter / Left / Right)
- roll.selectAll();
- settle (30);
- {
- shootMenu ("pianoroll-select", roll.selectMenuForSnapshot());
- const auto list = rows (roll.selectMenuForSnapshot());
- check ("PR Select: Invert selection, then Select time around / previous / next time",
- before (list, tr ("Invert selection"), tr ("Select time around selection")) && before (list, tr ("Select time around selection"), tr ("Select previous time"))
- && before (list, tr ("Select previous time"), tr ("Select next time")),
- list.joinIntoString (" | "));
- }
- check ("PR Ctrl+Enter is the key map's pianoRoll.selectTimeAround",
- keys::findAction ("pianoRoll.selectTimeAround") != nullptr && keys::findAction ("pianoRoll.timeNext") != nullptr);
- roll.runAction ("pianoRoll.selectTimeAround");
- const auto span = roll.timeSelectionForTests();
- check ("PR Select time around selection: the notes' span [0, 3.5 bars)", span.first == 0 && span.second == 3 * bar + bar / 2,
- juce::String (span.first) + ".." + juce::String (span.second));
- roll.runAction ("pianoRoll.timeNext");
- const auto next = roll.timeSelectionForTests();
- check ("PR Select next time: moved by its own length", next.first == 3 * bar + bar / 2 && next.second == 7 * bar);
- roll.runAction ("pianoRoll.timePrevious");
- roll.runAction ("pianoRoll.timePrevious");
- check ("PR Select previous time stops at the pattern's start", roll.timeSelectionForTests().first == 0);
- roll.runAction ("pianoRoll.selectTimeAround");
- check ("PR the same span again clears the time selection", roll.timeSelectionForTests().first < 0);
- }
- // ---- the chord progression tool: FL's MultiSelMenu on a chord of a selection of several
- {
- ChordToolState state;
- state.strip.blocks.resize (3);
- for (auto& b : state.strip.blocks)
- b.chord.intervals = { 0, 4, 7 };
- state.selected = { 0, 1 };
- ChordStripView strip (offline, state, 0);
- strip.setBounds (0, 0, 600, 80);
- const auto multi = strip.chordMenuForSnapshot (1);
- shootMenu ("chord-multiple-selection", multi);
- const auto list = rows (multi);
- check ("chord tool: a chord of a selection of two opens FL's \"Multiple selection\" menu",
- ! list.isEmpty() && list[0] == "#" + tr ("Multiple selection") && list.contains (tr ("Unlock")), list.joinIntoString (" | "));
- if (const auto* t = find (multi, tr ("Transpose")); t != nullptr && t->subMenu != nullptr)
- run (*t->subMenu, tr ("One semitone up"));
- check ("chord tool: Transpose › One semitone up moves both selected chords, not the third",
- state.strip.blocks[0].transpose == 1 && state.strip.blocks[1].transpose == 1 && state.strip.blocks[2].transpose == 0);
- run (multi, tr ("Lock"));
- check ("chord tool: Lock locks both", state.strip.blocks[0].locked && state.strip.blocks[1].locked && ! state.strip.blocks[2].locked);
- state.selected = { 2 };
- const auto one = rows (strip.chordMenuForSnapshot (2));
- check ("chord tool: one selected chord keeps the chord menu", ! one.isEmpty() && one[0] != "#" + tr ("Multiple selection"));
- }
- // ---- the Channel rack menu (FL's SSMenu): Color selected / Mute / Unmute selected, swing mix, the mixer tracks
- {
- {
- auto s = offline.getSong();
- while (s.channels.size() < 3)
- s.channels.push_back (s.channels.front());
- s.channels[0].mixerTrack = 2;
- s.channels[1].mixerTrack = 5;
- s.channels[2].mixerTrack = 5;
- s.channels[0].group = 0;
- if (s.channelGroups.empty())
- s.channelGroups.push_back ("Drums");
- offline.setSong (std::move (s));
- settle (30);
- }
- offline.setChannelSelection ({ 0, 1 }, 0);
- settle (30);
- const auto menu = mainUi.rackMenuForSnapshot();
- shootMenu ("channel-rack-menu", menu);
- const auto list = rows (menu);
- check ("rack menu: Group selected..., Color selected, Mute selected, Unmute selected, Transpose selected... (FL's order)",
- before (list, tr ("Group selected..."), tr ("Color selected")) && before (list, tr ("Color selected"), tr ("Mute selected"))
- && before (list, tr ("Mute selected"), tr ("Unmute selected")) && before (list, tr ("Unmute selected"), tr ("Transpose selected...")),
- list.joinIntoString (" | "));
- check ("rack menu: Set swing mix for selected, then Select mixer tracks for the selected channels",
- before (list, tr ("Transpose selected..."), tr ("Set swing mix for selected"))
- && before (list, tr ("Set swing mix for selected"), tr ("Select mixer tracks for the selected channels")));
- if (const auto* colours = find (menu, tr ("Color selected")); colours != nullptr && colours->subMenu != nullptr)
- check ("rack menu: Color selected › Gradient... / Random / All...", rows (*colours->subMenu).joinIntoString ("|") == tr ("Gradient...") + "|" + tr ("Random") + "|" + tr ("All..."));
- run (menu, tr ("Mute selected"));
- const auto& c = offline.getSong().channels;
- check ("rack menu: Mute selected mutes the two selected channels only", c[0].muted && c[1].muted && ! c[2].muted);
- run (mainUi.rackMenuForSnapshot(), tr ("Unmute selected"));
- check ("rack menu: Unmute selected", ! offline.getSong().channels[0].muted && ! offline.getSong().channels[1].muted);
- const auto swingMenu = mainUi.rackMenuForSnapshot(); // (kept: the items found point into it)
- if (const auto* swing = find (swingMenu, tr ("Set swing mix for selected")); swing != nullptr && swing->subMenu != nullptr)
- {
- run (*swing->subMenu, "25%");
- check ("rack menu: Set swing mix for selected › 25%", std::abs (offline.getSong().channels[0].swingMix - 0.25f) < 1.0e-6f
- && std::abs (offline.getSong().channels[1].swingMix - 0.25f) < 1.0e-6f
- && std::abs (offline.getSong().channels[2].swingMix - 0.25f) > 0.1f);
- }
- const auto colourMenu = mainUi.rackMenuForSnapshot();
- if (const auto* colours = find (colourMenu, tr ("Color selected")); colours != nullptr && colours->subMenu != nullptr)
- {
- run (*colours->subMenu, tr ("Random"));
- check ("rack menu: Color selected › Random colours the selected channels", offline.getSong().channels[0].colour != 0 && offline.getSong().channels[1].colour != 0);
- }
- run (mainUi.rackMenuForSnapshot(), tr ("Select mixer tracks for the selected channels"));
- check ("rack menu: Select mixer tracks for the selected channels selects inserts 2 and 5",
- mainUi.getMixerForSnapshot().getStripsForSnapshot().getSelection() == std::vector<int> { 2, 5 });
- // (no "Ungroup selected..." in the channel menu: FL 2026 shows none of its group items there, live check
- // 11-30 raw/fl-channel-menu-2sel.png; the filter menu's "Move selected channels to" holds it)
- shootMenu ("channel-menu", mainUi.getRackForSnapshot().getChannelMenuForSnapshot (0));
- check ("channel menu: no Ungroup selected... (FL 2026 shows none)", ! rows (mainUi.getRackForSnapshot().getChannelMenuForSnapshot (0)).contains (tr ("Ungroup selected...")));
- }
- // ---- the Browser: FL's sample menu "Open in new ... channel" items, the options menu's Search / Navigation history /
- // Actions / Structure sections, Ctrl+Up "Collapse structure"
- {
- auto& browser = mainUi.getBrowserForSnapshot();
- const auto root = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-rea190ta-" + juce::String (juce::Random::getSystemRandom().nextInt (1 << 30)));
- root.createDirectory();
- const auto wav = root.getChildFile ("tone.wav");
- {
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (out != nullptr)
- if (std::unique_ptr<juce::AudioFormatWriter> w (format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0)); w != nullptr)
- {
- out.release();
- juce::AudioBuffer<float> b (1, 4410);
- b.clear();
- w->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
- }
- }
- shootMenu ("browser-sample-menu", browser.buildFileMenu (wav));
- const auto fileMenu = rows (browser.buildFileMenu (wav));
- check ("Browser sample menu: Open in new sampler / Fruity Granulizer / Fruity Slicer / Slicex channel, after the audio editor",
- before (fileMenu, tr ("Edit in the audio editor..."), tr ("Open in new sampler channel"))
- && before (fileMenu, tr ("Open in new sampler channel"), tr ("Open in new Fruity Granulizer channel"))
- && before (fileMenu, tr ("Open in new Fruity Slicer channel"), tr ("Open in new Slicex channel")),
- fileMenu.joinIntoString (" | "));
- const auto channelsBefore = offline.getSong().channels.size();
- run (browser.buildFileMenu (wav), tr ("Open in new Fruity Slicer channel"));
- settle (200);
- const auto& chs = offline.getSong().channels;
- check ("Browser sample menu: Open in new Fruity Slicer channel adds a Fruity Slicer channel",
- chs.size() == channelsBefore + 1 && chs.back().instrument == InstrumentKind::fruityslicer);
- closeModals();
- shootMenu ("browser-options-menu", browser.buildViewMenu());
- const auto view = rows (browser.buildViewMenu());
- check ("Browser options menu: FL's Search, Navigation history, Actions and Structure sections first",
- view.size() > 12 && view[0] == "#" + tr ("Search") && view[1] == tr ("Find previous") && view[2] == tr ("Find next")
- && view[3] == "#" + tr ("Navigation history") && view[6] == "#" + tr ("Actions") && view[9] == "#" + tr ("Structure")
- && view[10] == tr ("Collapse structure"),
- view.joinIntoString (" | "));
- {
- const auto options = browser.buildViewMenu();
- const auto* previous = find (options, tr ("Find previous"));
- check ("Browser options menu: Find previous / next greyed without a search (as FL's)", previous != nullptr && ! previous->isEnabled);
- }
- const auto* collapse = keys::findAction ("browser.collapseAll");
- check ("Browser: Ctrl+Up is the key map's browser.collapseAll (FL's \"Ctrl+Up Collapse structure\")",
- collapse != nullptr && ! collapse->defaults.empty() && collapse->defaults.front().key == keys::up && collapse->defaults.front().mods == keys::ctrl);
- root.deleteRecursively();
- }
- // ---- the time display's menu and the mixer track menu as pictures (FL 2026 live references raw/fl-time-menu.png,
- // raw/fl-mixer-track-menu.png)
- {
- const auto timeMenu = mainUi.getTimeDisplayForSnapshot().buildMenu();
- shootMenu ("time-display-menu", timeMenu);
- const auto list = rows (timeMenu);
- check ("time display menu: FL's SMPTE 120 fps last of the rates", list.contains ("SMPTE 120 fps") && list.indexOf ("SMPTE 120 fps") == list.indexOf ("SMPTE 72 fps") + 1,
- list.joinIntoString (" | "));
- shootMenu ("mixer-track-menu", mainUi.getMixerForSnapshot().getStripsForSnapshot().buildMenu (1));
- }
- // ---- the time display: FL's 13 SMPTE rates with FL's words
- check ("time display: FL's SMPTE 120 fps, appended (old indexes stay)", timecode::rateCount == 13 && timecode::menuLabel (12) == "SMPTE 120 fps" && timecode::menuLabel (5) == "SMPTE 30 fps");
- check ("time display: FL's \"SMPTE 29.97 fps (drop)\" / \"SMPTE 29.97 (non-drop)\"",
- timecode::menuLabel (3) == "SMPTE 29.97 fps (drop)" && timecode::menuLabel (4) == "SMPTE 29.97 (non-drop)" && timecode::menuLabel (9) == "SMPTE 59.94 (non-drop)");
- // ---- the tempo tapper's Apply tempo is remembered (FL 25.2.5)
- {
- const auto was = tempoTapperApplyTempo();
- tempoTapperApplyTempo() = false;
- auto tapper = makeTempoTapperForSnapshot (offline, 0, 120.0);
- juce::ToggleButton* apply = nullptr;
- for (auto* child : tapper->getChildren())
- if (auto* t = dynamic_cast<juce::ToggleButton*> (child); t != nullptr && t->getButtonText() == tr ("Apply tempo"))
- apply = t;
- check ("tempo tapper: Apply tempo opens as it was left (off)", apply != nullptr && ! apply->getToggleState());
- if (apply != nullptr)
- apply->triggerClick();
- settle (30);
- check ("tempo tapper: ticking it is remembered", tempoTapperApplyTempo());
- tempoTapperApplyTempo() = was;
- }
- // ---- the Clip-launch clip menu: Live's "Select on Launch (Pref)" last
- {
- const auto was = clipGridSelectOnLaunch();
- check ("clip grid: Select on Launch is on by default (as LYNX always selected)", was);
- clipGridSelectOnLaunch() = was;
- }
- mainUi.setVisible (false);
- closeModals();
- layoutstyle::setCurrent (layoutBefore);
- return result;
- #endif
- }
|