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.

586 lines
12KB

  1. #pragma once
  2. #include "app.hpp"
  3. namespace rack {
  4. ////////////////////
  5. // Colors
  6. ////////////////////
  7. #define COLOR_BLACK_TRANSPARENT nvgRGBA(0x00, 0x00, 0x00, 0x00)
  8. #define COLOR_BLACK nvgRGB(0x00, 0x00, 0x00)
  9. #define COLOR_WHITE nvgRGB(0xff, 0xff, 0xff)
  10. #define COLOR_RED nvgRGB(0xed, 0x2c, 0x24)
  11. #define COLOR_ORANGE nvgRGB(0xf2, 0xb1, 0x20)
  12. #define COLOR_YELLOW nvgRGB(0xf9, 0xdf, 0x1c)
  13. #define COLOR_GREEN nvgRGB(0x90, 0xc7, 0x3e)
  14. #define COLOR_CYAN nvgRGB(0x22, 0xe6, 0xef)
  15. #define COLOR_BLUE nvgRGB(0x29, 0xb2, 0xef)
  16. #define COLOR_PURPLE nvgRGB(0xd5, 0x2b, 0xed)
  17. ////////////////////
  18. // Knobs
  19. ////////////////////
  20. struct Rogan : SVGKnob {
  21. Rogan() {
  22. minAngle = -0.83*M_PI;
  23. maxAngle = 0.83*M_PI;
  24. }
  25. };
  26. struct Rogan6PS : Rogan {
  27. Rogan6PS() {
  28. box.size = Vec(89, 89);
  29. // minAngle = -0.83*M_PI;
  30. // maxAngle = 0.83*M_PI;
  31. }
  32. };
  33. struct Rogan5PS : Rogan {
  34. Rogan5PS() {
  35. box.size = Vec(60, 60);
  36. }
  37. };
  38. struct Rogan3PS : Rogan {
  39. Rogan3PS() {
  40. box.size = Vec(52, 52);
  41. }
  42. };
  43. struct Rogan3P : Rogan {
  44. Rogan3P() {
  45. box.size = Vec(42, 42);
  46. }
  47. };
  48. struct Rogan2S : Rogan {
  49. Rogan2S() {
  50. box.size = Vec(43, 43);
  51. }
  52. };
  53. struct Rogan2PS : Rogan {
  54. Rogan2PS() {
  55. box.size = Vec(43, 43);
  56. }
  57. };
  58. struct Rogan2P : Rogan {
  59. Rogan2P() {
  60. box.size = Vec(34, 34);
  61. }
  62. };
  63. struct Rogan1PS : Rogan {
  64. Rogan1PS() {
  65. box.size = Vec(40, 40);
  66. }
  67. };
  68. struct Rogan1P : Rogan {
  69. Rogan1P() {
  70. box.size = Vec(31, 31);
  71. }
  72. };
  73. struct Rogan6PSWhite : Rogan6PS {
  74. Rogan6PSWhite() {
  75. setSVG(SVG::load("res/ComponentLibrary/Rogan6PSWhite.svg"));
  76. }
  77. };
  78. struct Rogan5PSGray : Rogan5PS {
  79. Rogan5PSGray() {
  80. setSVG(SVG::load("res/ComponentLibrary/Rogan5PSGray.svg"));
  81. }
  82. };
  83. struct Rogan3PSBlue : Rogan3PS {
  84. Rogan3PSBlue() {
  85. setSVG(SVG::load("res/ComponentLibrary/Rogan3PSBlue.svg"));
  86. }
  87. };
  88. struct Rogan3PSRed : Rogan3PS {
  89. Rogan3PSRed() {
  90. setSVG(SVG::load("res/ComponentLibrary/Rogan3PSRed.svg"));
  91. }
  92. };
  93. struct Rogan3PSGreen : Rogan3PS {
  94. Rogan3PSGreen() {
  95. setSVG(SVG::load("res/ComponentLibrary/Rogan3PSGreen.svg"));
  96. }
  97. };
  98. struct Rogan3PSWhite : Rogan3PS {
  99. Rogan3PSWhite() {
  100. setSVG(SVG::load("res/ComponentLibrary/Rogan3PSWhite.svg"));
  101. }
  102. };
  103. struct Rogan3PBlue : Rogan3P {
  104. Rogan3PBlue() {
  105. setSVG(SVG::load("res/ComponentLibrary/Rogan3PBlue.svg"));
  106. }
  107. };
  108. struct Rogan3PRed : Rogan3P {
  109. Rogan3PRed() {
  110. setSVG(SVG::load("res/ComponentLibrary/Rogan3PRed.svg"));
  111. }
  112. };
  113. struct Rogan3PGreen : Rogan3P {
  114. Rogan3PGreen() {
  115. setSVG(SVG::load("res/ComponentLibrary/Rogan3PGreen.svg"));
  116. }
  117. };
  118. struct Rogan3PWhite : Rogan3P {
  119. Rogan3PWhite() {
  120. setSVG(SVG::load("res/ComponentLibrary/Rogan3PWhite.svg"));
  121. }
  122. };
  123. struct Rogan2SGray : Rogan2S {
  124. Rogan2SGray() {
  125. setSVG(SVG::load("res/ComponentLibrary/Rogan2SGray.svg"));
  126. }
  127. };
  128. struct Rogan2PSBlue : Rogan2PS {
  129. Rogan2PSBlue() {
  130. setSVG(SVG::load("res/ComponentLibrary/Rogan2PSBlue.svg"));
  131. }
  132. };
  133. struct Rogan2PSRed : Rogan2PS {
  134. Rogan2PSRed() {
  135. setSVG(SVG::load("res/ComponentLibrary/Rogan2PSRed.svg"));
  136. }
  137. };
  138. struct Rogan2PSGreen : Rogan2PS {
  139. Rogan2PSGreen() {
  140. setSVG(SVG::load("res/ComponentLibrary/Rogan2PSGreen.svg"));
  141. }
  142. };
  143. struct Rogan2PSWhite : Rogan2PS {
  144. Rogan2PSWhite() {
  145. setSVG(SVG::load("res/ComponentLibrary/Rogan2PSWhite.svg"));
  146. }
  147. };
  148. struct Rogan2PBlue : Rogan2P {
  149. Rogan2PBlue() {
  150. setSVG(SVG::load("res/ComponentLibrary/Rogan2PBlue.svg"));
  151. }
  152. };
  153. struct Rogan2PRed : Rogan2P {
  154. Rogan2PRed() {
  155. setSVG(SVG::load("res/ComponentLibrary/Rogan2PRed.svg"));
  156. }
  157. };
  158. struct Rogan2PGreen : Rogan2P {
  159. Rogan2PGreen() {
  160. setSVG(SVG::load("res/ComponentLibrary/Rogan2PGreen.svg"));
  161. }
  162. };
  163. struct Rogan2PWhite : Rogan2P {
  164. Rogan2PWhite() {
  165. setSVG(SVG::load("res/ComponentLibrary/Rogan2PWhite.svg"));
  166. }
  167. };
  168. struct Rogan1PSBlue : Rogan1PS {
  169. Rogan1PSBlue() {
  170. setSVG(SVG::load("res/ComponentLibrary/Rogan1PSBlue.svg"));
  171. }
  172. };
  173. struct Rogan1PSRed : Rogan1PS {
  174. Rogan1PSRed() {
  175. setSVG(SVG::load("res/ComponentLibrary/Rogan1PSRed.svg"));
  176. }
  177. };
  178. struct Rogan1PSGreen : Rogan1PS {
  179. Rogan1PSGreen() {
  180. setSVG(SVG::load("res/ComponentLibrary/Rogan1PSGreen.svg"));
  181. }
  182. };
  183. struct Rogan1PSWhite : Rogan1PS {
  184. Rogan1PSWhite() {
  185. setSVG(SVG::load("res/ComponentLibrary/Rogan1PSWhite.svg"));
  186. }
  187. };
  188. struct Rogan1PBlue : Rogan1P {
  189. Rogan1PBlue() {
  190. setSVG(SVG::load("res/ComponentLibrary/Rogan1PBlue.svg"));
  191. }
  192. };
  193. struct Rogan1PRed : Rogan1P {
  194. Rogan1PRed() {
  195. setSVG(SVG::load("res/ComponentLibrary/Rogan1PRed.svg"));
  196. }
  197. };
  198. struct Rogan1PGreen : Rogan1P {
  199. Rogan1PGreen() {
  200. setSVG(SVG::load("res/ComponentLibrary/Rogan1PGreen.svg"));
  201. }
  202. };
  203. struct Rogan1PWhite : Rogan1P {
  204. Rogan1PWhite() {
  205. setSVG(SVG::load("res/ComponentLibrary/Rogan1PWhite.svg"));
  206. }
  207. };
  208. struct SynthTechAlco : SVGKnob {
  209. SynthTechAlco() {
  210. box.size = Vec(45, 45);
  211. minAngle = -0.82*M_PI;
  212. maxAngle = 0.82*M_PI;
  213. setSVG(SVG::load("res/ComponentLibrary/SynthTechAlco.svg"));
  214. }
  215. };
  216. struct Davies1900hKnob : SVGKnob {
  217. Davies1900hKnob() {
  218. box.size = Vec(36, 36);
  219. minAngle = -0.83*M_PI;
  220. maxAngle = 0.83*M_PI;
  221. }
  222. };
  223. struct Davies1900hWhiteKnob : Davies1900hKnob {
  224. Davies1900hWhiteKnob() {
  225. setSVG(SVG::load("res/ComponentLibrary/Davies1900hWhite.svg"));
  226. }
  227. };
  228. struct Davies1900hBlackKnob : Davies1900hKnob {
  229. Davies1900hBlackKnob() {
  230. setSVG(SVG::load("res/ComponentLibrary/Davies1900hBlack.svg"));
  231. }
  232. };
  233. struct Davies1900hRedKnob : Davies1900hKnob {
  234. Davies1900hRedKnob() {
  235. setSVG(SVG::load("res/ComponentLibrary/Davies1900hRed.svg"));
  236. }
  237. };
  238. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  239. Davies1900hLargeWhiteKnob() {
  240. setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeWhite.svg"));
  241. }
  242. };
  243. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  244. Davies1900hLargeBlackKnob() {
  245. setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeBlack.svg"));
  246. }
  247. };
  248. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  249. Davies1900hLargeRedKnob() {
  250. setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeRed.svg"));
  251. }
  252. };
  253. struct Davies1900hSmallBlackKnob : Davies1900hKnob {
  254. Davies1900hSmallBlackKnob() {
  255. setSVG(SVG::load("res/ComponentLibrary/Davies1900hSmallBlack.svg"));
  256. }
  257. };
  258. struct Davies1900hSmallBlackSnapKnob : Davies1900hSmallBlackKnob, SnapKnob {};
  259. struct Trimpot : SVGKnob {
  260. Trimpot() {
  261. box.size = Vec(17, 17);
  262. minAngle = -0.75*M_PI;
  263. maxAngle = 0.75*M_PI;
  264. setSVG(SVG::load("res/ComponentLibrary/Trimpot.svg"));
  265. }
  266. };
  267. struct BefacoBigKnob : SVGKnob {
  268. BefacoBigKnob() {
  269. box.size = Vec(75, 75);
  270. minAngle = -0.75*M_PI;
  271. maxAngle = 0.75*M_PI;
  272. setSVG(SVG::load("res/ComponentLibrary/BefacoBigKnob.svg"));
  273. }
  274. };
  275. struct BefacoBigSnapKnob : BefacoBigKnob, SnapKnob {};
  276. struct BefacoTinyKnob : SVGKnob {
  277. BefacoTinyKnob() {
  278. box.size = Vec(26, 26);
  279. minAngle = -0.75*M_PI;
  280. maxAngle = 0.75*M_PI;
  281. setSVG(SVG::load("res/ComponentLibrary/BefacoTinyKnob.svg"));
  282. }
  283. };
  284. struct BefacoSlidePot : SVGSlider {
  285. BefacoSlidePot() {
  286. Vec margin = Vec(3.5, 3.5);
  287. maxHandlePos = Vec(-1, -2).plus(margin);
  288. minHandlePos = Vec(-1, 87).plus(margin);
  289. background->svg = SVG::load("res/ComponentLibrary/BefacoSlidePot.svg");
  290. background->wrap();
  291. background->box.pos = margin;
  292. box.size = background->box.size.plus(margin.mult(2));
  293. handle->svg = SVG::load("res/ComponentLibrary/BefacoSlidePotHandle.svg");
  294. handle->wrap();
  295. }
  296. };
  297. ////////////////////
  298. // Jacks
  299. ////////////////////
  300. struct PJ301MPort : SVGPort {
  301. PJ301MPort() {
  302. padding = Vec(1, 1);
  303. background->svg = SVG::load("res/ComponentLibrary/PJ301M.svg");
  304. background->wrap();
  305. box.size = background->box.size;
  306. }
  307. };
  308. struct PJ3410Port : SVGPort {
  309. PJ3410Port() {
  310. padding = Vec(1, 1);
  311. background->svg = SVG::load("res/ComponentLibrary/PJ3410.svg");
  312. background->wrap();
  313. box.size = background->box.size;
  314. }
  315. };
  316. struct CL1362Port : SVGPort {
  317. CL1362Port() {
  318. padding = Vec(1, 1);
  319. background->svg = SVG::load("res/ComponentLibrary/CL1362.svg");
  320. background->wrap();
  321. box.size = background->box.size;
  322. }
  323. };
  324. ////////////////////
  325. // LEDs
  326. ////////////////////
  327. struct ValueLight : Light {
  328. float *value;
  329. };
  330. struct ColorValueLight : ValueLight {
  331. NVGcolor baseColor;
  332. void step() {
  333. float v = sqrtBipolar(getf(value));
  334. color = baseColor;
  335. color.a = clampf(v, 0.0, 1.0);
  336. }
  337. };
  338. struct RedValueLight : ColorValueLight {
  339. RedValueLight() {
  340. baseColor = COLOR_RED;
  341. }
  342. };
  343. struct YellowValueLight : ColorValueLight {
  344. YellowValueLight() {
  345. baseColor = COLOR_YELLOW;
  346. }
  347. };
  348. struct GreenValueLight : ColorValueLight {
  349. GreenValueLight() {
  350. baseColor = COLOR_GREEN;
  351. }
  352. };
  353. struct PolarityLight : ValueLight {
  354. NVGcolor posColor;
  355. NVGcolor negColor;
  356. void step() {
  357. float v = sqrtBipolar(getf(value));
  358. color = (v >= 0.0) ? posColor : negColor;
  359. color.a = clampf(fabsf(v), 0.0, 1.0);
  360. }
  361. };
  362. struct GreenRedPolarityLight : PolarityLight {
  363. GreenRedPolarityLight() {
  364. posColor = COLOR_GREEN;
  365. negColor = COLOR_RED;
  366. }
  367. };
  368. struct ModeValueLight : ValueLight {
  369. std::vector<NVGcolor> colors;
  370. void step() {
  371. int mode = clampi((int)roundf(getf(value)), 0, colors.size());
  372. color = colors[mode];
  373. }
  374. void addColor(NVGcolor color) {
  375. colors.push_back(color);
  376. }
  377. };
  378. template <typename BASE>
  379. struct LargeLight : BASE {
  380. LargeLight() {
  381. this->box.size = Vec(20, 20);
  382. }
  383. };
  384. template <typename BASE>
  385. struct MediumLight : BASE {
  386. MediumLight() {
  387. this->box.size = Vec(12, 12);
  388. }
  389. };
  390. template <typename BASE>
  391. struct SmallLight : BASE {
  392. SmallLight() {
  393. this->box.size = Vec(8, 8);
  394. }
  395. };
  396. template <typename BASE>
  397. struct TinyLight : BASE {
  398. TinyLight() {
  399. this->box.size = Vec(5, 5);
  400. }
  401. };
  402. ////////////////////
  403. // Switches and Buttons
  404. ////////////////////
  405. struct NKK : SVGSwitch, ToggleSwitch {
  406. NKK() {
  407. addFrame(SVG::load("res/ComponentLibrary/NKK_0.svg"));
  408. addFrame(SVG::load("res/ComponentLibrary/NKK_1.svg"));
  409. addFrame(SVG::load("res/ComponentLibrary/NKK_2.svg"));
  410. sw->wrap();
  411. box.size = sw->box.size;
  412. }
  413. };
  414. struct CKSS : SVGSwitch, ToggleSwitch {
  415. CKSS() {
  416. addFrame(SVG::load("res/ComponentLibrary/CKSS_0.svg"));
  417. addFrame(SVG::load("res/ComponentLibrary/CKSS_1.svg"));
  418. sw->wrap();
  419. box.size = sw->box.size;
  420. }
  421. };
  422. struct CKD6 : SVGSwitch, MomentarySwitch {
  423. CKD6() {
  424. addFrame(SVG::load("res/ComponentLibrary/CKD6_0.svg"));
  425. addFrame(SVG::load("res/ComponentLibrary/CKD6_1.svg"));
  426. sw->wrap();
  427. box.size = sw->box.size;
  428. }
  429. };
  430. struct TL1105 : SVGSwitch, MomentarySwitch {
  431. TL1105() {
  432. addFrame(SVG::load("res/ComponentLibrary/TL1105_0.svg"));
  433. addFrame(SVG::load("res/ComponentLibrary/TL1105_1.svg"));
  434. sw->wrap();
  435. box.size = sw->box.size;
  436. }
  437. };
  438. struct LEDButton : SVGSwitch, MomentarySwitch {
  439. LEDButton() {
  440. addFrame(SVG::load("res/ComponentLibrary/LEDButton.svg"));
  441. sw->wrap();
  442. box.size = sw->box.size;
  443. }
  444. };
  445. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  446. BefacoSwitch() {
  447. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_0.svg"));
  448. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_1.svg"));
  449. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_2.svg"));
  450. sw->wrap();
  451. box.size = sw->box.size;
  452. }
  453. };
  454. struct BefacoPush : SVGSwitch, MomentarySwitch {
  455. BefacoPush() {
  456. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_0.svg"));
  457. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_1.svg"));
  458. sw->wrap();
  459. box.size = sw->box.size;
  460. }
  461. };
  462. ////////////////////
  463. // Misc
  464. ////////////////////
  465. struct ScrewSilver : SVGScrew {
  466. ScrewSilver() {
  467. sw->svg = SVG::load("res/ComponentLibrary/ScrewSilver.svg");
  468. sw->wrap();
  469. box.size = sw->box.size;
  470. }
  471. };
  472. struct ScrewBlack : SVGScrew {
  473. ScrewBlack() {
  474. sw->svg = SVG::load("res/ComponentLibrary/ScrewBlack.svg");
  475. sw->wrap();
  476. box.size = sw->box.size;
  477. }
  478. };
  479. struct LightPanel : Panel {
  480. LightPanel() {
  481. // backgroundColor = nvgRGB(0xe6, 0xe6, 0xe6);
  482. backgroundColor = nvgRGB(0xf0, 0xf0, 0xf0);
  483. borderColor = nvgRGB(0xac, 0xac, 0xac);
  484. }
  485. };
  486. struct DarkPanel : Panel {
  487. DarkPanel() {
  488. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  489. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  490. }
  491. };
  492. } // namespace rack