Icons.cpp 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. #include "ui/Icons.h"
  2. #include "ui/Motion.h"
  3. #include <cmath>
  4. #include <map>
  5. #include "ui/Theme.h"
  6. namespace lynx
  7. {
  8. namespace icons
  9. {
  10. namespace
  11. {
  12. constexpr float pi = juce::MathConstants<float>::pi;
  13. void line (juce::Path& p, float x1, float y1, float x2, float y2)
  14. {
  15. p.startNewSubPath (x1, y1);
  16. p.lineTo (x2, y2);
  17. }
  18. void roundRect (juce::Path& p, float x, float y, float w, float h, float r)
  19. {
  20. p.addRoundedRectangle (x, y, w, h, r);
  21. }
  22. void polyline (juce::Path& p, std::initializer_list<juce::Point<float>> points, bool close = false)
  23. {
  24. bool first = true;
  25. for (auto pt : points)
  26. {
  27. if (first)
  28. p.startNewSubPath (pt);
  29. else
  30. p.lineTo (pt);
  31. first = false;
  32. }
  33. if (close)
  34. p.closeSubPath();
  35. }
  36. Shape make (Icon icon)
  37. {
  38. Shape s;
  39. auto& st = s.stroke;
  40. auto& fi = s.fill;
  41. // a page with a folded corner (file icons)
  42. auto page = [&st] {
  43. juce::Path p;
  44. polyline (p, { { 6.0f, 3.5f }, { 13.5f, 3.5f }, { 18.0f, 8.0f }, { 18.0f, 20.5f }, { 6.0f, 20.5f } }, true);
  45. st.addPath (p.createPathWithRoundedCorners (1.5f));
  46. polyline (st, { { 13.5f, 3.5f }, { 13.5f, 8.0f }, { 18.0f, 8.0f } });
  47. };
  48. // a speaker cone (mute and playback tools)
  49. auto speaker = [&st] {
  50. juce::Path p;
  51. polyline (p, { { 3.5f, 9.5f }, { 7.0f, 9.5f }, { 11.5f, 5.5f }, { 11.5f, 18.5f }, { 7.0f, 14.5f }, { 3.5f, 14.5f } }, true);
  52. st.addPath (p.createPathWithRoundedCorners (1.2f));
  53. };
  54. // a window outline with a title band (view icons)
  55. auto window = [&st] {
  56. roundRect (st, 3.5f, 4.5f, 17.0f, 15.0f, 2.0f);
  57. };
  58. // a horseshoe magnet with solid poles, opening downwards (the way FL users know the snap), scaled by `k` and moved
  59. // by (dx, dy) (snap icons)
  60. auto magnet = [&st, &fi] (float k, float dx, float dy) {
  61. const auto t = juce::AffineTransform::verticalFlip (24.0f).scaled (k).translated (dx, dy);
  62. juce::Path m;
  63. m.startNewSubPath (4.5f, 4.0f);
  64. m.lineTo (4.5f, 12.5f);
  65. m.addCentredArc (12.0f, 12.5f, 7.5f, 7.5f, 0.0f, pi * 1.5f, pi * 0.5f, false);
  66. m.lineTo (19.5f, 4.0f);
  67. m.lineTo (15.0f, 4.0f);
  68. m.lineTo (15.0f, 12.5f);
  69. m.addCentredArc (12.0f, 12.5f, 3.0f, 3.0f, 0.0f, pi * 0.5f, pi * 1.5f, false);
  70. m.lineTo (9.0f, 4.0f);
  71. m.closeSubPath();
  72. st.addPath (m, t);
  73. juce::Path poles;
  74. poles.addRectangle (4.5f, 4.0f, 4.5f, 3.5f);
  75. poles.addRectangle (15.0f, 4.0f, 4.5f, 3.5f);
  76. fi.addPath (poles, t);
  77. };
  78. switch (icon)
  79. {
  80. case Icon::none:
  81. break;
  82. // --- transport (solid) ---
  83. case Icon::play:
  84. {
  85. juce::Path tri;
  86. tri.addTriangle (7.0f, 4.5f, 7.0f, 19.5f, 19.5f, 12.0f);
  87. fi = tri.createPathWithRoundedCorners (2.0f);
  88. break;
  89. }
  90. case Icon::pause:
  91. fi.addRoundedRectangle (6.0f, 5.0f, 4.5f, 14.0f, 1.25f);
  92. fi.addRoundedRectangle (13.5f, 5.0f, 4.5f, 14.0f, 1.25f);
  93. break;
  94. case Icon::stop:
  95. fi.addRoundedRectangle (5.5f, 5.5f, 13.0f, 13.0f, 2.25f);
  96. break;
  97. case Icon::record:
  98. fi.addEllipse (5.0f, 5.0f, 14.0f, 14.0f);
  99. break;
  100. // --- small glyphs ---
  101. case Icon::chevronDown:
  102. polyline (st, { { 7.0f, 9.5f }, { 12.0f, 14.5f }, { 17.0f, 9.5f } });
  103. break;
  104. case Icon::more:
  105. for (float x : { 5.5f, 12.0f, 18.5f })
  106. fi.addEllipse (x - 1.75f, 10.25f, 3.5f, 3.5f);
  107. break;
  108. case Icon::plus:
  109. line (st, 12.0f, 5.0f, 12.0f, 19.0f);
  110. line (st, 5.0f, 12.0f, 19.0f, 12.0f);
  111. break;
  112. case Icon::check:
  113. polyline (st, { { 5.0f, 12.5f }, { 9.5f, 17.0f }, { 19.0f, 7.0f } });
  114. break;
  115. case Icon::close:
  116. line (st, 6.5f, 6.5f, 17.5f, 17.5f);
  117. line (st, 17.5f, 6.5f, 6.5f, 17.5f);
  118. break;
  119. case Icon::minimise:
  120. line (st, 6.0f, 12.0f, 18.0f, 12.0f);
  121. break;
  122. case Icon::maximise:
  123. roundRect (st, 5.5f, 5.5f, 13.0f, 13.0f, 2.0f);
  124. line (st, 5.5f, 9.0f, 18.5f, 9.0f);
  125. break;
  126. case Icon::restore: // two stacked windows
  127. roundRect (st, 4.5f, 8.5f, 11.0f, 11.0f, 1.75f);
  128. polyline (st, { { 8.5f, 4.5f }, { 17.5f, 4.5f }, { 19.5f, 6.5f }, { 19.5f, 15.5f } });
  129. break;
  130. case Icon::panelMenu: // three bars of decreasing length: "this window's options"
  131. line (st, 5.0f, 7.0f, 19.0f, 7.0f);
  132. line (st, 5.0f, 12.0f, 16.0f, 12.0f);
  133. line (st, 5.0f, 17.0f, 13.0f, 17.0f);
  134. break;
  135. // --- modes ---
  136. case Icon::pattern: // a 2x2 block of steps, one lit
  137. roundRect (st, 4.0f, 4.0f, 6.5f, 6.5f, 1.5f);
  138. roundRect (st, 4.0f, 13.5f, 6.5f, 6.5f, 1.5f);
  139. roundRect (st, 13.5f, 13.5f, 6.5f, 6.5f, 1.5f);
  140. fi.addRoundedRectangle (12.75f, 3.25f, 8.0f, 8.0f, 2.0f);
  141. break;
  142. case Icon::song: // clips staggered along three lanes
  143. fi.addRoundedRectangle (3.5f, 4.5f, 9.0f, 4.0f, 1.25f);
  144. fi.addRoundedRectangle (9.0f, 10.0f, 11.5f, 4.0f, 1.25f);
  145. fi.addRoundedRectangle (5.5f, 15.5f, 8.0f, 4.0f, 1.25f);
  146. break;
  147. case Icon::metronome:
  148. {
  149. juce::Path body;
  150. polyline (body, { { 9.0f, 3.5f }, { 15.0f, 3.5f }, { 19.0f, 20.5f }, { 5.0f, 20.5f } }, true);
  151. st.addPath (body.createPathWithRoundedCorners (2.0f));
  152. line (st, 12.0f, 16.5f, 17.5f, 6.0f);
  153. line (st, 7.0f, 16.5f, 17.0f, 16.5f);
  154. fi.addEllipse (14.0f, 8.0f, 3.5f, 3.5f);
  155. break;
  156. }
  157. // --- file ---
  158. case Icon::newFile:
  159. page();
  160. line (st, 12.0f, 11.0f, 12.0f, 17.0f);
  161. line (st, 9.0f, 14.0f, 15.0f, 14.0f);
  162. break;
  163. case Icon::file:
  164. page();
  165. break;
  166. case Icon::folder:
  167. {
  168. juce::Path f;
  169. polyline (f, { { 3.5f, 5.5f }, { 9.0f, 5.5f }, { 11.0f, 7.5f }, { 20.5f, 7.5f }, { 20.5f, 18.5f }, { 3.5f, 18.5f } }, true);
  170. st.addPath (f.createPathWithRoundedCorners (1.75f));
  171. break;
  172. }
  173. case Icon::open: // a folder with its front flap tipped open
  174. {
  175. juce::Path back;
  176. polyline (back, { { 4.0f, 18.5f }, { 3.5f, 5.5f }, { 9.0f, 5.5f }, { 11.0f, 7.5f }, { 18.0f, 7.5f }, { 18.0f, 10.5f } });
  177. st.addPath (back.createPathWithRoundedCorners (1.5f));
  178. juce::Path flap;
  179. polyline (flap, { { 4.0f, 18.5f }, { 7.0f, 10.5f }, { 21.0f, 10.5f }, { 18.0f, 18.5f } }, true);
  180. st.addPath (flap.createPathWithRoundedCorners (1.5f));
  181. break;
  182. }
  183. case Icon::save: // a disk
  184. {
  185. juce::Path body;
  186. polyline (body, { { 4.0f, 4.0f }, { 16.5f, 4.0f }, { 20.0f, 7.5f }, { 20.0f, 20.0f }, { 4.0f, 20.0f } }, true);
  187. st.addPath (body.createPathWithRoundedCorners (2.0f));
  188. polyline (st, { { 8.0f, 4.0f }, { 8.0f, 8.5f }, { 15.0f, 8.5f }, { 15.0f, 4.0f } });
  189. roundRect (st, 7.5f, 13.0f, 9.0f, 7.0f, 1.0f);
  190. break;
  191. }
  192. case Icon::exportAudio: // a waveform leaving a tray
  193. polyline (st, { { 3.5f, 14.0f }, { 3.5f, 19.5f }, { 20.5f, 19.5f }, { 20.5f, 14.0f } });
  194. line (st, 12.0f, 15.5f, 12.0f, 4.0f);
  195. polyline (st, { { 8.0f, 8.0f }, { 12.0f, 4.0f }, { 16.0f, 8.0f } });
  196. break;
  197. case Icon::settings: // three sliders
  198. line (st, 4.0f, 7.0f, 20.0f, 7.0f);
  199. line (st, 4.0f, 12.0f, 20.0f, 12.0f);
  200. line (st, 4.0f, 17.0f, 20.0f, 17.0f);
  201. fi.addEllipse (6.5f, 4.5f, 5.0f, 5.0f);
  202. fi.addEllipse (13.0f, 9.5f, 5.0f, 5.0f);
  203. fi.addEllipse (8.5f, 14.5f, 5.0f, 5.0f);
  204. break;
  205. case Icon::help:
  206. st.addEllipse (3.5f, 3.5f, 17.0f, 17.0f);
  207. st.startNewSubPath (9.5f, 10.0f);
  208. st.addCentredArc (12.0f, 10.0f, 2.5f, 2.5f, 0.0f, -pi * 0.5f, pi * 0.7f, false);
  209. st.lineTo (12.0f, 13.5f);
  210. fi.addEllipse (10.9f, 15.6f, 2.2f, 2.2f);
  211. break;
  212. case Icon::undo:
  213. case Icon::redo:
  214. {
  215. juce::Path p;
  216. p.startNewSubPath (19.0f, 18.5f);
  217. p.cubicTo (19.0f, 12.0f, 15.0f, 9.0f, 5.5f, 9.0f);
  218. polyline (p, { { 9.5f, 5.0f }, { 5.5f, 9.0f }, { 9.5f, 13.0f } });
  219. if (icon == Icon::redo)
  220. p.applyTransform (juce::AffineTransform::scale (-1.0f, 1.0f, 12.0f, 12.0f));
  221. st.addPath (p);
  222. break;
  223. }
  224. // --- views (the window buttons) ---
  225. case Icon::playlist: // clips on lanes inside a window
  226. window();
  227. fi.addRoundedRectangle (6.0f, 7.5f, 6.5f, 2.5f, 0.75f);
  228. fi.addRoundedRectangle (10.5f, 11.0f, 7.5f, 2.5f, 0.75f);
  229. fi.addRoundedRectangle (6.0f, 14.5f, 4.5f, 2.5f, 0.75f);
  230. fi.addRoundedRectangle (12.5f, 14.5f, 5.5f, 2.5f, 0.75f);
  231. break;
  232. case Icon::channelRack: // three channels: a name pad and a row of steps each
  233. for (int r = 0; r < 3; ++r)
  234. {
  235. const auto y = 4.5f + (float) r * 5.75f;
  236. roundRect (st, 3.5f, y, 6.5f, 3.5f, 1.0f);
  237. for (int c = 0; c < 3; ++c)
  238. {
  239. const auto x = 12.5f + (float) c * 3.0f;
  240. if ((r + c) % 2 == 0)
  241. fi.addRoundedRectangle (x - 0.25f, y - 0.25f, 2.5f, 4.0f, 0.6f);
  242. else
  243. fi.addRoundedRectangle (x + 0.5f, y + 1.25f, 1.0f, 1.0f, 0.3f);
  244. }
  245. }
  246. break;
  247. case Icon::pianoRoll: // a keyboard edge and notes
  248. window();
  249. line (st, 8.0f, 4.5f, 8.0f, 19.5f);
  250. line (st, 3.5f, 9.5f, 6.0f, 9.5f);
  251. line (st, 3.5f, 14.5f, 6.0f, 14.5f);
  252. fi.addRoundedRectangle (10.0f, 7.0f, 4.5f, 2.5f, 0.75f);
  253. fi.addRoundedRectangle (13.0f, 10.75f, 5.5f, 2.5f, 0.75f);
  254. fi.addRoundedRectangle (10.5f, 14.5f, 4.0f, 2.5f, 0.75f);
  255. break;
  256. case Icon::mixer: // three faders
  257. for (int i = 0; i < 3; ++i)
  258. line (st, 6.0f + (float) i * 6.0f, 4.0f, 6.0f + (float) i * 6.0f, 20.0f);
  259. fi.addRoundedRectangle (3.5f, 12.0f, 5.0f, 3.5f, 1.0f);
  260. fi.addRoundedRectangle (9.5f, 6.5f, 5.0f, 3.5f, 1.0f);
  261. fi.addRoundedRectangle (15.5f, 14.5f, 5.0f, 3.5f, 1.0f);
  262. break;
  263. case Icon::browser: // a tree: a folder and two items under it
  264. roundRect (st, 3.5f, 4.0f, 6.0f, 5.0f, 1.25f);
  265. polyline (st, { { 6.5f, 9.0f }, { 6.5f, 17.5f }, { 10.0f, 17.5f } });
  266. line (st, 6.5f, 12.5f, 10.0f, 12.5f);
  267. line (st, 12.5f, 6.5f, 20.5f, 6.5f);
  268. line (st, 13.0f, 12.5f, 20.5f, 12.5f);
  269. line (st, 13.0f, 17.5f, 18.0f, 17.5f);
  270. break;
  271. case Icon::pluginPicker: // a plug
  272. {
  273. line (st, 9.0f, 3.5f, 9.0f, 7.5f);
  274. line (st, 15.0f, 3.5f, 15.0f, 7.5f);
  275. juce::Path body;
  276. polyline (body, { { 5.5f, 7.5f }, { 18.5f, 7.5f }, { 18.5f, 11.0f }, { 14.5f, 16.0f }, { 9.5f, 16.0f }, { 5.5f, 11.0f } }, true);
  277. st.addPath (body.createPathWithRoundedCorners (1.75f));
  278. line (st, 12.0f, 16.0f, 12.0f, 20.5f);
  279. break;
  280. }
  281. // --- content ---
  282. case Icon::envelope: // an ADSR line on a base line (attack up, decay, sustain, release)
  283. polyline (st, { { 3.5f, 18.5f }, { 8.0f, 5.5f }, { 11.5f, 11.0f }, { 15.5f, 11.0f }, { 20.5f, 18.5f } });
  284. line (st, 3.5f, 20.0f, 20.5f, 20.0f);
  285. break;
  286. case Icon::wrench: // an open-end wrench, head at the upper right
  287. {
  288. juce::Path w;
  289. w.startNewSubPath (5.0f, 19.0f);
  290. w.lineTo (12.5f, 11.5f);
  291. st.addPath (w);
  292. // the head: a ring open towards the upper right (the jaws)
  293. st.addCentredArc (15.5f, 8.5f, 4.5f, 4.5f, 0.0f, pi * 0.55f, pi * 1.95f, true);
  294. break;
  295. }
  296. case Icon::audioFile: // a short waveform
  297. {
  298. const float heights[] = { 5.0f, 11.0f, 16.0f, 8.0f, 12.0f, 4.0f };
  299. for (int i = 0; i < 6; ++i)
  300. {
  301. const auto x = 4.5f + (float) i * 3.0f;
  302. line (st, x, 12.0f - heights[i] / 2.0f, x, 12.0f + heights[i] / 2.0f);
  303. }
  304. break;
  305. }
  306. case Icon::plugin: // a module with a jack
  307. roundRect (st, 4.0f, 6.5f, 16.0f, 12.0f, 2.0f);
  308. line (st, 8.5f, 3.5f, 8.5f, 6.5f);
  309. line (st, 15.5f, 3.5f, 15.5f, 6.5f);
  310. st.addEllipse (9.5f, 10.0f, 5.0f, 5.0f);
  311. break;
  312. case Icon::preset: // a knob
  313. st.addCentredArc (12.0f, 12.0f, 8.0f, 8.0f, 0.0f, -pi * 0.75f, pi * 0.75f, true);
  314. line (st, 12.0f, 12.0f, 15.5f, 8.5f);
  315. break;
  316. case Icon::project: // a diamond with a core
  317. {
  318. juce::Path d;
  319. polyline (d, { { 12.0f, 3.0f }, { 20.0f, 12.0f }, { 12.0f, 21.0f }, { 4.0f, 12.0f } }, true);
  320. st.addPath (d.createPathWithRoundedCorners (2.0f));
  321. fi.addEllipse (9.75f, 9.75f, 4.5f, 4.5f);
  322. break;
  323. }
  324. // --- edit tools ---
  325. case Icon::draw: // pencil
  326. {
  327. juce::Path p;
  328. polyline (p, { { 15.5f, 4.0f }, { 20.0f, 8.5f }, { 9.0f, 19.5f }, { 4.0f, 20.0f }, { 4.5f, 15.0f } }, true);
  329. st.addPath (p.createPathWithRoundedCorners (1.25f));
  330. line (st, 13.0f, 6.5f, 17.5f, 11.0f);
  331. break;
  332. }
  333. case Icon::brush: // a round brush: handle, ferrule and a filled tip
  334. {
  335. line (st, 20.0f, 4.0f, 13.5f, 10.5f);
  336. juce::Path ferrule;
  337. polyline (ferrule, { { 11.5f, 9.5f }, { 14.5f, 12.5f }, { 12.5f, 14.5f }, { 9.5f, 11.5f } }, true);
  338. st.addPath (ferrule.createPathWithRoundedCorners (0.75f));
  339. juce::Path tip;
  340. tip.startNewSubPath (9.0f, 12.5f);
  341. tip.quadraticTo (4.0f, 13.0f, 3.5f, 20.5f);
  342. tip.quadraticTo (11.0f, 20.0f, 11.5f, 15.0f);
  343. tip.closeSubPath();
  344. fi.addPath (tip);
  345. break;
  346. }
  347. case Icon::erase: // an eraser on a line
  348. {
  349. juce::Path p;
  350. polyline (p, { { 13.0f, 4.0f }, { 20.0f, 11.0f }, { 12.0f, 19.0f }, { 7.5f, 19.0f }, { 4.0f, 15.5f } }, true);
  351. st.addPath (p.createPathWithRoundedCorners (1.25f));
  352. line (st, 8.5f, 8.5f, 15.5f, 15.5f);
  353. line (st, 12.0f, 19.0f, 20.5f, 19.0f);
  354. break;
  355. }
  356. case Icon::mute: // a speaker with a cross
  357. speaker();
  358. line (st, 15.0f, 9.0f, 20.5f, 15.0f);
  359. line (st, 20.5f, 9.0f, 15.0f, 15.0f);
  360. break;
  361. case Icon::listen: // a speaker with two waves (playback tool)
  362. speaker();
  363. st.addCentredArc (12.0f, 12.0f, 3.5f, 3.5f, 0.0f, pi * 0.25f, pi * 0.75f, true);
  364. st.addCentredArc (12.0f, 12.0f, 7.5f, 7.5f, 0.0f, pi * 0.22f, pi * 0.78f, true);
  365. break;
  366. case Icon::knife: // a blade with a handle, cutting down to the left
  367. {
  368. juce::Path blade;
  369. polyline (blade, { { 4.0f, 20.0f }, { 13.5f, 8.0f }, { 17.0f, 11.5f } }, true);
  370. st.addPath (blade.createPathWithRoundedCorners (1.25f));
  371. line (st, 15.5f, 9.5f, 20.0f, 5.0f);
  372. break;
  373. }
  374. case Icon::select: // the four corners of a selection box
  375. {
  376. const float a = 4.0f, b = 20.0f, l = 4.5f;
  377. polyline (st, { { a, a + l }, { a, a }, { a + l, a } });
  378. polyline (st, { { b - l, a }, { b, a }, { b, a + l } });
  379. polyline (st, { { b, b - l }, { b, b }, { b - l, b } });
  380. polyline (st, { { a + l, b }, { a, b }, { a, b - l } });
  381. fi.addRoundedRectangle (9.5f, 9.5f, 5.0f, 5.0f, 1.0f);
  382. break;
  383. }
  384. case Icon::slice:
  385. case Icon::scissors:
  386. st.addEllipse (3.5f, 14.0f, 6.0f, 6.0f);
  387. st.addEllipse (14.5f, 14.0f, 6.0f, 6.0f);
  388. line (st, 8.5f, 15.0f, 17.5f, 3.5f);
  389. line (st, 15.5f, 15.0f, 6.5f, 3.5f);
  390. break;
  391. case Icon::zoom: // a magnifier with a plus
  392. st.addEllipse (3.5f, 3.5f, 13.0f, 13.0f);
  393. line (st, 14.5f, 14.5f, 20.5f, 20.5f);
  394. line (st, 10.0f, 7.0f, 10.0f, 13.0f);
  395. line (st, 7.0f, 10.0f, 13.0f, 10.0f);
  396. break;
  397. case Icon::deleteTool: // FL's delete tool: a ring crossed by a slash (round 190ig)
  398. st.addEllipse (4.5f, 4.5f, 15.0f, 15.0f);
  399. line (st, 6.9f, 17.1f, 17.1f, 6.9f);
  400. break;
  401. case Icon::slipArrows: // FL's slip tool: two solid arrowheads pointing apart (round 190ig)
  402. fi.addTriangle (3.0f, 12.0f, 10.5f, 6.5f, 10.5f, 17.5f);
  403. fi.addTriangle (21.0f, 12.0f, 13.5f, 6.5f, 13.5f, 17.5f);
  404. break;
  405. case Icon::slip: // a fixed frame with its content sliding inside
  406. roundRect (st, 3.5f, 5.5f, 17.0f, 13.0f, 2.0f);
  407. polyline (st, { { 9.0f, 9.5f }, { 6.5f, 12.0f }, { 9.0f, 14.5f } });
  408. polyline (st, { { 15.0f, 9.5f }, { 17.5f, 12.0f }, { 15.0f, 14.5f } });
  409. line (st, 7.0f, 12.0f, 17.0f, 12.0f);
  410. break;
  411. case Icon::ghost: // two overlapping notes, the back one hollow
  412. roundRect (st, 3.5f, 5.5f, 12.0f, 5.5f, 1.5f);
  413. fi.addRoundedRectangle (8.5f, 13.0f, 12.0f, 5.5f, 1.5f);
  414. break;
  415. case Icon::link:
  416. roundRect (st, 3.0f, 8.5f, 11.0f, 7.0f, 3.5f);
  417. roundRect (st, 10.0f, 8.5f, 11.0f, 7.0f, 3.5f);
  418. break;
  419. case Icon::magnet: // snap: a horseshoe magnet, its two poles solid (round 170e: the open "U" read as a letter)
  420. magnet (1.0f, 0.0f, 0.0f);
  421. break;
  422. // --- workspace and control contract ---
  423. case Icon::detach: // a window with an arrow leaving its corner
  424. polyline (st, { { 10.5f, 4.5f }, { 6.0f, 4.5f }, { 4.5f, 6.0f }, { 4.5f, 18.0f }, { 6.0f, 19.5f }, { 18.0f, 19.5f }, { 19.5f, 18.0f }, { 19.5f, 13.5f } });
  425. line (st, 12.0f, 12.0f, 19.5f, 4.5f);
  426. polyline (st, { { 14.0f, 4.5f }, { 19.5f, 4.5f }, { 19.5f, 10.0f } });
  427. break;
  428. case Icon::dock: // an arrow going into a window's corner
  429. polyline (st, { { 10.5f, 4.5f }, { 6.0f, 4.5f }, { 4.5f, 6.0f }, { 4.5f, 18.0f }, { 6.0f, 19.5f }, { 18.0f, 19.5f }, { 19.5f, 18.0f }, { 19.5f, 13.5f } });
  430. line (st, 19.5f, 4.5f, 12.0f, 12.0f);
  431. polyline (st, { { 12.0f, 6.5f }, { 12.0f, 12.0f }, { 17.5f, 12.0f } });
  432. break;
  433. case Icon::keyboard: // a small piano: outline, white-key gaps, two black keys
  434. roundRect (st, 3.0f, 6.0f, 18.0f, 12.0f, 2.0f);
  435. line (st, 9.0f, 13.0f, 9.0f, 18.0f);
  436. line (st, 15.0f, 13.0f, 15.0f, 18.0f);
  437. fi.addRoundedRectangle (7.25f, 6.0f, 3.5f, 7.0f, 0.75f);
  438. fi.addRoundedRectangle (13.25f, 6.0f, 3.5f, 7.0f, 0.75f);
  439. break;
  440. case Icon::automate: // a curve through two points
  441. {
  442. juce::Path c;
  443. c.startNewSubPath (4.0f, 17.0f);
  444. c.cubicTo (9.0f, 17.0f, 10.0f, 7.0f, 15.0f, 7.0f);
  445. c.lineTo (20.5f, 7.0f);
  446. st.addPath (c);
  447. fi.addEllipse (2.0f, 15.0f, 4.0f, 4.0f);
  448. fi.addEllipse (13.0f, 5.0f, 4.0f, 4.0f);
  449. break;
  450. }
  451. case Icon::rightClick: // a mouse with the right button lit
  452. {
  453. roundRect (st, 6.5f, 3.5f, 11.0f, 17.0f, 5.5f);
  454. line (st, 6.5f, 10.5f, 17.5f, 10.5f);
  455. line (st, 12.0f, 3.5f, 12.0f, 10.5f);
  456. juce::Path b;
  457. b.startNewSubPath (12.0f, 3.5f);
  458. b.lineTo (12.0f, 10.5f);
  459. b.lineTo (17.5f, 10.5f);
  460. b.lineTo (17.5f, 9.0f);
  461. b.quadraticTo (17.5f, 3.5f, 12.0f, 3.5f);
  462. b.closeSubPath();
  463. fi.addPath (b);
  464. break;
  465. }
  466. case Icon::tap: // a dot with two rings
  467. fi.addEllipse (9.5f, 9.5f, 5.0f, 5.0f);
  468. st.addCentredArc (12.0f, 12.0f, 5.5f, 5.5f, 0.0f, -pi * 0.35f, pi * 0.35f, true);
  469. st.addCentredArc (12.0f, 12.0f, 8.5f, 8.5f, 0.0f, -pi * 0.3f, pi * 0.3f, true);
  470. break;
  471. case Icon::mic: // recording options: a microphone
  472. roundRect (st, 9.0f, 3.0f, 6.0f, 11.0f, 3.0f);
  473. st.startNewSubPath (18.5f, 11.0f);
  474. st.addCentredArc (12.0f, 11.0f, 6.5f, 6.0f, 0.0f, pi * 0.5f, pi * 1.5f, false);
  475. line (st, 12.0f, 17.0f, 12.0f, 20.5f);
  476. line (st, 8.5f, 20.5f, 15.5f, 20.5f);
  477. break;
  478. case Icon::countIn: // a stopwatch: dial, crown and a hand, with the first quarter filled
  479. {
  480. st.addEllipse (4.5f, 6.0f, 15.0f, 15.0f);
  481. line (st, 10.0f, 3.0f, 14.0f, 3.0f);
  482. line (st, 12.0f, 3.0f, 12.0f, 6.0f);
  483. line (st, 12.0f, 13.5f, 12.0f, 9.5f);
  484. juce::Path quarter;
  485. quarter.startNewSubPath (12.0f, 13.5f);
  486. quarter.addCentredArc (12.0f, 13.5f, 5.0f, 5.0f, 0.0f, 0.0f, pi * 0.5f, false);
  487. quarter.closeSubPath();
  488. fi.addPath (quarter);
  489. break;
  490. }
  491. case Icon::waitInput: // an hourglass: two triangles between two bars, sand in the bottom one
  492. line (st, 6.0f, 3.5f, 18.0f, 3.5f);
  493. line (st, 6.0f, 20.5f, 18.0f, 20.5f);
  494. polyline (st, { { 7.5f, 3.5f }, { 7.5f, 6.5f }, { 12.0f, 12.0f }, { 7.5f, 17.5f }, { 7.5f, 20.5f } });
  495. polyline (st, { { 16.5f, 3.5f }, { 16.5f, 6.5f }, { 12.0f, 12.0f }, { 16.5f, 17.5f }, { 16.5f, 20.5f } });
  496. polyline (fi, { { 12.0f, 16.0f }, { 15.0f, 19.5f }, { 9.0f, 19.5f } }, true);
  497. break;
  498. case Icon::mouseLeft: // a mouse with the left button lit (the mirror of rightClick)
  499. {
  500. roundRect (st, 6.5f, 3.5f, 11.0f, 17.0f, 5.5f);
  501. line (st, 6.5f, 10.5f, 17.5f, 10.5f);
  502. line (st, 12.0f, 3.5f, 12.0f, 10.5f);
  503. juce::Path b;
  504. b.startNewSubPath (12.0f, 3.5f);
  505. b.lineTo (12.0f, 10.5f);
  506. b.lineTo (6.5f, 10.5f);
  507. b.lineTo (6.5f, 9.0f);
  508. b.quadraticTo (6.5f, 3.5f, 12.0f, 3.5f);
  509. b.closeSubPath();
  510. fi.addPath (b);
  511. break;
  512. }
  513. case Icon::mouseMiddle: // a mouse with its wheel button lit
  514. roundRect (st, 6.5f, 3.5f, 11.0f, 17.0f, 5.5f);
  515. line (st, 6.5f, 11.0f, 17.5f, 11.0f);
  516. fi.addRoundedRectangle (10.25f, 4.5f, 3.5f, 6.0f, 1.75f);
  517. break;
  518. case Icon::mouseWheel: // a narrower mouse with its wheel, and up/down chevrons beside it
  519. roundRect (st, 3.5f, 4.5f, 10.0f, 15.0f, 5.0f);
  520. line (st, 3.5f, 11.0f, 13.5f, 11.0f);
  521. fi.addRoundedRectangle (7.25f, 5.5f, 3.5f, 5.0f, 1.75f);
  522. polyline (st, { { 16.5f, 8.0f }, { 18.5f, 5.5f }, { 20.5f, 8.0f } });
  523. polyline (st, { { 16.5f, 16.0f }, { 18.5f, 18.5f }, { 20.5f, 16.0f } });
  524. break;
  525. case Icon::drumBrush: // a brush laying a row of short hits on the grid
  526. {
  527. line (st, 20.5f, 3.5f, 15.0f, 9.0f);
  528. juce::Path tip;
  529. tip.startNewSubPath (14.0f, 8.0f);
  530. tip.lineTo (16.0f, 10.0f);
  531. tip.quadraticTo (14.5f, 14.0f, 10.0f, 13.5f);
  532. tip.quadraticTo (10.5f, 9.5f, 14.0f, 8.0f);
  533. tip.closeSubPath();
  534. fi.addPath (tip);
  535. fi.addRoundedRectangle (3.0f, 17.0f, 4.0f, 3.5f, 1.0f);
  536. fi.addRoundedRectangle (9.0f, 17.0f, 4.0f, 3.5f, 1.0f);
  537. fi.addRoundedRectangle (15.0f, 17.0f, 4.0f, 3.5f, 1.0f);
  538. break;
  539. }
  540. case Icon::graph: // bars of different heights standing on a base line (a step graph)
  541. line (st, 3.5f, 20.5f, 20.5f, 20.5f);
  542. fi.addRoundedRectangle (4.0f, 11.0f, 3.0f, 8.0f, 1.0f);
  543. fi.addRoundedRectangle (8.5f, 6.0f, 3.0f, 13.0f, 1.0f);
  544. fi.addRoundedRectangle (13.0f, 13.5f, 3.0f, 5.5f, 1.0f);
  545. fi.addRoundedRectangle (17.5f, 9.0f, 3.0f, 10.0f, 1.0f);
  546. break;
  547. case Icon::follow: // a playhead line with an arrow carrying it to the right
  548. {
  549. line (st, 7.5f, 4.5f, 7.5f, 19.5f);
  550. juce::Path head;
  551. head.addTriangle (4.5f, 3.5f, 10.5f, 3.5f, 7.5f, 7.0f);
  552. fi.addPath (head);
  553. line (st, 11.5f, 12.0f, 19.5f, 12.0f);
  554. line (st, 16.5f, 9.0f, 19.5f, 12.0f);
  555. line (st, 16.5f, 15.0f, 19.5f, 12.0f);
  556. break;
  557. }
  558. case Icon::loop: // two arcs chasing each other around (a loop), arrow heads at their ends
  559. {
  560. constexpr float r = 7.0f;
  561. auto arcWithHead = [&] (float from, float to) {
  562. juce::Path a;
  563. a.addCentredArc (12.0f, 12.0f, r, r, 0.0f, from, to, true);
  564. st.addPath (a);
  565. // the head at the arc's end, pointing along it (clockwise); angles from 12 o'clock as JUCE's arcs
  566. const juce::Point<float> end (12.0f + r * std::sin (to), 12.0f - r * std::cos (to));
  567. const juce::Point<float> along (std::cos (to), std::sin (to)), out (std::sin (to), -std::cos (to));
  568. juce::Path h;
  569. h.addTriangle (end + along * 3.6f, end + out * 3.2f - along * 0.6f, end - out * 3.2f - along * 0.6f);
  570. fi.addPath (h);
  571. };
  572. arcWithHead (0.45f, 2.55f);
  573. arcWithHead (3.6f, 5.7f);
  574. break;
  575. }
  576. case Icon::stretch: // a waveform between two outward arrows (stretching audio)
  577. {
  578. juce::Path w;
  579. w.startNewSubPath (8.0f, 12.0f);
  580. w.lineTo (9.5f, 8.0f);
  581. w.lineTo (11.0f, 16.0f);
  582. w.lineTo (12.5f, 6.5f);
  583. w.lineTo (14.0f, 17.5f);
  584. w.lineTo (16.0f, 12.0f);
  585. st.addPath (w);
  586. line (st, 2.5f, 12.0f, 6.0f, 12.0f);
  587. line (st, 2.5f, 12.0f, 4.5f, 10.0f);
  588. line (st, 2.5f, 12.0f, 4.5f, 14.0f);
  589. line (st, 18.0f, 12.0f, 21.5f, 12.0f);
  590. line (st, 21.5f, 12.0f, 19.5f, 10.0f);
  591. line (st, 21.5f, 12.0f, 19.5f, 14.0f);
  592. break;
  593. }
  594. case Icon::dice: // a die showing five
  595. st.addRoundedRectangle (4.5f, 4.5f, 15.0f, 15.0f, 3.0f);
  596. for (const auto& [x, y] : { std::pair { 8.5f, 8.5f }, { 15.5f, 8.5f }, { 12.0f, 12.0f }, { 8.5f, 15.5f }, { 15.5f, 15.5f } })
  597. fi.addEllipse (x - 1.4f, y - 1.4f, 2.8f, 2.8f);
  598. break;
  599. case Icon::tuningFork: // two prongs on a stem, with a weighted foot
  600. {
  601. juce::Path f;
  602. f.startNewSubPath (8.5f, 3.5f);
  603. f.lineTo (8.5f, 10.0f);
  604. f.quadraticTo (8.5f, 14.0f, 12.0f, 14.0f);
  605. f.quadraticTo (15.5f, 14.0f, 15.5f, 10.0f);
  606. f.lineTo (15.5f, 3.5f);
  607. st.addPath (f);
  608. line (st, 12.0f, 14.0f, 12.0f, 18.0f);
  609. fi.addEllipse (10.0f, 17.0f, 4.0f, 4.0f);
  610. break;
  611. }
  612. case Icon::scaleSnap: // a small magnet over a few piano keys (snap to the scale)
  613. magnet (0.62f, 1.0f, 1.0f);
  614. roundRect (st, 11.5f, 12.5f, 9.0f, 8.0f, 1.5f);
  615. line (st, 14.5f, 16.5f, 14.5f, 20.5f);
  616. line (st, 17.5f, 16.5f, 17.5f, 20.5f);
  617. fi.addRoundedRectangle (13.6f, 12.5f, 1.8f, 4.0f, 0.5f);
  618. fi.addRoundedRectangle (16.6f, 12.5f, 1.8f, 4.0f, 0.5f);
  619. break;
  620. case Icon::tweak: // a knob with its pointer, and an arrow turning around it (the last moved control)
  621. {
  622. st.addEllipse (6.0f, 8.5f, 11.0f, 11.0f);
  623. line (st, 11.5f, 14.0f, 14.5f, 11.0f);
  624. constexpr float cx = 11.5f, cy = 14.0f, r = 9.0f, from = pi * 1.72f, to = pi * 2.28f;
  625. st.addCentredArc (cx, cy, r, r, 0.0f, from, to, true);
  626. const juce::Point<float> tip (cx + r * std::sin (to), cy - r * std::cos (to));
  627. const juce::Point<float> along (std::cos (to), std::sin (to)); // the arc's direction at its end
  628. const juce::Point<float> side (-along.y, along.x);
  629. polyline (st, { tip - along * 2.6f + side * 2.2f, tip, tip - along * 2.6f - side * 2.2f });
  630. break;
  631. }
  632. case Icon::slide: // a note with an arrow gliding up from its end (FL's slide notes)
  633. {
  634. fi.addRoundedRectangle (3.5f, 14.5f, 9.0f, 5.0f, 1.5f);
  635. line (st, 12.5f, 15.0f, 20.0f, 6.0f);
  636. polyline (st, { { 15.5f, 6.0f }, { 20.0f, 6.0f }, { 20.0f, 10.5f } });
  637. break;
  638. }
  639. case Icon::note: // an eighth note: a solid head, its stem and a flag
  640. fi.addEllipse (4.5f, 14.5f, 7.5f, 5.5f);
  641. line (st, 11.5f, 17.0f, 11.5f, 4.0f);
  642. polyline (st, { { 11.5f, 4.0f }, { 17.0f, 7.5f }, { 17.5f, 11.5f } });
  643. break;
  644. case Icon::chord: // three notes stacked on one start (a chord)
  645. fi.addRoundedRectangle (4.0f, 4.5f, 12.0f, 4.0f, 1.25f);
  646. fi.addRoundedRectangle (4.0f, 10.0f, 16.0f, 4.0f, 1.25f);
  647. fi.addRoundedRectangle (4.0f, 15.5f, 9.0f, 4.0f, 1.25f);
  648. break;
  649. case Icon::span: // a double arrow between two bar lines (a length)
  650. line (st, 3.5f, 6.0f, 3.5f, 18.0f);
  651. line (st, 20.5f, 6.0f, 20.5f, 18.0f);
  652. line (st, 6.5f, 12.0f, 17.5f, 12.0f);
  653. polyline (st, { { 9.0f, 9.5f }, { 6.5f, 12.0f }, { 9.0f, 14.5f } });
  654. polyline (st, { { 15.0f, 9.5f }, { 17.5f, 12.0f }, { 15.0f, 14.5f } });
  655. break;
  656. case Icon::blend: // two takes (notes) merging into one line (overdub)
  657. {
  658. fi.addRoundedRectangle (3.0f, 4.5f, 5.5f, 3.5f, 1.0f);
  659. fi.addRoundedRectangle (3.0f, 16.0f, 5.5f, 3.5f, 1.0f);
  660. juce::Path m;
  661. m.startNewSubPath (8.5f, 6.25f);
  662. m.quadraticTo (12.5f, 6.25f, 13.5f, 12.0f);
  663. m.startNewSubPath (8.5f, 17.75f);
  664. m.quadraticTo (12.5f, 17.75f, 13.5f, 12.0f);
  665. st.addPath (m);
  666. line (st, 13.5f, 12.0f, 20.5f, 12.0f);
  667. polyline (st, { { 17.5f, 9.0f }, { 20.5f, 12.0f }, { 17.5f, 15.0f } });
  668. break;
  669. }
  670. case Icon::filter: // a funnel
  671. {
  672. juce::Path f;
  673. polyline (f, { { 4.0f, 5.0f }, { 20.0f, 5.0f }, { 14.0f, 12.5f }, { 14.0f, 19.0f }, { 10.0f, 17.0f }, { 10.0f, 12.5f } }, true);
  674. st.addPath (f.createPathWithRoundedCorners (1.25f));
  675. break;
  676. }
  677. case Icon::tapTempo: // a fingertip tapping a pad, with the tap's two impact marks
  678. fi.addRoundedRectangle (4.0f, 16.0f, 16.0f, 4.0f, 1.5f);
  679. st.addRoundedRectangle (9.5f, 2.5f, 5.0f, 11.0f, 2.5f);
  680. line (st, 10.5f, 9.5f, 13.5f, 9.5f);
  681. line (st, 4.5f, 10.5f, 7.0f, 13.0f);
  682. line (st, 19.5f, 10.5f, 17.0f, 13.0f);
  683. break;
  684. case Icon::loopRecord: // a loop arrow around a record dot
  685. {
  686. constexpr float r = 8.0f;
  687. juce::Path a;
  688. a.addCentredArc (12.0f, 12.0f, r, r, 0.0f, pi * 0.25f, pi * 1.85f, true);
  689. st.addPath (a);
  690. const auto to = pi * 1.85f;
  691. const juce::Point<float> end (12.0f + r * std::sin (to), 12.0f - r * std::cos (to));
  692. const juce::Point<float> along (std::cos (to), std::sin (to)), out (std::sin (to), -std::cos (to));
  693. juce::Path h;
  694. h.addTriangle (end + along * 3.8f, end + out * 3.3f - along * 0.6f, end - out * 3.3f - along * 0.6f);
  695. fi.addPath (h);
  696. fi.addEllipse (8.5f, 8.5f, 7.0f, 7.0f);
  697. break;
  698. }
  699. case Icon::stepEdit: // three steps typed one after another (the last one hollow: the next), an arrow on to it
  700. fi.addRoundedRectangle (2.5f, 14.0f, 5.0f, 5.0f, 1.0f);
  701. fi.addRoundedRectangle (9.5f, 14.0f, 5.0f, 5.0f, 1.0f);
  702. st.addRoundedRectangle (16.5f, 14.0f, 5.0f, 5.0f, 1.0f);
  703. line (st, 5.0f, 9.0f, 17.5f, 9.0f);
  704. polyline (st, { { 15.0f, 6.0f }, { 18.5f, 9.0f }, { 15.0f, 12.0f } });
  705. break;
  706. case Icon::punch: // a record dot between two brackets (in and out)
  707. polyline (st, { { 7.0f, 4.5f }, { 4.0f, 4.5f }, { 4.0f, 19.5f }, { 7.0f, 19.5f } });
  708. polyline (st, { { 17.0f, 4.5f }, { 20.0f, 4.5f }, { 20.0f, 19.5f }, { 17.0f, 19.5f } });
  709. fi.addEllipse (8.0f, 8.0f, 8.0f, 8.0f);
  710. break;
  711. // --- round 190iv: the Simple top bar's save status, the Clip-launch control bar ---
  712. case Icon::cloud: // a cloud: two bumps on a flat base
  713. case Icon::cloudCheck: // the cloud with a check mark in it
  714. {
  715. juce::Path c;
  716. c.startNewSubPath (7.0f, 18.5f);
  717. c.lineTo (17.5f, 18.5f);
  718. c.addCentredArc (17.5f, 14.75f, 3.75f, 3.75f, 0.0f, pi, pi * 0.05f, false);
  719. c.addCentredArc (12.5f, 10.5f, 5.5f, 5.5f, 0.0f, pi * 0.42f, -pi * 0.55f, false);
  720. c.addCentredArc (7.0f, 14.5f, 4.0f, 4.0f, 0.0f, pi * 0.05f, -pi, false);
  721. c.closeSubPath();
  722. st.addPath (c);
  723. if (icon == Icon::cloudCheck)
  724. polyline (st, { { 9.5f, 14.0f }, { 11.5f, 16.0f }, { 15.0f, 12.0f } });
  725. break;
  726. }
  727. case Icon::sessionView: // three columns
  728. for (float x : { 6.0f, 11.0f, 16.0f })
  729. fi.addRectangle (x, 5.0f, 2.5f, 14.0f);
  730. break;
  731. case Icon::arrangementView: // three rows
  732. for (float y : { 6.0f, 11.0f, 16.0f })
  733. fi.addRectangle (5.0f, y, 14.0f, 2.5f);
  734. break;
  735. case Icon::backToArrangement: // an arrow into a dashed line (the clips give the Playlist back)
  736. {
  737. juce::Path head;
  738. head.addTriangle (8.0f, 8.0f, 8.0f, 16.0f, 12.5f, 12.0f);
  739. fi.addPath (head);
  740. fi.addRectangle (3.0f, 11.0f, 5.5f, 2.0f);
  741. for (float x : { 14.0f, 18.0f })
  742. fi.addRectangle (x, 11.0f, 2.5f, 2.0f);
  743. break;
  744. }
  745. case Icon::capture: // a dashed square
  746. polyline (st, { { 5.0f, 9.0f }, { 5.0f, 5.0f }, { 9.0f, 5.0f } });
  747. polyline (st, { { 15.0f, 5.0f }, { 19.0f, 5.0f }, { 19.0f, 9.0f } });
  748. polyline (st, { { 19.0f, 15.0f }, { 19.0f, 19.0f }, { 15.0f, 19.0f } });
  749. polyline (st, { { 9.0f, 19.0f }, { 5.0f, 19.0f }, { 5.0f, 15.0f } });
  750. break;
  751. case Icon::sessionRecord: // a ring
  752. st.addEllipse (6.0f, 6.0f, 12.0f, 12.0f);
  753. break;
  754. case Icon::browserPanel: // a narrow panel beside a wide one
  755. fi.addRectangle (3.5f, 5.0f, 5.5f, 14.0f);
  756. fi.addRectangle (10.5f, 5.0f, 10.0f, 14.0f);
  757. break;
  758. case Icon::metronomeDots: // a ring and a dot (the beat and the accent)
  759. st.addEllipse (3.5f, 8.0f, 8.0f, 8.0f);
  760. fi.addEllipse (13.0f, 8.0f, 8.0f, 8.0f);
  761. break;
  762. }
  763. return s;
  764. }
  765. } // namespace
  766. const Shape& get (Icon icon)
  767. {
  768. static std::map<Icon, Shape> cache;
  769. auto it = cache.find (icon);
  770. if (it == cache.end())
  771. it = cache.emplace (icon, make (icon)).first;
  772. return it->second;
  773. }
  774. float strokeWidth (float size)
  775. {
  776. // a fine line that thickens only a little with the size: 1.25 px at 14 px, 1.4 px at 20 px, 1.6 px from
  777. // 30 px (logical pixels; HiDPI screens draw it with proportionally more device pixels)
  778. return juce::jlimit (1.2f, 1.6f, 1.0f + size * 0.019f);
  779. }
  780. void draw (juce::Graphics& g, Icon icon, juce::Rectangle<float> area, juce::Colour colour)
  781. {
  782. if (icon == Icon::none || area.isEmpty())
  783. return;
  784. // a whole-pixel box on whole-pixel coordinates: the grid's half units then land on the same
  785. // sub-pixel phase on every button, so strokes look equally sharp everywhere
  786. const auto size = std::floor (juce::jmin (area.getWidth(), area.getHeight()));
  787. const auto box = juce::Rectangle<float> (std::round (area.getCentreX() - size * 0.5f), std::round (area.getCentreY() - size * 0.5f), size, size);
  788. const auto scale = size / 24.0f;
  789. const auto transform = juce::AffineTransform::scale (scale).translated (box.getX(), box.getY());
  790. const auto& shape = get (icon);
  791. g.setColour (colour);
  792. if (! shape.fill.isEmpty())
  793. g.fillPath (shape.fill, transform);
  794. if (! shape.stroke.isEmpty())
  795. g.strokePath (shape.stroke, juce::PathStrokeType (strokeWidth (size), juce::PathStrokeType::curved, juce::PathStrokeType::rounded), transform);
  796. }
  797. } // namespace icons
  798. IconButton::IconButton (const juce::String& name, Icon i, const juce::String& t)
  799. : juce::Button (name), icon (i), text (t), onColour (theme::colour::accent), iconOnColour (theme::colour::onAccent)
  800. {
  801. setMouseCursor (juce::MouseCursor::PointingHandCursor);
  802. }
  803. void IconButton::setIconSizing (float fraction, float maxPx)
  804. {
  805. if (fraction != iconFraction || maxPx != iconMax)
  806. {
  807. iconFraction = fraction;
  808. iconMax = maxPx;
  809. repaint();
  810. }
  811. }
  812. void IconButton::setIcon (Icon newIcon)
  813. {
  814. if (icon != newIcon)
  815. {
  816. icon = newIcon;
  817. repaint();
  818. }
  819. }
  820. void IconButton::setText (const juce::String& newText)
  821. {
  822. if (text != newText)
  823. {
  824. text = newText;
  825. repaint();
  826. }
  827. }
  828. void IconButton::setPrimary (bool b) { primary = b; repaint(); }
  829. void IconButton::setOnColour (juce::Colour c) { onColour = c; onColoursSet = true; repaint(); }
  830. void IconButton::setIconColourWhenOn (juce::Colour c) { iconOnColour = c; onColoursSet = true; repaint(); }
  831. void IconButton::setToggleLook (bool isSwitch) { toggleLook = isSwitch ? 1 : 0; repaint(); }
  832. bool IconButton::actsAsSwitch() const
  833. {
  834. return toggleLook >= 0 ? toggleLook == 1 : (isToggleable() || getRadioGroupId() != 0 || onColoursSet);
  835. }
  836. void IconButton::setFlat (bool b) { flat = b; repaint(); }
  837. void IconButton::setIconColour (juce::Colour c) { iconColour = c; repaint(); }
  838. void IconButton::setCorners (bool left, bool right)
  839. {
  840. roundLeft = left;
  841. roundRight = right;
  842. repaint();
  843. }
  844. void IconButton::mouseDown (const juce::MouseEvent& e)
  845. {
  846. if (e.mods.isPopupMenu() && onRightClick != nullptr)
  847. return; // handled on mouse up, without pressing the button
  848. juce::Button::mouseDown (e);
  849. }
  850. void IconButton::mouseUp (const juce::MouseEvent& e)
  851. {
  852. if (e.mods.isPopupMenu() && onRightClick != nullptr)
  853. {
  854. if (getLocalBounds().contains (e.getPosition()))
  855. onRightClick();
  856. return;
  857. }
  858. juce::Button::mouseUp (e);
  859. }
  860. void IconButton::mouseDoubleClick (const juce::MouseEvent& e)
  861. {
  862. if (onDoubleClick != nullptr && ! e.mods.isPopupMenu())
  863. onDoubleClick();
  864. }
  865. int IconButton::getIdealWidth (int height) const
  866. {
  867. const auto iconSize = icon == Icon::none ? 0 : juce::roundToInt (height * 0.55f);
  868. const auto textWidth = text.isEmpty() ? 0
  869. : juce::roundToInt (juce::GlyphArrangement::getStringWidth (juce::Font (theme::font (theme::type::body)), text));
  870. const auto gap = iconSize > 0 && textWidth > 0 ? 6 : 0;
  871. return juce::jmax (height, iconSize + gap + textWidth + (textWidth > 0 ? 20 : 0));
  872. }
  873. void IconButton::buttonStateChanged()
  874. {
  875. juce::Button::buttonStateChanged();
  876. const auto target = isOver() || isDown() ? 1.0f : 0.0f;
  877. if (! ui::motion::enabled()) // Settings › General › Animations off: no fade, no timer
  878. {
  879. stopTimer();
  880. hover = target;
  881. return;
  882. }
  883. if (target != hover && ! isTimerRunning())
  884. startTimerHz (60);
  885. }
  886. void IconButton::timerCallback()
  887. {
  888. const auto target = isOver() || isDown() ? 1.0f : 0.0f;
  889. const auto step = target > hover ? 0.34f : 0.18f; // in quickly, out a little slower
  890. hover = target > hover ? juce::jmin (target, hover + step) : juce::jmax (target, hover - step);
  891. if (hover == target)
  892. stopTimer();
  893. repaint();
  894. }
  895. void IconButton::setLook (Look newLook, float iconBoxPx)
  896. {
  897. if (newLook == look && iconBoxPx == lookIconBox)
  898. return;
  899. look = newLook;
  900. lookIconBox = iconBoxPx;
  901. repaint();
  902. }
  903. // Round 190iv: the Simple capsule segment and Live's control-bar boxes (Icons.h, IconButton::Look)
  904. void IconButton::paintLook (juce::Graphics& g, bool highlighted, bool down)
  905. {
  906. using namespace theme;
  907. const auto on = getToggleState();
  908. const auto enabled = isEnabled();
  909. const auto area = getLocalBounds().toFloat();
  910. const auto h = isTimerRunning() ? hover : (highlighted ? 1.0f : 0.0f);
  911. juce::Colour fg;
  912. if (look == Look::capsule)
  913. {
  914. // the capsule (drawn behind) is bg4; a segment shows hover and press only (SG-1: hover bg5, pressed bg6;
  915. // recording: the Record segment filled accentMuted)
  916. juce::Colour bg;
  917. if (down)
  918. bg = colour::bg6;
  919. else if (on && icon == Icon::record)
  920. bg = colour::accentMuted;
  921. else if (h > 0.0f)
  922. bg = colour::bg5.withAlpha (h);
  923. if (! bg.isTransparent())
  924. {
  925. // (the capsule's round ends: the first segment rounds its left, the last its right; setCorners)
  926. const auto r = area.getHeight() / 2.0f;
  927. juce::Path p;
  928. p.addRoundedRectangle (area.getX(), area.getY(), area.getWidth(), area.getHeight(), r, r, roundLeft, roundRight, roundLeft, roundRight);
  929. g.setColour (bg);
  930. g.fillPath (p);
  931. }
  932. fg = icon == Icon::record ? colour::record : (on ? colour::accent : colour::textPrimary);
  933. }
  934. else if (look == Look::liveBox)
  935. {
  936. // Live 12.4 (CL-2, ref/live-session.png): #363636 boxes, hover #464646, pressed #1e1e1e, lit #ffad56
  937. const juce::Colour rest { 0xff363636 }, over { 0xff464646 }, pressed { 0xff1e1e1e }, lit { 0xffffad56 };
  938. g.setColour (down ? pressed : on ? lit : rest.interpolatedWith (over, h));
  939. g.fillRect (area);
  940. fg = on && ! down ? juce::Colour (0xff070707) : juce::Colour (0xffb5b5b5).interpolatedWith (juce::Colours::white, h * 0.35f);
  941. }
  942. else if (look == Look::liveSelector)
  943. {
  944. // (ref/live-session.png x 1870..1900: the shown view's glyph #ffad56; Live's other glyph is #464646, 1.5:1 on the
  945. // band; LYNX keeps it at 3.4:1, the contrast floor of design190ia G1)
  946. fg = on ? juce::Colour (0xffffad56) : juce::Colour (0xff7a7a7a).interpolatedWith (juce::Colour (0xffb5b5b5), h);
  947. }
  948. else // liveGlyph: the bare transport glyphs on the band
  949. {
  950. const juce::Colour glyph { 0xffb5b5b5 };
  951. fg = on ? (icon == Icon::record ? colour::record : juce::Colour (0xff00d38d)) // (Live's playing green, CL token table)
  952. : glyph.interpolatedWith (juce::Colours::white, h * 0.35f);
  953. if (down)
  954. fg = fg.darker (0.3f);
  955. }
  956. if (! enabled)
  957. fg = juce::Colour (0xff696969);
  958. const auto box = lookIconBox > 0.0f ? lookIconBox : juce::jmin (area.getHeight() * iconFraction, iconMax);
  959. if (text.isEmpty())
  960. {
  961. icons::draw (g, icon, area.withSizeKeepingCentre (box, box), fg);
  962. return;
  963. }
  964. // a text box (Live's "Tap", "Key", "MIDI"): the small type, centred, the icon (if any) before it
  965. const auto f = theme::font (type::caption);
  966. auto content = area.reduced (3.0f, 0.0f);
  967. if (icon != Icon::none)
  968. {
  969. icons::draw (g, icon, content.removeFromLeft (box).withSizeKeepingCentre (box, box), fg);
  970. content.removeFromLeft (3.0f);
  971. }
  972. g.setColour (fg);
  973. g.setFont (f);
  974. g.drawFittedText (text, content.toNearestInt(), icon == Icon::none ? juce::Justification::centred : juce::Justification::centredLeft, 1, 0.8f);
  975. }
  976. void IconButton::paintButton (juce::Graphics& g, bool highlighted, bool down)
  977. {
  978. using namespace theme;
  979. if (look != Look::standard)
  980. {
  981. paintLook (g, highlighted, down);
  982. return;
  983. }
  984. const auto bounds = getLocalBounds().toFloat().reduced (0.5f);
  985. const auto on = getToggleState() || primary;
  986. const auto enabled = isEnabled();
  987. // the animated hover level (snaps to the state when nothing animates, e.g. in snapshots)
  988. const auto h = ! enabled ? 0.0f : isTimerRunning() ? hover : (highlighted ? 1.0f : 0.0f);
  989. const auto isSwitch = actsAsSwitch();
  990. // one state rule for every button kind (round 190je, core/ThemePalette.h buttonLook)
  991. const auto kind = ! flat ? themes::ButtonKind::secondary : isSwitch ? themes::ButtonKind::flatToggle : themes::ButtonKind::flatMomentary;
  992. auto state = buttonColours (kind, on, h, down, enabled);
  993. const auto ownOn = onColour != colour::accent; // a button with "on" colours of its own (bg6 + a red icon, a wash)
  994. if (on && enabled && (ownOn || flat))
  995. {
  996. state.fill = down ? colour::accentPressed : onColour.interpolatedWith (onColour.brighter (0.12f), h);
  997. state.edge = {};
  998. }
  999. else if (on && ! enabled && (ownOn || flat))
  1000. state.fill = onColour.withMultipliedAlpha (0.5f);
  1001. else if (enabled && ! on && ! down && isSwitch && flat && ownOn)
  1002. {
  1003. // the preview of this switch's own "on" look (bg6 with a red icon, a wash)
  1004. state.fill = onColour.withMultipliedAlpha (0.7f * h);
  1005. state.edge = iconOnColour.withAlpha (0.5f * h);
  1006. }
  1007. // the icon / text: as at rest before (a light grey), towards white under the mouse, towards the "on" colour on a switch
  1008. const auto idleFg = ! iconColour.isTransparent() ? iconColour : colour::textSecondary.brighter (0.25f);
  1009. const auto hoverFg = isSwitch && flat ? (ownOn ? iconOnColour : colour::accentHover)
  1010. : (! iconColour.isTransparent() ? iconColour.brighter (0.2f) : colour::textPrimary);
  1011. state.content = ! enabled ? colour::textDisabled : on ? iconOnColour : idleFg.interpolatedWith (down ? colour::textPrimary : hoverFg, down ? 1.0f : h);
  1012. if (! state.fill.isTransparent() || ! state.edge.isTransparent())
  1013. {
  1014. juce::Path p;
  1015. p.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md,
  1016. roundLeft, roundRight, roundLeft, roundRight);
  1017. if (! state.fill.isTransparent())
  1018. {
  1019. g.setColour (state.fill);
  1020. g.fillPath (p);
  1021. }
  1022. if (! state.edge.isTransparent())
  1023. {
  1024. juce::Path edge; // (on the pixel centres: `bounds` is inset by half a pixel, a crisp 1 px line)
  1025. edge.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md,
  1026. roundLeft, roundRight, roundLeft, roundRight);
  1027. g.setColour (state.edge);
  1028. g.strokePath (edge, juce::PathStrokeType (1.0f));
  1029. }
  1030. }
  1031. const auto fg = state.content;
  1032. auto area = getLocalBounds().toFloat();
  1033. const auto iconSize = juce::jmin (area.getHeight() * iconFraction, iconMax);
  1034. if (text.isEmpty())
  1035. {
  1036. icons::draw (g, icon, area.withSizeKeepingCentre (iconSize, iconSize), fg);
  1037. return;
  1038. }
  1039. const auto font = juce::Font (theme::font (type::body));
  1040. const auto textWidth = juce::GlyphArrangement::getStringWidth (font, text);
  1041. const auto gap = icon == Icon::none ? 0.0f : 6.0f;
  1042. const auto contentWidth = juce::jmin (area.getWidth() - 12.0f, (icon == Icon::none ? 0.0f : iconSize) + gap + textWidth);
  1043. auto content = area.withSizeKeepingCentre (contentWidth, area.getHeight());
  1044. if (icon != Icon::none)
  1045. icons::draw (g, icon, content.removeFromLeft (iconSize).withSizeKeepingCentre (iconSize, iconSize), fg);
  1046. content.removeFromLeft (gap);
  1047. g.setColour (fg);
  1048. g.setFont (font);
  1049. g.drawFittedText (text, content.toNearestInt(), juce::Justification::centredLeft, 1, 0.85f);
  1050. }
  1051. } // namespace lynx