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.

615 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::global("res/ComponentLibrary/RoundBlackKnob.svg")));
  31. }
  32. };
  33. struct RoundSmallBlackKnob : RoundKnob {
  34. RoundSmallBlackKnob() {
  35. setSVG(SVG::load(asset::global("res/ComponentLibrary/RoundSmallBlackKnob.svg")));
  36. }
  37. };
  38. struct RoundLargeBlackKnob : RoundKnob {
  39. RoundLargeBlackKnob() {
  40. setSVG(SVG::load(asset::global("res/ComponentLibrary/RoundLargeBlackKnob.svg")));
  41. }
  42. };
  43. struct RoundHugeBlackKnob : RoundKnob {
  44. RoundHugeBlackKnob() {
  45. setSVG(SVG::load(asset::global("res/ComponentLibrary/RoundHugeBlackKnob.svg")));
  46. }
  47. };
  48. struct RoundBlackSnapKnob : RoundBlackKnob {
  49. RoundBlackSnapKnob() {
  50. snap = true;
  51. smooth = false;
  52. }
  53. };
  54. struct Davies1900hKnob : 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(SVG::load(asset::global("res/ComponentLibrary/Davies1900hWhite.svg")));
  63. }
  64. };
  65. struct Davies1900hBlackKnob : Davies1900hKnob {
  66. Davies1900hBlackKnob() {
  67. setSVG(SVG::load(asset::global("res/ComponentLibrary/Davies1900hBlack.svg")));
  68. }
  69. };
  70. struct Davies1900hRedKnob : Davies1900hKnob {
  71. Davies1900hRedKnob() {
  72. setSVG(SVG::load(asset::global("res/ComponentLibrary/Davies1900hRed.svg")));
  73. }
  74. };
  75. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  76. Davies1900hLargeWhiteKnob() {
  77. setSVG(SVG::load(asset::global("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
  78. }
  79. };
  80. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  81. Davies1900hLargeBlackKnob() {
  82. setSVG(SVG::load(asset::global("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
  83. }
  84. };
  85. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  86. Davies1900hLargeRedKnob() {
  87. setSVG(SVG::load(asset::global("res/ComponentLibrary/Davies1900hLargeRed.svg")));
  88. }
  89. };
  90. struct Rogan : 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(SVG::load(asset::global("res/ComponentLibrary/Rogan6PSWhite.svg")));
  99. }
  100. };
  101. struct Rogan5PSGray : Rogan {
  102. Rogan5PSGray() {
  103. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan5PSGray.svg")));
  104. }
  105. };
  106. struct Rogan3PSBlue : Rogan {
  107. Rogan3PSBlue() {
  108. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PSBlue.svg")));
  109. }
  110. };
  111. struct Rogan3PSRed : Rogan {
  112. Rogan3PSRed() {
  113. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PSRed.svg")));
  114. }
  115. };
  116. struct Rogan3PSGreen : Rogan {
  117. Rogan3PSGreen() {
  118. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PSGreen.svg")));
  119. }
  120. };
  121. struct Rogan3PSWhite : Rogan {
  122. Rogan3PSWhite() {
  123. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PSWhite.svg")));
  124. }
  125. };
  126. struct Rogan3PBlue : Rogan {
  127. Rogan3PBlue() {
  128. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PBlue.svg")));
  129. }
  130. };
  131. struct Rogan3PRed : Rogan {
  132. Rogan3PRed() {
  133. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PRed.svg")));
  134. }
  135. };
  136. struct Rogan3PGreen : Rogan {
  137. Rogan3PGreen() {
  138. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PGreen.svg")));
  139. }
  140. };
  141. struct Rogan3PWhite : Rogan {
  142. Rogan3PWhite() {
  143. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan3PWhite.svg")));
  144. }
  145. };
  146. struct Rogan2SGray : Rogan {
  147. Rogan2SGray() {
  148. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2SGray.svg")));
  149. }
  150. };
  151. struct Rogan2PSBlue : Rogan {
  152. Rogan2PSBlue() {
  153. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PSBlue.svg")));
  154. }
  155. };
  156. struct Rogan2PSRed : Rogan {
  157. Rogan2PSRed() {
  158. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PSRed.svg")));
  159. }
  160. };
  161. struct Rogan2PSGreen : Rogan {
  162. Rogan2PSGreen() {
  163. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PSGreen.svg")));
  164. }
  165. };
  166. struct Rogan2PSWhite : Rogan {
  167. Rogan2PSWhite() {
  168. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PSWhite.svg")));
  169. }
  170. };
  171. struct Rogan2PBlue : Rogan {
  172. Rogan2PBlue() {
  173. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PBlue.svg")));
  174. }
  175. };
  176. struct Rogan2PRed : Rogan {
  177. Rogan2PRed() {
  178. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PRed.svg")));
  179. }
  180. };
  181. struct Rogan2PGreen : Rogan {
  182. Rogan2PGreen() {
  183. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PGreen.svg")));
  184. }
  185. };
  186. struct Rogan2PWhite : Rogan {
  187. Rogan2PWhite() {
  188. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan2PWhite.svg")));
  189. }
  190. };
  191. struct Rogan1PSBlue : Rogan {
  192. Rogan1PSBlue() {
  193. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PSBlue.svg")));
  194. }
  195. };
  196. struct Rogan1PSRed : Rogan {
  197. Rogan1PSRed() {
  198. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PSRed.svg")));
  199. }
  200. };
  201. struct Rogan1PSGreen : Rogan {
  202. Rogan1PSGreen() {
  203. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PSGreen.svg")));
  204. }
  205. };
  206. struct Rogan1PSWhite : Rogan {
  207. Rogan1PSWhite() {
  208. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PSWhite.svg")));
  209. }
  210. };
  211. struct Rogan1PBlue : Rogan {
  212. Rogan1PBlue() {
  213. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PBlue.svg")));
  214. }
  215. };
  216. struct Rogan1PRed : Rogan {
  217. Rogan1PRed() {
  218. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PRed.svg")));
  219. }
  220. };
  221. struct Rogan1PGreen : Rogan {
  222. Rogan1PGreen() {
  223. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PGreen.svg")));
  224. }
  225. };
  226. struct Rogan1PWhite : Rogan {
  227. Rogan1PWhite() {
  228. setSVG(SVG::load(asset::global("res/ComponentLibrary/Rogan1PWhite.svg")));
  229. }
  230. };
  231. struct SynthTechAlco : SVGKnob {
  232. SynthTechAlco() {
  233. minAngle = -0.82*M_PI;
  234. maxAngle = 0.82*M_PI;
  235. setSVG(SVG::load(asset::global("res/ComponentLibrary/SynthTechAlco.svg")));
  236. SVGWidget *cap = new SVGWidget;
  237. cap->setSVG(SVG::load(asset::global("res/ComponentLibrary/SynthTechAlco_cap.svg")));
  238. addChild(cap);
  239. }
  240. };
  241. struct Trimpot : SVGKnob {
  242. Trimpot() {
  243. minAngle = -0.75*M_PI;
  244. maxAngle = 0.75*M_PI;
  245. setSVG(SVG::load(asset::global("res/ComponentLibrary/Trimpot.svg")));
  246. }
  247. };
  248. struct BefacoBigKnob : SVGKnob {
  249. BefacoBigKnob() {
  250. minAngle = -0.75*M_PI;
  251. maxAngle = 0.75*M_PI;
  252. setSVG(SVG::load(asset::global("res/ComponentLibrary/BefacoBigKnob.svg")));
  253. }
  254. };
  255. struct BefacoBigSnapKnob : BefacoBigKnob {
  256. BefacoBigSnapKnob() {
  257. snap = true;
  258. smooth = false;
  259. }
  260. };
  261. struct BefacoTinyKnob : SVGKnob {
  262. BefacoTinyKnob() {
  263. minAngle = -0.75*M_PI;
  264. maxAngle = 0.75*M_PI;
  265. setSVG(SVG::load(asset::global("res/ComponentLibrary/BefacoTinyKnob.svg")));
  266. }
  267. };
  268. struct BefacoSlidePot : SVGSlider {
  269. BefacoSlidePot() {
  270. Vec margin = Vec(3.5, 3.5);
  271. maxHandlePos = Vec(-1, -2).plus(margin);
  272. minHandlePos = Vec(-1, 87).plus(margin);
  273. setSVGs(SVG::load(asset::global("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(asset::global("res/ComponentLibrary/BefacoSlidePotHandle.svg")));
  274. background->box.pos = margin;
  275. box.size = background->box.size.plus(margin.mult(2));
  276. }
  277. };
  278. struct LEDSlider : SVGSlider {
  279. LEDSlider() {
  280. maxHandlePos = mm2px(Vec(0.738, 0.738).plus(Vec(2, 0)));
  281. minHandlePos = mm2px(Vec(0.738, 22.078).plus(Vec(2, 0)));
  282. setSVGs(SVG::load(asset::global("res/ComponentLibrary/LEDSlider.svg")), NULL);
  283. }
  284. };
  285. /** API is unstable for LEDSlider. Will add a LightWidget later. */
  286. struct LEDSliderGreen : LEDSlider {
  287. LEDSliderGreen() {
  288. handle->setSVG(SVG::load(asset::global("res/ComponentLibrary/LEDSliderGreenHandle.svg")));
  289. }
  290. };
  291. struct LEDSliderRed : LEDSlider {
  292. LEDSliderRed() {
  293. handle->setSVG(SVG::load(asset::global("res/ComponentLibrary/LEDSliderRedHandle.svg")));
  294. }
  295. };
  296. struct LEDSliderYellow : LEDSlider {
  297. LEDSliderYellow() {
  298. handle->setSVG(SVG::load(asset::global("res/ComponentLibrary/LEDSliderYellowHandle.svg")));
  299. }
  300. };
  301. struct LEDSliderBlue : LEDSlider {
  302. LEDSliderBlue() {
  303. handle->setSVG(SVG::load(asset::global("res/ComponentLibrary/LEDSliderBlueHandle.svg")));
  304. }
  305. };
  306. struct LEDSliderWhite : LEDSlider {
  307. LEDSliderWhite() {
  308. handle->setSVG(SVG::load(asset::global("res/ComponentLibrary/LEDSliderWhiteHandle.svg")));
  309. }
  310. };
  311. ////////////////////
  312. // Ports
  313. ////////////////////
  314. struct PJ301MPort : SVGPort {
  315. PJ301MPort() {
  316. setSVG(SVG::load(asset::global("res/ComponentLibrary/PJ301M.svg")));
  317. }
  318. };
  319. struct PJ3410Port : SVGPort {
  320. PJ3410Port() {
  321. setSVG(SVG::load(asset::global("res/ComponentLibrary/PJ3410.svg")));
  322. }
  323. };
  324. struct CL1362Port : SVGPort {
  325. CL1362Port() {
  326. setSVG(SVG::load(asset::global("res/ComponentLibrary/CL1362.svg")));
  327. }
  328. };
  329. ////////////////////
  330. // Lights
  331. ////////////////////
  332. struct GrayModuleLightWidget : 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(SCHEME_RED);
  341. }
  342. };
  343. struct GreenLight : GrayModuleLightWidget {
  344. GreenLight() {
  345. addBaseColor(SCHEME_GREEN);
  346. }
  347. };
  348. struct YellowLight : GrayModuleLightWidget {
  349. YellowLight() {
  350. addBaseColor(SCHEME_YELLOW);
  351. }
  352. };
  353. struct BlueLight : GrayModuleLightWidget {
  354. BlueLight() {
  355. addBaseColor(SCHEME_BLUE);
  356. }
  357. };
  358. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  359. struct GreenRedLight : GrayModuleLightWidget {
  360. GreenRedLight() {
  361. addBaseColor(SCHEME_GREEN);
  362. addBaseColor(SCHEME_RED);
  363. }
  364. };
  365. struct RedGreenBlueLight : GrayModuleLightWidget {
  366. RedGreenBlueLight() {
  367. addBaseColor(SCHEME_RED);
  368. addBaseColor(SCHEME_GREEN);
  369. addBaseColor(SCHEME_BLUE);
  370. }
  371. };
  372. struct RGBLight : 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(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(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(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(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(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(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(Vec(9.0, 9.0));
  423. }
  424. };
  425. ////////////////////
  426. // Switches and Buttons
  427. ////////////////////
  428. struct NKK : SVGSwitch, ToggleSwitch {
  429. NKK() {
  430. addFrame(SVG::load(asset::global("res/ComponentLibrary/NKK_0.svg")));
  431. addFrame(SVG::load(asset::global("res/ComponentLibrary/NKK_1.svg")));
  432. addFrame(SVG::load(asset::global("res/ComponentLibrary/NKK_2.svg")));
  433. }
  434. };
  435. struct CKSS : SVGSwitch, ToggleSwitch {
  436. CKSS() {
  437. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKSS_0.svg")));
  438. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKSS_1.svg")));
  439. }
  440. };
  441. struct CKSSThree : SVGSwitch, ToggleSwitch {
  442. CKSSThree() {
  443. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKSSThree_0.svg")));
  444. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKSSThree_1.svg")));
  445. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKSSThree_2.svg")));
  446. }
  447. };
  448. struct CKD6 : SVGSwitch, MomentarySwitch {
  449. CKD6() {
  450. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKD6_0.svg")));
  451. addFrame(SVG::load(asset::global("res/ComponentLibrary/CKD6_1.svg")));
  452. }
  453. };
  454. struct TL1105 : SVGSwitch, MomentarySwitch {
  455. TL1105() {
  456. addFrame(SVG::load(asset::global("res/ComponentLibrary/TL1105_0.svg")));
  457. addFrame(SVG::load(asset::global("res/ComponentLibrary/TL1105_1.svg")));
  458. }
  459. };
  460. struct LEDButton : SVGSwitch, MomentarySwitch {
  461. LEDButton() {
  462. addFrame(SVG::load(asset::global("res/ComponentLibrary/LEDButton.svg")));
  463. }
  464. };
  465. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  466. BefacoSwitch() {
  467. addFrame(SVG::load(asset::global("res/ComponentLibrary/BefacoSwitch_0.svg")));
  468. addFrame(SVG::load(asset::global("res/ComponentLibrary/BefacoSwitch_1.svg")));
  469. addFrame(SVG::load(asset::global("res/ComponentLibrary/BefacoSwitch_2.svg")));
  470. }
  471. };
  472. struct BefacoPush : SVGSwitch, MomentarySwitch {
  473. BefacoPush() {
  474. addFrame(SVG::load(asset::global("res/ComponentLibrary/BefacoPush_0.svg")));
  475. addFrame(SVG::load(asset::global("res/ComponentLibrary/BefacoPush_1.svg")));
  476. }
  477. };
  478. struct LEDBezel : SVGSwitch, MomentarySwitch {
  479. LEDBezel() {
  480. addFrame(SVG::load(asset::global("res/ComponentLibrary/LEDBezel.svg")));
  481. }
  482. };
  483. struct PB61303 : SVGSwitch, MomentarySwitch {
  484. PB61303() {
  485. addFrame(SVG::load(asset::global("res/ComponentLibrary/PB61303.svg")));
  486. }
  487. };
  488. struct PB61303Button : SVGButton {
  489. PB61303Button() {
  490. setSVGs(SVG::load(asset::global("res/ComponentLibrary/PB61303.svg")), NULL);
  491. }
  492. };
  493. struct LEDBezelButton : SVGButton {
  494. LEDBezelButton() {
  495. setSVGs(SVG::load(asset::global("res/ComponentLibrary/LEDBezel.svg")), NULL);
  496. }
  497. };
  498. ////////////////////
  499. // Misc
  500. ////////////////////
  501. struct ScrewSilver : SVGScrew {
  502. ScrewSilver() {
  503. sw->setSVG(SVG::load(asset::global("res/ComponentLibrary/ScrewSilver.svg")));
  504. box.size = sw->box.size;
  505. }
  506. };
  507. struct ScrewBlack : SVGScrew {
  508. ScrewBlack() {
  509. sw->setSVG(SVG::load(asset::global("res/ComponentLibrary/ScrewBlack.svg")));
  510. box.size = sw->box.size;
  511. }
  512. };
  513. } // namespace rack