Browse Source

Confirm object cancellation (#15660)

Scott Lahteine 5 years ago
parent
commit
9aff30da0c
No account linked to committer's email address

+ 7
- 0
Marlin/src/feature/cancel_object.cpp View File

@@ -42,6 +42,13 @@ void CancelObject::set_active_object(const int8_t obj) {
42 42
   }
43 43
   else
44 44
     skipping = false;
45
+
46
+  #if HAS_DISPLAY
47
+    if (active_object >= 0)
48
+      ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object + 1));
49
+    else
50
+      ui.reset_status();
51
+  #endif
45 52
 }
46 53
 
47 54
 void CancelObject::cancel_object(const int8_t obj) {

+ 1
- 0
Marlin/src/feature/cancel_object.h View File

@@ -32,6 +32,7 @@ public:
32 32
   static void cancel_object(const int8_t obj);
33 33
   static void uncancel_object(const int8_t obj);
34 34
   static void report();
35
+  static inline bool is_canceled(const int8_t obj) { return TEST(canceled, obj); }
35 36
   static inline void clear_active_object() { set_active_object(-1); }
36 37
   static inline void cancel_active_object() { cancel_object(active_object); }
37 38
   static inline void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); }

+ 1
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -427,6 +427,7 @@ namespace Language_en {
427 427
   PROGMEM Language_Str MSG_PAUSE_PRINT                     = _UxGT("Pause Print");
428 428
   PROGMEM Language_Str MSG_RESUME_PRINT                    = _UxGT("Resume Print");
429 429
   PROGMEM Language_Str MSG_STOP_PRINT                      = _UxGT("Stop Print");
430
+  PROGMEM Language_Str MSG_PRINTING_OBJECT                 = _UxGT("Printing Object");
430 431
   PROGMEM Language_Str MSG_CANCEL_OBJECT                   = _UxGT("Cancel Object");
431 432
   PROGMEM Language_Str MSG_OUTAGE_RECOVERY                 = _UxGT("Outage Recovery");
432 433
   PROGMEM Language_Str MSG_MEDIA_MENU                      = _UxGT("Print from Media");

+ 1
- 4
Marlin/src/lcd/menu/menu.h View File

@@ -299,10 +299,7 @@ class MenuItem_bool {
299 299
   } \
300 300
   screen_items = _thisItemNr
301 301
 
302
-#define END_MENU() \
303
-  } \
304
-  screen_items = _thisItemNr; \
305
-  UNUSED(_skipStatic)
302
+#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
306 303
 
307 304
 #if ENABLED(ENCODER_RATE_MULTIPLIER)
308 305
   #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)

+ 30
- 26
Marlin/src/lcd/menu/menu_cancelobject.cpp View File

@@ -33,41 +33,45 @@
33 33
 
34 34
 #include "../../feature/cancel_object.h"
35 35
 
36
-//
37
-// TODO: Select the active object
38
-// upon entry to the menu and present
39
-// a confirmation screen.
40
-//
36
+static void lcd_cancel_object_confirm() {
37
+  const int8_t v = editable.int8;
38
+  const char item_num[] = {
39
+    ' ',
40
+    char((v > 9) ? '0' + (v / 10) : ' '),
41
+    char('0' + (v % 10)),
42
+    '\0'
43
+  };
44
+  do_select_screen_yn(
45
+    []{
46
+      cancelable.cancel_object(editable.int8 - 1);
47
+      #if HAS_BUZZER
48
+        ui.completion_feedback();
49
+      #endif
50
+    },
51
+    ui.goto_previous_screen,
52
+    GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?")
53
+  );
54
+}
55
+
41 56
 void menu_cancelobject() {
42 57
   START_MENU();
43 58
   BACK_ITEM(MSG_MAIN);
44 59
 
45
-  GCODES_ITEM(MSG_CANCEL_OBJECT, PSTR("M486 C"));
46
-
47 60
   // Draw cancelable items in a loop
48
-  for (int8_t i = 0; i < cancelable.object_count; i++) {
49
-    if (!TEST(cancelable.canceled, i)) {
50
-      editable.int8 = i;
51
-      ACTION_ITEM(MSG_CANCEL_OBJECT, [](){
52
-        cancelable.cancel_object(editable.int8);
53
-        ui.quick_feedback();
54
-      });
55
-      MENU_ITEM_ADDON_START(LCD_WIDTH - 2 - (i >= 10));
56
-        lcd_put_int(i);
61
+  int8_t a = cancelable.active_object;
62
+  for (int8_t i = -1; i < cancelable.object_count; i++) {
63
+    if (i == a) continue;
64
+    int8_t j = i < 0 ? a : i;
65
+    if (!cancelable.is_canceled(j)) {
66
+      editable.int8 = j + 1;
67
+      SUBMENU(MSG_CANCEL_OBJECT, lcd_cancel_object_confirm);
68
+      MENU_ITEM_ADDON_START(LCD_WIDTH - 2 - (j >= 9));
69
+        lcd_put_int(editable.int8);
57 70
       MENU_ITEM_ADDON_END();
58 71
     }
72
+    if (i < 0) SKIP_ITEM();
59 73
   }
60 74
 
61
-  /*
62
-  MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_CANCEL_OBJECT, &editable.int8, -1, 32, [](){
63
-    if (editable.int8 > -1) {
64
-      cancelable.cancel_object(editable.int8);
65
-      ui.quick_feedback();
66
-      editable.int8 = -1;
67
-    }
68
-  });
69
-  */
70
-
71 75
   END_MENU();
72 76
 }
73 77
 

Loading…
Cancel
Save