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.

563 lines
13KB

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