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.

631 lines
13KB

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