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.

129 lines
4.7KB

  1. #include "cubefader.hpp"
  2. #include "gui_components.hpp"
  3. namespace rack_plugin_CastleRocktronics {
  4. struct CubefaderWidget : ModuleWidget {
  5. CubefaderWidget(Cubefader *module);
  6. private:
  7. int moduleWidth;
  8. void placeGuiElements();
  9. void placeAudioInputs(int x, int y, int verticalSpacing);
  10. void placeCvInputs(int x, int y, int horizontalSpacing);
  11. void placeOutput(int x, int y);
  12. void placeSlider(int x, int y);
  13. void placeTrimpots(int x, int y, int horizontalSpacing);
  14. void placeScrews();
  15. };
  16. CubefaderWidget::CubefaderWidget(Cubefader *module) : ModuleWidget(module) {
  17. this->moduleWidth = 12.0f * RACK_GRID_WIDTH;
  18. box.size = Vec(moduleWidth, RACK_GRID_HEIGHT);
  19. {
  20. SVGPanel *panel = new SVGPanel();
  21. panel->box.size = box.size;
  22. panel->setBackground(
  23. SVG::load(assetPlugin(plugin, "res/panels/cubefader.svg")));
  24. addChild(panel);
  25. }
  26. placeGuiElements();
  27. };
  28. void CubefaderWidget::placeGuiElements() {
  29. int y = (RACK_GRID_HEIGHT / 4) * 3 - 30;
  30. int x = (moduleWidth / 3) - 34;
  31. int horizontalSpacing = 49;
  32. placeCvInputs(x, y, horizontalSpacing);
  33. placeOutput(x + (horizontalSpacing * 2) + 1, y + horizontalSpacing + 3);
  34. addParam(createParam<DelvinToggleTwo>(
  35. Vec(x + 7, y + 60), module, Cubefader::UNI_BI_TOGGLE, 0.0f, 1.0f, 1.0f));
  36. placeTrimpots(x + 4, y - 24, horizontalSpacing);
  37. x = (moduleWidth / 6) - 20;
  38. y = (RACK_GRID_HEIGHT / 4) - 9;
  39. int verticalSpacing = 89;
  40. placeAudioInputs(x, y, verticalSpacing);
  41. placeScrews();
  42. }
  43. void CubefaderWidget::placeAudioInputs(int startingX, int startingY,
  44. int spacing) {
  45. for (int i = 0; i != Cubefader::INPUT_001; i += 2) {
  46. Cubefader::Inputs inputLeft = static_cast<Cubefader::Inputs>(i);
  47. Cubefader::Inputs inputRight = static_cast<Cubefader::Inputs>(i + 1);
  48. int y = startingY + (spacing * (i / 2));
  49. addInput(
  50. createInput<SevenHalfKnurled>(Vec(startingX, y), module, inputLeft));
  51. addInput(createInput<SevenHalfKnurled>(Vec(startingX + spacing, y), module,
  52. inputRight));
  53. }
  54. for (int i = Cubefader::INPUT_001; i != Cubefader::X_CV; i += 2) {
  55. Cubefader::Inputs inputLeft = static_cast<Cubefader::Inputs>(i);
  56. Cubefader::Inputs inputRight = static_cast<Cubefader::Inputs>(i + 1);
  57. int x = startingX + (spacing / 2);
  58. int y = startingY + (spacing * ((i - 4) / 2)) - (spacing / 3);
  59. addInput(createInput<SevenHalfKnurled>(Vec(x, y), module, inputLeft));
  60. addInput(
  61. createInput<SevenHalfKnurled>(Vec(x + spacing, y), module, inputRight));
  62. }
  63. }
  64. void CubefaderWidget::placeOutput(int x, int y) {
  65. addOutput(
  66. createOutput<SevenHalfKnurled>(Vec(x, y), module, Cubefader::OUTPUT));
  67. }
  68. void CubefaderWidget::placeCvInputs(int x, int y, int horizontalSpacing) {
  69. addInput(createInput<SevenHalfKnurled>(Vec(x, y), module, Cubefader::X_CV));
  70. addInput(createInput<SevenHalfKnurled>(Vec(x + horizontalSpacing, y), module,
  71. Cubefader::Y_CV));
  72. addInput(createInput<SevenHalfKnurled>(
  73. Vec(x + (horizontalSpacing * 2) + 1, y), module, Cubefader::Z_CV));
  74. }
  75. void CubefaderWidget::placeTrimpots(int x, int y, int horizontalSpacing) {
  76. addParam(createParam<CastleTrimpot>(Vec(x, y), module, Cubefader::X_TRIMPOT,
  77. -2.0f, 2.0f, 1.0f));
  78. addParam(createParam<CastleTrimpot>(Vec(x + horizontalSpacing, y), module,
  79. Cubefader::Y_TRIMPOT, -2.0f, 2.0f, 1.0f));
  80. addParam(createParam<CastleTrimpot>(Vec(x + (horizontalSpacing * 2) + 1, y),
  81. module, Cubefader::Z_TRIMPOT, -2.0f, 2.0f,
  82. 1.0f));
  83. }
  84. void CubefaderWidget::placeScrews() {
  85. addChild(createScrew<MThreeScrew>(Vec(RACK_GRID_WIDTH + 1, 2)));
  86. addChild(
  87. createScrew<MThreeScrew>(Vec((box.size.x - 2 * RACK_GRID_WIDTH) + 1, 2)));
  88. addChild(createScrew<MThreeScrew>(
  89. Vec(RACK_GRID_WIDTH + 1, RACK_GRID_HEIGHT - RACK_GRID_WIDTH + 1)));
  90. addChild(
  91. createScrew<MThreeScrew>(Vec((box.size.x - 2 * RACK_GRID_WIDTH) + 1,
  92. RACK_GRID_HEIGHT - RACK_GRID_WIDTH + 1)));
  93. }
  94. } // namespace rack_plugin_CastleRocktronics
  95. using namespace rack_plugin_CastleRocktronics;
  96. RACK_PLUGIN_MODEL_INIT(CastleRocktronics, Cubefader) {
  97. // p->addModel(createModel<CubefaderWidget>("CastleRocktronics",
  98. // "CR-V01_Cubefader", "Cubefader",
  99. // UTILITY_TAG, MIXER_TAG));
  100. return Model::create<Cubefader, CubefaderWidget>("CastleRocktronics",
  101. "CR-V01_Cubefader", "Cubefader",
  102. UTILITY_TAG, MIXER_TAG);
  103. }