Move single-use to lambdas
This commit is contained in:
parent
84ce3a6bea
commit
0be9fdb455
2 changed files with 18 additions and 28 deletions
|
@ -42,16 +42,6 @@
|
|||
#define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
|
||||
#define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
|
||||
|
||||
#if MACHINE_CAN_STOP
|
||||
void menu_abort_confirm() {
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
|
||||
ui.abort_print, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
|
||||
);
|
||||
}
|
||||
#endif // MACHINE_CAN_STOP
|
||||
|
||||
#if ENABLED(PRUSA_MMU2)
|
||||
#include "../../lcd/menu/menu_mmu2.h"
|
||||
#endif
|
||||
|
@ -105,7 +95,13 @@ void menu_main() {
|
|||
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
|
||||
#endif
|
||||
#if MACHINE_CAN_STOP
|
||||
SUBMENU(MSG_STOP_PRINT, menu_abort_confirm);
|
||||
SUBMENU(MSG_STOP_PRINT, []{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
|
||||
ui.abort_print, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
|
||||
);
|
||||
});
|
||||
#endif
|
||||
SUBMENU(MSG_TUNE, menu_tune);
|
||||
}
|
||||
|
|
|
@ -72,22 +72,6 @@ inline void sdcard_start_selected_file() {
|
|||
ui.reset_status();
|
||||
}
|
||||
|
||||
#if ENABLED(SD_MENU_CONFIRM_START)
|
||||
|
||||
void menu_sd_confirm() {
|
||||
char * const longest = card.longest_filename();
|
||||
char buffer[strlen(longest) + 2];
|
||||
buffer[0] = ' ';
|
||||
strcpy(buffer + 1, longest);
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
|
||||
sdcard_start_selected_file, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class MenuItem_sdfile : public MenuItem_sdbase {
|
||||
public:
|
||||
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) {
|
||||
|
@ -101,7 +85,17 @@ class MenuItem_sdfile : public MenuItem_sdbase {
|
|||
sd_items = screen_items;
|
||||
#endif
|
||||
#if ENABLED(SD_MENU_CONFIRM_START)
|
||||
MenuItem_submenu::action(pstr, menu_sd_confirm);
|
||||
MenuItem_submenu::action(pstr, []{
|
||||
char * const longest = card.longest_filename();
|
||||
char buffer[strlen(longest) + 2];
|
||||
buffer[0] = ' ';
|
||||
strcpy(buffer + 1, longest);
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
|
||||
sdcard_start_selected_file, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
|
||||
);
|
||||
});
|
||||
#else
|
||||
sdcard_start_selected_file();
|
||||
UNUSED(pstr);
|
||||
|
|
Reference in a new issue