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.

570 lines
13KB

  1. #pragma once
  2. #include "app.hpp"
  3. #include "asset.hpp"
  4. namespace rack {
  5. ////////////////////
  6. // Colors
  7. ////////////////////
  8. static const NVGcolor COLOR_BLACK_TRANSPARENT = nvgRGBA(0x00, 0x00, 0x00, 0x00);
  9. static const NVGcolor COLOR_BLACK = nvgRGB(0x00, 0x00, 0x00);
  10. static const NVGcolor COLOR_WHITE = nvgRGB(0xff, 0xff, 0xff);
  11. static const NVGcolor COLOR_RED = nvgRGB(0xed, 0x2c, 0x24);
  12. static const NVGcolor COLOR_ORANGE = nvgRGB(0xf2, 0xb1, 0x20);
  13. static const NVGcolor COLOR_YELLOW = nvgRGB(0xf9, 0xdf, 0x1c);
  14. static const NVGcolor COLOR_GREEN = nvgRGB(0x90, 0xc7, 0x3e);
  15. static const NVGcolor COLOR_CYAN = nvgRGB(0x22, 0xe6, 0xef);
  16. static const NVGcolor COLOR_BLUE = nvgRGB(0x29, 0xb2, 0xef);
  17. static const NVGcolor COLOR_PURPLE = nvgRGB(0xd5, 0x2b, 0xed);
  18. static const NVGcolor COLOR_LIGHT_PANEL = nvgRGB(0xe6, 0xe6, 0xe6);
  19. static const NVGcolor COLOR_DARK_PANEL = nvgRGB(0x17, 0x17, 0x17);
  20. ////////////////////
  21. // Knobs
  22. ////////////////////
  23. struct RoundKnob : SVGKnob {
  24. RoundKnob() {
  25. minAngle = -0.83*M_PI;
  26. maxAngle = 0.83*M_PI;
  27. }
  28. };
  29. struct RoundBlackKnob : RoundKnob {
  30. RoundBlackKnob() {
  31. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/RoundBlack.svg")));
  32. box.size = Vec(38, 38);
  33. }
  34. };
  35. struct RoundSmallBlackKnob : RoundBlackKnob {
  36. RoundSmallBlackKnob() {
  37. box.size = Vec(28, 28);
  38. }
  39. };
  40. struct RoundLargeBlackKnob : RoundBlackKnob {
  41. RoundLargeBlackKnob() {
  42. box.size = Vec(46, 46);
  43. }
  44. };
  45. struct RoundHugeBlackKnob : RoundBlackKnob {
  46. RoundHugeBlackKnob() {
  47. box.size = Vec(56, 56);
  48. }
  49. };
  50. struct RoundSmallBlackSnapKnob : RoundSmallBlackKnob {
  51. RoundSmallBlackSnapKnob() {
  52. snap = true;
  53. }
  54. };
  55. struct Davies1900hKnob : SVGKnob {
  56. Davies1900hKnob() {
  57. minAngle = -0.83*M_PI;
  58. maxAngle = 0.83*M_PI;
  59. }
  60. };
  61. struct Davies1900hWhiteKnob : Davies1900hKnob {
  62. Davies1900hWhiteKnob() {
  63. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hWhite.svg")));
  64. }
  65. };
  66. struct Davies1900hBlackKnob : Davies1900hKnob {
  67. Davies1900hBlackKnob() {
  68. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hBlack.svg")));
  69. }
  70. };
  71. struct Davies1900hRedKnob : Davies1900hKnob {
  72. Davies1900hRedKnob() {
  73. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hRed.svg")));
  74. }
  75. };
  76. struct Davies1900hLargeWhiteKnob : Davies1900hKnob {
  77. Davies1900hLargeWhiteKnob() {
  78. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeWhite.svg")));
  79. }
  80. };
  81. struct Davies1900hLargeBlackKnob : Davies1900hKnob {
  82. Davies1900hLargeBlackKnob() {
  83. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeBlack.svg")));
  84. }
  85. };
  86. struct Davies1900hLargeRedKnob : Davies1900hKnob {
  87. Davies1900hLargeRedKnob() {
  88. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Davies1900hLargeRed.svg")));
  89. }
  90. };
  91. struct Rogan : SVGKnob {
  92. Rogan() {
  93. minAngle = -0.83*M_PI;
  94. maxAngle = 0.83*M_PI;
  95. }
  96. };
  97. struct Rogan6PSWhite : Rogan {
  98. Rogan6PSWhite() {
  99. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan6PSWhite.svg")));
  100. }
  101. };
  102. struct Rogan5PSGray : Rogan {
  103. Rogan5PSGray() {
  104. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan5PSGray.svg")));
  105. }
  106. };
  107. struct Rogan3PSBlue : Rogan {
  108. Rogan3PSBlue() {
  109. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSBlue.svg")));
  110. }
  111. };
  112. struct Rogan3PSRed : Rogan {
  113. Rogan3PSRed() {
  114. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSRed.svg")));
  115. }
  116. };
  117. struct Rogan3PSGreen : Rogan {
  118. Rogan3PSGreen() {
  119. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSGreen.svg")));
  120. }
  121. };
  122. struct Rogan3PSWhite : Rogan {
  123. Rogan3PSWhite() {
  124. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PSWhite.svg")));
  125. }
  126. };
  127. struct Rogan3PBlue : Rogan {
  128. Rogan3PBlue() {
  129. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PBlue.svg")));
  130. }
  131. };
  132. struct Rogan3PRed : Rogan {
  133. Rogan3PRed() {
  134. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PRed.svg")));
  135. }
  136. };
  137. struct Rogan3PGreen : Rogan {
  138. Rogan3PGreen() {
  139. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PGreen.svg")));
  140. }
  141. };
  142. struct Rogan3PWhite : Rogan {
  143. Rogan3PWhite() {
  144. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan3PWhite.svg")));
  145. }
  146. };
  147. struct Rogan2SGray : Rogan {
  148. Rogan2SGray() {
  149. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2SGray.svg")));
  150. }
  151. };
  152. struct Rogan2PSBlue : Rogan {
  153. Rogan2PSBlue() {
  154. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSBlue.svg")));
  155. }
  156. };
  157. struct Rogan2PSRed : Rogan {
  158. Rogan2PSRed() {
  159. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSRed.svg")));
  160. }
  161. };
  162. struct Rogan2PSGreen : Rogan {
  163. Rogan2PSGreen() {
  164. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSGreen.svg")));
  165. }
  166. };
  167. struct Rogan2PSWhite : Rogan {
  168. Rogan2PSWhite() {
  169. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PSWhite.svg")));
  170. }
  171. };
  172. struct Rogan2PBlue : Rogan {
  173. Rogan2PBlue() {
  174. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PBlue.svg")));
  175. }
  176. };
  177. struct Rogan2PRed : Rogan {
  178. Rogan2PRed() {
  179. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PRed.svg")));
  180. }
  181. };
  182. struct Rogan2PGreen : Rogan {
  183. Rogan2PGreen() {
  184. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PGreen.svg")));
  185. }
  186. };
  187. struct Rogan2PWhite : Rogan {
  188. Rogan2PWhite() {
  189. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan2PWhite.svg")));
  190. }
  191. };
  192. struct Rogan1PSBlue : Rogan {
  193. Rogan1PSBlue() {
  194. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSBlue.svg")));
  195. }
  196. };
  197. struct Rogan1PSRed : Rogan {
  198. Rogan1PSRed() {
  199. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSRed.svg")));
  200. }
  201. };
  202. struct Rogan1PSGreen : Rogan {
  203. Rogan1PSGreen() {
  204. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSGreen.svg")));
  205. }
  206. };
  207. struct Rogan1PSWhite : Rogan {
  208. Rogan1PSWhite() {
  209. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PSWhite.svg")));
  210. }
  211. };
  212. struct Rogan1PBlue : Rogan {
  213. Rogan1PBlue() {
  214. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PBlue.svg")));
  215. }
  216. };
  217. struct Rogan1PRed : Rogan {
  218. Rogan1PRed() {
  219. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PRed.svg")));
  220. }
  221. };
  222. struct Rogan1PGreen : Rogan {
  223. Rogan1PGreen() {
  224. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PGreen.svg")));
  225. }
  226. };
  227. struct Rogan1PWhite : Rogan {
  228. Rogan1PWhite() {
  229. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Rogan1PWhite.svg")));
  230. }
  231. };
  232. struct SynthTechAlco : SVGKnob {
  233. SynthTechAlco() {
  234. minAngle = -0.82*M_PI;
  235. maxAngle = 0.82*M_PI;
  236. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/SynthTechAlco.svg")));
  237. SVGWidget *cap = new SVGWidget();
  238. cap->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/SynthTechAlco_cap.svg")));
  239. addChild(cap);
  240. }
  241. };
  242. struct Trimpot : SVGKnob {
  243. Trimpot() {
  244. box.size = Vec(17, 17);
  245. minAngle = -0.75*M_PI;
  246. maxAngle = 0.75*M_PI;
  247. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/Trimpot.svg")));
  248. }
  249. };
  250. struct BefacoBigKnob : SVGKnob {
  251. BefacoBigKnob() {
  252. box.size = Vec(75, 75);
  253. minAngle = -0.75*M_PI;
  254. maxAngle = 0.75*M_PI;
  255. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoBigKnob.svg")));
  256. }
  257. };
  258. struct BefacoBigSnapKnob : BefacoBigKnob {
  259. BefacoBigSnapKnob() {
  260. snap = true;
  261. }
  262. };
  263. struct BefacoTinyKnob : SVGKnob {
  264. BefacoTinyKnob() {
  265. box.size = Vec(26, 26);
  266. minAngle = -0.75*M_PI;
  267. maxAngle = 0.75*M_PI;
  268. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/BefacoTinyKnob.svg")));
  269. }
  270. };
  271. struct BefacoSlidePot : SVGFader {
  272. BefacoSlidePot() {
  273. Vec margin = Vec(3.5, 3.5);
  274. maxHandlePos = Vec(-1, -2).plus(margin);
  275. minHandlePos = Vec(-1, 87).plus(margin);
  276. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePot.svg"));
  277. background->wrap();
  278. background->box.pos = margin;
  279. box.size = background->box.size.plus(margin.mult(2));
  280. handle->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePotHandle.svg"));
  281. handle->wrap();
  282. }
  283. };
  284. ////////////////////
  285. // IO widgets
  286. ////////////////////
  287. struct USB_B_AudioWidget : AudioWidget, SVGWidget {
  288. USB_B_AudioWidget() {
  289. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/USB-B.svg")));
  290. }
  291. };
  292. struct MIDI_DIN_MidiWidget : MidiWidget, SVGWidget {
  293. MIDI_DIN_MidiWidget() {
  294. setSVG(SVG::load(assetGlobal("res/ComponentLibrary/MIDI_DIN.svg")));
  295. }
  296. };
  297. ////////////////////
  298. // Jacks
  299. ////////////////////
  300. struct PJ301MPort : SVGPort {
  301. PJ301MPort() {
  302. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ301M.svg"));
  303. background->wrap();
  304. box.size = background->box.size;
  305. }
  306. };
  307. struct PJ3410Port : SVGPort {
  308. PJ3410Port() {
  309. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ3410.svg"));
  310. background->wrap();
  311. box.size = background->box.size;
  312. }
  313. };
  314. struct CL1362Port : SVGPort {
  315. CL1362Port() {
  316. background->svg = SVG::load(assetGlobal("res/ComponentLibrary/CL1362.svg"));
  317. background->wrap();
  318. box.size = background->box.size;
  319. }
  320. };
  321. ////////////////////
  322. // Lights
  323. ////////////////////
  324. struct RedLight : ModuleLightWidget {
  325. RedLight() {
  326. addBaseColor(COLOR_RED);
  327. }
  328. };
  329. struct GreenLight : ModuleLightWidget {
  330. GreenLight() {
  331. addBaseColor(COLOR_GREEN);
  332. }
  333. };
  334. struct YellowLight : ModuleLightWidget {
  335. YellowLight() {
  336. addBaseColor(COLOR_YELLOW);
  337. }
  338. };
  339. struct BlueLight : ModuleLightWidget {
  340. BlueLight() {
  341. addBaseColor(COLOR_BLUE);
  342. }
  343. };
  344. /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */
  345. struct GreenRedLight : ModuleLightWidget {
  346. GreenRedLight() {
  347. addBaseColor(COLOR_GREEN);
  348. addBaseColor(COLOR_RED);
  349. }
  350. };
  351. struct RedGreenBlueLight : ModuleLightWidget {
  352. RedGreenBlueLight() {
  353. addBaseColor(COLOR_RED);
  354. addBaseColor(COLOR_GREEN);
  355. addBaseColor(COLOR_BLUE);
  356. }
  357. };
  358. /** Based on the size of 5mm LEDs */
  359. template <typename BASE>
  360. struct LargeLight : BASE {
  361. LargeLight() {
  362. this->box.size = mm2px(Vec(5.179, 5.179));
  363. }
  364. };
  365. /** Based on the size of 3mm LEDs */
  366. template <typename BASE>
  367. struct MediumLight : BASE {
  368. MediumLight() {
  369. this->box.size = mm2px(Vec(3.176, 3.176));
  370. }
  371. };
  372. /** Based on the size of 2mm LEDs */
  373. template <typename BASE>
  374. struct SmallLight : BASE {
  375. SmallLight() {
  376. this->box.size = mm2px(Vec(2.176, 2.176));
  377. }
  378. };
  379. /** Based on the size of 1mm LEDs */
  380. template <typename BASE>
  381. struct TinyLight : BASE {
  382. TinyLight() {
  383. this->box.size = mm2px(Vec(1.088, 1.088));
  384. }
  385. };
  386. ////////////////////
  387. // Switches and Buttons
  388. ////////////////////
  389. struct NKK : SVGSwitch, ToggleSwitch {
  390. NKK() {
  391. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_0.svg")));
  392. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_1.svg")));
  393. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/NKK_2.svg")));
  394. }
  395. };
  396. struct CKSS : SVGSwitch, ToggleSwitch {
  397. CKSS() {
  398. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_0.svg")));
  399. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSS_1.svg")));
  400. }
  401. };
  402. struct CKSSThree : SVGSwitch, ToggleSwitch {
  403. CKSSThree() {
  404. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_0.svg")));
  405. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_1.svg")));
  406. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKSSThree_2.svg")));
  407. }
  408. };
  409. struct CKD6 : SVGSwitch, MomentarySwitch {
  410. CKD6() {
  411. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_0.svg")));
  412. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/CKD6_1.svg")));
  413. }
  414. };
  415. struct TL1105 : SVGSwitch, MomentarySwitch {
  416. TL1105() {
  417. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_0.svg")));
  418. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/TL1105_1.svg")));
  419. }
  420. };
  421. struct LEDButton : SVGSwitch, MomentarySwitch {
  422. LEDButton() {
  423. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDButton.svg")));
  424. }
  425. };
  426. struct BefacoSwitch : SVGSwitch, ToggleSwitch {
  427. BefacoSwitch() {
  428. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_0.svg")));
  429. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_1.svg")));
  430. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSwitch_2.svg")));
  431. }
  432. };
  433. struct BefacoPush : SVGSwitch, MomentarySwitch {
  434. BefacoPush() {
  435. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_0.svg")));
  436. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/BefacoPush_1.svg")));
  437. }
  438. };
  439. struct PB61303 : SVGSwitch, MomentarySwitch {
  440. PB61303() {
  441. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/PB61303.svg")));
  442. }
  443. };
  444. struct LEDBezel : SVGSwitch, MomentarySwitch {
  445. LEDBezel() {
  446. addFrame(SVG::load(assetGlobal("res/ComponentLibrary/LEDBezel.svg")));
  447. }
  448. };
  449. ////////////////////
  450. // Misc
  451. ////////////////////
  452. struct ScrewSilver : SVGScrew {
  453. ScrewSilver() {
  454. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewSilver.svg")));
  455. box.size = sw->box.size;
  456. }
  457. };
  458. struct ScrewBlack : SVGScrew {
  459. ScrewBlack() {
  460. sw->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/ScrewBlack.svg")));
  461. box.size = sw->box.size;
  462. }
  463. };
  464. struct LightPanel : Panel {
  465. LightPanel() {
  466. backgroundColor = COLOR_LIGHT_PANEL;
  467. }
  468. };
  469. struct DarkPanel : Panel {
  470. DarkPanel() {
  471. backgroundColor = COLOR_DARK_PANEL;
  472. }
  473. };
  474. } // namespace rack