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.

306 lines
8.3KB

  1. struct OnOffSwitch : SVGSwitch, ToggleSwitch {
  2. OnOffSwitch() {
  3. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/OffSwitch.svg")));
  4. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/OnSwitch.svg")));
  5. }
  6. };
  7. struct LoopSwitch : SVGSwitch, ToggleSwitch {
  8. LoopSwitch() {
  9. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/LoopOffButton.svg")));
  10. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/LoopOnButton.svg")));
  11. }
  12. };
  13. struct CvGateSwitch : SVGSwitch, ToggleSwitch {
  14. CvGateSwitch() {
  15. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/CvButton.svg")));
  16. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/GateButton.svg")));
  17. }
  18. };
  19. struct AddButton : SVGSwitch, MomentarySwitch {
  20. AddButton() {
  21. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/AddButton.svg")));
  22. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/AddButtonDown.svg")));
  23. }
  24. };
  25. struct PlayButton : SVGSwitch, MomentarySwitch {
  26. PlayButton() {
  27. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/PlayButton.svg")));
  28. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/PlayButtonDown.svg")));
  29. }
  30. };
  31. struct DotButton : SVGSwitch, MomentarySwitch {
  32. DotButton() {
  33. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/DotButton.svg")));
  34. }
  35. };
  36. struct DotDotButton : SVGSwitch, MomentarySwitch {
  37. DotDotButton() {
  38. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/DotDotButton.svg")));
  39. }
  40. };
  41. struct StopButton : SVGSwitch, MomentarySwitch {
  42. StopButton() {
  43. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/StopButton.svg")));
  44. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/StopButtonDown.svg")));
  45. }
  46. };
  47. struct RecordButton : SVGSwitch, MomentarySwitch {
  48. RecordButton() {
  49. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/RecordButton.svg")));
  50. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/RecordButtonDown.svg")));
  51. }
  52. };
  53. struct UpButton : SVGSwitch, MomentarySwitch {
  54. UpButton() {
  55. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/UpButton.svg")));
  56. }
  57. };
  58. struct DownButton : SVGSwitch, MomentarySwitch {
  59. DownButton() {
  60. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/DownButton.svg")));
  61. }
  62. };
  63. struct LeftButton : SVGSwitch, MomentarySwitch {
  64. LeftButton() {
  65. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/LeftButton.svg")));
  66. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/LeftButtonDown.svg")));
  67. }
  68. };
  69. struct RightButton : SVGSwitch, MomentarySwitch {
  70. RightButton() {
  71. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/RightButton.svg")));
  72. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/RightButtonDown.svg")));
  73. }
  74. };
  75. struct RotaryEncoderKnob : SVGKnob{
  76. RotaryEncoderKnob(){
  77. minAngle = -99999.f;
  78. maxAngle = 99999.f;
  79. speed = 0.00001f;
  80. smooth = false;
  81. }
  82. };
  83. struct StartEncoder : RotaryEncoderKnob {
  84. StartEncoder() {
  85. // minAngle = -99999.f;
  86. // maxAngle = 99999.f;
  87. // speed = 0.00004f;
  88. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/StartEncoder.svg")));
  89. }
  90. };
  91. struct StopEncoder : RotaryEncoderKnob {
  92. StopEncoder() {
  93. // minAngle = -99999.f;
  94. // maxAngle = 99999.f;
  95. // speed = 0.00004f;
  96. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/StopEncoder.svg")));
  97. }
  98. };
  99. struct ArrowSnapKnob : SVGKnob {
  100. ArrowSnapKnob() {
  101. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/ArrowKnob.svg")));
  102. snap = true;
  103. smooth = false;
  104. minAngle = -3.1414f;
  105. maxAngle = 3.1415f - (3.1415f * 0.25f);
  106. // shadow->opacity = 0.0;
  107. }
  108. };
  109. struct SmallKnob : SVGKnob {
  110. SmallKnob(){
  111. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/SmallKnob.svg")));
  112. minAngle = -3.1414f + (3.1415f * 0.25f);
  113. maxAngle = 3.1415f - (3.1415f * 0.25f);
  114. }
  115. };
  116. struct MrChainkov : SVGKnob {
  117. MrChainkov(){
  118. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/MrChainkov.svg")));
  119. minAngle = -3.1414f * 0.5f;
  120. maxAngle = 3.1415f * 0.5f;
  121. }
  122. };
  123. struct PiongKnob : SVGKnob {
  124. PiongKnob(){
  125. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/PiongKnob.svg")));
  126. minAngle = -3.1414f + (3.1415f * 0.25f);
  127. maxAngle = 3.1415f - (3.1415f * 0.25f);
  128. }
  129. };
  130. struct PiongKnobSmall : SVGKnob {
  131. PiongKnobSmall(){
  132. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/PiongKnobSmall.svg")));
  133. minAngle = -3.1414f + (3.1415f * 0.25f);
  134. maxAngle = 3.1415f - (3.1415f * 0.25f);
  135. }
  136. };
  137. struct TransparentSnapKnob : SVGKnob {
  138. TransparentSnapKnob() {
  139. setSVG(SVG::load(assetPlugin(plugin, "res/knobs/TransparentKnob.svg")));
  140. snap = true;
  141. smooth = false;
  142. shadow->opacity = 0.0;
  143. }
  144. };
  145. struct RoundSmallBlackSnapKnob : RoundSmallBlackKnob {
  146. RoundSmallBlackSnapKnob() {
  147. snap = true;
  148. smooth = false;
  149. }
  150. };
  151. struct SmallOutputPort : SVGPort {
  152. SmallOutputPort() {
  153. setSVG(SVG::load(assetPlugin(plugin, "res/ports/SmallDarkPort.svg")));
  154. shadow->opacity = 0.0;
  155. }
  156. };
  157. struct SmallDarkPort : SVGPort {
  158. SmallDarkPort() {
  159. setSVG(SVG::load(assetPlugin(plugin, "res/ports/SmallDarkPort.svg")));
  160. // shadow->opacity = 0.0;
  161. }
  162. };
  163. struct FlatDarkPort : SVGPort {
  164. FlatDarkPort() {
  165. setSVG(SVG::load(assetPlugin(plugin, "res/ports/FlatDarkPort.svg")));
  166. // shadow->opacity = 0.0;
  167. }
  168. };
  169. struct DarkHole : SVGPort {
  170. DarkHole() {
  171. setSVG(SVG::load(assetPlugin(plugin, "res/ports/DarkHole.svg")));
  172. shadow->opacity = 0.0;
  173. }
  174. };
  175. struct SmallHole : SVGPort {
  176. SmallHole() {
  177. setSVG(SVG::load(assetPlugin(plugin, "res/ports/SmallHole.svg")));
  178. shadow->opacity = 0.0;
  179. }
  180. };
  181. struct SmallBrightPort : SVGPort {
  182. SmallBrightPort() {
  183. setSVG(SVG::load(assetPlugin(plugin, "res/ports/SmallBrightPort.svg")));
  184. // shadow->opacity = 0.0;
  185. }
  186. };
  187. struct FlatInputPort : SVGPort {
  188. FlatInputPort() {
  189. setSVG(SVG::load(assetPlugin(plugin, "res/ports/FlatInputPort.svg")));
  190. }
  191. };
  192. struct InputPort : SVGPort {
  193. InputPort() {
  194. setSVG(SVG::load(assetPlugin(plugin, "res/ports/InputPort.svg")));
  195. }
  196. };
  197. struct InputGatePort : SVGPort {
  198. InputGatePort() {
  199. setSVG(SVG::load(assetPlugin(plugin, "res/ports/InputGatePort.svg")));
  200. shadow->opacity = 0.0;
  201. }
  202. };
  203. struct VOctOutputPort : SVGPort {
  204. VOctOutputPort() {
  205. setSVG(SVG::load(assetPlugin(plugin, "res/ports/VOctOutputPort.svg")));
  206. shadow->opacity = 0.0;
  207. }
  208. };
  209. struct VOctInputPort : SVGPort {
  210. VOctInputPort() {
  211. setSVG(SVG::load(assetPlugin(plugin, "res/ports/VOctInputPort.svg")));
  212. shadow->opacity = 0.0;
  213. }
  214. };
  215. struct OutputGatePort : SVGPort {
  216. OutputGatePort() {
  217. setSVG(SVG::load(assetPlugin(plugin, "res/ports/OutputGatePort.svg")));
  218. shadow->opacity = 0.0;
  219. }
  220. };
  221. struct OutputPort : SVGPort {
  222. OutputPort() {
  223. setSVG(SVG::load(assetPlugin(plugin, "res/ports/OutputPort.svg")));
  224. }
  225. };
  226. struct PeaceScrewButton : SVGSwitch, MomentarySwitch {
  227. PeaceScrewButton() {
  228. addFrame(SVG::load(assetPlugin(plugin, "res/misc/PeaceScrew.svg")));
  229. }
  230. };
  231. struct PeaceScrew : SVGScrew {
  232. PeaceScrew() {
  233. sw->setSVG(SVG::load(assetPlugin(plugin, "res/misc/PeaceScrew.svg")));
  234. box.size = sw->box.size;
  235. // sw->rotate(randomUniform() * 360.f);
  236. }
  237. };
  238. struct TreeScrew : SVGScrew {
  239. TreeScrew() {
  240. sw->setSVG(SVG::load(assetPlugin(plugin, "res/misc/TreeScrew.svg")));
  241. box.size = sw->box.size;
  242. // rotate(randomUniform() * 360.f);
  243. }
  244. };
  245. struct OrangeLight : GrayModuleLightWidget {
  246. OrangeLight(){
  247. addBaseColor(nvgRGB(0xff, 0xaa, 0x44));
  248. }
  249. };
  250. struct WhiteLight : GrayModuleLightWidget {
  251. WhiteLight(){
  252. addBaseColor(nvgRGB(0xff, 0xff, 0xfa));
  253. }
  254. };
  255. struct AutoOrGate : SVGSwitch, ToggleSwitch {
  256. AutoOrGate() {
  257. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/AG_Gate.svg")));
  258. addFrame(SVG::load(assetPlugin(plugin, "res/buttons/AG_Auto.svg")));
  259. }
  260. };
  261. class TriggerSwitch{
  262. public:
  263. bool down;
  264. int state = 0;
  265. float wait = 0;
  266. int update(float v){
  267. if(v > 0.0f){
  268. if(!down){
  269. down = true;
  270. state = 2;
  271. }else
  272. state = 1;
  273. }else if(v <= 0.0f && down){
  274. down = false;
  275. state = -1;
  276. }else{
  277. state = 0;
  278. }
  279. return state;
  280. }
  281. };
  282. class RotaryEncoder{
  283. public:
  284. float offset;
  285. float speed = 0.5f;
  286. float delta(float v){
  287. float r = v - offset;
  288. offset = v;
  289. return r * speed;
  290. }
  291. void init(float o){
  292. offset = o;
  293. }
  294. };
  295. // class Util{
  296. // public:
  297. // bool blackkeys[12] = {false, true, false, true, false, false, true, false, true, false, true, false};
  298. // };
  299. // // const bool Util::blackkeys[12] = ;