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.

594 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. /** A light to displayed over PB61303. Must add a color by subclassing or templating. */
  382. template <typename BASE>
  383. struct LEDBezelLight : BASE {
  384. LEDBezelLight() {
  385. this->bgColor = COLOR_BLACK_TRANSPARENT;
  386. this->box.size = mm2px(Vec(6.0, 6.0));
  387. }
  388. };
  389. /** A light to displayed over PB61303. Must add a color by subclassing or templating.
  390. 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(Vec(0.5, 0.5)).
  391. */
  392. template <typename BASE>
  393. struct PB61303Light : BASE {
  394. PB61303Light() {
  395. this->bgColor = COLOR_BLACK_TRANSPARENT;
  396. this->box.size = mm2px(Vec(9.0, 9.0));
  397. }
  398. };
  399. ////////////////////
  400. // Switches and Buttons
  401. ////////////////////
  402. struct NKK : SVGSwitch, ToggleSwitch {
  403. NKK() {
  404. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_0.svg")));
  405. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_1.svg")));
  406. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_2.svg")));
  407. }
  408. };
  409. struct CKSS : SVGSwitch, ToggleSwitch {
  410. CKSS() {
  411. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_0.svg")));
  412. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_1.svg")));
  413. }
  414. };
  415. struct CKSSThree : SVGSwitch, ToggleSwitch {
  416. CKSSThree() {
  417. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_0.svg")));
  418. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_1.svg")));
  419. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_2.svg")));
  420. }
  421. };
  422. struct CKD6 : SVGSwitch, MomentarySwitch {
  423. CKD6() {
  424. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_0.svg")));
  425. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_1.svg")));
  426. }
  427. };
  428. struct TL1105 : SVGSwitch, MomentarySwitch {
  429. TL1105() {
  430. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_0.svg")));
  431. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_1.svg")));
  432. }
  433. };
  434. struct LEDButton : SVGSwitch, MomentarySwitch {
  435. LEDButton() {
  436. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDButton.svg")));
  437. }
  438. };
  439. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  440. BefacoSwitch() {
  441. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_0.svg")));
  442. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_1.svg")));
  443. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_2.svg")));
  444. }
  445. };
  446. struct BefacoPush : SVGSwitch, MomentarySwitch {
  447. BefacoPush() {
  448. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_0.svg")));
  449. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_1.svg")));
  450. }
  451. };
  452. struct LEDBezel : SVGSwitch, MomentarySwitch {
  453. LEDBezel() {
  454. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")));
  455. }
  456. };
  457. struct PB61303 : SVGSwitch, MomentarySwitch {
  458. PB61303() {
  459. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")));
  460. }
  461. };
  462. struct PB61303Button : SVGButton {
  463. PB61303Button() {
  464. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")), NULL);
  465. }
  466. };
  467. struct LEDBezelButton : SVGButton {
  468. LEDBezelButton() {
  469. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")), NULL);
  470. }
  471. };
  472. ////////////////////
  473. // Misc
  474. ////////////////////
  475. struct ScrewSilver : SVGScrew {
  476. ScrewSilver() {
  477. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewSilver.svg")));
  478. box.size = sw->box.size;
  479. }
  480. };
  481. struct ScrewBlack : SVGScrew {
  482. ScrewBlack() {
  483. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewBlack.svg")));
  484. box.size = sw->box.size;
  485. }
  486. };
  487. struct LightPanel : Panel {
  488. LightPanel() {
  489. backgroundColor = COLOR_LIGHT_PANEL;
  490. }
  491. };
  492. struct DarkPanel : Panel {
  493. DarkPanel() {
  494. backgroundColor = COLOR_DARK_PANEL;
  495. }
  496. };
  497. } // namespace rack