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.

457 lines
8.5KB

  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 : SpriteKnob {
  263. BefacoSlidePot() {
  264. box.size = Vec(12, 122);
  265. spriteOffset = Vec(-2, -6);
  266. spriteSize = Vec(18, 134);
  267. minIndex = 97;
  268. maxIndex = 0;
  269. spriteCount = 98;
  270. spriteImage = Image::load("res/ComponentLibrary/BefacoSlidePot.png");
  271. }
  272. };
  273. ////////////////////
  274. // Jacks
  275. ////////////////////
  276. struct PJ301MPort : SpritePort {
  277. PJ301MPort() {
  278. box.size = Vec(24, 24);
  279. spriteOffset = Vec(-2, -2);
  280. spriteSize = Vec(30, 30);
  281. spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
  282. // setSVG(SVG::load("res/ComponentLibrary/PJ301M.svg"));
  283. }
  284. };
  285. struct PJ3410Port : SpritePort {
  286. PJ3410Port() {
  287. box.size = Vec(32, 31);
  288. spriteOffset = Vec(-1, -1);
  289. spriteSize = Vec(36, 36);
  290. spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
  291. // setSVG(SVG::load("res/ComponentLibrary/PJ3410.svg"));
  292. }
  293. };
  294. struct CL1362Port : SpritePort {
  295. CL1362Port() {
  296. box.size = Vec(33, 29);
  297. spriteOffset = Vec(-2, -2);
  298. spriteSize = Vec(39, 36);
  299. spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
  300. // setSVG(SVG::load("res/ComponentLibrary/CL1362.svg"));
  301. }
  302. };
  303. ////////////////////
  304. // Lights
  305. ////////////////////
  306. struct ValueLight : Light {
  307. float *value;
  308. };
  309. template <int COLOR>
  310. struct ColorValueLight : ValueLight {
  311. void step() {
  312. float v = sqrtBipolar(getf(value));
  313. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v);
  314. }
  315. };
  316. typedef ColorValueLight<COLOR_RED> RedValueLight;
  317. typedef ColorValueLight<COLOR_YELLOW> YellowValueLight;
  318. typedef ColorValueLight<COLOR_GREEN> GreenValueLight;
  319. template <int COLOR_POS, int COLOR_NEG>
  320. struct PolarityLight : ValueLight {
  321. void step() {
  322. float v = sqrtBipolar(getf(value));
  323. if (v >= 0.0)
  324. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v);
  325. else
  326. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v);
  327. }
  328. };
  329. typedef PolarityLight<COLOR_GREEN, COLOR_RED> GreenRedPolarityLight;
  330. template <typename BASE>
  331. struct LargeLight : BASE {
  332. LargeLight() {
  333. this->box.size = Vec(20, 20);
  334. }
  335. };
  336. template <typename BASE>
  337. struct MediumLight : BASE {
  338. MediumLight() {
  339. this->box.size = Vec(12, 12);
  340. }
  341. };
  342. template <typename BASE>
  343. struct SmallLight : BASE {
  344. SmallLight() {
  345. this->box.size = Vec(8, 8);
  346. }
  347. };
  348. ////////////////////
  349. // Misc
  350. ////////////////////
  351. /** If you don't add these to your ModuleWidget, it will fall out of the rack... */
  352. struct Screw : SpriteWidget {
  353. Screw() {
  354. box.size = Vec(15, 14);
  355. spriteOffset = Vec(0, 0);
  356. spriteSize = Vec(15, 14);
  357. }
  358. };
  359. struct BlackScrew : Screw {
  360. BlackScrew() {
  361. spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png");
  362. }
  363. };
  364. struct SilverScrew : Screw {
  365. SilverScrew() {
  366. spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png");
  367. }
  368. };
  369. struct LightPanel : Panel {
  370. LightPanel() {
  371. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  372. borderColor = nvgRGB(0xa1, 0xa1, 0xa1);
  373. }
  374. };
  375. struct DarkPanel : Panel {
  376. DarkPanel() {
  377. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  378. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  379. }
  380. };
  381. } // namespace rack