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.

617 lines
15KB

  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. // TODO
  51. // quantity.snap = true;
  52. // quantity.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(asset::system("res/ComponentLibrary/Davies1900hWhite.svg")));
  64. }
  65. };
  66. struct Davies1900hBlackKnob : Davies1900hKnob {
  67. Davies1900hBlackKnob() {
  68. setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hBlack.svg")));
  69. }
  70. };
  71. struct Davies1900hRedKnob : Davies1900hKnob {
  72. Davies1900hRedKnob() {
  73. setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hRed.svg")));
  74. }
  75. };
  76. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  77. Davies1900hLargeWhiteKnob() {
  78. setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
  79. }
  80. };
  81. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  82. Davies1900hLargeBlackKnob() {
  83. setSVG(SVG::load(asset::system("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
  84. }
  85. };
  86. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  87. Davies1900hLargeRedKnob() {
  88. setSVG(SVG::load(asset::system("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(asset::system("res/ComponentLibrary/Rogan6PSWhite.svg")));
  100. }
  101. };
  102. struct Rogan5PSGray : Rogan {
  103. Rogan5PSGray() {
  104. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan5PSGray.svg")));
  105. }
  106. };
  107. struct Rogan3PSBlue : Rogan {
  108. Rogan3PSBlue() {
  109. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSBlue.svg")));
  110. }
  111. };
  112. struct Rogan3PSRed : Rogan {
  113. Rogan3PSRed() {
  114. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSRed.svg")));
  115. }
  116. };
  117. struct Rogan3PSGreen : Rogan {
  118. Rogan3PSGreen() {
  119. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSGreen.svg")));
  120. }
  121. };
  122. struct Rogan3PSWhite : Rogan {
  123. Rogan3PSWhite() {
  124. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PSWhite.svg")));
  125. }
  126. };
  127. struct Rogan3PBlue : Rogan {
  128. Rogan3PBlue() {
  129. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PBlue.svg")));
  130. }
  131. };
  132. struct Rogan3PRed : Rogan {
  133. Rogan3PRed() {
  134. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PRed.svg")));
  135. }
  136. };
  137. struct Rogan3PGreen : Rogan {
  138. Rogan3PGreen() {
  139. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PGreen.svg")));
  140. }
  141. };
  142. struct Rogan3PWhite : Rogan {
  143. Rogan3PWhite() {
  144. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan3PWhite.svg")));
  145. }
  146. };
  147. struct Rogan2SGray : Rogan {
  148. Rogan2SGray() {
  149. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2SGray.svg")));
  150. }
  151. };
  152. struct Rogan2PSBlue : Rogan {
  153. Rogan2PSBlue() {
  154. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSBlue.svg")));
  155. }
  156. };
  157. struct Rogan2PSRed : Rogan {
  158. Rogan2PSRed() {
  159. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSRed.svg")));
  160. }
  161. };
  162. struct Rogan2PSGreen : Rogan {
  163. Rogan2PSGreen() {
  164. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSGreen.svg")));
  165. }
  166. };
  167. struct Rogan2PSWhite : Rogan {
  168. Rogan2PSWhite() {
  169. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PSWhite.svg")));
  170. }
  171. };
  172. struct Rogan2PBlue : Rogan {
  173. Rogan2PBlue() {
  174. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PBlue.svg")));
  175. }
  176. };
  177. struct Rogan2PRed : Rogan {
  178. Rogan2PRed() {
  179. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PRed.svg")));
  180. }
  181. };
  182. struct Rogan2PGreen : Rogan {
  183. Rogan2PGreen() {
  184. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PGreen.svg")));
  185. }
  186. };
  187. struct Rogan2PWhite : Rogan {
  188. Rogan2PWhite() {
  189. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan2PWhite.svg")));
  190. }
  191. };
  192. struct Rogan1PSBlue : Rogan {
  193. Rogan1PSBlue() {
  194. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSBlue.svg")));
  195. }
  196. };
  197. struct Rogan1PSRed : Rogan {
  198. Rogan1PSRed() {
  199. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSRed.svg")));
  200. }
  201. };
  202. struct Rogan1PSGreen : Rogan {
  203. Rogan1PSGreen() {
  204. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSGreen.svg")));
  205. }
  206. };
  207. struct Rogan1PSWhite : Rogan {
  208. Rogan1PSWhite() {
  209. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PSWhite.svg")));
  210. }
  211. };
  212. struct Rogan1PBlue : Rogan {
  213. Rogan1PBlue() {
  214. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PBlue.svg")));
  215. }
  216. };
  217. struct Rogan1PRed : Rogan {
  218. Rogan1PRed() {
  219. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PRed.svg")));
  220. }
  221. };
  222. struct Rogan1PGreen : Rogan {
  223. Rogan1PGreen() {
  224. setSVG(SVG::load(asset::system("res/ComponentLibrary/Rogan1PGreen.svg")));
  225. }
  226. };
  227. struct Rogan1PWhite : Rogan {
  228. Rogan1PWhite() {
  229. setSVG(SVG::load(asset::system("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(asset::system("res/ComponentLibrary/SynthTechAlco.svg")));
  237. SVGWidget *cap = new SVGWidget;
  238. cap->setSVG(SVG::load(asset::system("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(asset::system("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(asset::system("res/ComponentLibrary/BefacoBigKnob.svg")));
  254. }
  255. };
  256. struct BefacoBigSnapKnob : BefacoBigKnob {
  257. BefacoBigSnapKnob() {
  258. // TODO
  259. // quantity.snap = true;
  260. // quantity.smooth = false;
  261. }
  262. };
  263. struct BefacoTinyKnob : SVGKnob {
  264. BefacoTinyKnob() {
  265. minAngle = -0.75*M_PI;
  266. maxAngle = 0.75*M_PI;
  267. setSVG(SVG::load(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg")));
  268. }
  269. };
  270. struct BefacoSlidePot : SVGSlider {
  271. BefacoSlidePot() {
  272. math::Vec margin = math::Vec(3.5, 3.5);
  273. maxHandlePos = math::Vec(-1, -2).plus(margin);
  274. minHandlePos = math::Vec(-1, 87).plus(margin);
  275. setSVGs(SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(asset::system("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
  276. background->box.pos = margin;
  277. box.size = background->box.size.plus(margin.mult(2));
  278. }
  279. };
  280. struct LEDSlider : SVGSlider {
  281. LEDSlider() {
  282. maxHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0)));
  283. minHandlePos = mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0)));
  284. setSVGs(SVG::load(asset::system("res/ComponentLibrary/LEDSlider.svg")), NULL);
  285. }
  286. };
  287. /** API is unstable for LEDSlider. Will add a LightWidget later. */
  288. struct LEDSliderGreen : LEDSlider {
  289. LEDSliderGreen() {
  290. handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
  291. }
  292. };
  293. struct LEDSliderRed : LEDSlider {
  294. LEDSliderRed() {
  295. handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderRedHandle.svg")));
  296. }
  297. };
  298. struct LEDSliderYellow : LEDSlider {
  299. LEDSliderYellow() {
  300. handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
  301. }
  302. };
  303. struct LEDSliderBlue : LEDSlider {
  304. LEDSliderBlue() {
  305. handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
  306. }
  307. };
  308. struct LEDSliderWhite : LEDSlider {
  309. LEDSliderWhite() {
  310. handle->setSVG(SVG::load(asset::system("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
  311. }
  312. };
  313. ////////////////////
  314. // Ports
  315. ////////////////////
  316. struct PJ301MPort : SVGPort {
  317. PJ301MPort() {
  318. setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ301M.svg")));
  319. }
  320. };
  321. struct PJ3410Port : SVGPort {
  322. PJ3410Port() {
  323. setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ3410.svg")));
  324. }
  325. };
  326. struct CL1362Port : SVGPort {
  327. CL1362Port() {
  328. setSVG(SVG::load(asset::system("res/ComponentLibrary/CL1362.svg")));
  329. }
  330. };
  331. ////////////////////
  332. // Lights
  333. ////////////////////
  334. struct GrayModuleLightWidget : ModuleLightWidget {
  335. GrayModuleLightWidget() {
  336. bgColor = nvgRGB(0x5a, 0x5a, 0x5a);
  337. borderColor = nvgRGBA(0, 0, 0, 0x60);
  338. }
  339. };
  340. struct RedLight : GrayModuleLightWidget {
  341. RedLight() {
  342. addBaseColor(SCHEME_RED);
  343. }
  344. };
  345. struct GreenLight : GrayModuleLightWidget {
  346. GreenLight() {
  347. addBaseColor(SCHEME_GREEN);
  348. }
  349. };
  350. struct YellowLight : GrayModuleLightWidget {
  351. YellowLight() {
  352. addBaseColor(SCHEME_YELLOW);
  353. }
  354. };
  355. struct BlueLight : GrayModuleLightWidget {
  356. BlueLight() {
  357. addBaseColor(SCHEME_BLUE);
  358. }
  359. };
  360. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  361. struct GreenRedLight : GrayModuleLightWidget {
  362. GreenRedLight() {
  363. addBaseColor(SCHEME_GREEN);
  364. addBaseColor(SCHEME_RED);
  365. }
  366. };
  367. struct RedGreenBlueLight : GrayModuleLightWidget {
  368. RedGreenBlueLight() {
  369. addBaseColor(SCHEME_RED);
  370. addBaseColor(SCHEME_GREEN);
  371. addBaseColor(SCHEME_BLUE);
  372. }
  373. };
  374. struct RGBLight : ModuleLightWidget {
  375. RGBLight() {
  376. addBaseColor(nvgRGBf(1, 0, 0));
  377. addBaseColor(nvgRGBf(0, 1, 0));
  378. addBaseColor(nvgRGBf(0, 0, 1));
  379. }
  380. };
  381. /** Based on the size of 5mm LEDs */
  382. template <typename BASE>
  383. struct LargeLight : BASE {
  384. LargeLight() {
  385. this->box.size = mm2px(math::Vec(5.179, 5.179));
  386. }
  387. };
  388. /** Based on the size of 3mm LEDs */
  389. template <typename BASE>
  390. struct MediumLight : BASE {
  391. MediumLight() {
  392. this->box.size = mm2px(math::Vec(3.176, 3.176));
  393. }
  394. };
  395. /** Based on the size of 2mm LEDs */
  396. template <typename BASE>
  397. struct SmallLight : BASE {
  398. SmallLight() {
  399. this->box.size = mm2px(math::Vec(2.176, 2.176));
  400. }
  401. };
  402. /** Based on the size of 1mm LEDs */
  403. template <typename BASE>
  404. struct TinyLight : BASE {
  405. TinyLight() {
  406. this->box.size = mm2px(math::Vec(1.088, 1.088));
  407. }
  408. };
  409. /** A light to displayed over PB61303. Must add a color by subclassing or templating. */
  410. template <typename BASE>
  411. struct LEDBezelLight : BASE {
  412. LEDBezelLight() {
  413. this->bgColor = color::BLACK_TRANSPARENT;
  414. this->box.size = mm2px(math::Vec(6.0, 6.0));
  415. }
  416. };
  417. /** A light to displayed over PB61303. Must add a color by subclassing or templating.
  418. 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)).
  419. */
  420. template <typename BASE>
  421. struct PB61303Light : BASE {
  422. PB61303Light() {
  423. this->bgColor = color::BLACK_TRANSPARENT;
  424. this->box.size = mm2px(math::Vec(9.0, 9.0));
  425. }
  426. };
  427. ////////////////////
  428. // Switches and Buttons
  429. ////////////////////
  430. struct NKK : SVGSwitch, ToggleSwitch {
  431. NKK() {
  432. addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_0.svg")));
  433. addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_1.svg")));
  434. addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_2.svg")));
  435. }
  436. };
  437. struct CKSS : SVGSwitch, ToggleSwitch {
  438. CKSS() {
  439. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_0.svg")));
  440. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_1.svg")));
  441. }
  442. };
  443. struct CKSSThree : SVGSwitch, ToggleSwitch {
  444. CKSSThree() {
  445. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_0.svg")));
  446. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_1.svg")));
  447. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_2.svg")));
  448. }
  449. };
  450. struct CKD6 : SVGSwitch, MomentarySwitch {
  451. CKD6() {
  452. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg")));
  453. addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_1.svg")));
  454. }
  455. };
  456. struct TL1105 : SVGSwitch, MomentarySwitch {
  457. TL1105() {
  458. addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_0.svg")));
  459. addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_1.svg")));
  460. }
  461. };
  462. struct LEDButton : SVGSwitch, MomentarySwitch {
  463. LEDButton() {
  464. addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDButton.svg")));
  465. }
  466. };
  467. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  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, MomentarySwitch {
  475. BefacoPush() {
  476. addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_0.svg")));
  477. addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_1.svg")));
  478. }
  479. };
  480. struct LEDBezel : SVGSwitch, MomentarySwitch {
  481. LEDBezel() {
  482. addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg")));
  483. }
  484. };
  485. struct PB61303 : SVGSwitch, MomentarySwitch {
  486. PB61303() {
  487. addFrame(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg")));
  488. }
  489. };
  490. struct PB61303Button : SVGButton {
  491. PB61303Button() {
  492. setSVGs(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg")), NULL);
  493. }
  494. };
  495. struct LEDBezelButton : SVGButton {
  496. LEDBezelButton() {
  497. setSVGs(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg")), NULL);
  498. }
  499. };
  500. ////////////////////
  501. // Misc
  502. ////////////////////
  503. struct ScrewSilver : SVGScrew {
  504. ScrewSilver() {
  505. sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewSilver.svg")));
  506. box.size = sw->box.size;
  507. }
  508. };
  509. struct ScrewBlack : SVGScrew {
  510. ScrewBlack() {
  511. sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewBlack.svg")));
  512. box.size = sw->box.size;
  513. }
  514. };
  515. } // namespace rack