@@ -390,9 +390,14 @@ void ModelMixesPage::rebuild(FormWindow * window, int8_t focusMixIndex)
390390void ModelMixesPage::editMix (FormWindow * window, uint8_t channel, uint8_t mixIndex)
391391{
392392 Window::clearFocus ();
393- Window * editWindow = new MixEditWindow (channel, mixIndex);
393+ Window *editWindow = new MixEditWindow (channel, mixIndex);
394394 editWindow->setCloseHandler ([=]() {
395- rebuild (window, mixIndex);
395+ int8_t newIndex = mixIndex;
396+ if (is_memclear (&g_model.mixData [mixIndex], sizeof (MixData))) {
397+ deleteMix (mixIndex);
398+ newIndex--;
399+ }
400+ rebuild (window, newIndex);
396401 });
397402}
398403
@@ -426,17 +431,19 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
426431 int mixIndex = 0 ;
427432 MixData * mix = g_model.mixData ;
428433 for (uint8_t ch = 0 ; ch < MAX_OUTPUT_CHANNELS; ch++) {
429- if (mixIndex < MAX_MIXERS && mix->destCh == ch) {
434+
435+ bool skip_mix = (ch == 0 && is_memclear (mix, sizeof (MixData)));
436+
437+ if (mixIndex < MAX_MIXERS && mix->destCh == ch && !skip_mix) {
430438
431439 coord_t h = grid.getWindowHeight ();
432440 auto txt = new MixLineTitle (window, grid.getLabelSlot (),
433441 getSourceString (MIXSRC_CH1 + ch),
434442 BUTTON_BACKGROUND, COLOR_THEME_PRIMARY1 | CENTERED);
435443
436444 uint8_t count = 0 ;
437- while (mixIndex < MAX_MIXERS && mix->destCh == ch) {
438- // First mix cannot be empty
439- if (!mixIndex && !mix->srcRaw ) break ;
445+ while (mixIndex < MAX_MIXERS && mix->destCh == ch && !skip_mix) {
446+
440447 Button * button = new MixLineButton (window, grid.getFieldSlot (), mixIndex);
441448 button->setPressHandler ([=]() -> uint8_t {
442449 button->bringToTop ();
@@ -519,6 +526,8 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
519526 grid.spacer (button->height () - 1 );
520527 ++mixIndex;
521528 ++mix;
529+
530+ skip_mix = (ch == 0 && is_memclear (mix, sizeof (MixData)));
522531 }
523532
524533 h = grid.getWindowHeight () - h + 1 ;
@@ -527,12 +536,12 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
527536 grid.spacer (7 );
528537 }
529538 else {
530- auto button = new TextButton (window, grid.getLabelSlot (), getSourceString (MIXSRC_CH1 + ch));
531- if (focusMixIndex == mixIndex)
532- button->setFocus (SET_FOCUS_DEFAULT);
539+ auto button = new TextButton (window, grid.getLabelSlot (),
540+ getSourceString (MIXSRC_CH1 + ch));
541+ if (focusMixIndex == mixIndex) button->setFocus (SET_FOCUS_DEFAULT);
533542 button->setPressHandler ([=]() -> uint8_t {
534543 button->bringToTop ();
535- Menu * menu = new Menu (window);
544+ Menu *menu = new Menu (window);
536545 menu->addLine (STR_EDIT, [=]() {
537546 insertMix (mixIndex, ch);
538547 editMix (window, ch, mixIndex);
@@ -542,16 +551,16 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
542551 if (s_copyMode != 0 ) {
543552 menu->addLine (STR_PASTE, [=]() {
544553 copyMix (s_copySrcIdx, mixIndex, ch);
545- if (s_copyMode == MOVE_MODE) {
546- deleteMix ((s_copySrcIdx >= mixIndex) ? s_copySrcIdx+1 : s_copySrcIdx);
554+ if (s_copyMode == MOVE_MODE) {
555+ deleteMix ((s_copySrcIdx >= mixIndex) ? s_copySrcIdx + 1
556+ : s_copySrcIdx);
547557 s_copyMode = 0 ;
548558 }
549559 rebuild (window, -1 );
550560 return 0 ;
551561 });
552562 }
553563 }
554- // TODO STR_MOVE
555564 return 0 ;
556565 });
557566
0 commit comments