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.

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