@@ -369,13 +369,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
369
369
void MenuItem_static::draw (const uint8_t row, PGM_P const pstr, const uint8_t style/* =SS_DEFAULT*/ , const char * const vstr/* =nullptr*/ ) {
370
370
371
371
if (mark_as_selected (row, style & SS_INVERT)) {
372
-
373
372
pixel_len_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
374
-
375
- const int8_t plen = pstr ? utf8_strlen_P (pstr) : 0 ,
376
- vlen = vstr ? utf8_strlen (vstr) : 0 ;
373
+
374
+ const int plen = pstr ? calculateWidth (pstr) : 0 ,
375
+ vlen = vstr ? utf8_strlen (vstr) : 0 ;
377
376
if (style & SS_CENTER) {
378
- int8_t pad = (LCD_WIDTH - plen - vlen) / 2 ;
377
+ int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2 ;
379
378
while (--pad >= 0 ) n -= lcd_put_wchar (' ' );
380
379
}
381
380
@@ -400,8 +399,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
400
399
if (mark_as_selected (row, sel)) {
401
400
const uint8_t vallen = (pgm ? utf8_strlen_P (inStr) : utf8_strlen ((char *)inStr)),
402
401
pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP (u8g.getU8g (), inStr) : uxg_GetUtf8StrPixelWidth (u8g.getU8g (), (char *)inStr));
402
+ const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1 ;
403
403
404
- pixel_len_t n = lcd_put_u8str_ind_P (pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
404
+ pixel_len_t n = lcd_put_u8str_ind_P (pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen * prop ) * (MENU_FONT_WIDTH);
405
405
if (vallen) {
406
406
lcd_put_wchar (' :' );
407
407
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar (' ' );
@@ -414,15 +414,16 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
414
414
void MenuEditItemBase::draw_edit_screen (PGM_P const pstr, const char * const value/* =nullptr*/ ) {
415
415
ui.encoder_direction_normal ();
416
416
417
+ const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1 ;
417
418
const u8g_uint_t labellen = utf8_strlen_P (pstr), vallen = utf8_strlen (value);
418
- bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
419
+ bool extra_row = labellen * prop > LCD_WIDTH - 2 - vallen * prop ;
419
420
420
421
#if ENABLED(USE_BIG_EDIT_FONT)
421
422
// Use the menu font if the label won't fit on a single line
422
423
constexpr u8g_uint_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
423
424
u8g_uint_t lcd_chr_fit, one_chr_width;
424
- if (labellen <= lcd_edit_width - 1 ) {
425
- if (labellen + vallen + 1 > lcd_edit_width) extra_row = true ;
425
+ if (labellen * prop <= lcd_edit_width - 1 ) {
426
+ if (labellen * prop + vallen * prop + 1 > lcd_edit_width) extra_row = true ;
426
427
lcd_chr_fit = lcd_edit_width + 1 ;
427
428
one_chr_width = EDIT_FONT_WIDTH;
428
429
ui.set_font (FONT_EDIT);
@@ -454,7 +455,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
454
455
onpage = PAGE_CONTAINS (baseline - (EDIT_FONT_ASCENT - 1 ), baseline);
455
456
}
456
457
if (onpage) {
457
- lcd_put_wchar (((lcd_chr_fit - 1 ) - (vallen + 1 )) * one_chr_width, baseline, ' ' ); // Right-justified, padded, add a leading space
458
+ lcd_put_wchar (((lcd_chr_fit - 1 ) - (vallen * prop + 1 )) * one_chr_width, baseline, ' ' ); // Right-justified, padded, add a leading space
458
459
lcd_put_u8str (value);
459
460
}
460
461
}
@@ -478,8 +479,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
478
479
void MenuItem_confirm::draw_select_screen (PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/* =nullptr*/ , PGM_P const suff/* =nullptr*/ ) {
479
480
ui.draw_select_screen_prompt (pref, string, suff);
480
481
draw_boxed_string (1 , LCD_HEIGHT - 1 , no, !yesno);
481
- const u8g_uint_t xpos = (LCD_WIDTH) / (USE_WIDE_GLYPH ? 2 : 1 );
482
- draw_boxed_string (xpos - (utf8_strlen_P (yes) + 1 ), LCD_HEIGHT - 1 , yes, yesno);
482
+ draw_boxed_string (LCD_WIDTH - (utf8_strlen_P (yes) * (USE_WIDE_GLYPH ? 2 : 1 ) + 1 ), LCD_HEIGHT - 1 , yes, yesno);
483
483
}
484
484
485
485
#if ENABLED(SDSUPPORT)
0 commit comments