Browse Source

Move single-use to lambdas

Scott Lahteine 5 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
 #define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
42
 #define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
43
 #define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
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
 #if ENABLED(PRUSA_MMU2)
45
 #if ENABLED(PRUSA_MMU2)
56
   #include "../../lcd/menu/menu_mmu2.h"
46
   #include "../../lcd/menu/menu_mmu2.h"
57
 #endif
47
 #endif
105
       ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
95
       ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
106
     #endif
96
     #endif
107
     #if MACHINE_CAN_STOP
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
     #endif
105
     #endif
110
     SUBMENU(MSG_TUNE, menu_tune);
106
     SUBMENU(MSG_TUNE, menu_tune);
111
   }
107
   }

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

72
   ui.reset_status();
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
 class MenuItem_sdfile : public MenuItem_sdbase {
75
 class MenuItem_sdfile : public MenuItem_sdbase {
92
   public:
76
   public:
93
     static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) {
77
     static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) {
101
         sd_items = screen_items;
85
         sd_items = screen_items;
102
       #endif
86
       #endif
103
       #if ENABLED(SD_MENU_CONFIRM_START)
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
       #else
99
       #else
106
         sdcard_start_selected_file();
100
         sdcard_start_selected_file();
107
         UNUSED(pstr);
101
         UNUSED(pstr);

Loading…
Cancel
Save