Skip to content

Commit

Permalink
🚸 Scroll long filename on MKS TFT (MarlinFirmware#23031)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlopi authored and mh-dm committed May 15, 2022
1 parent 5dbad64 commit 8583283
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Marlin/src/lcd/tft/ui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,17 @@ void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr,
void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
menu_item(row);
tft_string.set(pstr, itemIndex, itemString);
if (vstr)
tft_string.add(vstr);
if (vstr) tft_string.add(vstr);
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string);
}

#if ENABLED(SDSUPPORT)

void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) {
menu_item(row, sel);
if (isDir)
tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, theCard.longest_filename());
if (isDir) tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
constexpr uint8_t maxlen = (MENU_ITEM_HEIGHT) - (MENU_TEXT_Y_OFFSET) + 1;
tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, ui.scrolled_filename(theCard, maxlen, row, sel));
}

#endif
Expand Down

0 comments on commit 8583283

Please sign in to comment.