ConfigurationScreen.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "Sequencer.h"
  2. #include "ConfigurationScreen.h"
  3. #include "colors.h"
  4. #include <iostream>
  5. ConfigurationScreen::ConfigurationScreen(Sequencer& seq)
  6. : parent(seq)
  7. {
  8. }
  9. void ConfigurationScreen::keyPressed(unsigned char x, unsigned char y)
  10. {
  11. std::cout << "config clicked x=" << (int)x << ", y=" << (int)y << std::endl;
  12. if(x == 8) { // very right
  13. } else if(y == 8) { // very top
  14. bool playing = sequencer.player.isPlaying();
  15. switch(x) {
  16. case 5:
  17. disable();
  18. sequencer.playbackScreen.enable();
  19. break;
  20. }
  21. } else {
  22. if(y == 0) { // bpm
  23. unsigned int bit = (1 << (configWidth - x - 1));
  24. unsigned int beatsCount = sequencer.beats.size() ^ bit;
  25. std::cout << "set number of beats to " << beatsCount << std::endl;
  26. sequencer.beats.resize(beatsCount);
  27. }
  28. }
  29. refreshAll();
  30. }
  31. void ConfigurationScreen::keyReleased(unsigned char x, unsigned char y)
  32. {
  33. refreshAll();
  34. }
  35. void ConfigurationScreen::refresh(unsigned char x, unsigned char y)
  36. {
  37. if(x == 8) { // very right
  38. } else if(y == 8) { // very top
  39. switch(x) {
  40. case 5:
  41. setColor(x, y, colors::activeOption);
  42. break;
  43. }
  44. } else {
  45. if(y == 0) { // bpm
  46. unsigned int beatsCount = sequencer.beats.size();
  47. if(beatsCount & (1 << (configWidth - x - 1))) {
  48. setColor(x, y, colors::activeBeatsCount);
  49. } else {
  50. setColor(x, y, colors::inactiveBeatsCount);
  51. }
  52. }
  53. }
  54. }