You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

620 lines
16KB

  1. #pragma once
  2. #include "rack.hpp"
  3. namespace rack {
  4. /** Component Library by [Grayscale](https://grayscale.info/).
  5. Copied from `LICENSE.md`:
  6. The **Component Library graphics** in the `res/ComponentLibrary` directory are copyright © 2019 [Grayscale](http://grayscale.info/) and licensed under [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/).
  7. You may not freely sell plugins using Component Library graphics.
  8. However, a free commercial license is available for plugins sold through the [VCV Store](https://vcvrack.com/plugins.html).
  9. Email contact@vcvrack.com for more information about licensing or the VCV Store.
  10. */
  11. namespace component {
  12. ////////////////////
  13. // Color scheme
  14. ////////////////////
  15. static const NVGcolor BLACK_TRANSPARENT = nvgRGBA(0x00, 0x00, 0x00, 0x00);
  16. static const NVGcolor BLACK = nvgRGB(0x00, 0x00, 0x00);
  17. static const NVGcolor WHITE = nvgRGB(0xff, 0xff, 0xff);
  18. static const NVGcolor RED = nvgRGB(0xed, 0x2c, 0x24);
  19. static const NVGcolor ORANGE = nvgRGB(0xf2, 0xb1, 0x20);
  20. static const NVGcolor YELLOW = nvgRGB(0xf9, 0xdf, 0x1c);
  21. static const NVGcolor GREEN = nvgRGB(0x90, 0xc7, 0x3e);
  22. static const NVGcolor CYAN = nvgRGB(0x22, 0xe6, 0xef);
  23. static const NVGcolor BLUE = nvgRGB(0x29, 0xb2, 0xef);
  24. static const NVGcolor PURPLE = nvgRGB(0xd5, 0x2b, 0xed);
  25. static const NVGcolor LIGHT_GRAY = nvgRGB(0xe6, 0xe6, 0xe6);
  26. static const NVGcolor DARK_GRAY = nvgRGB(0x17, 0x17, 0x17);
  27. ////////////////////
  28. // Knobs
  29. ////////////////////
  30. struct RoundKnob : app::SvgKnob {
  31. RoundKnob() {
  32. minAngle = -0.83*M_PI;
  33. maxAngle = 0.83*M_PI;
  34. }
  35. };
  36. struct RoundBlackKnob : RoundKnob {
  37. RoundBlackKnob() {
  38. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundBlackKnob.svg")));
  39. }
  40. };
  41. struct RoundSmallBlackKnob : RoundKnob {
  42. RoundSmallBlackKnob() {
  43. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundSmallBlackKnob.svg")));
  44. }
  45. };
  46. struct RoundLargeBlackKnob : RoundKnob {
  47. RoundLargeBlackKnob() {
  48. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundLargeBlackKnob.svg")));
  49. }
  50. };
  51. struct RoundHugeBlackKnob : RoundKnob {
  52. RoundHugeBlackKnob() {
  53. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/RoundHugeBlackKnob.svg")));
  54. }
  55. };
  56. struct RoundBlackSnapKnob : RoundBlackKnob {
  57. RoundBlackSnapKnob() {
  58. snap = true;
  59. }
  60. };
  61. struct Davies1900hKnob : app::SvgKnob {
  62. Davies1900hKnob() {
  63. minAngle = -0.83*M_PI;
  64. maxAngle = 0.83*M_PI;
  65. }
  66. };
  67. struct Davies1900hWhiteKnob : Davies1900hKnob {
  68. Davies1900hWhiteKnob() {
  69. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hWhite.svg")));
  70. }
  71. };
  72. struct Davies1900hBlackKnob : Davies1900hKnob {
  73. Davies1900hBlackKnob() {
  74. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hBlack.svg")));
  75. }
  76. };
  77. struct Davies1900hRedKnob : Davies1900hKnob {
  78. Davies1900hRedKnob() {
  79. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hRed.svg")));
  80. }
  81. };
  82. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  83. Davies1900hLargeWhiteKnob() {
  84. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
  85. }
  86. };
  87. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  88. Davies1900hLargeBlackKnob() {
  89. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
  90. }
  91. };
  92. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  93. Davies1900hLargeRedKnob() {
  94. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Davies1900hLargeRed.svg")));
  95. }
  96. };
  97. struct Rogan : app::SvgKnob {
  98. Rogan() {
  99. minAngle = -0.83*M_PI;
  100. maxAngle = 0.83*M_PI;
  101. }
  102. };
  103. struct Rogan6PSWhite : Rogan {
  104. Rogan6PSWhite() {
  105. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg")));
  106. }
  107. };
  108. struct Rogan5PSGray : Rogan {
  109. Rogan5PSGray() {
  110. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan5PSGray.svg")));
  111. }
  112. };
  113. struct Rogan3PSBlue : Rogan {
  114. Rogan3PSBlue() {
  115. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg")));
  116. }
  117. };
  118. struct Rogan3PSRed : Rogan {
  119. Rogan3PSRed() {
  120. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSRed.svg")));
  121. }
  122. };
  123. struct Rogan3PSGreen : Rogan {
  124. Rogan3PSGreen() {
  125. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg")));
  126. }
  127. };
  128. struct Rogan3PSWhite : Rogan {
  129. Rogan3PSWhite() {
  130. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg")));
  131. }
  132. };
  133. struct Rogan3PBlue : Rogan {
  134. Rogan3PBlue() {
  135. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PBlue.svg")));
  136. }
  137. };
  138. struct Rogan3PRed : Rogan {
  139. Rogan3PRed() {
  140. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PRed.svg")));
  141. }
  142. };
  143. struct Rogan3PGreen : Rogan {
  144. Rogan3PGreen() {
  145. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PGreen.svg")));
  146. }
  147. };
  148. struct Rogan3PWhite : Rogan {
  149. Rogan3PWhite() {
  150. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan3PWhite.svg")));
  151. }
  152. };
  153. struct Rogan2SGray : Rogan {
  154. Rogan2SGray() {
  155. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2SGray.svg")));
  156. }
  157. };
  158. struct Rogan2PSBlue : Rogan {
  159. Rogan2PSBlue() {
  160. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg")));
  161. }
  162. };
  163. struct Rogan2PSRed : Rogan {
  164. Rogan2PSRed() {
  165. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSRed.svg")));
  166. }
  167. };
  168. struct Rogan2PSGreen : Rogan {
  169. Rogan2PSGreen() {
  170. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg")));
  171. }
  172. };
  173. struct Rogan2PSWhite : Rogan {
  174. Rogan2PSWhite() {
  175. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg")));
  176. }
  177. };
  178. struct Rogan2PBlue : Rogan {
  179. Rogan2PBlue() {
  180. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PBlue.svg")));
  181. }
  182. };
  183. struct Rogan2PRed : Rogan {
  184. Rogan2PRed() {
  185. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PRed.svg")));
  186. }
  187. };
  188. struct Rogan2PGreen : Rogan {
  189. Rogan2PGreen() {
  190. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PGreen.svg")));
  191. }
  192. };
  193. struct Rogan2PWhite : Rogan {
  194. Rogan2PWhite() {
  195. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan2PWhite.svg")));
  196. }
  197. };
  198. struct Rogan1PSBlue : Rogan {
  199. Rogan1PSBlue() {
  200. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg")));
  201. }
  202. };
  203. struct Rogan1PSRed : Rogan {
  204. Rogan1PSRed() {
  205. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSRed.svg")));
  206. }
  207. };
  208. struct Rogan1PSGreen : Rogan {
  209. Rogan1PSGreen() {
  210. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg")));
  211. }
  212. };
  213. struct Rogan1PSWhite : Rogan {
  214. Rogan1PSWhite() {
  215. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg")));
  216. }
  217. };
  218. struct Rogan1PBlue : Rogan {
  219. Rogan1PBlue() {
  220. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PBlue.svg")));
  221. }
  222. };
  223. struct Rogan1PRed : Rogan {
  224. Rogan1PRed() {
  225. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PRed.svg")));
  226. }
  227. };
  228. struct Rogan1PGreen : Rogan {
  229. Rogan1PGreen() {
  230. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PGreen.svg")));
  231. }
  232. };
  233. struct Rogan1PWhite : Rogan {
  234. Rogan1PWhite() {
  235. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Rogan1PWhite.svg")));
  236. }
  237. };
  238. struct SynthTechAlco : app::SvgKnob {
  239. SynthTechAlco() {
  240. minAngle = -0.82*M_PI;
  241. maxAngle = 0.82*M_PI;
  242. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg")));
  243. SvgWidget *cap = new SvgWidget;
  244. cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg")));
  245. addChild(cap);
  246. }
  247. };
  248. struct Trimpot : app::SvgKnob {
  249. Trimpot() {
  250. minAngle = -0.75*M_PI;
  251. maxAngle = 0.75*M_PI;
  252. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg")));
  253. }
  254. };
  255. struct BefacoBigKnob : app::SvgKnob {
  256. BefacoBigKnob() {
  257. minAngle = -0.75*M_PI;
  258. maxAngle = 0.75*M_PI;
  259. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg")));
  260. }
  261. };
  262. struct BefacoBigSnapKnob : BefacoBigKnob {
  263. BefacoBigSnapKnob() {
  264. snap = true;
  265. }
  266. };
  267. struct BefacoTinyKnob : app::SvgKnob {
  268. BefacoTinyKnob() {
  269. minAngle = -0.75*M_PI;
  270. maxAngle = 0.75*M_PI;
  271. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg")));
  272. }
  273. };
  274. struct BefacoSlidePot : app::SvgSlider {
  275. BefacoSlidePot() {
  276. math::Vec margin = math::Vec(3.5, 3.5);
  277. maxHandlePos = math::Vec(-1, -2).plus(margin);
  278. minHandlePos = math::Vec(-1, 87).plus(margin);
  279. setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")));
  280. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
  281. background->box.pos = margin;
  282. box.size = background->box.size.plus(margin.mult(2));
  283. }
  284. };
  285. struct LEDSlider : app::SvgSlider {
  286. LEDSlider() {
  287. maxHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0)));
  288. minHandlePos = mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0)));
  289. setBackgroundSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSlider.svg")));
  290. }
  291. };
  292. /** API is unstable for LEDSlider. Will add a LightWidget later. */
  293. struct LEDSliderGreen : LEDSlider {
  294. LEDSliderGreen() {
  295. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
  296. }
  297. };
  298. struct LEDSliderRed : LEDSlider {
  299. LEDSliderRed() {
  300. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg")));
  301. }
  302. };
  303. struct LEDSliderYellow : LEDSlider {
  304. LEDSliderYellow() {
  305. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
  306. }
  307. };
  308. struct LEDSliderBlue : LEDSlider {
  309. LEDSliderBlue() {
  310. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
  311. }
  312. };
  313. struct LEDSliderWhite : LEDSlider {
  314. LEDSliderWhite() {
  315. setHandleSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
  316. }
  317. };
  318. ////////////////////
  319. // Ports
  320. ////////////////////
  321. struct PJ301MPort : app::SvgPort {
  322. PJ301MPort() {
  323. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ301M.svg")));
  324. }
  325. };
  326. struct PJ3410Port : app::SvgPort {
  327. PJ3410Port() {
  328. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/PJ3410.svg")));
  329. }
  330. };
  331. struct CL1362Port : app::SvgPort {
  332. CL1362Port() {
  333. setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/CL1362.svg")));
  334. }
  335. };
  336. ////////////////////
  337. // Lights
  338. ////////////////////
  339. struct GrayModuleLightWidget : app::ModuleLightWidget {
  340. GrayModuleLightWidget() {
  341. bgColor = nvgRGB(0x5a, 0x5a, 0x5a);
  342. borderColor = nvgRGBA(0, 0, 0, 0x60);
  343. }
  344. };
  345. struct RedLight : GrayModuleLightWidget {
  346. RedLight() {
  347. addBaseColor(RED);
  348. }
  349. };
  350. struct GreenLight : GrayModuleLightWidget {
  351. GreenLight() {
  352. addBaseColor(GREEN);
  353. }
  354. };
  355. struct YellowLight : GrayModuleLightWidget {
  356. YellowLight() {
  357. addBaseColor(YELLOW);
  358. }
  359. };
  360. struct BlueLight : GrayModuleLightWidget {
  361. BlueLight() {
  362. addBaseColor(BLUE);
  363. }
  364. };
  365. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  366. struct GreenRedLight : GrayModuleLightWidget {
  367. GreenRedLight() {
  368. addBaseColor(GREEN);
  369. addBaseColor(RED);
  370. }
  371. };
  372. struct RedGreenBlueLight : GrayModuleLightWidget {
  373. RedGreenBlueLight() {
  374. addBaseColor(RED);
  375. addBaseColor(GREEN);
  376. addBaseColor(BLUE);
  377. }
  378. };
  379. struct RGBLight : app::ModuleLightWidget {
  380. RGBLight() {
  381. addBaseColor(nvgRGBf(1, 0, 0));
  382. addBaseColor(nvgRGBf(0, 1, 0));
  383. addBaseColor(nvgRGBf(0, 0, 1));
  384. }
  385. };
  386. /** Based on the size of 5mm LEDs */
  387. template <typename BASE>
  388. struct LargeLight : BASE {
  389. LargeLight() {
  390. this->box.size = mm2px(math::Vec(5.179, 5.179));
  391. }
  392. };
  393. /** Based on the size of 3mm LEDs */
  394. template <typename BASE>
  395. struct MediumLight : BASE {
  396. MediumLight() {
  397. this->box.size = mm2px(math::Vec(3.176, 3.176));
  398. }
  399. };
  400. /** Based on the size of 2mm LEDs */
  401. template <typename BASE>
  402. struct SmallLight : BASE {
  403. SmallLight() {
  404. this->box.size = mm2px(math::Vec(2.176, 2.176));
  405. }
  406. };
  407. /** Based on the size of 1mm LEDs */
  408. template <typename BASE>
  409. struct TinyLight : BASE {
  410. TinyLight() {
  411. this->box.size = mm2px(math::Vec(1.088, 1.088));
  412. }
  413. };
  414. /** A light to displayed over PB61303. Must add a color by subclassing or templating. */
  415. template <typename BASE>
  416. struct LEDBezelLight : BASE {
  417. LEDBezelLight() {
  418. this->bgColor = color::BLACK_TRANSPARENT;
  419. this->box.size = mm2px(math::Vec(6.0, 6.0));
  420. }
  421. };
  422. /** A light to displayed over PB61303. Must add a color by subclassing or templating.
  423. Don't add this as a child of the PB61303 itself. Instead, just place it over it as a sibling in the scene graph, offset by mm2px(math::Vec(0.5, 0.5)).
  424. */
  425. template <typename BASE>
  426. struct PB61303Light : BASE {
  427. PB61303Light() {
  428. this->bgColor = color::BLACK_TRANSPARENT;
  429. this->box.size = mm2px(math::Vec(9.0, 9.0));
  430. }
  431. };
  432. ////////////////////
  433. // Switches
  434. ////////////////////
  435. struct NKK : app::SvgSwitch {
  436. NKK() {
  437. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_0.svg")));
  438. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_1.svg")));
  439. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/NKK_2.svg")));
  440. }
  441. };
  442. struct CKSS : app::SvgSwitch {
  443. CKSS() {
  444. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_0.svg")));
  445. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSS_1.svg")));
  446. }
  447. };
  448. struct CKSSThree : app::SvgSwitch {
  449. CKSSThree() {
  450. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_0.svg")));
  451. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_1.svg")));
  452. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKSSThree_2.svg")));
  453. }
  454. };
  455. struct CKD6 : app::SvgSwitch {
  456. CKD6() {
  457. momentary = true;
  458. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_0.svg")));
  459. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/CKD6_1.svg")));
  460. }
  461. };
  462. struct TL1105 : app::SvgSwitch {
  463. TL1105() {
  464. momentary = true;
  465. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_0.svg")));
  466. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/TL1105_1.svg")));
  467. }
  468. };
  469. struct LEDButton : app::SvgSwitch {
  470. LEDButton() {
  471. momentary = true;
  472. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDButton.svg")));
  473. }
  474. };
  475. struct BefacoSwitch : app::SvgSwitch {
  476. BefacoSwitch() {
  477. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_0.svg")));
  478. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_1.svg")));
  479. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoSwitch_2.svg")));
  480. }
  481. };
  482. struct BefacoPush : app::SvgSwitch {
  483. BefacoPush() {
  484. momentary = true;
  485. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_0.svg")));
  486. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoPush_1.svg")));
  487. }
  488. };
  489. struct LEDBezel : app::SvgSwitch {
  490. LEDBezel() {
  491. momentary = true;
  492. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/LEDBezel.svg")));
  493. }
  494. };
  495. struct PB61303 : app::SvgSwitch {
  496. PB61303() {
  497. momentary = true;
  498. addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/PB61303.svg")));
  499. }
  500. };
  501. ////////////////////
  502. // Misc
  503. ////////////////////
  504. struct ScrewSilver : app::SvgScrew {
  505. ScrewSilver() {
  506. sw->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewSilver.svg")));
  507. box.size = sw->box.size;
  508. }
  509. };
  510. struct ScrewBlack : app::SvgScrew {
  511. ScrewBlack() {
  512. sw->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/ScrewBlack.svg")));
  513. box.size = sw->box.size;
  514. }
  515. };
  516. } // namespace component
  517. } // namespace rack