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.

64 lines
1.6KB

  1. #include "rack.hpp"
  2. using namespace rack;
  3. extern Model *modelAudioInterface;
  4. extern Model *modelMIDIToCVInterface;
  5. extern Model *modelQuadMIDIToCVInterface;
  6. extern Model *modelMIDICCToCVInterface;
  7. extern Model *modelMIDITriggerToCVInterface;
  8. extern Model *modelBlank;
  9. extern Model *modelNotes;
  10. struct GridChoice : LedDisplayChoice {
  11. virtual void setId(int id) {}
  12. };
  13. struct Grid16MidiWidget : MidiWidget {
  14. LedDisplaySeparator *hSeparators[4];
  15. LedDisplaySeparator *vSeparators[4];
  16. GridChoice *gridChoices[4][4];
  17. void createGridChoices() {
  18. Vec pos = channelChoice->box.getBottomLeft();
  19. for (int x = 1; x < 4; x++) {
  20. vSeparators[x] = Widget::create<LedDisplaySeparator>(pos);
  21. addChild(vSeparators[x]);
  22. }
  23. for (int y = 0; y < 4; y++) {
  24. hSeparators[y] = Widget::create<LedDisplaySeparator>(pos);
  25. addChild(hSeparators[y]);
  26. for (int x = 0; x < 4; x++) {
  27. GridChoice *gridChoice = createGridChoice();
  28. assert(gridChoice);
  29. gridChoice->box.pos = pos;
  30. gridChoice->setId(4*y + x);
  31. gridChoices[x][y] = gridChoice;
  32. addChild(gridChoice);
  33. }
  34. pos = gridChoices[0][y]->box.getBottomLeft();
  35. }
  36. for (int x = 1; x < 4; x++) {
  37. vSeparators[x]->box.size.y = pos.y - vSeparators[x]->box.pos.y;
  38. }
  39. }
  40. void step() override {
  41. MidiWidget::step();
  42. for (int x = 1; x < 4; x++) {
  43. vSeparators[x]->box.pos.x = box.size.x / 4 * x;
  44. }
  45. for (int y = 0; y < 4; y++) {
  46. hSeparators[y]->box.size.x = box.size.x;
  47. for (int x = 0; x < 4; x++) {
  48. gridChoices[x][y]->box.size.x = box.size.x / 4;
  49. gridChoices[x][y]->box.pos.x = box.size.x / 4 * x;
  50. }
  51. }
  52. }
  53. virtual GridChoice *createGridChoice() {return NULL;}
  54. };