menu redesign: hierarchical entries
This commit is contained in:
+45
-50
@@ -132,22 +132,18 @@ static void handleInput() {
|
||||
if (delta != 0) {
|
||||
switch(currentState) {
|
||||
case UI_MENU_MAIN:
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = mainMenuCount - 1;
|
||||
if (menuSelection >= mainMenuCount) menuSelection = 0;
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = randomizeMenuPolyCount - 1;
|
||||
if (menuSelection >= randomizeMenuPolyCount) menuSelection = 0;
|
||||
int next = menuSelection;
|
||||
int count = 0;
|
||||
do {
|
||||
next += (delta > 0 ? 1 : -1);
|
||||
if (next < 0) next = menuItemsCount - 1;
|
||||
if (next >= menuItemsCount) next = 0;
|
||||
count++;
|
||||
} while (!isItemVisible(next) && count < menuItemsCount);
|
||||
menuSelection = next;
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = setupMenuCount - 1;
|
||||
if (menuSelection >= setupMenuCount) menuSelection = 0;
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
{
|
||||
midiChannels[randomizeTrack] += (delta > 0 ? 1 : -1);
|
||||
@@ -198,14 +194,13 @@ static void handleInput() {
|
||||
if (!buttonConsumed) { // Short press action
|
||||
switch(currentState) {
|
||||
case UI_MENU_MAIN:
|
||||
if (menuSelection == 0) { currentState = UI_MENU_RANDOMIZE; menuSelection = 0; break; }
|
||||
if (menuSelection == 1) { currentState = UI_MENU_SETUP; menuSelection = 0; break; }
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
if (menuSelection == 0) { currentState = UI_MENU_SETUP; menuSelection = 0; break; }
|
||||
|
||||
if (menuSelection == 1) { // Melody
|
||||
if (menuItems[menuSelection].isGroup) {
|
||||
menuItems[menuSelection].expanded = !menuItems[menuSelection].expanded;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(menuItems[menuSelection].id) {
|
||||
case MENU_ID_MELODY:
|
||||
midi.lock();
|
||||
melodySeeds[randomizeTrack] = random(10000);
|
||||
if (isPlaying) {
|
||||
@@ -219,8 +214,8 @@ static void handleInput() {
|
||||
midi.unlock();
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 2) { // Scale
|
||||
|
||||
case MENU_ID_SCALE:
|
||||
generateRandomScale();
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
@@ -232,23 +227,27 @@ static void handleInput() {
|
||||
}
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 3) { currentState = UI_EDIT_TEMPO; break; } // Tempo
|
||||
if (menuSelection == 4) { // Song Mode
|
||||
|
||||
case MENU_ID_TEMPO: currentState = UI_EDIT_TEMPO; break;
|
||||
|
||||
case MENU_ID_SONG_MODE:
|
||||
songModeEnabled = !songModeEnabled;
|
||||
if (songModeEnabled) {
|
||||
songModeNeedsNext = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (menuSelection == 5) { currentState = UI_RANDOMIZE_TRACK_EDIT; break; } // Track
|
||||
if (menuSelection == 6) { trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break; } // Mute
|
||||
if (menuSelection == 7) { currentState = UI_EDIT_FLAVOUR; break; } // Flavour
|
||||
if (menuSelection == 8) { mutationEnabled = !mutationEnabled; break; } // Mutation
|
||||
case MENU_ID_TRACK_SELECT: currentState = UI_RANDOMIZE_TRACK_EDIT; break;
|
||||
case MENU_ID_MUTE: trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break;
|
||||
case MENU_ID_FLAVOUR: currentState = UI_EDIT_FLAVOUR; break;
|
||||
case MENU_ID_MUTATION: mutationEnabled = !mutationEnabled; break;
|
||||
|
||||
case MENU_ID_CHANNEL: currentState = UI_SETUP_CHANNEL_EDIT; break;
|
||||
case MENU_ID_RESET: factoryReset(); break;
|
||||
|
||||
if (menuSelection >= THEME_1_INDEX_POLY) { // Themes
|
||||
const int selectedTheme = menuSelection - THEME_1_INDEX_POLY + 1;
|
||||
default:
|
||||
if (menuItems[menuSelection].id >= MENU_ID_THEME_1 && menuItems[menuSelection].id <= MENU_ID_THEME_7) {
|
||||
const int selectedTheme = menuItems[menuSelection].id - MENU_ID_THEME_1 + 1;
|
||||
if (isPlaying) {
|
||||
queuedTheme = selectedTheme;
|
||||
midi.lock();
|
||||
@@ -260,23 +259,19 @@ static void handleInput() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
if (menuSelection == 0) { currentState = UI_MENU_RANDOMIZE; menuSelection = 0; break; }
|
||||
if (menuSelection == 1) { currentState = UI_SETUP_CHANNEL_EDIT; break; }
|
||||
if (menuSelection == 2) { factoryReset(); break; }
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
currentState = UI_MENU_SETUP;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_EDIT_TEMPO:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_EDIT_FLAVOUR:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
@@ -290,7 +285,7 @@ static void handleInput() {
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_RANDOMIZE_TRACK_EDIT:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
@@ -352,9 +347,7 @@ static void drawUI() {
|
||||
ui.draw(local_currentState, local_menuSelection,
|
||||
local_midiChannel, local_tempo, local_strategy,
|
||||
local_queuedTheme, local_currentThemeIndex, local_numScaleNotes, local_scaleNotes, local_melodySeed,
|
||||
local_mutationEnabled, local_songModeEnabled, (const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
mainMenu, mainMenuCount, randomizeMenuPoly, randomizeMenuPolyCount, setupMenu, setupMenuCount,
|
||||
THEME_1_INDEX_POLY, MODE_POLY, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
local_mutationEnabled, local_songModeEnabled, (const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
static void updateLeds() {
|
||||
@@ -371,6 +364,7 @@ static void updateLeds() {
|
||||
int local_numScaleNotes;
|
||||
int local_scaleNotes[12];
|
||||
bool local_trackMute[NUM_TRACKS];
|
||||
int local_randomizeTrack;
|
||||
|
||||
midi.lock();
|
||||
memcpy(local_sequence, sequence, sizeof(local_sequence));
|
||||
@@ -383,16 +377,17 @@ static void updateLeds() {
|
||||
local_sequenceChangeScheduled = sequenceChangeScheduled;
|
||||
local_playMode = playMode;
|
||||
local_numScaleNotes = numScaleNotes;
|
||||
local_randomizeTrack = randomizeTrack;
|
||||
memcpy(local_scaleNotes, scaleNotes, sizeof(local_scaleNotes));
|
||||
memcpy(local_trackMute, (const void*)trackMute, sizeof(local_trackMute));
|
||||
midi.unlock();
|
||||
|
||||
PlayMode ledDisplayMode = MODE_POLY; // Default to POLY (MAIN section view)
|
||||
|
||||
if (local_currentState == UI_MENU_RANDOMIZE) {
|
||||
// Main section items: Setup(0), Melody(1), Scale(2), Tempo(3), Song Mode(4)
|
||||
bool isMainSection = (local_menuSelection <= 4);
|
||||
if (!isMainSection) {
|
||||
if (local_currentState == UI_MENU_MAIN) {
|
||||
MenuItemID id = menuItems[local_menuSelection].id;
|
||||
// Check if we are in the Track group (IDs between TRACK_SELECT and THEME_7)
|
||||
if (id >= MENU_ID_TRACK_SELECT && id <= MENU_ID_THEME_7) {
|
||||
// It's a TRACK section item (Track, Mute, Flavour, Mutation, Themes)
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
@@ -403,7 +398,7 @@ static void updateLeds() {
|
||||
|
||||
ui.updateLeds((const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
local_currentState, local_songModeEnabled, local_songRepeatsRemaining,
|
||||
local_sequenceChangeScheduled, ledDisplayMode, local_numScaleNotes,
|
||||
local_sequenceChangeScheduled, ledDisplayMode, local_randomizeTrack, local_numScaleNotes,
|
||||
local_scaleNotes, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user