From e2a790b759f282232f07b5ef22218ec2d9b9ad6c Mon Sep 17 00:00:00 2001 From: Marcio T Date: Fri, 10 Sep 2021 19:03:46 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Enhance=20FTDI=20Eve=20Touch=20U?= =?UTF-8?q?I=20file=20select=20dialog=20(#22742)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/confirm_start_print_dialog_box.cpp | 6 +++--- .../generic/confirm_start_print_dialog_box.h | 5 ++--- .../ftdi_eve_touch_ui/generic/files_screen.cpp | 18 +++++++++--------- .../ftdi_eve_touch_ui/generic/files_screen.h | 10 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.cpp index 47aac62860..7f566539a1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.cpp @@ -33,7 +33,7 @@ using namespace ExtUI; constexpr static ConfirmStartPrintDialogBoxData &mydata = screen_data.ConfirmStartPrintDialogBox; void ConfirmStartPrintDialogBox::onRedraw(draw_mode_t) { - const char *filename = getLongFilename(); + const char *filename = getFilename(); char buffer[strlen_P(GET_TEXT(MSG_START_PRINT_CONFIRMATION)) + strlen(filename) + 1]; sprintf_P(buffer, GET_TEXT(MSG_START_PRINT_CONFIRMATION), filename); drawMessage((const char *)buffer); @@ -52,10 +52,10 @@ bool ConfirmStartPrintDialogBox::onTouchEnd(uint8_t tag) { } } -const char *ConfirmStartPrintDialogBox::getFilename(bool longName) { +const char *ConfirmStartPrintDialogBox::getFilename(bool shortName) { FileList files; files.seek(mydata.file_index, true); - return longName ? files.longFilename() : files.shortFilename(); + return shortName ? files.shortFilename() : files.filename(); } void ConfirmStartPrintDialogBox::show(uint8_t file_index) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.h index e073ed55fa..1f74fde94b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_start_print_dialog_box.h @@ -31,10 +31,9 @@ struct ConfirmStartPrintDialogBoxData { class ConfirmStartPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { private: - inline static const char *getShortFilename() {return getFilename(false);} - inline static const char *getLongFilename() {return getFilename(true);} + inline static const char *getShortFilename() {return getFilename(true);} - static const char *getFilename(bool longName); + static const char *getFilename(bool shortName = false); public: static void onRedraw(draw_mode_t); static bool onTouchEnd(uint8_t); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp index 8b9c877fc5..5076e58adf 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp @@ -70,10 +70,10 @@ void FilesScreen::onEntry() { BaseScreen::onEntry(); } -const char *FilesScreen::getSelectedFilename(bool longName) { +const char *FilesScreen::getSelectedFilename(bool shortName) { FileList files; files.seek(getSelectedFileIndex(), true); - return longName ? files.longFilename() : files.shortFilename(); + return shortName ? files.shortFilename() : files.filename(); } void FilesScreen::drawSelectedFile() { @@ -132,13 +132,13 @@ void FilesScreen::drawFileList() { mydata.num_page = max(1,ceil(float(files.count()) / FILES_PER_PAGE)); mydata.cur_page = min(mydata.cur_page, mydata.num_page-1); mydata.flags.is_root = files.isAtRootDir(); + mydata.flags.is_empty = true; uint16_t fileIndex = mydata.cur_page * FILES_PER_PAGE; for (uint8_t i = 0; i < FILES_PER_PAGE; i++, fileIndex++) { - if (files.seek(fileIndex)) - drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); - else - break; + if (!files.seek(fileIndex)) break; + drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); + mydata.flags.is_empty = false; } } @@ -252,11 +252,11 @@ bool FilesScreen::onTouchEnd(uint8_t tag) { mydata.scroll_pos = 0; mydata.scroll_max = 0; if (FTDI::ftdi_chip >= 810) { - const char *longFilename = getSelectedLongFilename(); - if (longFilename[0]) { + const char *filename = getSelectedFilename(); + if (filename[0]) { CommandProcessor cmd; constexpr int dim[4] = {LIST_POS}; - const uint16_t text_width = cmd.font(font_medium).text_width(longFilename); + const uint16_t text_width = cmd.font(font_medium).text_width(filename); if (text_width > dim[2]) mydata.scroll_max = text_width - dim[2] + MARGIN_L + MARGIN_R + 10; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h index bf2b415364..cb950d4cac 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h @@ -27,8 +27,9 @@ struct FilesScreenData { struct { - uint8_t is_dir : 1; - uint8_t is_root : 1; + uint8_t is_dir : 1; + uint8_t is_root : 1; + uint8_t is_empty : 1; } flags; uint8_t selected_tag; uint8_t num_page; @@ -46,9 +47,8 @@ class FilesScreen : public BaseScreen, public CachedScreen