Browse Source

Introduced new function lcd_implementation_mark_as_selected()

New function now drops the prechar (select character) and makes the first
column usable for text.
Marking the line is now constantly made by highlighting (reverse).

Replaced selection code in:
lcd_implementation_drawmenu_generic()
_drawmenu_setting_edit_generic()
_drawmenu_sd()

with new function.
pull/1/head
AnHardt 10 years ago
parent
commit
f708884808
  1. 43
      Marlin/dogm_lcd_implementation.h

43
Marlin/dogm_lcd_implementation.h

@ -283,12 +283,8 @@ static void lcd_implementation_status_screen() {
#endif #endif
} }
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
char c; if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
uint8_t n = LCD_WIDTH - 1 - 2;
if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) {
u8g.setColorIndex(1); // black on white u8g.setColorIndex(1); // black on white
u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black u8g.setColorIndex(0); // following text must be white on black
@ -296,9 +292,14 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
else { else {
u8g.setColorIndex(1); // unmarked text is black on white u8g.setColorIndex(1); // unmarked text is black on white
} }
u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); }
u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
char c;
uint8_t n = LCD_WIDTH - 2;
lcd_implementation_mark_as_selected(row, pre_char);
while((c = pgm_read_byte(pstr))) { while((c = pgm_read_byte(pstr))) {
u8g.print(c); u8g.print(c);
@ -306,29 +307,23 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
n--; n--;
} }
while(n--) u8g.print(' '); while(n--) u8g.print(' ');
u8g.print(post_char); u8g.print(post_char);
u8g.print(' '); u8g.print(' ');
u8g.setColorIndex(1); // restore settings to black on white
} }
static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
char c; char c;
uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); uint8_t n = LCD_WIDTH - 2 - (pgm ? strlen_P(data) : (strlen(data)));
u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); lcd_implementation_mark_as_selected(row, pre_char);
u8g.print(pre_char);
while( (c = pgm_read_byte(pstr)) != '\0' ) { while( (c = pgm_read_byte(pstr))) {
u8g.print(c); u8g.print(c);
pstr++; pstr++;
n--; n--;
} }
u8g.print(':'); u8g.print(':');
while(n--) u8g.print(' '); while(n--) u8g.print(' ');
if (pgm) { lcd_printPGM(data); } else { u8g.print(data); } if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
} }
@ -392,25 +387,15 @@ static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, ch
longFilename[n] = '\0'; longFilename[n] = '\0';
} }
if (isSelected) { lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
u8g.setColorIndex(1); // black on white
u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black
}
u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
u8g.print(' '); // Indent by 1 char
if (isDir) u8g.print(LCD_STR_FOLDER[0]); if (isDir) u8g.print(LCD_STR_FOLDER[0]);
while((c = *filename) != '\0') { while((c = *filename) != '\0') {
u8g.print(c); u8g.print(c);
filename++; filename++;
n--; n--;
} }
while(n--) u8g.print(' '); while(n--) u8g.print(' ');
if (isSelected) u8g.setColorIndex(1); // black on white
} }
#define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true) #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)

Loading…
Cancel
Save