IssuesShot190ll.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // --issuesshot190ll <prefix> (round 190ll, issues #200, #203): the Piano roll's scale choice in the three layouts —
  2. // the FL layout's scale box and the FL menu its click opens (Root note | Scale, two columns as FL's View › Scale
  3. // highlighting), docked in the Clip-launch layout (Live's Clip View Scale: root box | scale box) and in the Simple
  4. // layout (BandLab's Smart View: key box | scale box) — and a folder dropped on the Browser (the outline while it is
  5. // dragged over, the folder in the list afterwards). <prefix>-checks.txt lists what was checked. Run with
  6. // XDG_CONFIG_HOME / APPDATA pointing to a scratch folder (the Browser's folder list is written). @150:
  7. // LYNX_SHOT_SCALE=1.5 and LYNX_SHOT_SUFFIX=@150. Included in the app class of Main.cpp (savePng / saveMenus).
  8. bool runIssuesShot190ll (const juce::String& prefix)
  9. {
  10. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  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. using namespace lynx;
  18. ui::motion::enabled() = false;
  19. // ---- #203: the Piano roll's scale choice --------------------------------------------------------------------
  20. {
  21. AudioEngine engine (false);
  22. auto song = Song::makeDefault();
  23. song.currentPattern = 0;
  24. auto& p = song.patterns.front();
  25. p.notes.clear();
  26. std::int64_t start = 0;
  27. for (const auto key : { 62, 65, 69, 67, 64, 62, 60, 62 }) // a D minor line
  28. {
  29. Note n;
  30. n.channel = 4;
  31. n.start = start;
  32. n.length = 2 * ticksPerStep;
  33. n.key = key;
  34. p.notes.push_back (n);
  35. start += 2 * ticksPerStep;
  36. }
  37. engine.setSong (std::move (song));
  38. engine.setSelectedChannel (4);
  39. engine.dispatchPendingMessages();
  40. PianoRollComponent roll (engine);
  41. roll.setBounds (0, 0, 1180, 420);
  42. roll.setVisible (true);
  43. roll.scrollToNotes (true);
  44. engine.dispatchPendingMessages();
  45. // FL layout: one box, FL's two-column menu on a click
  46. layoutstyle::setCurrent (layoutstyle::Style::pattern);
  47. roll.setScaleForSnapshot (2, 2); // D Natural minor
  48. check ("fl_one_box", ! roll.scaleBoxesSplitForTests());
  49. check ("fl_box_text", roll.scaleTextForTests() == tr ("{0} {1}", { "D", tr ("Natural minor") }), roll.scaleTextForTests());
  50. const auto menu = roll.getScaleHighlightMenuForSnapshot();
  51. juce::StringArray items;
  52. int majors = 0, breaks = 0;
  53. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  54. {
  55. const auto& item = it.getItem();
  56. items.add (item.isSeparator ? juce::String ("-") : item.text.upToFirstOccurrenceOf ("\t", false, false));
  57. majors += item.text == tr ("Major") ? 1 : 0;
  58. breaks += item.shouldBreakAfter ? 1 : 0;
  59. }
  60. const auto rootHeader = items.indexOf (tr ("Root note")), scaleHeader = items.indexOf (tr ("Scale"));
  61. check ("fl_menu_roots_then_scales", rootHeader == 0 && scaleHeader == 13, items.joinIntoString (" | "));
  62. check ("fl_menu_each_scale_once", majors == 1, juce::String (majors));
  63. check ("fl_menu_two_columns", breaks == 1);
  64. check ("fl_menu_size", items.size() < 12 + (int) notetools::scales().size() + 8, juce::String (items.size()));
  65. savePng (shot::snapshot (roll), prefix + "-203-fl-pianoroll.png");
  66. saveMenus (juce::StringArray { tr ("Scale") }, std::vector<juce::PopupMenu> { menu }, prefix + "-203-fl-scale-menu.png");
  67. // the FL menu picks: a scale keeps the root, a root keeps the scale
  68. roll.setScaleForSnapshot (2, 1);
  69. check ("fl_scale_keeps_root", roll.scaleRootForTests() == 2 && roll.scaleIndexForTests() == 1);
  70. // docked, the Clip-launch layout (Live's Clip View Scale) and the Simple layout (BandLab's Smart View)
  71. for (const auto style : { layoutstyle::Style::clipLaunch, layoutstyle::Style::simple })
  72. {
  73. const juce::String name = style == layoutstyle::Style::clipLaunch ? "cliplaunch" : "simple";
  74. layoutstyle::setCurrent (style);
  75. roll.setDocked (true);
  76. roll.setBounds (0, 0, 1180, 300);
  77. roll.resized();
  78. check ((name + "_two_boxes").toRawUTF8(), roll.scaleBoxesSplitForTests());
  79. check ((name + "_scale_list_once").toRawUTF8(), roll.scaleNameItemsForTests() == (int) notetools::scales().size() + 1,
  80. juce::String (roll.scaleNameItemsForTests()));
  81. roll.setScaleForSnapshot (0, 0);
  82. roll.pickScaleRootForTests (9); // A first, with no scale: kept for the scale picked next
  83. check ((name + "_root_waits").toRawUTF8(), roll.scaleIndexForTests() == 0);
  84. roll.pickScaleNameForTests (3); // No scale, Automatic, Major, Natural minor
  85. check ((name + "_a_minor").toRawUTF8(), roll.scaleRootForTests() == 9 && roll.scaleIndexForTests() == 2,
  86. juce::String (roll.scaleRootForTests()) + " " + juce::String (roll.scaleIndexForTests()));
  87. roll.pickScaleRootForTests (2); // the root alone: D minor
  88. check ((name + "_root_keeps_scale").toRawUTF8(), roll.scaleRootForTests() == 2 && roll.scaleIndexForTests() == 2);
  89. check ((name + "_boxes_show_it").toRawUTF8(), roll.scaleRootTextForTests() == "D" && roll.scaleNameTextForTests() == tr ("Natural minor"),
  90. roll.scaleRootTextForTests() + " | " + roll.scaleNameTextForTests());
  91. roll.setScaleForSnapshot (2, 2); // (the FL menu / a project's saved scale: the boxes follow)
  92. savePng (shot::snapshot (roll), prefix + "-203-" + name + "-pianoroll.png");
  93. roll.setDocked (false);
  94. }
  95. layoutstyle::setCurrent (layoutstyle::Style::pattern);
  96. roll.setBounds (0, 0, 1180, 420);
  97. roll.resized();
  98. check ("undocked_one_box_again", ! roll.scaleBoxesSplitForTests() && roll.scaleRootForTests() == 2 && roll.scaleIndexForTests() == 2);
  99. }
  100. // ---- #200: a folder dropped on the Browser joins its list ---------------------------------------------------
  101. {
  102. AudioEngine engine (false);
  103. const auto folder = juce::File (prefix + "-library").getChildFile ("My Drum Kit 190ll");
  104. folder.getChildFile ("Kicks").createDirectory();
  105. for (const auto* n : { "Kick 01.wav", "Kick 02.wav" })
  106. writeWaveDemo (folder.getChildFile ("Kicks").getChildFile (n), 120.0);
  107. writeWaveDemo (folder.getChildFile ("Snare.wav"), 120.0);
  108. BrowserComponent browser (engine);
  109. browser.setBounds (0, 0, 260, 600);
  110. browser.setVisible (true);
  111. engine.dispatchPendingMessages();
  112. check ("browser_wants_a_folder", browser.isInterestedInFileDrag ({ folder.getFullPathName() }));
  113. check ("browser_not_a_file_alone", ! browser.isInterestedInFileDrag ({ folder.getChildFile ("Snare.wav").getFullPathName() }));
  114. browser.fileDragEnter ({ folder.getFullPathName() }, 100, 200);
  115. savePng (shot::snapshot (browser), prefix + "-200-browser-drag-over.png");
  116. browser.filesDropped ({ folder.getFullPathName() }, 100, 200);
  117. engine.dispatchPendingMessages();
  118. savePng (shot::snapshot (browser), prefix + "-200-browser-after-drop.png");
  119. const auto added = browser.addUserFolders ({ folder.getFullPathName() }); // (again: listed already)
  120. check ("browser_folder_once", added == 0);
  121. savePng (shot::snapshot (browser), prefix + "-200-browser-drop-again.png");
  122. }
  123. report.add (juce::String ("result=") + (allOk ? "OK" : "FAIL"));
  124. juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
  125. return allOk;
  126. }