Browse Source

config screen: darken expand key if exceeding max number of beats

Fabian Peter Hammerle 10 years ago
parent
commit
118cd091a0
2 changed files with 11 additions and 6 deletions
  1. 8 6
      ConfigurationScreen.cpp
  2. 3 0
      ConfigurationScreen.h

+ 8 - 6
ConfigurationScreen.cpp

@@ -22,9 +22,6 @@ void ConfigurationScreen::keyPressed(unsigned char x, unsigned char y)
                 break;
         }
     } else {
-        Player::Bpm minBpm = 1;
-        Player::Bpm maxBpm = (1 << (configWidth * 2)) - 1;
-        BeatIndex maxBeatsCount = (1 << configWidth) - 1;
         switch(y) {
             case 0: { // number of beats
                 unsigned int bit = (1 << (configWidth - x - 1));
@@ -92,9 +89,14 @@ void ConfigurationScreen::refresh(unsigned char x, unsigned char y)
                     setColor(x, y, colors::inactiveBeatsCount);
                 }
                 } break;
-            case 1: // sequence expansion
-               setColor(x, y, colors::sequenceExpansionButton);
-               break;
+            case 1: { // sequence expansion
+                unsigned int factor = x + 2;
+                if(sequencer.beats.size() * factor <= maxBeatsCount) {
+                    setColor(x, y, colors::sequenceExpansionButton);
+                } else {
+                    setColor(x, y, colors::dark);
+                }
+                } break;
             case 2: // reduce erasing conflicts
                setColor(x, y, colors::sequenceReductionErasingConflictsButton);
                break;

+ 3 - 0
ConfigurationScreen.h

@@ -10,6 +10,9 @@ class ConfigurationScreen : public Screen
 public:
 
     midi::Launchpad::KeyCoordinate configWidth = midi::Launchpad::width - 1;
+    Player::Bpm minBpm = 1;
+    Player::Bpm maxBpm = (1 << (configWidth * 2)) - 1;
+    BeatIndex maxBeatsCount = (1 << configWidth) - 1;
 
     ConfigurationScreen(Sequencer& seq);