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.

componentlibrary.hpp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #pragma once
  2. #include "app.hpp"
  3. #include "asset.hpp"
  4. namespace rack {
  5. ////////////////////
  6. // Colors
  7. ////////////////////
  8. static const NVGcolor COLOR_BLACK_TRANSPARENT = nvgRGBA(0x00, 0x00, 0x00, 0x00);
  9. static const NVGcolor COLOR_BLACK = nvgRGB(0x00, 0x00, 0x00);
  10. static const NVGcolor COLOR_WHITE = nvgRGB(0xff, 0xff, 0xff);
  11. static const NVGcolor COLOR_RED = nvgRGB(0xed, 0x2c, 0x24);
  12. static const NVGcolor COLOR_ORANGE = nvgRGB(0xf2, 0xb1, 0x20);
  13. static const NVGcolor COLOR_YELLOW = nvgRGB(0xf9, 0xdf, 0x1c);
  14. static const NVGcolor COLOR_GREEN = nvgRGB(0x90, 0xc7, 0x3e);
  15. static const NVGcolor COLOR_CYAN = nvgRGB(0x22, 0xe6, 0xef);
  16. static const NVGcolor COLOR_BLUE = nvgRGB(0x29, 0xb2, 0xef);
  17. static const NVGcolor COLOR_PURPLE = nvgRGB(0xd5, 0x2b, 0xed);
  18. static const NVGcolor COLOR_LIGHT_PANEL = nvgRGB(0xe6, 0xe6, 0xe6);
  19. static const NVGcolor COLOR_DARK_PANEL = nvgRGB(0x17, 0x17, 0x17);
  20. ////////////////////
  21. // Knobs
  22. ////////////////////
  23. struct RoundKnob : SVGKnob {
  24. RoundKnob() {
  25. minAngle = -0.83*M_PI;
  26. maxAngle = 0.83*M_PI;
  27. }
  28. };
  29. struct RoundBlackKnob : RoundKnob {
  30. RoundBlackKnob() {
  31. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/RoundBlack.svg")));
  32. box.size = Vec(38, 38);
  33. }
  34. };
  35. struct RoundSmallBlackKnob : RoundBlackKnob {
  36. RoundSmallBlackKnob() {
  37. box.size = Vec(28, 28);
  38. }
  39. };
  40. struct RoundLargeBlackKnob : RoundBlackKnob {
  41. RoundLargeBlackKnob() {
  42. box.size = Vec(46, 46);
  43. }
  44. };
  45. struct RoundHugeBlackKnob : RoundBlackKnob {
  46. RoundHugeBlackKnob() {
  47. box.size = Vec(56, 56);
  48. }
  49. };
  50. struct RoundSmallBlackSnapKnob : RoundSmallBlackKnob {
  51. RoundSmallBlackSnapKnob() {
  52. snap = true;
  53. }
  54. };
  55. struct Davies1900hKnob : SVGKnob {
  56. Davies1900hKnob() {
  57. minAngle = -0.83*M_PI;
  58. maxAngle = 0.83*M_PI;
  59. }
  60. };
  61. struct Davies1900hWhiteKnob : Davies1900hKnob {
  62. Davies1900hWhiteKnob() {
  63. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hWhite.svg")));
  64. }
  65. };
  66. struct Davies1900hBlackKnob : Davies1900hKnob {
  67. Davies1900hBlackKnob() {
  68. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hBlack.svg")));
  69. }
  70. };
  71. struct Davies1900hRedKnob : Davies1900hKnob {
  72. Davies1900hRedKnob() {
  73. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hRed.svg")));
  74. }
  75. };
  76. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  77. Davies1900hLargeWhiteKnob() {
  78. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
  79. }
  80. };
  81. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  82. Davies1900hLargeBlackKnob() {
  83. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
  84. }
  85. };
  86. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  87. Davies1900hLargeRedKnob() {
  88. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeRed.svg")));
  89. }
  90. };
  91. struct Rogan : SVGKnob {
  92. Rogan() {
  93. minAngle = -0.83*M_PI;
  94. maxAngle = 0.83*M_PI;
  95. }
  96. };
  97. struct Rogan6PSWhite : Rogan {
  98. Rogan6PSWhite() {
  99. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan6PSWhite.svg")));
  100. }
  101. };
  102. struct Rogan5PSGray : Rogan {
  103. Rogan5PSGray() {
  104. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan5PSGray.svg")));
  105. }
  106. };
  107. struct Rogan3PSBlue : Rogan {
  108. Rogan3PSBlue() {
  109. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSBlue.svg")));
  110. }
  111. };
  112. struct Rogan3PSRed : Rogan {
  113. Rogan3PSRed() {
  114. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSRed.svg")));
  115. }
  116. };
  117. struct Rogan3PSGreen : Rogan {
  118. Rogan3PSGreen() {
  119. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSGreen.svg")));
  120. }
  121. };
  122. struct Rogan3PSWhite : Rogan {
  123. Rogan3PSWhite() {
  124. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSWhite.svg")));
  125. }
  126. };
  127. struct Rogan3PBlue : Rogan {
  128. Rogan3PBlue() {
  129. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PBlue.svg")));
  130. }
  131. };
  132. struct Rogan3PRed : Rogan {
  133. Rogan3PRed() {
  134. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PRed.svg")));
  135. }
  136. };
  137. struct Rogan3PGreen : Rogan {
  138. Rogan3PGreen() {
  139. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PGreen.svg")));
  140. }
  141. };
  142. struct Rogan3PWhite : Rogan {
  143. Rogan3PWhite() {
  144. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PWhite.svg")));
  145. }
  146. };
  147. struct Rogan2SGray : Rogan {
  148. Rogan2SGray() {
  149. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2SGray.svg")));
  150. }
  151. };
  152. struct Rogan2PSBlue : Rogan {
  153. Rogan2PSBlue() {
  154. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSBlue.svg")));
  155. }
  156. };
  157. struct Rogan2PSRed : Rogan {
  158. Rogan2PSRed() {
  159. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSRed.svg")));
  160. }
  161. };
  162. struct Rogan2PSGreen : Rogan {
  163. Rogan2PSGreen() {
  164. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSGreen.svg")));
  165. }
  166. };
  167. struct Rogan2PSWhite : Rogan {
  168. Rogan2PSWhite() {
  169. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSWhite.svg")));
  170. }
  171. };
  172. struct Rogan2PBlue : Rogan {
  173. Rogan2PBlue() {
  174. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PBlue.svg")));
  175. }
  176. };
  177. struct Rogan2PRed : Rogan {
  178. Rogan2PRed() {
  179. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PRed.svg")));
  180. }
  181. };
  182. struct Rogan2PGreen : Rogan {
  183. Rogan2PGreen() {
  184. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PGreen.svg")));
  185. }
  186. };
  187. struct Rogan2PWhite : Rogan {
  188. Rogan2PWhite() {
  189. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PWhite.svg")));
  190. }
  191. };
  192. struct Rogan1PSBlue : Rogan {
  193. Rogan1PSBlue() {
  194. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSBlue.svg")));
  195. }
  196. };
  197. struct Rogan1PSRed : Rogan {
  198. Rogan1PSRed() {
  199. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSRed.svg")));
  200. }
  201. };
  202. struct Rogan1PSGreen : Rogan {
  203. Rogan1PSGreen() {
  204. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSGreen.svg")));
  205. }
  206. };
  207. struct Rogan1PSWhite : Rogan {
  208. Rogan1PSWhite() {
  209. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSWhite.svg")));
  210. }
  211. };
  212. struct Rogan1PBlue : Rogan {
  213. Rogan1PBlue() {
  214. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PBlue.svg")));
  215. }
  216. };
  217. struct Rogan1PRed : Rogan {
  218. Rogan1PRed() {
  219. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PRed.svg")));
  220. }
  221. };
  222. struct Rogan1PGreen : Rogan {
  223. Rogan1PGreen() {
  224. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PGreen.svg")));
  225. }
  226. };
  227. struct Rogan1PWhite : Rogan {
  228. Rogan1PWhite() {
  229. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PWhite.svg")));
  230. }
  231. };
  232. struct SynthTechAlco : SVGKnob {
  233. SynthTechAlco() {
  234. minAngle = -0.82*M_PI;
  235. maxAngle = 0.82*M_PI;
  236. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/SynthTechAlco.svg")));
  237. SVGWidget *cap = new SVGWidget();
  238. cap->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/SynthTechAlco_cap.svg")));
  239. addChild(cap);
  240. }
  241. };
  242. struct Trimpot : SVGKnob {
  243. Trimpot() {
  244. box.size = Vec(17, 17);
  245. minAngle = -0.75*M_PI;
  246. maxAngle = 0.75*M_PI;
  247. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Trimpot.svg")));
  248. }
  249. };
  250. struct BefacoBigKnob : SVGKnob {
  251. BefacoBigKnob() {
  252. box.size = Vec(75, 75);
  253. minAngle = -0.75*M_PI;
  254. maxAngle = 0.75*M_PI;
  255. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoBigKnob.svg")));
  256. }
  257. };
  258. struct BefacoBigSnapKnob : BefacoBigKnob {
  259. BefacoBigSnapKnob() {
  260. snap = true;
  261. }
  262. };
  263. struct BefacoTinyKnob : SVGKnob {
  264. BefacoTinyKnob() {
  265. box.size = Vec(26, 26);
  266. minAngle = -0.75*M_PI;
  267. maxAngle = 0.75*M_PI;
  268. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoTinyKnob.svg")));
  269. }
  270. };
  271. struct BefacoSlidePot : SVGFader {
  272. BefacoSlidePot() {
  273. Vec margin = Vec(3.5, 3.5);
  274. maxHandlePos = Vec(-1, -2).plus(margin);
  275. minHandlePos = Vec(-1, 87).plus(margin);
  276. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePot.svg"));
  277. background->wrap();
  278. background->box.pos = margin;
  279. box.size = background->box.size.plus(margin.mult(2));
  280. handle->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePotHandle.svg"));
  281. handle->wrap();
  282. }
  283. };
  284. ////////////////////
  285. // Jacks
  286. ////////////////////
  287. struct PJ301MPort : SVGPort {
  288. PJ301MPort() {
  289. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ301M.svg"));
  290. background->wrap();
  291. box.size = background->box.size;
  292. }
  293. };
  294. struct PJ3410Port : SVGPort {
  295. PJ3410Port() {
  296. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ3410.svg"));
  297. background->wrap();
  298. box.size = background->box.size;
  299. }
  300. };
  301. struct CL1362Port : SVGPort {
  302. CL1362Port() {
  303. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/CL1362.svg"));
  304. background->wrap();
  305. box.size = background->box.size;
  306. }
  307. };
  308. ////////////////////
  309. // Lights
  310. ////////////////////
  311. struct GrayModuleLightWidget : ModuleLightWidget {
  312. GrayModuleLightWidget() {
  313. bgColor = nvgRGB(0x5a, 0x5a, 0x5a);
  314. borderColor = nvgRGBA(0, 0, 0, 0x60);
  315. }
  316. };
  317. struct RedLight : GrayModuleLightWidget {
  318. RedLight() {
  319. addBaseColor(COLOR_RED);
  320. }
  321. };
  322. struct GreenLight : GrayModuleLightWidget {
  323. GreenLight() {
  324. addBaseColor(COLOR_GREEN);
  325. }
  326. };
  327. struct YellowLight : GrayModuleLightWidget {
  328. YellowLight() {
  329. addBaseColor(COLOR_YELLOW);
  330. }
  331. };
  332. struct BlueLight : GrayModuleLightWidget {
  333. BlueLight() {
  334. addBaseColor(COLOR_BLUE);
  335. }
  336. };
  337. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  338. struct GreenRedLight : GrayModuleLightWidget {
  339. GreenRedLight() {
  340. addBaseColor(COLOR_GREEN);
  341. addBaseColor(COLOR_RED);
  342. }
  343. };
  344. struct RedGreenBlueLight : GrayModuleLightWidget {
  345. RedGreenBlueLight() {
  346. addBaseColor(COLOR_RED);
  347. addBaseColor(COLOR_GREEN);
  348. addBaseColor(COLOR_BLUE);
  349. }
  350. };
  351. /** Based on the size of 5mm LEDs */
  352. template <typename BASE>
  353. struct LargeLight : BASE {
  354. LargeLight() {
  355. this->box.size = mm2px(Vec(5.179, 5.179));
  356. }
  357. };
  358. /** Based on the size of 3mm LEDs */
  359. template <typename BASE>
  360. struct MediumLight : BASE {
  361. MediumLight() {
  362. this->box.size = mm2px(Vec(3.176, 3.176));
  363. }
  364. };
  365. /** Based on the size of 2mm LEDs */
  366. template <typename BASE>
  367. struct SmallLight : BASE {
  368. SmallLight() {
  369. this->box.size = mm2px(Vec(2.176, 2.176));
  370. }
  371. };
  372. /** Based on the size of 1mm LEDs */
  373. template <typename BASE>
  374. struct TinyLight : BASE {
  375. TinyLight() {
  376. this->box.size = mm2px(Vec(1.088, 1.088));
  377. }
  378. };
  379. ////////////////////
  380. // Switches and Buttons
  381. ////////////////////
  382. struct NKK : SVGSwitch, ToggleSwitch {
  383. NKK() {
  384. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_0.svg")));
  385. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_1.svg")));
  386. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_2.svg")));
  387. }
  388. };
  389. struct CKSS : SVGSwitch, ToggleSwitch {
  390. CKSS() {
  391. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_0.svg")));
  392. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_1.svg")));
  393. }
  394. };
  395. struct CKSSThree : SVGSwitch, ToggleSwitch {
  396. CKSSThree() {
  397. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_0.svg")));
  398. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_1.svg")));
  399. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_2.svg")));
  400. }
  401. };
  402. struct CKD6 : SVGSwitch, MomentarySwitch {
  403. CKD6() {
  404. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_0.svg")));
  405. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_1.svg")));
  406. }
  407. };
  408. struct TL1105 : SVGSwitch, MomentarySwitch {
  409. TL1105() {
  410. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_0.svg")));
  411. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_1.svg")));
  412. }
  413. };
  414. struct LEDButton : SVGSwitch, MomentarySwitch {
  415. LEDButton() {
  416. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDButton.svg")));
  417. }
  418. };
  419. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  420. BefacoSwitch() {
  421. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_0.svg")));
  422. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_1.svg")));
  423. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_2.svg")));
  424. }
  425. };
  426. struct BefacoPush : SVGSwitch, MomentarySwitch {
  427. BefacoPush() {
  428. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_0.svg")));
  429. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_1.svg")));
  430. }
  431. };
  432. struct PB61303 : SVGSwitch, MomentarySwitch {
  433. PB61303() {
  434. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")));
  435. }
  436. };
  437. struct LEDBezel : SVGSwitch, MomentarySwitch {
  438. LEDBezel() {
  439. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")));
  440. }
  441. };
  442. ////////////////////
  443. // Misc
  444. ////////////////////
  445. struct ScrewSilver : SVGScrew {
  446. ScrewSilver() {
  447. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewSilver.svg")));
  448. box.size = sw->box.size;
  449. }
  450. };
  451. struct ScrewBlack : SVGScrew {
  452. ScrewBlack() {
  453. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewBlack.svg")));
  454. box.size = sw->box.size;
  455. }
  456. };
  457. struct LightPanel : Panel {
  458. LightPanel() {
  459. backgroundColor = COLOR_LIGHT_PANEL;
  460. }
  461. };
  462. struct DarkPanel : Panel {
  463. DarkPanel() {
  464. backgroundColor = COLOR_DARK_PANEL;
  465. }
  466. };
  467. } // namespace rack