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.

561 lines
11KB

  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.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 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 Trimpot : SVGKnob {
  254. Trimpot() {
  255. box.size = Vec(17, 17);
  256. minAngle = -0.75*M_PI;
  257. maxAngle = 0.75*M_PI;
  258. setSVG(SVG::load("res/ComponentLibrary/Trimpot.svg"));
  259. }
  260. };
  261. struct BefacoBigKnob : SVGKnob {
  262. BefacoBigKnob() {
  263. box.size = Vec(75, 75);
  264. minAngle = -0.75*M_PI;
  265. maxAngle = 0.75*M_PI;
  266. setSVG(SVG::load("res/ComponentLibrary/BefacoBigKnob.svg"));
  267. }
  268. };
  269. struct BefacoTinyKnob : SVGKnob {
  270. BefacoTinyKnob() {
  271. box.size = Vec(26, 26);
  272. minAngle = -0.75*M_PI;
  273. maxAngle = 0.75*M_PI;
  274. setSVG(SVG::load("res/ComponentLibrary/BefacoTinyKnob.svg"));
  275. }
  276. };
  277. struct BefacoSlidePot : SVGSlider {
  278. BefacoSlidePot() {
  279. Vec margin = Vec(3.5, 3.5);
  280. maxHandlePos = Vec(-1, -2).plus(margin);
  281. minHandlePos = Vec(-1, 87).plus(margin);
  282. background->svg = SVG::load("res/ComponentLibrary/BefacoSlidePot.svg");
  283. background->wrap();
  284. background->box.pos = margin;
  285. box.size = background->box.size.plus(margin.mult(2));
  286. handle->svg = SVG::load("res/ComponentLibrary/BefacoSlidePotHandle.svg");
  287. handle->wrap();
  288. }
  289. };
  290. ////////////////////
  291. // Jacks
  292. ////////////////////
  293. struct PJ301MPort : SVGPort {
  294. PJ301MPort() {
  295. padding = Vec(1, 1);
  296. background->svg = SVG::load("res/ComponentLibrary/PJ301M.svg");
  297. background->wrap();
  298. box.size = background->box.size;
  299. }
  300. };
  301. struct PJ3410Port : SVGPort {
  302. PJ3410Port() {
  303. padding = Vec(1, 1);
  304. background->svg = SVG::load("res/ComponentLibrary/PJ3410.svg");
  305. background->wrap();
  306. box.size = background->box.size;
  307. }
  308. };
  309. struct CL1362Port : SVGPort {
  310. CL1362Port() {
  311. padding = Vec(1, 1);
  312. background->svg = SVG::load("res/ComponentLibrary/CL1362.svg");
  313. background->wrap();
  314. box.size = background->box.size;
  315. }
  316. };
  317. ////////////////////
  318. // LEDs
  319. ////////////////////
  320. struct ValueLight : Light {
  321. float *value;
  322. };
  323. struct ColorValueLight : ValueLight {
  324. NVGcolor baseColor;
  325. void step() {
  326. float v = sqrtBipolar(getf(value));
  327. color = baseColor;
  328. color.a = clampf(v, 0.0, 1.0);
  329. }
  330. };
  331. struct RedValueLight : ColorValueLight {
  332. RedValueLight() {
  333. baseColor = COLOR_RED;
  334. }
  335. };
  336. struct YellowValueLight : ColorValueLight {
  337. YellowValueLight() {
  338. baseColor = COLOR_YELLOW;
  339. }
  340. };
  341. struct GreenValueLight : ColorValueLight {
  342. GreenValueLight() {
  343. baseColor = COLOR_GREEN;
  344. }
  345. };
  346. struct PolarityLight : ValueLight {
  347. NVGcolor posColor;
  348. NVGcolor negColor;
  349. void step() {
  350. float v = sqrtBipolar(getf(value));
  351. color = (v >= 0.0) ? posColor : negColor;
  352. color.a = clampf(fabsf(v), 0.0, 1.0);
  353. }
  354. };
  355. struct GreenRedPolarityLight : PolarityLight {
  356. GreenRedPolarityLight() {
  357. posColor = COLOR_GREEN;
  358. negColor = COLOR_RED;
  359. }
  360. };
  361. struct ModeValueLight : ValueLight {
  362. std::vector<NVGcolor> colors;
  363. void step() {
  364. int mode = clampi((int)roundf(getf(value)), 0, colors.size());
  365. color = colors[mode];
  366. }
  367. void addColor(NVGcolor color) {
  368. colors.push_back(color);
  369. }
  370. };
  371. template <typename BASE>
  372. struct LargeLight : BASE {
  373. LargeLight() {
  374. this->box.size = Vec(20, 20);
  375. }
  376. };
  377. template <typename BASE>
  378. struct MediumLight : BASE {
  379. MediumLight() {
  380. this->box.size = Vec(12, 12);
  381. }
  382. };
  383. template <typename BASE>
  384. struct SmallLight : BASE {
  385. SmallLight() {
  386. this->box.size = Vec(8, 8);
  387. }
  388. };
  389. ////////////////////
  390. // Switches and Buttons
  391. ////////////////////
  392. struct NKK : SVGSwitch, ToggleSwitch {
  393. NKK() {
  394. addFrame(SVG::load("res/ComponentLibrary/NKK_0.svg"));
  395. addFrame(SVG::load("res/ComponentLibrary/NKK_1.svg"));
  396. addFrame(SVG::load("res/ComponentLibrary/NKK_2.svg"));
  397. sw->wrap();
  398. box.size = sw->box.size;
  399. }
  400. };
  401. struct CKSS : SVGSwitch, ToggleSwitch {
  402. CKSS() {
  403. addFrame(SVG::load("res/ComponentLibrary/CKSS_0.svg"));
  404. addFrame(SVG::load("res/ComponentLibrary/CKSS_1.svg"));
  405. sw->wrap();
  406. box.size = sw->box.size;
  407. }
  408. };
  409. struct CKD6 : SVGSwitch, MomentarySwitch {
  410. CKD6() {
  411. addFrame(SVG::load("res/ComponentLibrary/CKD6_0.svg"));
  412. addFrame(SVG::load("res/ComponentLibrary/CKD6_1.svg"));
  413. sw->wrap();
  414. box.size = sw->box.size;
  415. }
  416. };
  417. struct TL1105 : SVGSwitch, MomentarySwitch {
  418. TL1105() {
  419. addFrame(SVG::load("res/ComponentLibrary/TL1105_0.svg"));
  420. addFrame(SVG::load("res/ComponentLibrary/TL1105_1.svg"));
  421. sw->wrap();
  422. box.size = sw->box.size;
  423. }
  424. };
  425. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  426. BefacoSwitch() {
  427. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_0.svg"));
  428. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_1.svg"));
  429. addFrame(SVG::load("res/ComponentLibrary/BefacoSwitch_2.svg"));
  430. sw->wrap();
  431. box.size = sw->box.size;
  432. }
  433. };
  434. struct BefacoPush : SVGSwitch, MomentarySwitch {
  435. BefacoPush() {
  436. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_0.svg"));
  437. addFrame(SVG::load("res/ComponentLibrary/BefacoPush_1.svg"));
  438. sw->wrap();
  439. box.size = sw->box.size;
  440. }
  441. };
  442. ////////////////////
  443. // Misc
  444. ////////////////////
  445. struct ScrewSilver : SVGScrew {
  446. ScrewSilver() {
  447. sw->svg = SVG::load("res/ComponentLibrary/ScrewSilver.svg");
  448. sw->wrap();
  449. box.size = sw->box.size;
  450. }
  451. };
  452. struct ScrewBlack : SVGScrew {
  453. ScrewBlack() {
  454. sw->svg = SVG::load("res/ComponentLibrary/ScrewBlack.svg");
  455. sw->wrap();
  456. box.size = sw->box.size;
  457. }
  458. };
  459. struct LightPanel : Panel {
  460. LightPanel() {
  461. // backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  462. backgroundColor = nvgRGB(0xf4, 0xf4, 0xf4);
  463. borderColor = nvgRGB(0xac, 0xac, 0xac);
  464. }
  465. };
  466. struct DarkPanel : Panel {
  467. DarkPanel() {
  468. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  469. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  470. }
  471. };
  472. } // namespace rack