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.

584 lines
12KB

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