Reduced string storage using tokens (#15593)
This commit is contained in:
@ -1006,40 +1006,41 @@ void MarlinUI::draw_status_screen() {
|
||||
int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
|
||||
while (--pad >= 0) { lcd_put_wchar(' '); n--; }
|
||||
}
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
n = lcd_put_u8str_ind_P(pstr, itemIndex, n);
|
||||
if (valstr) n -= lcd_put_u8str_max(valstr, n);
|
||||
for (; n > 0; --n) lcd_put_wchar(' ');
|
||||
}
|
||||
|
||||
// Draw a generic menu item with pre_char (if selected) and post_char
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) {
|
||||
uint8_t n = LCD_WIDTH - 2;
|
||||
lcd_put_wchar(0, row, sel ? pre_char : ' ');
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2);
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
lcd_put_wchar(post_char);
|
||||
}
|
||||
|
||||
// Draw an edit menu item with label and value string
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
|
||||
int8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data));
|
||||
// Draw a menu item with a (potentially) editable value
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) {
|
||||
const uint8_t vlen = data ? (pgm ? utf8_strlen_P(data) : utf8_strlen(data)) : 0;
|
||||
lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
lcd_put_wchar(':');
|
||||
for (; n > 0; --n) lcd_put_wchar(' ');
|
||||
if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data);
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2 - vlen);
|
||||
if (vlen) {
|
||||
lcd_put_wchar(':');
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the edit screen for an editable menu item
|
||||
void MenuEditItemBase::edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
|
||||
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
|
||||
lcd_put_u8str_P(0, 1, pstr);
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, LCD_WIDTH - 1);
|
||||
if (value != nullptr) {
|
||||
lcd_put_wchar(':');
|
||||
int len = utf8_strlen(value);
|
||||
const lcd_uint_t valrow = (utf8_strlen_P(pstr) + 1 + len + 1) > (LCD_WIDTH - 2) ? 2 : 1; // Value on the next row if it won't fit
|
||||
lcd_put_wchar((LCD_WIDTH - 1) - (len + 1), valrow, ' '); // Right-justified, padded, add a leading space
|
||||
const lcd_uint_t valrow = (n < len + 1) ? 2 : 1; // Value on the next row if it won't fit
|
||||
lcd_put_wchar((LCD_WIDTH - 1) - (len + 1), valrow, ' '); // Right-justified, padded, leading space
|
||||
lcd_put_u8str(value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user