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.

608 lines
14KB

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