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.

512 lines
9.9KB

  1. #pragma once
  2. #include "app.hpp"
  3. namespace rack {
  4. enum ColorNames {
  5. COLOR_BLACK,
  6. COLOR_WHITE,
  7. COLOR_RED,
  8. COLOR_ORANGE,
  9. COLOR_YELLOW,
  10. COLOR_GREEN,
  11. COLOR_CYAN,
  12. COLOR_BLUE,
  13. COLOR_PURPLE,
  14. NUM_COLORS
  15. };
  16. extern const NVGcolor colors[NUM_COLORS];
  17. ////////////////////
  18. // Knobs
  19. ////////////////////
  20. struct Rogan : SVGKnob {
  21. Rogan() {
  22. minAngle = -0.75*M_PI;
  23. maxAngle = 0.75*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.75*M_PI;
  220. maxAngle = 0.75*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 Trimpot : SVGKnob {
  239. Trimpot() {
  240. box.size = Vec(17, 17);
  241. minAngle = -0.75*M_PI;
  242. maxAngle = 0.75*M_PI;
  243. setSVG(SVG::load("res/ComponentLibrary/Trimpot.svg"));
  244. }
  245. };
  246. struct BefacoBigKnob : SVGKnob {
  247. BefacoBigKnob() {
  248. box.size = Vec(75, 75);
  249. minAngle = -0.75*M_PI;
  250. maxAngle = 0.75*M_PI;
  251. setSVG(SVG::load("res/ComponentLibrary/BefacoBigKnob.svg"));
  252. }
  253. };
  254. struct BefacoTinyKnob : SVGKnob {
  255. BefacoTinyKnob() {
  256. box.size = Vec(26, 26);
  257. minAngle = -0.75*M_PI;
  258. maxAngle = 0.75*M_PI;
  259. setSVG(SVG::load("res/ComponentLibrary/BefacoTinyKnob.svg"));
  260. }
  261. };
  262. struct BefacoSlidePot : SVGSlider {
  263. BefacoSlidePot() {
  264. Vec margin = Vec(3.5, 3.5);
  265. maxHandlePos = Vec(-1, -2).plus(margin);
  266. minHandlePos = Vec(-1, 87).plus(margin);
  267. background->svg = SVG::load("res/ComponentLibrary/BefacoSlidePot.svg");
  268. background->wrap();
  269. background->box.pos = margin;
  270. box.size = background->box.size.plus(margin.mult(2));
  271. handle->svg = SVG::load("res/ComponentLibrary/BefacoSlidePotHandle.svg");
  272. handle->wrap();
  273. }
  274. };
  275. ////////////////////
  276. // Jacks
  277. ////////////////////
  278. struct PJ301MPort : SVGPort {
  279. PJ301MPort() {
  280. padding = Vec(1, 1);
  281. background->svg = SVG::load("res/ComponentLibrary/PJ301M.svg");
  282. background->wrap();
  283. box.size = background->box.size;
  284. }
  285. };
  286. struct PJ3410Port : SVGPort {
  287. PJ3410Port() {
  288. padding = Vec(1, 1);
  289. background->svg = SVG::load("res/ComponentLibrary/PJ3410.svg");
  290. background->wrap();
  291. box.size = background->box.size;
  292. }
  293. };
  294. struct CL1362Port : SVGPort {
  295. CL1362Port() {
  296. padding = Vec(1, 1);
  297. background->svg = SVG::load("res/ComponentLibrary/CL1362.svg");
  298. background->wrap();
  299. box.size = background->box.size;
  300. }
  301. };
  302. ////////////////////
  303. // LEDs
  304. ////////////////////
  305. struct ValueLight : Light {
  306. float *value;
  307. };
  308. template <int COLOR>
  309. struct ColorValueLight : ValueLight {
  310. void step() {
  311. float v = sqrtBipolar(getf(value));
  312. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v);
  313. }
  314. };
  315. typedef ColorValueLight<COLOR_RED> RedValueLight;
  316. typedef ColorValueLight<COLOR_YELLOW> YellowValueLight;
  317. typedef ColorValueLight<COLOR_GREEN> GreenValueLight;
  318. template <int COLOR_POS, int COLOR_NEG>
  319. struct PolarityLight : ValueLight {
  320. void step() {
  321. float v = sqrtBipolar(getf(value));
  322. if (v >= 0.0)
  323. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v);
  324. else
  325. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v);
  326. }
  327. };
  328. typedef PolarityLight<COLOR_GREEN, COLOR_RED> GreenRedPolarityLight;
  329. template <typename BASE>
  330. struct LargeLight : BASE {
  331. LargeLight() {
  332. this->box.size = Vec(20, 20);
  333. }
  334. };
  335. template <typename BASE>
  336. struct MediumLight : BASE {
  337. MediumLight() {
  338. this->box.size = Vec(12, 12);
  339. }
  340. };
  341. template <typename BASE>
  342. struct SmallLight : BASE {
  343. SmallLight() {
  344. this->box.size = Vec(8, 8);
  345. }
  346. };
  347. ////////////////////
  348. // Switches and Buttons
  349. ////////////////////
  350. struct NKK : SVGSwitch, ToggleSwitch {
  351. NKK() {
  352. addFrame(SVG::load("res/ComponentLibrary/NKK0.svg"));
  353. addFrame(SVG::load("res/ComponentLibrary/NKK1.svg"));
  354. addFrame(SVG::load("res/ComponentLibrary/NKK2.svg"));
  355. sw->wrap();
  356. box.size = sw->box.size;
  357. }
  358. };
  359. struct CKSS : SVGSwitch, ToggleSwitch {
  360. CKSS() {
  361. addFrame(SVG::load("res/ComponentLibrary/CKSS0.svg"));
  362. addFrame(SVG::load("res/ComponentLibrary/CKSS1.svg"));
  363. sw->wrap();
  364. box.size = sw->box.size;
  365. }
  366. };
  367. struct CKD6 : SVGSwitch, MomentarySwitch {
  368. CKD6() {
  369. addFrame(SVG::load("res/ComponentLibrary/CKD6_0.svg"));
  370. addFrame(SVG::load("res/ComponentLibrary/CKD6_1.svg"));
  371. sw->wrap();
  372. box.size = sw->box.size;
  373. }
  374. };
  375. struct TL1105 : SVGSwitch, MomentarySwitch {
  376. TL1105() {
  377. addFrame(SVG::load("res/ComponentLibrary/TL1105_0.svg"));
  378. addFrame(SVG::load("res/ComponentLibrary/TL1105_1.svg"));
  379. sw->wrap();
  380. box.size = sw->box.size;
  381. }
  382. };
  383. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  384. BefacoSwitch() {
  385. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_0.svg"));
  386. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_1.svg"));
  387. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_2.svg"));
  388. sw->wrap();
  389. box.size = sw->box.size;
  390. }
  391. };
  392. struct BefacoPush : SVGSwitch, MomentarySwitch {
  393. BefacoPush() {
  394. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_0.svg"));
  395. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_1.svg"));
  396. sw->wrap();
  397. box.size = sw->box.size;
  398. }
  399. };
  400. ////////////////////
  401. // Misc
  402. ////////////////////
  403. struct ScrewSilver : SVGScrew {
  404. ScrewSilver() {
  405. sw->svg = SVG::load("res/ComponentLibrary/ScrewSilver.svg");
  406. sw->wrap();
  407. box.size = sw->box.size;
  408. }
  409. };
  410. struct ScrewBlack : SVGScrew {
  411. ScrewBlack() {
  412. sw->svg = SVG::load("res/ComponentLibrary/ScrewBlack.svg");
  413. sw->wrap();
  414. box.size = sw->box.size;
  415. }
  416. };
  417. struct LightPanel : Panel {
  418. LightPanel() {
  419. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  420. borderColor = nvgRGB(0xac, 0xac, 0xac);
  421. }
  422. };
  423. struct DarkPanel : Panel {
  424. DarkPanel() {
  425. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  426. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  427. }
  428. };
  429. } // namespace rack