IssuesShot190jz.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. // --issueshot190jz <prefix> (round 190jz, issues #192, #194, #195): the docked Browser and the maximize area in the three
  2. // layouts (left, closed, right, panels that follow the free area), the audio clip fade handles as the mouse shows them
  3. // (FL 2026: small triangles in the waveform's colour on hover, white when hovered, the tension circle), the fade hints,
  4. // the tension menu and Settings › LYNX extras with the W switch. <prefix>-checks.txt lists what was checked. Included in
  5. // the app class of Main.cpp (it uses savePng / saveMenus / writeWaveDemo / lookAndFeel). @150: LYNX_SHOT_SCALE=1.5 and
  6. // LYNX_SHOT_SUFFIX=@150.
  7. bool runIssuesShot190jz (const juce::String& prefix)
  8. {
  9. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  10. juce::StringArray report;
  11. bool allOk = true;
  12. const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
  13. report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
  14. allOk = allOk && ok;
  15. };
  16. using namespace lynx;
  17. using workspace::Panel;
  18. const auto text = [] (juce::Rectangle<int> r) { return r.toString(); };
  19. // a loop of the demo kind as the audio clip's file
  20. const auto wav = juce::File (prefix + "-loop.wav");
  21. writeWaveDemo (wav, 120.0);
  22. ui::motion::enabled() = false; // (panels show at once)
  23. AudioEngine engine (false);
  24. MainComponent ui (engine, false);
  25. ui.setSize (1920, 1040);
  26. {
  27. auto song = Song::makeDefault();
  28. song.bpm = 120.0;
  29. ChannelDef audio;
  30. audio.instrument = InstrumentKind::audioClip;
  31. audio.name = "Main Vox";
  32. audio.samplePath = wav.getFullPathName().toStdString();
  33. audio.colour = 0xff3a9a4c;
  34. song.channels.push_back (audio);
  35. const auto ch = (int) song.channels.size() - 1;
  36. song.playlistTracks.resize (12);
  37. Clip a;
  38. a.kind = ClipKind::audio;
  39. a.channel = ch;
  40. a.track = 2;
  41. a.start = 4 * ppq;
  42. a.length = 8 * ppq;
  43. song.playlist.push_back (a); // (the fades are set below, step by step)
  44. Clip b = a;
  45. b.track = 4;
  46. b.start = 4 * ppq;
  47. b.length = 3 * ppq;
  48. song.playlist.push_back (b);
  49. song.playlistTracks[2].height = 84; // FL's capture: tall tracks (Alt+wheel)
  50. song.playlistTracks[4].height = 84;
  51. engine.setSong (std::move (song));
  52. }
  53. engine.dispatchPendingMessages();
  54. auto& ws = ui.workspaceForTest();
  55. const auto frameOf = [&ws] (Panel p) { return ws.frameBounds (ws.getFrame (p)); };
  56. const auto browserRect = [&] { return frameOf (Panel::browser); };
  57. const auto shoot = [&] (const juce::String& name) {
  58. engine.dispatchPendingMessages();
  59. savePng (shot::snapshot (ui), prefix + name);
  60. };
  61. // ---- #192: the docked Browser and the maximize area (FL 2026 shots fl-192-*)
  62. ws.resetLayout();
  63. ws.show (Panel::playlist);
  64. ws.toggleMaximised (Panel::playlist);
  65. {
  66. const auto b = browserRect(), p = frameOf (Panel::playlist);
  67. check ("browser_docked_left", ws.getBrowserDock() == workspace::Dock::left && ws.isBrowserDockedPanel (Panel::browser) && b.getX() == 0
  68. && b.getHeight() == ws.getHeight(), text (b));
  69. check ("maximized_playlist_beside_browser", p.getX() == b.getRight() && p.getRight() == ws.getWidth() && p.getHeight() == ws.getHeight(),
  70. text (p));
  71. }
  72. shoot ("-192-browser-left-playlist-max.png");
  73. ui.runActionForSnapshot ("panel.browser"); // Alt+F8: the Browser has the focus? then closed (FL's F-key rule)
  74. if (ws.isPanelVisible (Panel::browser))
  75. ui.runActionForSnapshot ("panel.browser");
  76. check ("alt_f8_closes_browser", ! ws.isPanelVisible (Panel::browser));
  77. check ("maximized_playlist_whole_desktop", frameOf (Panel::playlist) == ws.getLocalBounds(), text (frameOf (Panel::playlist)));
  78. shoot ("-192-browser-closed-playlist-max.png");
  79. ui.runActionForSnapshot ("panel.browser");
  80. check ("alt_f8_shows_browser_docked", ws.isBrowserDockedPanel (Panel::browser) && frameOf (Panel::playlist).getX() == browserRect().getRight());
  81. ws.dockBrowser (workspace::Dock::right);
  82. {
  83. const auto b = browserRect(), p = frameOf (Panel::playlist);
  84. check ("browser_docked_right", b.getRight() == ws.getWidth() && b.getY() == 0 && b.getHeight() == ws.getHeight(), text (b));
  85. check ("maximized_playlist_left_of_browser", p.getX() == 0 && p.getRight() == b.getX(), text (p));
  86. }
  87. shoot ("-192-browser-right-playlist-max.png");
  88. ws.dockBrowser (workspace::Dock::left);
  89. check ("browser_docked_left_again", browserRect().getX() == 0 && frameOf (Panel::playlist).getX() == browserRect().getRight());
  90. // restored windows follow the free area (FL: Alt+F8 moves them by the Browser's width; the one at the right edge keeps it)
  91. ws.toggleMaximised (Panel::playlist);
  92. ws.show (Panel::mixer);
  93. ws.toggleMaximised (Panel::mixer);
  94. ws.show (Panel::playlist);
  95. shoot ("-192-restored-windows-browser-shown.png");
  96. const auto mixerShown = frameOf (Panel::mixer), playlistShown = frameOf (Panel::playlist);
  97. const auto bw = browserRect().getWidth();
  98. ws.hide (Panel::browser);
  99. shoot ("-192-restored-windows-browser-closed.png");
  100. check ("maximized_mixer_follows", frameOf (Panel::mixer) == ws.getLocalBounds() && mixerShown.getX() == bw, text (mixerShown));
  101. check ("restored_playlist_follows", frameOf (Panel::playlist).getX() == playlistShown.getX() - bw && frameOf (Panel::playlist).getRight() == playlistShown.getRight(),
  102. text (playlistShown) + " -> " + text (frameOf (Panel::playlist)));
  103. ws.show (Panel::browser);
  104. check ("restored_playlist_back", frameOf (Panel::playlist) == playlistShown, text (frameOf (Panel::playlist)));
  105. ws.hide (Panel::mixer);
  106. // the Clip-launch layout (Live's browser is a side panel): the docked Browser and the maximized arrangement beside it
  107. ui.setLayoutStyle (layoutstyle::Style::clipLaunch);
  108. engine.dispatchPendingMessages();
  109. ws.show (Panel::browser);
  110. if (! ws.isMaximised (Panel::playlist))
  111. ws.toggleMaximised (Panel::playlist);
  112. check ("clip_launch_side_panel", ws.isBrowserDockedPanel (Panel::browser) && frameOf (Panel::playlist).getX() == browserRect().getRight(),
  113. text (frameOf (Panel::playlist)));
  114. shoot ("-192-cliplaunch-browser-left.png");
  115. // the Simple layout: one maximized window; the Browser opened beside it, closed it fills the window again
  116. ui.setLayoutStyle (layoutstyle::Style::simple);
  117. engine.dispatchPendingMessages();
  118. // (what the Simple layout's first start does, MainComponent::setLayoutStyle; this window keeps no layouts)
  119. for (const auto p : { Panel::channelRack, Panel::pianoRoll, Panel::mixer, Panel::browser })
  120. ws.hide (p);
  121. ws.show (Panel::playlist);
  122. if (! ws.isMaximised (Panel::playlist))
  123. ws.toggleMaximised (Panel::playlist);
  124. check ("simple_playlist_whole_window", ! ws.isPanelVisible (Panel::browser) && frameOf (Panel::playlist) == ws.getLocalBounds(),
  125. text (frameOf (Panel::playlist)));
  126. shoot ("-192-simple.png");
  127. ws.show (Panel::browser);
  128. check ("simple_browser_beside", frameOf (Panel::playlist).getX() == browserRect().getRight());
  129. shoot ("-192-simple-browser.png");
  130. ws.hide (Panel::browser);
  131. ui.setLayoutStyle (layoutstyle::Style::pattern);
  132. engine.dispatchPendingMessages();
  133. // ---- #194: the fade handles (FL 2026 shots fl-194-*)
  134. ui.selectTabForSnapshot (2);
  135. engine.dispatchPendingMessages();
  136. auto& pl = ui.getPlaylistForSnapshot();
  137. pl.setViewForSnapshot (240.0, 1, 0);
  138. engine.dispatchPendingMessages();
  139. pl.createComponentSnapshot (pl.getLocalBounds()); // (starts the waveform's analysis)
  140. ui::WaveformCache::getInstance()->waitUntilIdle (8000);
  141. const auto clipArea = [&] (int index, int pad) { return pl.clipBoundsForSnapshot (index).expanded (pad, pad).getIntersection (pl.getLocalBounds()); };
  142. const auto shootClip = [&] (int index, const juce::String& name) {
  143. pl.repaint();
  144. engine.dispatchPendingMessages();
  145. savePng (shot::snapshot (pl, clipArea (index, 14)), prefix + name);
  146. };
  147. const auto setClip = [&] (int index, std::function<void (Clip&)> change) {
  148. engine.editSong ([index, change] (Song& s) { change (s.playlist[(std::size_t) index]); });
  149. engine.dispatchPendingMessages();
  150. };
  151. // 1. idle, no fades: nothing drawn; 2. the clip hovered: the small triangles at the body's top corners
  152. pl.hoverFadeForSnapshot (-1, -1);
  153. shootClip (0, "-194-idle-clip.png");
  154. pl.hoverFadeForSnapshot (0, 0);
  155. shootClip (0, "-194-hover-clip.png");
  156. pl.hoverFadeForSnapshot (0, 1);
  157. shootClip (0, "-194-hover-fade-handle.png");
  158. const auto in0 = pl.fadeHandlePointForSnapshot (0, 0);
  159. {
  160. const auto h = pl.hintAt (in0.toInt() + juce::Point<int> (2, 2));
  161. check ("hover_hint_fade_in_auto", h.text.startsWith (tr ("Fade in: {0}", { "0'00.000''" })) && h.text.contains (tr ("(auto)"))
  162. && h.text.contains (tr ("Hold Alt to snap")), h.text);
  163. }
  164. // 3. a fade-in of one beat (0.5 s at 120 BPM), dragged by hand: FL's S curve, the circle at its middle, manual
  165. setClip (0, [] (Clip& c) {
  166. c.fadeIn = ppq;
  167. clipops::setManualFade (c, 0, true);
  168. });
  169. {
  170. const auto h = pl.fadeDragHintForSnapshot (0, 1);
  171. check ("drag_hint_fade_in", h.text.startsWith (tr ("Fade in: {0}", { "0'00.500''" })), h.text);
  172. const auto hover = pl.hintAt (pl.fadeHandlePointForSnapshot (0, 0).toInt() + juce::Point<int> (2, 2));
  173. check ("hover_hint_manual_has_no_auto", ! hover.text.contains (tr ("(auto)")), hover.text);
  174. }
  175. pl.hoverFadeForSnapshot (0, 1);
  176. shootClip (0, "-194-drag-fade-in.png");
  177. pl.hoverFadeForSnapshot (-1, -1);
  178. shootClip (0, "-194-fade-in-idle.png");
  179. pl.hoverFadeForSnapshot (0, 3);
  180. shootClip (0, "-194-hover-tension.png");
  181. {
  182. const auto circle = pl.fadeTensionPointForSnapshot (0, 0);
  183. const auto r = pl.clipBoundsForSnapshot (0);
  184. check ("tension_circle_mid_fade", std::abs (circle.x - ((float) r.getX() + (float) (pl.xOfTickForSnapshot (ppq) - pl.xOfTickForSnapshot (0.0)) * 0.5f)) < 1.0f,
  185. juce::String (circle.x) + "," + juce::String (circle.y));
  186. const auto h = pl.hintAt (circle.toInt());
  187. check ("hover_hint_tension_0", h.text == tr ("Tension: {0}%", { "0" }), h.text);
  188. }
  189. // 4. the tension at 15 % (FL's drag of 26 px up)
  190. setClip (0, [] (Clip& c) { c.fadeInTension = clipops::fadeTensionFromHandle (0.15); });
  191. {
  192. const auto h = pl.fadeDragHintForSnapshot (0, 3);
  193. check ("drag_hint_tension_15", h.text == tr ("Tension: {0}%", { "15" }), h.text);
  194. }
  195. pl.hoverFadeForSnapshot (0, 3);
  196. shootClip (0, "-194-drag-tension.png");
  197. // 5. a fade-out on the short clip, dragged by hand (FL: "Fade out: 0'00.112''")
  198. setClip (1, [] (Clip& c) {
  199. c.fadeOut = ppq / 2;
  200. clipops::setManualFade (c, 1, true);
  201. });
  202. {
  203. const auto h = pl.fadeDragHintForSnapshot (1, 2);
  204. check ("drag_hint_fade_out", h.text.startsWith (tr ("Fade out: {0}", { "0'00.250''" })), h.text);
  205. }
  206. pl.hoverFadeForSnapshot (1, 2);
  207. shootClip (1, "-194-drag-fade-out.png");
  208. pl.hoverFadeForSnapshot (-1, -1);
  209. saveMenus (juce::StringArray { "Fade in tension", "Fade out tension" },
  210. std::vector<juce::PopupMenu> { pl.fadeTensionMenu (0, 0), pl.fadeTensionMenu (1, 1) }, prefix + "-194-tension-menu.png");
  211. // the whole Playlist with the faded clips, idle
  212. savePng (shot::snapshot (pl), prefix + "-194-playlist.png");
  213. // ---- #195: Home and the W extra
  214. {
  215. auto& km = ui.getKeyMapForSnapshot();
  216. check ("home_in_playlist", km.find ({ keys::home, keys::none }, keys::Context::playlist, false) == "playlist.toStart");
  217. check ("home_in_piano_roll", km.find ({ keys::home, keys::none }, keys::Context::pianoRoll, false) == "pianoRoll.toStart");
  218. check ("home_not_in_mixer", km.find ({ keys::home, keys::none }, keys::Context::mixer, false).empty());
  219. engine.seek (16.0 * ppq);
  220. engine.dispatchPendingMessages();
  221. ui.runActionForSnapshot ("playlist.toStart");
  222. check ("home_marks_the_start", EditorGlobals::get().seekMark == 0, juce::String (EditorGlobals::get().seekMark));
  223. check ("w_extra_off", ! transportedit::wGoesToStart());
  224. workflowextras::setExtra ("transport.wToStart", true);
  225. check ("w_extra_on", transportedit::wGoesToStart() && workflowextras::uiOptionsText().contains ("wToStart=1"));
  226. SettingsHooks hooks;
  227. auto page = makeExtrasPage (engine, hooks, false);
  228. page->setSize (760, 1500);
  229. savePng (shot::snapshot (*page), prefix + "-195-extras.png");
  230. workflowextras::setExtra ("transport.wToStart", false);
  231. }
  232. juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
  233. return allOk;
  234. }