Browse Source

🚸 Scroll long filename on MKS TFT (#23031)

Zlopi 3 years ago
parent
commit
c0337da633
No account linked to committer's email address
1 changed files with 4 additions and 5 deletions
  1. 4
    5
      Marlin/src/lcd/tft/ui_common.cpp

+ 4
- 5
Marlin/src/lcd/tft/ui_common.cpp View File

@@ -167,8 +167,7 @@ void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr,
167 167
 void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
168 168
   menu_item(row);
169 169
   tft_string.set(pstr, itemIndex, itemString);
170
-  if (vstr)
171
-    tft_string.add(vstr);
170
+  if (vstr) tft_string.add(vstr);
172 171
   tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string);
173 172
 }
174 173
 
@@ -176,9 +175,9 @@ void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t st
176 175
 
177 176
   void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) {
178 177
     menu_item(row, sel);
179
-    if (isDir)
180
-      tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
181
-    tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, theCard.longest_filename());
178
+    if (isDir) tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
179
+    constexpr uint8_t maxlen = (MENU_ITEM_HEIGHT) - (MENU_TEXT_Y_OFFSET) + 1;
180
+    tft.add_text(MENU_ITEM_ICON_SPACE, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, ui.scrolled_filename(theCard, maxlen, row, sel));
182 181
   }
183 182
 
184 183
 #endif

Loading…
Cancel
Save