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.

583 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. background->svg = SVG::load("res/ComponentLibrary/PJ301M.svg");
  303. background->wrap();
  304. box.size = background->box.size;
  305. }
  306. };
  307. struct PJ3410Port : SVGPort {
  308. PJ3410Port() {
  309. background->svg = SVG::load("res/ComponentLibrary/PJ3410.svg");
  310. background->wrap();
  311. box.size = background->box.size;
  312. }
  313. };
  314. struct CL1362Port : SVGPort {
  315. CL1362Port() {
  316. background->svg = SVG::load("res/ComponentLibrary/CL1362.svg");
  317. background->wrap();
  318. box.size = background->box.size;
  319. }
  320. };
  321. ////////////////////
  322. // LEDs
  323. ////////////////////
  324. struct ValueLight : Light {
  325. float *value;
  326. };
  327. struct ColorValueLight : ValueLight {
  328. NVGcolor baseColor;
  329. void step() {
  330. float v = sqrtBipolar(getf(value));
  331. color = baseColor;
  332. color.a = clampf(v, 0.0, 1.0);
  333. }
  334. };
  335. struct RedValueLight : ColorValueLight {
  336. RedValueLight() {
  337. baseColor = COLOR_RED;
  338. }
  339. };
  340. struct YellowValueLight : ColorValueLight {
  341. YellowValueLight() {
  342. baseColor = COLOR_YELLOW;
  343. }
  344. };
  345. struct GreenValueLight : ColorValueLight {
  346. GreenValueLight() {
  347. baseColor = COLOR_GREEN;
  348. }
  349. };
  350. struct PolarityLight : ValueLight {
  351. NVGcolor posColor;
  352. NVGcolor negColor;
  353. void step() {
  354. float v = sqrtBipolar(getf(value));
  355. color = (v >= 0.0) ? posColor : negColor;
  356. color.a = clampf(fabsf(v), 0.0, 1.0);
  357. }
  358. };
  359. struct GreenRedPolarityLight : PolarityLight {
  360. GreenRedPolarityLight() {
  361. posColor = COLOR_GREEN;
  362. negColor = COLOR_RED;
  363. }
  364. };
  365. struct ModeValueLight : ValueLight {
  366. std::vector<NVGcolor> colors;
  367. void step() {
  368. int mode = clampi((int)roundf(getf(value)), 0, colors.size());
  369. color = colors[mode];
  370. }
  371. void addColor(NVGcolor color) {
  372. colors.push_back(color);
  373. }
  374. };
  375. template <typename BASE>
  376. struct LargeLight : BASE {
  377. LargeLight() {
  378. this->box.size = Vec(20, 20);
  379. }
  380. };
  381. template <typename BASE>
  382. struct MediumLight : BASE {
  383. MediumLight() {
  384. this->box.size = Vec(12, 12);
  385. }
  386. };
  387. template <typename BASE>
  388. struct SmallLight : BASE {
  389. SmallLight() {
  390. this->box.size = Vec(8, 8);
  391. }
  392. };
  393. template <typename BASE>
  394. struct TinyLight : BASE {
  395. TinyLight() {
  396. this->box.size = Vec(5, 5);
  397. }
  398. };
  399. ////////////////////
  400. // Switches and Buttons
  401. ////////////////////
  402. struct NKK : SVGSwitch, ToggleSwitch {
  403. NKK() {
  404. addFrame(SVG::load("res/ComponentLibrary/NKK_0.svg"));
  405. addFrame(SVG::load("res/ComponentLibrary/NKK_1.svg"));
  406. addFrame(SVG::load("res/ComponentLibrary/NKK_2.svg"));
  407. sw->wrap();
  408. box.size = sw->box.size;
  409. }
  410. };
  411. struct CKSS : SVGSwitch, ToggleSwitch {
  412. CKSS() {
  413. addFrame(SVG::load("res/ComponentLibrary/CKSS_0.svg"));
  414. addFrame(SVG::load("res/ComponentLibrary/CKSS_1.svg"));
  415. sw->wrap();
  416. box.size = sw->box.size;
  417. }
  418. };
  419. struct CKD6 : SVGSwitch, MomentarySwitch {
  420. CKD6() {
  421. addFrame(SVG::load("res/ComponentLibrary/CKD6_0.svg"));
  422. addFrame(SVG::load("res/ComponentLibrary/CKD6_1.svg"));
  423. sw->wrap();
  424. box.size = sw->box.size;
  425. }
  426. };
  427. struct TL1105 : SVGSwitch, MomentarySwitch {
  428. TL1105() {
  429. addFrame(SVG::load("res/ComponentLibrary/TL1105_0.svg"));
  430. addFrame(SVG::load("res/ComponentLibrary/TL1105_1.svg"));
  431. sw->wrap();
  432. box.size = sw->box.size;
  433. }
  434. };
  435. struct LEDButton : SVGSwitch, MomentarySwitch {
  436. LEDButton() {
  437. addFrame(SVG::load("res/ComponentLibrary/LEDButton.svg"));
  438. sw->wrap();
  439. box.size = sw->box.size;
  440. }
  441. };
  442. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  443. BefacoSwitch() {
  444. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_0.svg"));
  445. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_1.svg"));
  446. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_2.svg"));
  447. sw->wrap();
  448. box.size = sw->box.size;
  449. }
  450. };
  451. struct BefacoPush : SVGSwitch, MomentarySwitch {
  452. BefacoPush() {
  453. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_0.svg"));
  454. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_1.svg"));
  455. sw->wrap();
  456. box.size = sw->box.size;
  457. }
  458. };
  459. ////////////////////
  460. // Misc
  461. ////////////////////
  462. struct ScrewSilver : SVGScrew {
  463. ScrewSilver() {
  464. sw->svg = SVG::load("res/ComponentLibrary/ScrewSilver.svg");
  465. sw->wrap();
  466. box.size = sw->box.size;
  467. }
  468. };
  469. struct ScrewBlack : SVGScrew {
  470. ScrewBlack() {
  471. sw->svg = SVG::load("res/ComponentLibrary/ScrewBlack.svg");
  472. sw->wrap();
  473. box.size = sw->box.size;
  474. }
  475. };
  476. struct LightPanel : Panel {
  477. LightPanel() {
  478. // backgroundColor = nvgRGB(0xe6, 0xe6, 0xe6);
  479. backgroundColor = nvgRGB(0xf0, 0xf0, 0xf0);
  480. borderColor = nvgRGB(0xac, 0xac, 0xac);
  481. }
  482. };
  483. struct DarkPanel : Panel {
  484. DarkPanel() {
  485. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  486. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  487. }
  488. };
  489. } // namespace rack