Confirm object cancellation (#15660)

2.0.x
Scott Lahteine 5 years ago committed by GitHub
parent 78899fc241
commit 9aff30da0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,6 +42,13 @@ void CancelObject::set_active_object(const int8_t obj) {
}
else
skipping = false;
#if HAS_DISPLAY
if (active_object >= 0)
ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object + 1));
else
ui.reset_status();
#endif
}
void CancelObject::cancel_object(const int8_t obj) {

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

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

@ -299,10 +299,7 @@ class MenuItem_bool {
} \
screen_items = _thisItemNr
#define END_MENU() \
} \
screen_items = _thisItemNr; \
UNUSED(_skipStatic)
#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
#if ENABLED(ENCODER_RATE_MULTIPLIER)
#define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)

@ -33,41 +33,45 @@
#include "../../feature/cancel_object.h"
//
// TODO: Select the active object
// upon entry to the menu and present
// a confirmation screen.
//
static void lcd_cancel_object_confirm() {
const int8_t v = editable.int8;
const char item_num[] = {
' ',
char((v > 9) ? '0' + (v / 10) : ' '),
char('0' + (v % 10)),
'\0'
};
do_select_screen_yn(
[]{
cancelable.cancel_object(editable.int8 - 1);
#if HAS_BUZZER
ui.completion_feedback();
#endif
},
ui.goto_previous_screen,
GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?")
);
}
void menu_cancelobject() {
START_MENU();
BACK_ITEM(MSG_MAIN);
GCODES_ITEM(MSG_CANCEL_OBJECT, PSTR("M486 C"));
// Draw cancelable items in a loop
for (int8_t i = 0; i < cancelable.object_count; i++) {
if (!TEST(cancelable.canceled, i)) {
editable.int8 = i;
ACTION_ITEM(MSG_CANCEL_OBJECT, [](){
cancelable.cancel_object(editable.int8);
ui.quick_feedback();
});
MENU_ITEM_ADDON_START(LCD_WIDTH - 2 - (i >= 10));
lcd_put_int(i);
int8_t a = cancelable.active_object;
for (int8_t i = -1; i < cancelable.object_count; i++) {
if (i == a) continue;
int8_t j = i < 0 ? a : i;
if (!cancelable.is_canceled(j)) {
editable.int8 = j + 1;
SUBMENU(MSG_CANCEL_OBJECT, lcd_cancel_object_confirm);
MENU_ITEM_ADDON_START(LCD_WIDTH - 2 - (j >= 9));
lcd_put_int(editable.int8);
MENU_ITEM_ADDON_END();
}
if (i < 0) SKIP_ITEM();
}
/*
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_CANCEL_OBJECT, &editable.int8, -1, 32, [](){
if (editable.int8 > -1) {
cancelable.cancel_object(editable.int8);
ui.quick_feedback();
editable.int8 = -1;
}
});
*/
END_MENU();
}

Loading…
Cancel
Save