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.
AnHardt 10 years ago
parent
commit
f708884808
1 changed files with 14 additions and 29 deletions
  1. 14
    29
      Marlin/dogm_lcd_implementation.h

+ 14
- 29
Marlin/dogm_lcd_implementation.h View File

283
   #endif
283
   #endif
284
 }
284
 }
285
 
285
 
286
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
287
-  char c;
288
-  
289
-  uint8_t n = LCD_WIDTH - 1 - 2;
290
-  
291
-  if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) {
286
+static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
287
+  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
292
     u8g.setColorIndex(1);  // black on white
288
     u8g.setColorIndex(1);  // black on white
293
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
289
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
294
     u8g.setColorIndex(0);  // following text must be white on black
290
     u8g.setColorIndex(0);  // following text must be white on black
296
   else {
292
   else {
297
     u8g.setColorIndex(1); // unmarked text is black on white
293
     u8g.setColorIndex(1); // unmarked text is black on white
298
   }
294
   }
299
-  
300
-  u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
301
-  u8g.print(pre_char == '>' ? ' ' : pre_char);  // Row selector is obsolete
295
+  u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
296
+}
297
+
298
+static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
299
+  char c;
300
+  uint8_t n = LCD_WIDTH - 2;
301
+
302
+  lcd_implementation_mark_as_selected(row, pre_char);
302
 
303
 
303
   while((c = pgm_read_byte(pstr))) {
304
   while((c = pgm_read_byte(pstr))) {
304
     u8g.print(c);
305
     u8g.print(c);
306
     n--;
307
     n--;
307
   }
308
   }
308
   while(n--) u8g.print(' ');
309
   while(n--) u8g.print(' ');
309
-  
310
   u8g.print(post_char);
310
   u8g.print(post_char);
311
   u8g.print(' ');
311
   u8g.print(' ');
312
-  u8g.setColorIndex(1);  // restore settings to black on white
313
 }
312
 }
314
 
313
 
315
 static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
314
 static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
316
   char c;
315
   char c;
317
-  uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data));
316
+  uint8_t n = LCD_WIDTH - 2 - (pgm ? strlen_P(data) : (strlen(data)));
318
 
317
 
319
-  u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
320
-  u8g.print(pre_char);
318
+  lcd_implementation_mark_as_selected(row, pre_char);
321
 
319
 
322
-  while( (c = pgm_read_byte(pstr)) != '\0' ) {
320
+  while( (c = pgm_read_byte(pstr))) {
323
     u8g.print(c);
321
     u8g.print(c);
324
     pstr++;
322
     pstr++;
325
     n--;
323
     n--;
326
   }
324
   }
327
-
328
   u8g.print(':');
325
   u8g.print(':');
329
-
330
   while(n--) u8g.print(' ');
326
   while(n--) u8g.print(' ');
331
-
332
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
327
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
333
 }
328
 }
334
 
329
 
392
     longFilename[n] = '\0';
387
     longFilename[n] = '\0';
393
   }
388
   }
394
 
389
 
395
-  if (isSelected) {
396
-    u8g.setColorIndex(1); // black on white
397
-    u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
398
-    u8g.setColorIndex(0); // following text must be white on black
399
-  }
400
-
401
-  u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
402
-  u8g.print(' '); // Indent by 1 char
390
+  lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
403
 
391
 
404
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
392
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
405
-
406
   while((c = *filename) != '\0') {
393
   while((c = *filename) != '\0') {
407
     u8g.print(c);
394
     u8g.print(c);
408
     filename++;
395
     filename++;
409
     n--;
396
     n--;
410
   }
397
   }
411
   while(n--) u8g.print(' ');
398
   while(n--) u8g.print(' ');
412
-
413
-  if (isSelected) u8g.setColorIndex(1); // black on white
414
 }
399
 }
415
 
400
 
416
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
401
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)

Loading…
Cancel
Save