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.

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