123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include "Sequencer.h"
- #include "ConfigurationScreen.h"
- #include "colors.h"
- #include <iostream>
- ConfigurationScreen::ConfigurationScreen(Sequencer& seq)
- : parent(seq)
- {
- }
- void ConfigurationScreen::keyPressed(unsigned char x, unsigned char y)
- {
- std::cout << "config clicked x=" << (int)x << ", y=" << (int)y << std::endl;
- if(x == 8) { // very right
- } else if(y == 8) { // very top
- bool playing = sequencer.player.isPlaying();
- switch(x) {
- case 5:
- disable();
- sequencer.playbackScreen.enable();
- break;
- }
- } else {
- switch(y) {
- case 0: { // number of beats
- unsigned int bit = (1 << (configWidth - x - 1));
- unsigned int beatsCount = sequencer.beats.size() ^ bit;
- std::cout << "set number of beats to " << beatsCount << std::endl;
- sequencer.beats.resize(beatsCount);
- } break;
- case 1: { // sequence expansion
- unsigned int factor = x + 2;
- sequencer.beats.expand(factor);
- sequencer.player.setBpm(sequencer.player.getBpm() * factor);
- } break;
- }
- }
- refreshAll();
- }
- void ConfigurationScreen::keyReleased(unsigned char x, unsigned char y)
- {
- refreshAll();
- }
- void ConfigurationScreen::refresh(unsigned char x, unsigned char y)
- {
- if(x == 8) { // very right
- } else if(y == 8) { // very top
- switch(x) {
- case 5:
- setColor(x, y, colors::activeOption);
- break;
- }
- } else {
- switch(y) {
- case 0: { // number of beats
- unsigned int beatsCount = sequencer.beats.size();
- if(beatsCount & (1 << (configWidth - x - 1))) {
- setColor(x, y, colors::activeBeatsCount);
- } else {
- setColor(x, y, colors::inactiveBeatsCount);
- }
- } break;
- case 1: // sequence expansion
- setColor(x, y, colors::sequenceExpansionButton);
- break;
- }
- }
- }
|