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.

628 lines
14KB

  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/RoundBlackKnob.svg")));
  32. }
  33. };
  34. struct RoundSmallBlackKnob : RoundKnob {
  35. RoundSmallBlackKnob() {
  36. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/RoundSmallBlackKnob.svg")));
  37. }
  38. };
  39. struct RoundLargeBlackKnob : RoundKnob {
  40. RoundLargeBlackKnob() {
  41. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/RoundLargeBlackKnob.svg")));
  42. }
  43. };
  44. struct RoundHugeBlackKnob : RoundKnob {
  45. RoundHugeBlackKnob() {
  46. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/RoundHugeBlackKnob.svg")));
  47. }
  48. };
  49. struct RoundBlackSnapKnob : RoundBlackKnob {
  50. RoundBlackSnapKnob() {
  51. snap = true;
  52. smooth = false;
  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. minAngle = -0.75*M_PI;
  245. maxAngle = 0.75*M_PI;
  246. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Trimpot.svg")));
  247. }
  248. };
  249. struct BefacoBigKnob : SVGKnob {
  250. BefacoBigKnob() {
  251. minAngle = -0.75*M_PI;
  252. maxAngle = 0.75*M_PI;
  253. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoBigKnob.svg")));
  254. }
  255. };
  256. struct BefacoBigSnapKnob : BefacoBigKnob {
  257. BefacoBigSnapKnob() {
  258. snap = true;
  259. smooth = false;
  260. }
  261. };
  262. struct BefacoTinyKnob : SVGKnob {
  263. BefacoTinyKnob() {
  264. minAngle = -0.75*M_PI;
  265. maxAngle = 0.75*M_PI;
  266. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoTinyKnob.svg")));
  267. }
  268. };
  269. struct BefacoSlidePot : SVGSlider {
  270. BefacoSlidePot() {
  271. Vec margin = Vec(3.5, 3.5);
  272. maxHandlePos = Vec(-1, -2).plus(margin);
  273. minHandlePos = Vec(-1, 87).plus(margin);
  274. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
  275. background->box.pos = margin;
  276. box.size = background->box.size.plus(margin.mult(2));
  277. }
  278. };
  279. struct LEDSlider : SVGSlider {
  280. LEDSlider() {
  281. maxHandlePos = mm2px(Vec(0.738, 0.738).plus(Vec(2, 0)));
  282. minHandlePos = mm2px(Vec(0.738, 22.078).plus(Vec(2, 0)));
  283. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/LEDSlider.svg")), NULL);
  284. }
  285. };
  286. /** API is unstable for LEDSlider. Will add a LightWidget later. */
  287. struct LEDSliderGreen : LEDSlider {
  288. LEDSliderGreen() {
  289. handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
  290. }
  291. };
  292. struct LEDSliderRed : LEDSlider {
  293. LEDSliderRed() {
  294. handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderRedHandle.svg")));
  295. }
  296. };
  297. struct LEDSliderYellow : LEDSlider {
  298. LEDSliderYellow() {
  299. handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
  300. }
  301. };
  302. struct LEDSliderBlue : LEDSlider {
  303. LEDSliderBlue() {
  304. handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
  305. }
  306. };
  307. struct LEDSliderWhite : LEDSlider {
  308. LEDSliderWhite() {
  309. handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
  310. }
  311. };
  312. ////////////////////
  313. // Ports
  314. ////////////////////
  315. struct PJ301MPort : SVGPort {
  316. PJ301MPort() {
  317. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/PJ301M.svg")));
  318. }
  319. };
  320. struct PJ3410Port : SVGPort {
  321. PJ3410Port() {
  322. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/PJ3410.svg")));
  323. }
  324. };
  325. struct CL1362Port : SVGPort {
  326. CL1362Port() {
  327. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/CL1362.svg")));
  328. }
  329. };
  330. ////////////////////
  331. // Lights
  332. ////////////////////
  333. struct GrayModuleLightWidget : ModuleLightWidget {
  334. GrayModuleLightWidget() {
  335. bgColor = nvgRGB(0x5a, 0x5a, 0x5a);
  336. borderColor = nvgRGBA(0, 0, 0, 0x60);
  337. }
  338. };
  339. struct RedLight : GrayModuleLightWidget {
  340. RedLight() {
  341. addBaseColor(COLOR_RED);
  342. }
  343. };
  344. struct GreenLight : GrayModuleLightWidget {
  345. GreenLight() {
  346. addBaseColor(COLOR_GREEN);
  347. }
  348. };
  349. struct YellowLight : GrayModuleLightWidget {
  350. YellowLight() {
  351. addBaseColor(COLOR_YELLOW);
  352. }
  353. };
  354. struct BlueLight : GrayModuleLightWidget {
  355. BlueLight() {
  356. addBaseColor(COLOR_BLUE);
  357. }
  358. };
  359. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  360. struct GreenRedLight : GrayModuleLightWidget {
  361. GreenRedLight() {
  362. addBaseColor(COLOR_GREEN);
  363. addBaseColor(COLOR_RED);
  364. }
  365. };
  366. struct RedGreenBlueLight : GrayModuleLightWidget {
  367. RedGreenBlueLight() {
  368. addBaseColor(COLOR_RED);
  369. addBaseColor(COLOR_GREEN);
  370. addBaseColor(COLOR_BLUE);
  371. }
  372. };
  373. struct RGBLight : ModuleLightWidget {
  374. RGBLight() {
  375. addBaseColor(nvgRGBf(1, 0, 0));
  376. addBaseColor(nvgRGBf(0, 1, 0));
  377. addBaseColor(nvgRGBf(0, 0, 1));
  378. }
  379. };
  380. /** Based on the size of 5mm LEDs */
  381. template <typename BASE>
  382. struct LargeLight : BASE {
  383. LargeLight() {
  384. this->box.size = mm2px(Vec(5.179, 5.179));
  385. }
  386. };
  387. /** Based on the size of 3mm LEDs */
  388. template <typename BASE>
  389. struct MediumLight : BASE {
  390. MediumLight() {
  391. this->box.size = mm2px(Vec(3.176, 3.176));
  392. }
  393. };
  394. /** Based on the size of 2mm LEDs */
  395. template <typename BASE>
  396. struct SmallLight : BASE {
  397. SmallLight() {
  398. this->box.size = mm2px(Vec(2.176, 2.176));
  399. }
  400. };
  401. /** Based on the size of 1mm LEDs */
  402. template <typename BASE>
  403. struct TinyLight : BASE {
  404. TinyLight() {
  405. this->box.size = mm2px(Vec(1.088, 1.088));
  406. }
  407. };
  408. /** A light to displayed over PB61303. Must add a color by subclassing or templating. */
  409. template <typename BASE>
  410. struct LEDBezelLight : BASE {
  411. LEDBezelLight() {
  412. this->bgColor = COLOR_BLACK_TRANSPARENT;
  413. this->box.size = mm2px(Vec(6.0, 6.0));
  414. }
  415. };
  416. /** A light to displayed over PB61303. Must add a color by subclassing or templating.
  417. 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)).
  418. */
  419. template <typename BASE>
  420. struct PB61303Light : BASE {
  421. PB61303Light() {
  422. this->bgColor = COLOR_BLACK_TRANSPARENT;
  423. this->box.size = mm2px(Vec(9.0, 9.0));
  424. }
  425. };
  426. ////////////////////
  427. // Switches and Buttons
  428. ////////////////////
  429. struct NKK : SVGSwitch, ToggleSwitch {
  430. NKK() {
  431. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_0.svg")));
  432. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_1.svg")));
  433. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_2.svg")));
  434. }
  435. };
  436. struct CKSS : SVGSwitch, ToggleSwitch {
  437. CKSS() {
  438. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_0.svg")));
  439. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_1.svg")));
  440. }
  441. };
  442. struct CKSSThree : SVGSwitch, ToggleSwitch {
  443. CKSSThree() {
  444. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_0.svg")));
  445. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_1.svg")));
  446. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_2.svg")));
  447. }
  448. };
  449. struct CKD6 : SVGSwitch, MomentarySwitch {
  450. CKD6() {
  451. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_0.svg")));
  452. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_1.svg")));
  453. }
  454. };
  455. struct TL1105 : SVGSwitch, MomentarySwitch {
  456. TL1105() {
  457. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_0.svg")));
  458. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_1.svg")));
  459. }
  460. };
  461. struct LEDButton : SVGSwitch, MomentarySwitch {
  462. LEDButton() {
  463. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDButton.svg")));
  464. }
  465. };
  466. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  467. BefacoSwitch() {
  468. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_0.svg")));
  469. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_1.svg")));
  470. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_2.svg")));
  471. }
  472. };
  473. struct BefacoPush : SVGSwitch, MomentarySwitch {
  474. BefacoPush() {
  475. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_0.svg")));
  476. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_1.svg")));
  477. }
  478. };
  479. struct LEDBezel : SVGSwitch, MomentarySwitch {
  480. LEDBezel() {
  481. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")));
  482. }
  483. };
  484. struct PB61303 : SVGSwitch, MomentarySwitch {
  485. PB61303() {
  486. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")));
  487. }
  488. };
  489. struct PB61303Button : SVGButton {
  490. PB61303Button() {
  491. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")), NULL);
  492. }
  493. };
  494. struct LEDBezelButton : SVGButton {
  495. LEDBezelButton() {
  496. setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")), NULL);
  497. }
  498. };
  499. ////////////////////
  500. // Misc
  501. ////////////////////
  502. struct ScrewSilver : SVGScrew {
  503. ScrewSilver() {
  504. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewSilver.svg")));
  505. box.size = sw->box.size;
  506. }
  507. };
  508. struct ScrewBlack : SVGScrew {
  509. ScrewBlack() {
  510. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewBlack.svg")));
  511. box.size = sw->box.size;
  512. }
  513. };
  514. struct LightPanel : Panel {
  515. LightPanel() {
  516. backgroundColor = COLOR_LIGHT_PANEL;
  517. }
  518. };
  519. struct DarkPanel : Panel {
  520. DarkPanel() {
  521. backgroundColor = COLOR_DARK_PANEL;
  522. }
  523. };
  524. } // namespace rack