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.

448 lines
11KB

  1. #pragma once
  2. #include "componentlibrary.hpp"
  3. #include "app.hpp"
  4. #include "asset.hpp"
  5. #include <vector>
  6. #include <jansson.h>
  7. #include "widgets.hpp"
  8. #include <iostream>
  9. using namespace std;
  10. namespace rack_plugin_Bark {
  11. ///Colour--------------------------------------------------
  12. const NVGcolor BARK_GREEN = nvgRGBA(73, 191, 0, 255);
  13. const NVGcolor BARK_YELLOW1 = nvgRGBA(255, 212, 42, 255);
  14. const NVGcolor BARK_YELLOW2 = nvgRGBA(255, 192, 42, 255);
  15. const NVGcolor BARK_ORANGE = nvgRGBA(250, 123, 0, 255);
  16. const NVGcolor BARK_RED = nvgRGBA(186, 15, 0, 255);
  17. const NVGcolor BARK_CLIPPING = nvgRGBA(240, 255, 255, 255);//white
  18. ///Colour--------------------------------------------------
  19. //const int btnLock;
  20. ////Screw----
  21. struct BarkScrew1 : SVGScrew {
  22. BarkScrew1() {
  23. sw->svg = SVG::load(assetPlugin(plugin, "res/components/BarkScrew1.svg"));
  24. sw->wrap();
  25. box.size = sw->box.size;
  26. }
  27. };
  28. struct BarkScrew2 : SVGScrew {
  29. BarkScrew2() {
  30. sw->svg = SVG::load(assetPlugin(plugin, "res/components/BarkScrew2.svg"));
  31. sw->wrap();
  32. box.size = sw->box.size;
  33. }
  34. };
  35. struct BarkScrew3 : SVGScrew {
  36. BarkScrew3() {
  37. sw->svg = SVG::load(assetPlugin(plugin, "res/components/BarkScrew3.svg"));
  38. sw->wrap();
  39. box.size = sw->box.size;
  40. }
  41. };
  42. struct BarkScrew4 : SVGScrew {
  43. BarkScrew4() {
  44. sw->svg = SVG::load(assetPlugin(plugin, "res/components/BarkScrew4.svg"));
  45. sw->wrap();
  46. box.size = sw->box.size;
  47. }
  48. };
  49. struct BarkScrew01 : SVGKnob {
  50. BarkScrew01() {
  51. minAngle = -6.99 * M_PI;
  52. maxAngle = 6.99 * M_PI;
  53. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkScrew01.svg")));
  54. sw->wrap();
  55. box.size = sw->box.size;
  56. speed = 0.18f;
  57. }
  58. void randomize() override {}
  59. };
  60. struct BarkScrew02 : SVGKnob {
  61. BarkScrew02() {
  62. minAngle = -2.0 * M_PI;
  63. maxAngle = 2.0 * M_PI;
  64. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkScrew01.svg")));
  65. sw->wrap();
  66. box.size = sw->box.size;
  67. speed = 0.5f;
  68. }
  69. void randomize() override {}
  70. };
  71. ////Toggle----
  72. struct BarkSwitch : SVGSwitch, ToggleSwitch {
  73. BarkSwitch() {
  74. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitch_0.svg"))); // State=0
  75. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitch_1.svg"))); // State=1
  76. }
  77. };
  78. struct BarkSwitchSmall : SVGSwitch, ToggleSwitch {
  79. BarkSwitchSmall() {
  80. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitchSmall_0.svg")));
  81. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitchSmall_1.svg")));
  82. }
  83. };
  84. struct BarkSwitchSmallSide : SVGSwitch, ToggleSwitch {
  85. BarkSwitchSmallSide() {
  86. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitchSmallSide_0.svg")));
  87. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkSwitchSmallSide_1.svg")));
  88. }
  89. };
  90. struct BarkButton1 : SVGSwitch, MomentarySwitch {
  91. BarkButton1() {
  92. addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonReset_0.svg")));
  93. }
  94. };
  95. //struct BarkButtonMinus : SVGSwitch, ToggleSwitch {
  96. // BarkButtonMinus() {
  97. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonMinus.svg")));
  98. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonMinus_0.svg")));
  99. // }
  100. //};
  101. //struct BarkButtonPlus : SVGSwitch, ToggleSwitch { //MomentarySwitch
  102. // BarkButtonPlus() {
  103. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonPlus.svg")));
  104. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonPlus_0.svg")));
  105. // }
  106. //};
  107. //struct BarkBtnLockSnap : SVGSwitch, ToggleSwitch {
  108. // BarkBtnLockSnap() {
  109. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonLock.svg")));
  110. // addFrame(SVG::load(assetPlugin(plugin, "res/components/BarkButtonUnlock.svg")));
  111. // }
  112. //};
  113. ////Slider----
  114. struct BarkSlide1 : SVGFader {
  115. BarkSlide1() {
  116. ///TODO: toggle for snap or fade or momentary button to snap to nearest
  117. snap = false;
  118. maxHandlePos = Vec(95.f, 0.0f);
  119. minHandlePos = Vec(-5.0f, 0.0f);
  120. background->svg = SVG::load(assetPlugin(plugin, "res/components/Barkslider1.svg"));
  121. background->wrap();
  122. background->box.pos = Vec(0.0f, 0.0f);
  123. box.size = background->box.size;
  124. handle->svg = SVG::load(assetPlugin(plugin, "res/components/BarksliderHandle1.svg"));
  125. handle->wrap();
  126. handle->box.pos = Vec(0.0f, 0.0f);
  127. speed = 0.5f;
  128. }
  129. ///flips up/down axis to left/right
  130. void onDragMove(EventDragMove &e) override {
  131. EventDragMove e2 = e;
  132. e2.mouseRel = Vec(e.mouseRel.y, -e.mouseRel.x);
  133. SVGFader::onDragMove(e2);
  134. }
  135. ///turns off randomising
  136. void randomize() override {}
  137. };
  138. ////Ports----
  139. ///Port In--
  140. struct BarkInPort : SVGPort {
  141. BarkInPort() {
  142. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkInPort.svg"));
  143. background->wrap();
  144. box.size = background->box.size;
  145. }
  146. };
  147. struct BarkInPort1 : SVGPort {
  148. BarkInPort1() {
  149. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkInPort1.svg"));
  150. background->wrap();
  151. box.size = background->box.size;
  152. }
  153. };
  154. struct BarkInPort2 : SVGPort {
  155. BarkInPort2() {
  156. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkInPort2.svg"));
  157. background->wrap();
  158. box.size = background->box.size;
  159. }
  160. };
  161. struct BarkPatchPortIn : SVGPort {
  162. BarkPatchPortIn() {
  163. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkPatchPortIn.svg"));
  164. background->wrap();
  165. box.size = background->box.size;
  166. }
  167. };
  168. struct BarkInPort350 : SVGPort {
  169. BarkInPort350() {
  170. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkInPort350.svg"));
  171. background->wrap();
  172. box.size = background->box.size;
  173. }
  174. };
  175. ///Port Out--
  176. struct BarkOutPort : SVGPort {
  177. BarkOutPort() {
  178. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkOutPort.svg"));
  179. background->wrap();
  180. box.size = background->box.size;
  181. }
  182. };
  183. struct BarkOutPort1 : SVGPort {
  184. BarkOutPort1() {
  185. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkOutPort1.svg"));
  186. background->wrap();
  187. box.size = background->box.size;
  188. }
  189. };
  190. struct BarkOutPort2 : SVGPort {
  191. BarkOutPort2() {
  192. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkOutPort2.svg"));
  193. background->wrap();
  194. box.size = background->box.size;
  195. }
  196. };
  197. struct BarkPatchPortOut : SVGPort {
  198. BarkPatchPortOut() {
  199. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkPatchPortOut.svg"));
  200. background->wrap();
  201. box.size = background->box.size;
  202. }
  203. };
  204. struct BarkOutPort350 : SVGPort {
  205. BarkOutPort350() {
  206. background->svg = SVG::load(assetPlugin(plugin, "res/components/BarkOutPort350.svg"));
  207. background->wrap();
  208. box.size = background->box.size;
  209. }
  210. };
  211. ////Knobs----
  212. struct BarkKnob9 : SVGKnob {
  213. BarkKnob9() {
  214. minAngle = -0.835 * M_PI;
  215. maxAngle = 0.831 * M_PI;
  216. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob9.svg")));
  217. sw->wrap();
  218. box.size = sw->box.size;
  219. }
  220. };
  221. struct BarkKnob24 : SVGKnob {
  222. BarkKnob24() {
  223. minAngle = -0.835 * M_PI;
  224. maxAngle = 0.831 * M_PI;
  225. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob24.svg")));
  226. sw->wrap();
  227. box.size = sw->box.size;
  228. }
  229. };
  230. struct BarkKnob26 : SVGKnob {
  231. BarkKnob26() {
  232. minAngle = -0.829 * M_PI;
  233. maxAngle = 0.831 * M_PI;
  234. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob26.svg")));
  235. sw->wrap();
  236. box.size = sw->box.size;
  237. speed = 0.65f;
  238. }
  239. };
  240. struct BarkKnob30 : SVGKnob {
  241. BarkKnob30() {
  242. minAngle = -0.835 * M_PI;
  243. maxAngle = 0.831 * M_PI;
  244. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob30.svg")));
  245. sw->wrap();
  246. box.size = sw->box.size;
  247. speed = 0.7f;
  248. }
  249. };
  250. struct BarkKnob40 : SVGKnob {
  251. BarkKnob40() {
  252. minAngle = -0.827 * M_PI;
  253. maxAngle = 0.825 * M_PI;
  254. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob40.svg")));
  255. sw->wrap();
  256. box.size = sw->box.size;
  257. speed = 0.8f;
  258. shadow->box.pos = Vec(0, sw->box.size.y * 0.07f);
  259. }
  260. };
  261. struct BarkKnob57 : SVGKnob {
  262. BarkKnob57() {
  263. minAngle = -0.835 * M_PI;
  264. maxAngle = 0.831 * M_PI;
  265. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob57.svg")));
  266. sw->wrap();
  267. box.size = sw->box.size;
  268. }
  269. };
  270. //struct snapMode : SVGKnob {
  271. // ParamWidget *modeSwitch;
  272. // void step() override {
  273. // snap = (modeSwitch->value > 0.f);
  274. // SVGKnob::snap();
  275. // //snapMode->modeSwitch = modeSwitch
  276. // }
  277. //};
  278. struct BarkKnob70 : SVGKnob {
  279. BarkKnob70() {
  280. minAngle = -0.83 * M_PI;
  281. maxAngle = 0.828 * M_PI;
  282. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob70.svg")));
  283. sw->wrap();
  284. box.size = sw->box.size;
  285. speed = 0.5f;
  286. shadow->box.pos = Vec(0, sw->box.size.y * 0.05);
  287. }
  288. };
  289. struct BarkKnob70Snap : SVGKnob {
  290. BarkKnob70Snap() {
  291. snap = true;
  292. minAngle = -0.83 * M_PI;
  293. maxAngle = 0.828 * M_PI;
  294. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob70.svg")));
  295. sw->wrap();
  296. box.size = sw->box.size;
  297. speed = 0.5f;
  298. shadow->box.pos = Vec(0, sw->box.size.y * 0.05);
  299. }
  300. };
  301. struct BarkKnob84 : SVGKnob {
  302. BarkKnob84() {
  303. minAngle = -0.835 * M_PI;
  304. maxAngle = 0.831 * M_PI;
  305. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob84.svg")));
  306. sw->wrap();
  307. box.size = sw->box.size;
  308. }
  309. };
  310. struct BarkKnob92 : SVGKnob {
  311. BarkKnob92() {
  312. minAngle = -0.83 * M_PI;
  313. maxAngle = 0.83 * M_PI;
  314. setSVG(SVG::load(assetPlugin(plugin, "res/components/BarkKnob92.svg")));
  315. sw->wrap();
  316. box.size = sw->box.size;
  317. }
  318. };
  319. struct KnobTest1 : SVGKnob {
  320. KnobTest1() {
  321. setSVG(SVG::load(assetPlugin(plugin, "res/components/KnobTest1.svg")));
  322. }
  323. };
  324. ///Light----
  325. struct greenLight : GrayModuleLightWidget {
  326. greenLight() {
  327. addBaseColor(BARK_GREEN);
  328. }
  329. };
  330. struct yellowLight1 : GrayModuleLightWidget {
  331. yellowLight1() {
  332. addBaseColor(BARK_YELLOW1);
  333. }
  334. };
  335. struct yellowLight2 : GrayModuleLightWidget {
  336. yellowLight2() {
  337. addBaseColor(BARK_YELLOW2);
  338. }
  339. };
  340. struct orangeLight : GrayModuleLightWidget {
  341. orangeLight() {
  342. addBaseColor(BARK_ORANGE);
  343. }
  344. };
  345. struct redLight : GrayModuleLightWidget {
  346. redLight() {
  347. addBaseColor(BARK_RED);
  348. }
  349. };
  350. struct clipLight : GrayModuleLightWidget {
  351. clipLight() {
  352. addBaseColor(BARK_CLIPPING);
  353. }
  354. };
  355. struct ParamInLight : GrayModuleLightWidget {
  356. ParamInLight() {
  357. addBaseColor(BARK_CLIPPING);
  358. }
  359. };
  360. template <typename BASE>
  361. struct BiggerLight : BASE {
  362. BiggerLight() {
  363. this->box.size = Vec(10, 10);//px
  364. this->bgColor = nvgRGBA(192, 192, 192, 32);//silver
  365. }
  366. };
  367. template <typename BASE>
  368. struct BigLight : BASE {
  369. BigLight() {
  370. this->box.size = Vec(8, 8);//px
  371. this->bgColor = nvgRGBA(192, 192, 192, 32);//silver
  372. }
  373. };
  374. template <typename BASE>
  375. struct SmallerLight : BASE {
  376. SmallerLight() {
  377. this->box.size = Vec(4, 4);//px
  378. this->bgColor = nvgRGBA(192, 192, 192, 45);//silver
  379. }
  380. };
  381. template <typename BASE>
  382. struct SmallerLightFA : BASE {
  383. SmallerLightFA() {
  384. this->box.size = Vec(4, 4);//px
  385. this->bgColor = nvgRGBA(56, 56, 56, 255);//panel
  386. this->borderColor = nvgRGBA(56, 56, 56, 255);//panel
  387. }
  388. };
  389. template <typename BASE>
  390. struct SmallestLight : BASE {
  391. SmallestLight() {
  392. this->box.size = Vec(3, 3);//px
  393. this->bgColor = nvgRGBA(192, 192, 192, 45);//silver
  394. }
  395. };
  396. } // namespace rack_plugin_Bark