Confirm object cancellation (#15660)

This commit is contained in:
Scott Lahteine
2019-10-27 19:50:21 -05:00
committed by GitHub
parent 78899fc241
commit 9aff30da0c
5 changed files with 40 additions and 30 deletions

View File

@ -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)

View File

@ -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();
}