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.

610 lines
15KB

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