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.

239 lines
4.9KB

  1. #pragma once
  2. #include "scene.hpp"
  3. namespace rack {
  4. enum ColorNames {
  5. COLOR_BLACK,
  6. COLOR_WHITE,
  7. COLOR_RED,
  8. COLOR_ORANGE,
  9. COLOR_YELLOW,
  10. COLOR_GREEN,
  11. COLOR_CYAN,
  12. COLOR_BLUE,
  13. COLOR_PURPLE,
  14. NUM_COLORS
  15. };
  16. extern const NVGcolor colors[NUM_COLORS];
  17. ////////////////////
  18. // Knobs
  19. ////////////////////
  20. struct SynthTechAlco : SpriteKnob {
  21. SynthTechAlco() {
  22. box.size = Vec(45, 45);
  23. spriteOffset = Vec(-3, -2);
  24. spriteSize = Vec(51, 51);
  25. minIndex = 49;
  26. maxIndex = -51;
  27. spriteCount = 120;
  28. spriteImage = Image::load("res/ComponentLibrary/SynthTechAlco.png");
  29. }
  30. };
  31. struct KnobDavies1900h : SpriteKnob {
  32. KnobDavies1900h() {
  33. box.size = Vec(36, 36);
  34. spriteOffset = Vec(-2, -2);
  35. spriteSize = Vec(42, 42);
  36. minIndex = 44;
  37. maxIndex = -46;
  38. spriteCount = 120;
  39. }
  40. };
  41. struct KnobDavies1900hWhite : KnobDavies1900h {
  42. KnobDavies1900hWhite() {
  43. spriteImage = Image::load("res/ComponentLibrary/Davies1900hWhite.png");
  44. }
  45. };
  46. struct KnobDavies1900hBlack : KnobDavies1900h {
  47. KnobDavies1900hBlack() {
  48. spriteImage = Image::load("res/ComponentLibrary/Davies1900hBlack.png");
  49. }
  50. };
  51. struct KnobDavies1900hRed : KnobDavies1900h {
  52. KnobDavies1900hRed() {
  53. spriteImage = Image::load("res/ComponentLibrary/Davies1900hRed.png");
  54. }
  55. };
  56. struct BefacoBigKnob : SpriteKnob {
  57. BefacoBigKnob() {
  58. box.size = Vec(75, 75);
  59. spriteOffset = Vec(-2, -2);
  60. spriteSize = Vec(81, 81);
  61. minIndex = 44;
  62. maxIndex = -46;
  63. spriteCount = 120;
  64. spriteImage = Image::load("res/ComponentLibrary/BefacoBigKnob.png");
  65. }
  66. };
  67. struct BefacoTinyKnob : SpriteKnob {
  68. BefacoTinyKnob() {
  69. box.size = Vec(26, 26);
  70. spriteOffset = Vec(-2, -2);
  71. spriteSize = Vec(32, 32);
  72. minIndex = 44;
  73. maxIndex = -46;
  74. spriteCount = 120;
  75. spriteImage = Image::load("res/ComponentLibrary/BefacoTinyKnob.png");
  76. }
  77. };
  78. struct BefacoSlidePot : SpriteKnob {
  79. BefacoSlidePot() {
  80. box.size = Vec(12, 122);
  81. spriteOffset = Vec(-2, -6);
  82. spriteSize = Vec(18, 134);
  83. minIndex = 97;
  84. maxIndex = 0;
  85. spriteCount = 98;
  86. spriteImage = Image::load("res/ComponentLibrary/BefacoSlidePot.png");
  87. }
  88. };
  89. ////////////////////
  90. // Jacks
  91. ////////////////////
  92. template <typename BASE>
  93. struct PJ301M : BASE {
  94. PJ301M() {
  95. this->box.size = Vec(24, 24);
  96. this->spriteOffset = Vec(-2, -2);
  97. this->spriteSize = Vec(30, 30);
  98. this->spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
  99. }
  100. };
  101. typedef PJ301M<InputPort> InputPortPJ301M;
  102. typedef PJ301M<OutputPort> OutputPortPJ301M;
  103. template <typename BASE>
  104. struct PJ3410 : BASE {
  105. PJ3410() {
  106. this->box.size = Vec(32, 31);
  107. this->spriteOffset = Vec(-1, -1);
  108. this->spriteSize = Vec(36, 36);
  109. this->spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
  110. }
  111. };
  112. typedef PJ3410<InputPort> InputPortPJ3410;
  113. typedef PJ3410<OutputPort> OutputPortPJ3410;
  114. template <typename BASE>
  115. struct CL1362 : BASE {
  116. CL1362() {
  117. this->box.size = Vec(33, 29);
  118. this->spriteOffset = Vec(-2, -2);
  119. this->spriteSize = Vec(39, 36);
  120. this->spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
  121. }
  122. };
  123. typedef CL1362<InputPort> InputPortCL1362;
  124. typedef CL1362<OutputPort> OutputPortCL1362;
  125. ////////////////////
  126. // Lights
  127. ////////////////////
  128. struct ValueLight : Light {
  129. float *value;
  130. };
  131. template <int COLOR>
  132. struct ColorValueLight : ValueLight {
  133. void step() {
  134. float v = sqrtBipolar(getf(value));
  135. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v);
  136. }
  137. };
  138. typedef ColorValueLight<COLOR_RED> RedValueLight;
  139. typedef ColorValueLight<COLOR_YELLOW> YellowValueLight;
  140. typedef ColorValueLight<COLOR_GREEN> GreenValueLight;
  141. template <int COLOR_POS, int COLOR_NEG>
  142. struct PolarityLight : ValueLight {
  143. void step() {
  144. float v = sqrtBipolar(getf(value));
  145. if (v >= 0.0)
  146. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v);
  147. else
  148. color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v);
  149. }
  150. };
  151. typedef PolarityLight<COLOR_GREEN, COLOR_RED> GreenRedPolarityLight;
  152. template <typename BASE>
  153. struct LargeLight : BASE {
  154. LargeLight() {
  155. this->box.size = Vec(20, 20);
  156. }
  157. };
  158. template <typename BASE>
  159. struct MediumLight : BASE {
  160. MediumLight() {
  161. this->box.size = Vec(12, 12);
  162. }
  163. };
  164. template <typename BASE>
  165. struct SmallLight : BASE {
  166. SmallLight() {
  167. this->box.size = Vec(8, 8);
  168. }
  169. };
  170. ////////////////////
  171. // Misc
  172. ////////////////////
  173. /** If you don't add these to your ModuleWidget, it will fall out of the rack... */
  174. struct Screw : SpriteWidget {
  175. Screw() {
  176. box.size = Vec(15, 14);
  177. spriteOffset = Vec(0, 0);
  178. spriteSize = Vec(15, 14);
  179. }
  180. };
  181. struct BlackScrew : Screw {
  182. BlackScrew() {
  183. spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png");
  184. }
  185. };
  186. struct SilverScrew : Screw {
  187. SilverScrew() {
  188. spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png");
  189. }
  190. };
  191. struct LightPanel : Panel {
  192. LightPanel() {
  193. backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8);
  194. borderColor = nvgRGB(0xa1, 0xa1, 0xa1);
  195. }
  196. };
  197. struct DarkPanel : Panel {
  198. DarkPanel() {
  199. backgroundColor = nvgRGB(0x17, 0x17, 0x17);
  200. borderColor = nvgRGB(0x5e, 0x5e, 0x5e);
  201. }
  202. };
  203. } // namespace rack