Browse Source

Move single-use to lambdas

Scott Lahteine 4 years ago
parent
commit
0be9fdb455
2 changed files with 18 additions and 28 deletions
  1. 7
    11
      Marlin/src/lcd/menu/menu_main.cpp
  2. 11
    17
      Marlin/src/lcd/menu/menu_media.cpp

+ 7
- 11
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -42,16 +42,6 @@
42 42
 #define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
43 43
 #define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
44 44
 
45
-#if MACHINE_CAN_STOP
46
-  void menu_abort_confirm() {
47
-    MenuItem_confirm::select_screen(
48
-      GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
49
-      ui.abort_print, ui.goto_previous_screen,
50
-      GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
51
-    );
52
-  }
53
-#endif // MACHINE_CAN_STOP
54
-
55 45
 #if ENABLED(PRUSA_MMU2)
56 46
   #include "../../lcd/menu/menu_mmu2.h"
57 47
 #endif
@@ -105,7 +95,13 @@ void menu_main() {
105 95
       ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
106 96
     #endif
107 97
     #if MACHINE_CAN_STOP
108
-      SUBMENU(MSG_STOP_PRINT, menu_abort_confirm);
98
+      SUBMENU(MSG_STOP_PRINT, []{
99
+        MenuItem_confirm::select_screen(
100
+          GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
101
+          ui.abort_print, ui.goto_previous_screen,
102
+          GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
103
+        );
104
+      });
109 105
     #endif
110 106
     SUBMENU(MSG_TUNE, menu_tune);
111 107
   }

+ 11
- 17
Marlin/src/lcd/menu/menu_media.cpp View File

@@ -72,22 +72,6 @@ inline void sdcard_start_selected_file() {
72 72
   ui.reset_status();
73 73
 }
74 74
 
75
-#if ENABLED(SD_MENU_CONFIRM_START)
76
-
77
-  void menu_sd_confirm() {
78
-    char * const longest = card.longest_filename();
79
-    char buffer[strlen(longest) + 2];
80
-    buffer[0] = ' ';
81
-    strcpy(buffer + 1, longest);
82
-    MenuItem_confirm::select_screen(
83
-      GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
84
-      sdcard_start_selected_file, ui.goto_previous_screen,
85
-      GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
86
-    );
87
-  }
88
-
89
-#endif
90
-
91 75
 class MenuItem_sdfile : public MenuItem_sdbase {
92 76
   public:
93 77
     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 {
101 85
         sd_items = screen_items;
102 86
       #endif
103 87
       #if ENABLED(SD_MENU_CONFIRM_START)
104
-        MenuItem_submenu::action(pstr, menu_sd_confirm);
88
+        MenuItem_submenu::action(pstr, []{
89
+          char * const longest = card.longest_filename();
90
+          char buffer[strlen(longest) + 2];
91
+          buffer[0] = ' ';
92
+          strcpy(buffer + 1, longest);
93
+          MenuItem_confirm::select_screen(
94
+            GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
95
+            sdcard_start_selected_file, ui.goto_previous_screen,
96
+            GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
97
+          );
98
+        });
105 99
       #else
106 100
         sdcard_start_selected_file();
107 101
         UNUSED(pstr);

Loading…
Cancel
Save