BrowserShot190iz.inc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // --browsershot190iz <folder> (round 190iz): the Browser drawn offscreen for the reference | LYNX
  2. // pairs — FL's six icon tabs (each one selected), the Current project tree with FL's guides, the hover star, the
  3. // tags (the TAGS panel with picked tags and its filtered list, the row menu's Tags section), the preview strip with
  4. // a part played from the middle, and the Clip-launch layout's Live-style browser (Samples, Instruments,
  5. // Collections, the tag chips). <folder>/checks.txt lists what was checked. Included in the app class of Main.cpp.
  6. bool runBrowserShot190iz (const juce::File& folder)
  7. {
  8. using namespace lynx;
  9. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  10. folder.createDirectory();
  11. juce::StringArray report;
  12. bool allOk = true;
  13. const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
  14. report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
  15. allOk = allOk && ok;
  16. };
  17. // a small sample library of the user's own (a folder the Browser lists), with drum and loop names
  18. const auto library = folder.getChildFile ("library").getChildFile ("My Samples");
  19. for (const auto* name : { "Drums/Kick Hard.wav", "Drums/Kick Soft.wav", "Drums/Snare Tight.wav", "Drums/Hat Closed.wav", "Drums/Clap Wide.wav",
  20. "Loops/Break 120.wav", "Loops/Pad Dark 90.wav", "Bass/808 Long.wav" })
  21. {
  22. const auto f = library.getChildFile (name);
  23. f.getParentDirectory().createDirectory();
  24. if (! f.existsAsFile())
  25. writeWaveDemo (f, 120.0);
  26. }
  27. PluginHost::settingsFolder().createDirectory();
  28. PluginHost::settingsFolder().getChildFile ("browser-folders.txt").replaceWithText (library.getFullPathName());
  29. BrowserComponent::readPrefs = false;
  30. AudioEngine engine (false);
  31. // tags (FL's "Add a tag": comma-separated) and a starred file
  32. auto& tags = BrowserComponent::tagStore();
  33. tags = {};
  34. const auto path = [&library] (const char* name) { return library.getChildFile (name).getFullPathName().toStdString(); };
  35. tags.add ({ path ("Drums/Kick Hard.wav"), path ("Drums/Kick Soft.wav"), path ("Bass/808 Long.wav") }, "Kick,808");
  36. tags.add ({ path ("Drums/Kick Hard.wav"), path ("Drums/Snare Tight.wav") }, "Punchy");
  37. tags.add ({ path ("Loops/Pad Dark 90.wav") }, "Dark,Pad");
  38. check ("tags_made", tags.all().size() == 5 && tags.has (path ("Drums/Kick Hard.wav"), "808"));
  39. BrowserComponent browser (engine);
  40. browser.setStarred (library.getChildFile ("Drums").getChildFile ("Snare Tight.wav"), true);
  41. auto save = [&] (juce::Component& c, const juce::String& name) {
  42. const auto image = shot::paint (c, theme::colour::bg2);
  43. const auto f = shot::file (folder.getChildFile (name));
  44. f.deleteFile();
  45. juce::PNGImageFormat png;
  46. bool ok = false;
  47. if (auto out = f.createOutputStream())
  48. ok = png.writeImageToStream (image, *out);
  49. check (name.toRawUTF8(), ok && image.getWidth() > 0);
  50. };
  51. // 1. FL layout: the six icon tabs, each selected (FL's order), 260 px wide as LYNX's default Browser panel
  52. browser.setSize (260, 700);
  53. for (const auto t : browserplaces::tabOrder)
  54. {
  55. browser.setTab ((int) t);
  56. save (browser, "fl-tab-" + juce::String (browserplaces::tabName (t)).toLowerCase() + ".png");
  57. }
  58. check ("tab_order", browserplaces::slotOf (browserplaces::Tab::starred) == 5 && browserplaces::slotOf (browserplaces::Tab::plugins) == 2);
  59. // 2. PROJECT with its sections open (FL's "Current project" first, its tree metrics) and ALL with the library open
  60. browser.showProjectForSnapshot();
  61. save (browser, "fl-project-tree.png");
  62. browser.setSize (260, 900); // (tall enough for the library's rows under the places)
  63. browser.setTab (BrowserComponent::allTab);
  64. browser.locateFile (library.getChildFile ("Drums").getChildFile ("Kick Hard.wav"));
  65. browser.hoverRowForSnapshot ("Kick Soft");
  66. save (browser, "fl-all-hover-star.png");
  67. browser.setSize (260, 700);
  68. // 3. tags: the TAGS panel with Kick picked (Any), then Kick + Punchy with All; the row menu's Tags section
  69. browser.setTagsPanelShown (true);
  70. browser.setPickedTags ({ "Kick" });
  71. check ("tag_filter_any", browser.pickedTags().size() == 1);
  72. save (browser, "fl-tags-any.png");
  73. browser.setTagMatch (browsertags::Match::all);
  74. browser.setPickedTags ({ "Kick", "Punchy" });
  75. save (browser, "fl-tags-all.png");
  76. check ("tag_filter_all_one_item", tags.filter ({ "Kick", "Punchy" }, browsertags::Match::all).size() == 1);
  77. saveMenus ({ "Kick Hard.wav" }, { browser.buildFileMenu (library.getChildFile ("Drums").getChildFile ("Kick Hard.wav")) },
  78. folder.getChildFile ("fl-file-menu-tags.png").getFullPathName());
  79. browser.setPickedTags ({});
  80. browser.setTagsPanelShown (false);
  81. // 4. the preview strip: a part played from 40 % (FL's Shift+Click / Live's click in the waveform)
  82. browser.showPreviewPlayedForSnapshot (library.getChildFile ("Loops").getChildFile ("Break 120.wav"), 0.4);
  83. juce::Thread::sleep (400);
  84. save (browser, "fl-preview-from-middle.png");
  85. // 5. the Clip-launch layout: Live's sidebar and list (330 px wide as Live's browser in the reference shot)
  86. browser.setSize (330, 740);
  87. browser.setLiveLayout (true);
  88. check ("live_layout", browser.isLiveLayout());
  89. auto entry = [] (browserplaces::Category c) {
  90. browserplaces::Entry e;
  91. e.category = c;
  92. return e;
  93. };
  94. browser.showLiveEntry (entry (browserplaces::Category::samples));
  95. save (browser, "live-samples.png");
  96. browser.showLiveEntry (entry (browserplaces::Category::instruments));
  97. save (browser, "live-instruments.png");
  98. browser.showLiveEntry (entry (browserplaces::Category::audioEffects));
  99. save (browser, "live-audio-effects.png");
  100. browserplaces::Entry favourites;
  101. favourites.group = browserplaces::Group::collections;
  102. favourites.category = browserplaces::Category::collection;
  103. favourites.collection = 0;
  104. browser.showLiveEntry (favourites);
  105. save (browser, "live-favorites.png");
  106. browser.showLiveEntry (entry (browserplaces::Category::samples));
  107. browser.setTagsPanelShown (true);
  108. browser.setTagMatch (browsertags::Match::any);
  109. browser.setPickedTags ({ "808" });
  110. save (browser, "live-tag-chips.png");
  111. browser.setPickedTags ({});
  112. browser.setTagsPanelShown (false);
  113. browser.setLiveLayout (false);
  114. check ("back_to_fl", ! browser.isLiveLayout());
  115. BrowserComponent::tagStore() = {};
  116. folder.getChildFile ("checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
  117. return allOk;
  118. }