🧑💻 Extend LCD string substitution (#24278)
This commit is contained in:
@@ -96,16 +96,15 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) {
|
||||
lcd_gotopixel(int(col) * (TFT_COL_WIDTH), int(row) * MENU_LINE_HEIGHT);
|
||||
}
|
||||
|
||||
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) {
|
||||
if (max_length < 1) return 0;
|
||||
tft_string.set();
|
||||
tft_string.add(c);
|
||||
tft_string.set(c);
|
||||
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
lcd_gotopixel((cursor.x + 1) * (TFT_COL_WIDTH) + tft_string.width(), cursor.y * MENU_LINE_HEIGHT);
|
||||
return tft_string.width();
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
|
||||
if (max_length < 1) return 0;
|
||||
tft_string.set(utf8_pstr);
|
||||
tft_string.trim();
|
||||
@@ -115,7 +114,7 @@ int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
|
||||
return tft_string.width();
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
|
||||
int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_P(utf8_str, max_length);
|
||||
}
|
||||
|
||||
@@ -133,7 +132,7 @@ void lcd_put_int(const int i) {
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char) {
|
||||
menu_item(row, sel);
|
||||
|
||||
uint8_t *string = (uint8_t *)FTOP(fstr);
|
||||
const char *string = FTOP(fstr);
|
||||
MarlinImage image = noImage;
|
||||
switch (*string) {
|
||||
case 0x01: image = imgRefresh; break; // LCD_STR_REFRESH
|
||||
@@ -147,18 +146,19 @@ void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, c
|
||||
tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, image, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
tft_string.set(string, itemIndex, FTOP(itemString));
|
||||
tft_string.set(string, itemIndex, itemStringC, itemStringF);
|
||||
|
||||
tft.add_text(offset, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
|
||||
// Draw a menu item with a (potentially) editable value
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const data, const bool pgm) {
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) {
|
||||
menu_item(row, sel);
|
||||
|
||||
tft_string.set(FTOP(fstr), itemIndex, FTOP(itemString));
|
||||
tft_string.set(fstr, itemIndex, itemStringC, itemStringF);
|
||||
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
if (data) {
|
||||
tft_string.set(data);
|
||||
if (inStr) {
|
||||
tft_string.set(inStr);
|
||||
tft.add_text(TFT_WIDTH - MENU_TEXT_X_OFFSET - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr
|
||||
// Draw a static item with no left-right margin required. Centered by default.
|
||||
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
menu_item(row);
|
||||
tft_string.set(FTOP(fstr), itemIndex, FTOP(itemString));
|
||||
tft_string.set(fstr, itemIndex, itemStringC, itemStringF);
|
||||
if (vstr) tft_string.add(vstr);
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string);
|
||||
}
|
||||
|
Reference in New Issue
Block a user