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.

213 lines
6.6KB

  1. #pragma once
  2. #include "componentlibrary.hpp"
  3. #include <vector>
  4. #include <jansson.h>
  5. #include "widgets.hpp"
  6. #include <iostream>
  7. using namespace std;
  8. namespace rack {
  9. struct BidooBlueKnob : RoundKnob {
  10. BidooBlueKnob() {
  11. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlueKnobBidoo.svg")));
  12. }
  13. };
  14. struct BidooHugeBlueKnob : RoundKnob {
  15. BidooHugeBlueKnob() {
  16. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/HugeBlueKnobBidoo.svg")));
  17. }
  18. };
  19. struct BidooLargeBlueKnob : RoundKnob {
  20. BidooLargeBlueKnob() {
  21. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/LargeBlueKnobBidoo.svg")));
  22. }
  23. };
  24. struct BidooSmallBlueKnob : RoundKnob {
  25. BidooSmallBlueKnob() {
  26. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/SmallBlueKnobBidoo.svg")));
  27. }
  28. };
  29. struct BidooBlueSnapKnob : RoundBlackSnapKnob {
  30. BidooBlueSnapKnob() {
  31. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlueKnobBidoo.svg")));
  32. }
  33. };
  34. struct BidooBlueTrimpot : Trimpot {
  35. BidooBlueTrimpot() {
  36. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlueTrimpotBidoo.svg")));
  37. }
  38. };
  39. struct BlueCKD6 : SVGSwitch, MomentarySwitch {
  40. BlueCKD6() {
  41. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlueCKD6_0.svg")));
  42. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlueCKD6_1.svg")));
  43. }
  44. };
  45. struct BidooziNCColoredKnob : RoundKnob {
  46. BidooziNCColoredKnob() {
  47. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/ziNCBlueKnobBidoo.svg")));
  48. }
  49. float *coeff;
  50. void draw(NVGcontext *vg) override {
  51. for (NSVGshape *shape = this->sw->svg->handle->shapes; shape != NULL; shape = shape->next) {
  52. std::string str(shape->id);
  53. if (str == "bidooziNCBlueKnob") {
  54. int corrCoef = rescale(clamp(*coeff,0.0f,1.0f),0.0f,1.0f,0.0f,255.0f);
  55. shape->fill.color = (((unsigned int)clamp(42+corrCoef,0,255)) | ((unsigned int)clamp(87-corrCoef,0,255) << 8) | ((unsigned int)clamp(117-corrCoef,0,255) << 16));
  56. shape->fill.color |= (unsigned int)(255) << 24;
  57. }
  58. }
  59. RoundKnob::draw(vg);
  60. }
  61. };
  62. struct BidooColoredKnob : RoundKnob {
  63. BidooColoredKnob() {
  64. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/BlackKnobBidoo.svg")));
  65. }
  66. void draw(NVGcontext *vg) override {
  67. for (NSVGshape *shape = this->sw->svg->handle->shapes; shape != NULL; shape = shape->next) {
  68. std::string str(shape->id);
  69. if (str == "bidooKnob") {
  70. shape->fill.color = (((unsigned int)42+(unsigned int)value*21) | (((unsigned int)87-(unsigned int)value*8) << 8) | (((unsigned int)117-(unsigned int)value) << 16));
  71. shape->fill.color |= (unsigned int)(255) << 24;
  72. }
  73. }
  74. RoundKnob::draw(vg);
  75. }
  76. };
  77. struct BidooMorphKnob : RoundKnob {
  78. BidooMorphKnob() {
  79. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/SpiralKnobBidoo.svg")));
  80. }
  81. };
  82. struct BidooColoredTrimpot : RoundKnob {
  83. BidooColoredTrimpot() {
  84. minAngle = -0.75f*M_PI;
  85. maxAngle = 0.75f*M_PI;
  86. setSVG(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/TrimpotBidoo.svg")));
  87. }
  88. void draw(NVGcontext *vg) override {
  89. for (NSVGshape *shape = this->sw->svg->handle->shapes; shape != NULL; shape = shape->next) {
  90. std::string str(shape->id);
  91. if (str == "bidooTrimPot") {
  92. if (value == 0.0f) {
  93. shape->fill.color = (((unsigned int)128) | ((unsigned int)128 << 8) | ((unsigned int)128 << 16));
  94. shape->fill.color |= (unsigned int)(120) << 24;
  95. } else {
  96. shape->fill.color = (((unsigned int)255) | (((unsigned int)(205 - (value *15)))<< 8) | ((unsigned int)10 << 16));
  97. shape->fill.color |= ((unsigned int)255) << 24;
  98. }
  99. }
  100. }
  101. RoundKnob::draw(vg);
  102. }
  103. };
  104. struct BidooSlidePotLong : SVGFader {
  105. BidooSlidePotLong() {
  106. snap = true;
  107. maxHandlePos = Vec(0.0f, 0.0f);
  108. minHandlePos = Vec(0.0f, 84.0f);
  109. background->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooSlidePotLong.svg"));
  110. background->wrap();
  111. background->box.pos = Vec(0.0f, 0.0f);
  112. box.size = background->box.size;
  113. handle->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooSlidePotHandle.svg"));
  114. handle->wrap();
  115. }
  116. void randomize() override {
  117. setValue(roundf(rescale(randomUniform(), 0.0f, 1.0f, minValue, maxValue)));
  118. }
  119. };
  120. struct BidooSlidePotShort : SVGFader {
  121. BidooSlidePotShort() {
  122. snap = true;
  123. maxHandlePos = Vec(0.0f, 0.0f);
  124. minHandlePos = Vec(0.0f, 60.0f);
  125. background->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooSlidePotShort.svg"));
  126. background->wrap();
  127. background->box.pos = Vec(0.0f, 0.0f);
  128. box.size = background->box.size;
  129. handle->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooSlidePotHandle.svg"));
  130. handle->wrap();
  131. }
  132. void randomize() override {
  133. setValue(roundf(rescale(randomUniform(), 0.0f, 1.0f, minValue, maxValue)));
  134. }
  135. };
  136. struct BidooLongSlider : SVGFader {
  137. BidooLongSlider() {
  138. maxHandlePos = Vec(0.0f, 0.0f);
  139. minHandlePos = Vec(0.0f, 84.0f);
  140. background->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooLongSlider.svg"));
  141. background->wrap();
  142. background->box.pos = Vec(0.0f, 0.0f);
  143. box.size = background->box.size;
  144. handle->svg = SVG::load(assetPlugin(plugin,"res/ComponentLibrary/bidooLongSliderHandle.svg"));
  145. handle->wrap();
  146. }
  147. };
  148. struct CKSS8 : SVGSwitch, ToggleSwitch {
  149. CKSS8() {
  150. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_0.svg")));
  151. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_1.svg")));
  152. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_2.svg")));
  153. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_3.svg")));
  154. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_4.svg")));
  155. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_5.svg")));
  156. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_6.svg")));
  157. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS8_7.svg")));
  158. sw->wrap();
  159. box.size = sw->box.size;
  160. }
  161. };
  162. struct CKSS4 : SVGSwitch, ToggleSwitch {
  163. CKSS4() {
  164. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS4_0.svg")));
  165. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS4_1.svg")));
  166. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS4_2.svg")));
  167. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/CKSS4_3.svg")));
  168. sw->wrap();
  169. box.size = sw->box.size;
  170. }
  171. };
  172. struct TinyPJ301MPort : SVGPort {
  173. TinyPJ301MPort() {
  174. background->svg = SVG::load(assetPlugin(plugin, "res/ComponentLibrary/TinyPJ301M.svg"));
  175. background->wrap();
  176. box.size = background->box.size;
  177. }
  178. };
  179. struct MiniLEDButton : SVGSwitch, MomentarySwitch {
  180. MiniLEDButton() {
  181. addFrame(SVG::load(assetPlugin(plugin,"res/ComponentLibrary/miniLEDButton.svg")));
  182. sw->wrap();
  183. box.size = sw->box.size;
  184. }
  185. };
  186. } // namespace rack