SmartTipShot190ok.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // --smarttipshot190ok <folder> [project.flp] (round 190ok, owner decision D1): the smart-disable tip off screen, at
  2. // 100 % and 150 %: the hint bar's notice (shown once) and the CPU meter's hint that keeps it. With an FL project its
  3. // own slots are counted (Exoplanet: 111 of its 113 slots in use are off); without one, 20 effects with Smart disable off
  4. // are made; the stopped load is the one round 190of measured on Exoplanet (16 % of a core). Also Settings › Audio (Safe
  5. // overloads). <folder>/checks.txt lists the checks. Included in the app class of Main.cpp.
  6. bool runSmartTipShot190ok (const juce::String& folderPath, const juce::String& project)
  7. {
  8. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  9. const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
  10. const juce::File folder (folderPath);
  11. folder.createDirectory();
  12. juce::String checks;
  13. bool allOk = true;
  14. const auto check = [&checks, &allOk] (const juce::String& what, bool ok) {
  15. checks << (ok ? "ok " : "FAIL ") << what << "\n";
  16. allOk = allOk && ok;
  17. };
  18. using namespace lynx;
  19. {
  20. AudioEngine offline (false);
  21. MainComponent ui (offline, false);
  22. ui.setSize (1920, 1080);
  23. if (project.isNotEmpty())
  24. ui.openFile (juce::File (project));
  25. else
  26. offline.editSong ([] (Song& s) {
  27. for (int t = 1; t <= 10 && t < (int) s.mixer.size(); ++t)
  28. for (const auto kind : { EffectKind::reverb, EffectKind::delay })
  29. {
  30. auto slot = makeEffectSlot (kind);
  31. slot.smartDisable = false;
  32. s.mixer[(std::size_t) t].effects.push_back (slot);
  33. }
  34. });
  35. offline.dispatchPendingMessages();
  36. const auto c = smarttip::count (offline.getSong());
  37. const double stoppedLoad = 0.161;
  38. check ("the project's slots: " + juce::String (c.off) + " of " + juce::String (c.total) + " with Smart disable off",
  39. c.total > 0 && smarttip::due (c, stoppedLoad));
  40. check ("a light stopped project gets no tip (1 % load)", ! smarttip::due (c, 0.01));
  41. auto& meter = ui.getPerfMeterForSnapshot();
  42. ui.showSmartDisableTip (c.off, c.total, false);
  43. const auto meterHint = meter.hintAt ({ meter.getWidth() / 2, meter.getHeight() / 4 }); // (the CPU half)
  44. check ("the CPU meter's hint starts with the tip", meterHint.text.startsWith (ui.smartDisableNoticeText (c.off, c.total)));
  45. const auto toolbar = ui.getToolbarBoundsForSnapshot();
  46. const auto save = [&ui, &folder, toolbar] (const juce::String& name) {
  47. for (const auto scale : { 1.0f, 1.5f })
  48. savePng (ui.createComponentSnapshot (toolbar, true, scale),
  49. folder.getChildFile (name + (scale > 1.0f ? "@150.png" : ".png")).getFullPathName());
  50. };
  51. const auto notice = ui.smartDisableNoticeText (c.off, c.total);
  52. check ("the notice names FL's macro", notice.contains ("Switch smart disable for all plugins") || notice.contains (tr ("Switch smart disable for all plugins")));
  53. ui.setHintForSnapshot ({ notice }); // the notice the hint bar shows once
  54. save ("smart-tip-notice");
  55. ui.setHintForSnapshot (meterHint); // the CPU meter's hint (the mouse over it)
  56. save ("smart-tip-cpu-hint");
  57. // FL's extended hint panel (View): the CPU meter's whole hint, the tip in full
  58. ui.showExtendedHintForSnapshot (true);
  59. if (auto* panel = ui.extendedHintForSnapshot())
  60. {
  61. if (auto* e = dynamic_cast<ui::ExtendedHintPanel*> (panel))
  62. e->setHint (meterHint, false);
  63. for (const auto scale : { 1.0f, 1.5f })
  64. savePng (panel->createComponentSnapshot (panel->getLocalBounds(), true, scale),
  65. folder.getChildFile (scale > 1.0f ? "smart-tip-extended@150.png" : "smart-tip-extended.png").getFullPathName());
  66. }
  67. ui.showExtendedHintForSnapshot (false);
  68. // Tools › Macros › "Switch smart disable for all plugins" takes the tip away and switches every slot on
  69. ui.switchSmartDisableForAllForSnapshot();
  70. offline.dispatchPendingMessages();
  71. const auto after = smarttip::count (offline.getSong());
  72. check ("after the macro: 0 slots off, no tip", after.off == 0 && meter.smartDisableTip().isEmpty());
  73. }
  74. {
  75. // Settings › Audio with the round's two options: "Safe overloads" under "Auto close" (FL's Input / output panel,
  76. // checked by default) and "Smart disable for new instrument plugins" under "Smart disable" (a LYNX extra)
  77. AudioEngine offline (false);
  78. auto page = makeSettingsPanel (offline, SettingsPage::audio);
  79. check ("the audio settings page", page != nullptr && page->getHeight() > 0);
  80. if (page != nullptr)
  81. for (const auto scale : { 1.0f, 1.5f })
  82. savePng (page->createComponentSnapshot (page->getLocalBounds(), true, scale),
  83. folder.getChildFile (scale > 1.0f ? "settings-audio@150.png" : "settings-audio.png").getFullPathName());
  84. }
  85. folder.getChildFile ("checks.txt").replaceWithText (checks);
  86. return allOk;
  87. }