| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- // Round 190te (0.1.33): #356 effects told the song position of their own audio (LYNX extra, core/LatencyTransport.h),
- // queue item 58 (a file dropped into LYNX on Linux finishes the XDND drag as accepted: JUCE fix 62), queue item 82
- // (the Playlist's Time markers › Delete, as FL's). Included in the app class of Main.cpp; --round190tetest <report>
- // and --selftest "round190te".
- juce::String round190teCheck (juce::String& log)
- {
- 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;
- };
- // ---- #356: the extra's two switches, their defaults and its engine path ---------------------------------------
- {
- check ("356 off by default in the Pattern layout, on in Clip-launch and Simple",
- ! extras::defaultOn ("plugins.latencyTransport") && extras::defaultOn ("plugins.latencyTransportOther"));
- SettingsHooks hooks;
- hooks.getGeneral = [] { return GeneralOptions {}; };
- AudioEngine offline (false);
- const auto patternBefore = latencytransport::patternOn.load(), otherBefore = latencytransport::otherOn.load();
- workflowextras::setExtra ("plugins.latencyTransport", true);
- workflowextras::setExtra ("plugins.latencyTransportOther", false);
- check ("356 the page's switches reach the engine's flags",
- latencytransport::patternOn.load() && ! latencytransport::otherOn.load() && lynxExtraOn (offline, hooks, "plugins.latencyTransport")
- && ! lynxExtraOn (offline, hooks, "plugins.latencyTransportOther"));
- latencytransport::patternOn = patternBefore;
- latencytransport::otherOn = otherBefore;
- juce::String engineLog;
- const auto engine = latencyTransportSelfTest (engineLog);
- log << engineLog;
- check ("356 LYNX's play head and the JSFX host (in LYNX's process and in a process of its own)", engine == "OK", engine);
- }
- // ---- #357: Mixer track › Channel routing › Route selected channels starting from this track (Ctrl+Shift+L) ----
- // FL routes each selected Channel rack channel to its own insert in a row from the selected one, naming and
- // colouring the inserts after the channels; Ctrl+L routes them all to this one. The key with the Mixer
- // focused and with the Channel rack focused (keys sent as the system delivers them: Ctrl = the command key,
- // ⌘ on macOS), then the menu items.
- {
- using Panel = workspace::Panel;
- AudioEngine offline (false);
- auto song = Song::makeDefault();
- song.mixer = Song::defaultMixer ((int) song.channels.size() + 8);
- for (std::size_t c = 0; c < song.channels.size(); ++c)
- {
- song.channels[c].colour = 0xff102030u + (std::uint32_t) c * 0x00101010u;
- song.channels[c].mixerTrack = 0;
- }
- offline.setSong (song);
- MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- settle();
- ui.showPanelsForSnapshot ({ Panel::playlist, Panel::channelRack, Panel::mixer });
- settle();
- const auto reset = [&] {
- offline.editSong ([] (Song& s) {
- for (auto& c : s.channels)
- c.mixerTrack = 0;
- for (std::size_t t = 1; t < s.mixer.size(); ++t)
- {
- s.mixer[t].name = "Insert " + std::to_string (t);
- s.mixer[t].colour = 0;
- }
- });
- settle();
- };
- const auto describe = [&] {
- juce::String d;
- const auto& s = offline.getSong();
- for (std::size_t c = 0; c < s.channels.size(); ++c)
- d << juce::String::fromUTF8 (s.channels[c].name.c_str()) << "->" << s.channels[c].mixerTrack << " ";
- for (int t = 3; t <= 5 && t < (int) s.mixer.size(); ++t)
- d << "| " << t << " " << juce::String::fromUTF8 (s.mixer[(std::size_t) t].name.c_str()) << " " << juce::String::toHexString ((int) s.mixer[(std::size_t) t].colour);
- return d;
- };
- // channels 1 and 2 selected, insert 3 selected: 1 -> 3, 2 -> 4, the inserts named and coloured after them
- const auto routedFrom3 = [&] {
- const auto& s = offline.getSong();
- return s.channels.size() > 2 && s.channels[1].mixerTrack == 3 && s.channels[2].mixerTrack == 4 && s.channels[0].mixerTrack == 0
- && s.mixer[3].name == s.channels[1].name && s.mixer[4].name == s.channels[2].name && s.mixer[3].colour == s.channels[1].colour
- && s.mixer[4].colour == s.channels[2].colour && s.mixer[5].name == "Insert 5";
- };
- const auto allTo3 = [&] {
- const auto& s = offline.getSong();
- return s.channels.size() > 2 && s.channels[1].mixerTrack == 3 && s.channels[2].mixerTrack == 3 && s.channels[0].mixerTrack == 0;
- };
- const auto prepare = [&] (Panel focused) {
- reset();
- offline.setChannelSelection ({ 1, 2 }, 1);
- ui.selectMixerTrackForSnapshot (3);
- ui.workspaceForTest().activate (focused);
- settle();
- };
- const auto press = [&] (bool shift) {
- ui.keyPressed (juce::KeyPress ('L', juce::ModifierKeys (juce::ModifierKeys::commandModifier | (shift ? juce::ModifierKeys::shiftModifier : 0)), 0));
- settle();
- };
- prepare (Panel::mixer);
- press (true);
- check ("357 Ctrl+Shift+L (Mixer focused): each selected channel to its own insert from the selected one, named and coloured after it",
- routedFrom3(), describe());
- offline.undo();
- settle();
- check ("357 ... one undo step puts it back", offline.getSong().channels[1].mixerTrack == 0 && offline.getSong().mixer[3].name == "Insert 3", describe());
- prepare (Panel::channelRack);
- press (true);
- // (FL 2026, live check 190te: with the Channel rack focused the key routes nothing; FL's plain L, Pattern / Song,
- // takes it there, which LYNX doesn't copy)
- check ("357 Ctrl+Shift+L with the Channel rack focused routes nothing, as in FL", ! routedFrom3() && offline.getSong().channels[1].mixerTrack == 0, describe());
- prepare (Panel::mixer);
- press (false);
- check ("357 Ctrl+L (Mixer focused): all selected channels to the selected insert", allTo3(), describe());
- // the menu: Mixer track › Channel routing has both items, in FL's order; each runs
- prepare (Panel::mixer);
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- auto menu = strips.buildMenu (3);
- juce::PopupMenu* routing = nullptr;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().text == tr ("Channel routing"))
- routing = it.getItem().subMenu.get();
- juce::StringArray items;
- const juce::PopupMenu::Item* from = nullptr;
- if (routing != nullptr)
- for (juce::PopupMenu::MenuItemIterator it (*routing); it.next();)
- {
- items.add (it.getItem().text.upToFirstOccurrenceOf ("\t", false, false));
- if (it.getItem().text.startsWith (tr ("Route selected channels starting from this track")))
- from = &it.getItem();
- }
- check ("357 Mixer track > Channel routing: Route selected channels to this track, then ... starting from this track",
- items.indexOf (tr ("Route selected channels to this track")) == 0 && items.indexOf (tr ("Route selected channels starting from this track")) == 1,
- items.joinIntoString (" | "));
- if (from != nullptr && from->isEnabled && from->action != nullptr)
- from->action();
- settle();
- check ("357 ... and the menu item routes them", routedFrom3(), describe());
- // FL greys "starting from this track" with one channel selected (live check 190te), and its key does nothing then
- reset();
- offline.setChannelSelection ({ 2 }, 2);
- settle();
- menu = strips.buildMenu (3);
- bool greyed = false;
- for (juce::PopupMenu::MenuItemIterator it (menu, true); it.next();)
- if (it.getItem().text.startsWith (tr ("Route selected channels starting from this track")))
- greyed = ! it.getItem().isEnabled;
- ui.selectMixerTrackForSnapshot (3);
- ui.workspaceForTest().activate (Panel::mixer);
- settle();
- press (true);
- check ("357 one channel selected: the item is greyed and Ctrl+Shift+L changes nothing, as in FL",
- greyed && offline.getSong().channels[2].mixerTrack == 0 && offline.getSong().mixer[3].name == "Insert 3", describe());
- #if JUCE_LINUX || JUCE_WINDOWS
- // the way the system delivers them: a click on insert 3's header in a window, then the key to the focused
- // component's window (as --keyroute190sjtest), with the Channel rack's own key map in front of it
- if (juce::Desktop::getInstance().getDisplays().getPrimaryDisplay() != nullptr)
- {
- reset();
- offline.setChannelSelection ({ 1, 2 }, 1);
- juce::DocumentWindow window ("round190te #357", juce::Colours::black, 0);
- window.setUsingNativeTitleBar (true);
- window.setContentNonOwned (&ui, true);
- window.setVisible (true);
- ui.workspaceForTest().activate (Panel::channelRack);
- ui.grabKeyboardFocus(); // (as the app's main window gives it at start)
- for (int k = 0; k < 20; ++k)
- settle();
- // (the peer the Mixer is in: on Windows each panel has a native window of its own inside the main one)
- auto* peer = strips.getPeer() != nullptr ? strips.getPeer() : window.getPeer();
- if (peer != nullptr && strips.isShowing())
- {
- const auto at = peer->getComponent().getLocalPoint (&strips, strips.headerAreaForSnapshot (3).getCentre().toFloat());
- const auto now = juce::Time::currentTimeMillis();
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), 1.0f, 0.0f, now);
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, {}, 1.0f, 0.0f, now + 40);
- settle();
- const juce::ModifierKeys mods (juce::ModifierKeys::commandModifier | juce::ModifierKeys::shiftModifier);
- auto* focused = juce::Component::getCurrentlyFocusedComponent();
- auto* keyPeer = focused != nullptr && focused->getPeer() != nullptr ? focused->getPeer() : peer;
- juce::String arrived;
- MainComponent::keySeenForCheck = [&arrived] (const juce::KeyPress& k) { arrived << k.getTextDescription() << " "; };
- juce::ModifierKeys::currentModifiers = mods;
- keyPeer->handleKeyPress (juce::KeyPress ('L', mods, 0));
- juce::ModifierKeys::currentModifiers = {};
- MainComponent::keySeenForCheck = nullptr;
- settle();
- juce::String focusPath;
- for (auto* c = focused; c != nullptr && focusPath.length() < 200; c = c->getParentComponent())
- focusPath << (focusPath.isEmpty() ? "" : " < ") << juce::String (typeid (*c).name()).getLastCharacters (30);
- juce::String selectedChannels;
- for (auto c : offline.getSelectedChannels())
- selectedChannels << c << " ";
- log << "info 357 click test: focused " << focusPath << "; the main window got: " << (arrived.isEmpty() ? juce::String ("nothing") : arrived)
- << "; selected channels after the click: " << selectedChannels << "\n";
- check ("357 a click on insert 3 in a window, then Ctrl+Shift+L as the system sends it: the row is routed",
- routedFrom3(), describe() + " (focused panel " + juce::String ((int) ui.workspaceForTest().getFocused()) + ")");
- }
- else
- log << "info 357 the Mixer isn't showing in the window: the click test is skipped\n";
- window.setVisible (false);
- window.clearContentComponent();
- settle();
- }
- #endif
- }
- // ---- item 82: the Playlist's Time markers › Delete -----------------------------------------------------------
- {
- AudioEngine offline (false);
- offline.setSong (Song::makeDefault());
- PlaylistComponent playlist (offline);
- playlist.setSize (1200, 600);
- const auto timeMarkersItem = [&] (const juce::String& text) { // (Time markers' own item, not a marker's)
- const auto menu = playlist.rulerMenu (300, 4);
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().text == tr ("Time markers") && it.getItem().subMenu != nullptr)
- for (juce::PopupMenu::MenuItemIterator sub (*it.getItem().subMenu); sub.next();)
- if (sub.getItem().text == text && sub.getItem().action != nullptr)
- return std::optional<bool> (sub.getItem().isEnabled);
- return std::optional<bool>();
- };
- const auto state = [] (std::optional<bool> v) { return v.has_value() ? juce::String (*v ? "enabled" : "greyed") : juce::String ("missing"); };
- const auto none = timeMarkersItem (tr ("Delete")), noLoop = timeMarkersItem (tr ("Change to marker loop"));
- check ("82 with no marker and no time selection, Time markers > Delete and Change to marker loop are enabled, as in FL 2026's Playlist",
- none.has_value() && *none && noLoop.has_value() && *noLoop, state (none) + ", " + state (noLoop));
- const auto markersBefore = offline.getSong().markers().size();
- juce::PopupMenu menu = playlist.rulerMenu (300, 4);
- for (juce::PopupMenu::MenuItemIterator it (menu, true); it.next();)
- if ((it.getItem().text == tr ("Delete") || it.getItem().text == tr ("Change to marker loop")) && it.getItem().action != nullptr)
- it.getItem().action();
- offline.dispatchPendingMessages();
- check ("82 ... and then they change nothing", offline.getSong().markers().size() == markersBefore && ! offline.getSong().hasLoop());
- offline.editSong ([] (Song& s) { s.addMarker ({ 4 * (std::int64_t) ppq, "Verse" }); });
- offline.dispatchPendingMessages();
- const auto one = timeMarkersItem (tr ("Delete"));
- check ("82 ... Delete with a marker", one.has_value() && *one);
- }
- #if JUCE_LINUX
- // ---- item 58: a file dropped into LYNX finishes the drag as accepted, action copy (JUCE fix 62) --------------
- // GTK-, Qt- and XWayland-style sources (ui/XdndTestSourceX11, round 190sk / 190sq) drag a file onto a JUCE
- // component that takes files, then onto one that refuses them
- if (juce::Desktop::getInstance().getDisplays().getPrimaryDisplay() != nullptr && std::getenv ("LYNX_SKIP_XDND190TE") == nullptr)
- {
- 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 root = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190te-" + juce::String (juce::Random::getSystemRandom().nextInt (1 << 30)));
- const auto wav = root.getChildFile ("drop/loop 58.wav");
- wav.getParentDirectory().createDirectory();
- wav.replaceWithText ("RIFF");
- const auto uri = juce::URL (wav).toString (false).toStdString();
- struct Target final : juce::Component, juce::FileDragAndDropTarget
- {
- explicit Target (bool t) : takes (t) {}
- const bool takes;
- int drops = 0;
- juce::StringArray files;
- bool isInterestedInFileDrag (const juce::StringArray&) override { return takes; }
- void filesDropped (const juce::StringArray& f, int, int) override
- {
- ++drops;
- files = f;
- }
- void paint (juce::Graphics& g) override { g.fillAll (juce::Colour (takes ? 0xff303038 : 0xff383030)); }
- };
- struct Host final : juce::Component
- {
- Target taking { true }, refusing { false };
- Host()
- {
- addAndMakeVisible (taking);
- addAndMakeVisible (refusing);
- }
- void resized() override
- {
- taking.setBounds (0, 0, getWidth() / 2, getHeight());
- refusing.setBounds (getWidth() / 2, 0, getWidth() / 2, getHeight());
- }
- } host;
- host.setSize (800, 300);
- juce::DocumentWindow window ("round190te item 58", juce::Colours::black, 0);
- window.setUsingNativeTitleBar (true);
- window.setContentNonOwned (&host, true);
- window.setTopLeftPosition (80, 80);
- window.setVisible (true);
- settle (400);
- auto* peer = window.getPeer();
- const auto handle = peer != nullptr ? (unsigned long) (juce::pointer_sized_uint) peer->getNativeHandle() : 0ul;
- const auto physical = [] (juce::Point<int> g) { return juce::Desktop::getInstance().getDisplays().logicalToPhysical (g); };
- // the XdndActionCopy atom (atoms are the server's: any connection gives the same number)
- unsigned long copyAtom = 0;
- if (auto* x11 = dlopen ("libX11.so.6", RTLD_NOW))
- {
- auto open = (void* (*) (const char*)) dlsym (x11, "XOpenDisplay");
- auto close = (int (*) (void*)) dlsym (x11, "XCloseDisplay");
- auto intern = (unsigned long (*) (void*, const char*, int)) dlsym (x11, "XInternAtom");
- if (auto* d = open != nullptr && close != nullptr && intern != nullptr ? open (nullptr) : nullptr)
- {
- copyAtom = intern (d, "XdndActionCopy", 0);
- close (d);
- }
- }
- check ("58 the test window and the XdndActionCopy atom", handle != 0 && copyAtom != 0);
- const auto path = [&] (juce::Component& over) {
- std::vector<xdndtest::Step> steps;
- const auto a = physical (over.localPointToGlobal (juce::Point<int> (20, 20)));
- const auto b = physical (over.localPointToGlobal (over.getLocalBounds().getCentre()));
- for (int i = 0; i <= 12; ++i)
- steps.push_back ({ a.x + (b.x - a.x) * i / 12, a.y + (b.y - a.y) * i / 12, i == 0 || i == 12 ? 300 : 16 });
- return steps;
- };
- const auto runDrag = [&] (const std::vector<xdndtest::Step>& steps, xdndtest::Style style) {
- std::atomic<bool> done { false };
- xdndtest::PathResult r;
- std::thread source ([&] {
- r = xdndtest::runPath (handle, steps, uri, style, style == xdndtest::Style::gtk || style == xdndtest::Style::qt ? 0 : 20, true);
- done = true;
- });
- const auto end = juce::Time::getMillisecondCounter() + 20000u;
- while (! done.load() && juce::Time::getMillisecondCounter() < end)
- settle (4);
- source.join();
- settle (200);
- return r;
- };
- const auto describe = [] (const xdndtest::PathResult& r) {
- return "statuses " + juce::String (r.statusesFromTarget) + " (accepted " + juce::String (r.acceptedFromTarget) + "), finished "
- + juce::String (r.finishedFromTarget) + ": flags " + juce::String (r.finishedFlags) + ", action " + juce::String ((juce::int64) r.finishedAction)
- + (r.error.empty() ? juce::String() : ", " + juce::String (r.error));
- };
- if (handle != 0 && copyAtom != 0)
- for (const auto& [name, style] : { std::pair { "GTK file manager", xdndtest::Style::gtk }, std::pair { "Qt file manager", xdndtest::Style::qt },
- std::pair { "Wayland file manager (XWayland)", xdndtest::Style::xwayland } })
- {
- host.taking.drops = host.refusing.drops = 0;
- auto r = runDrag (path (host.taking), style);
- check (juce::String ("58 ") + name + ": a drop LYNX takes finishes as accepted, action copy",
- r.ran && host.taking.drops == 1 && host.taking.files.size() == 1 && host.taking.files[0].endsWith ("loop 58.wav")
- && r.finishedFromTarget == 1 && (r.finishedFlags & 1) == 1 && (unsigned long) r.finishedAction == copyAtom,
- describe (r));
- r = runDrag (path (host.refusing), style);
- check (juce::String ("58 ") + name + ": a drop nobody takes finishes as not accepted, no action",
- r.ran && host.refusing.drops == 0 && host.taking.drops == 1 && r.finishedFromTarget == 1 && (r.finishedFlags & 1) == 0
- && r.finishedAction == 0,
- describe (r));
- }
- window.setVisible (false);
- window.clearContentComponent();
- settle (100);
- root.deleteRecursively();
- }
- else
- log << "info 58 skipped: no display\n";
- #endif
- return result;
- }
|