Browse Source

Merge pull request #1464 from AnHardt/iss1448-Menu

Unified menu selection - by hilighting - made first column avilable
Scott Lahteine 10 years ago
parent
commit
b65c5d8ec6
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
 
412
     longFilename[n] = '\0';
407
     longFilename[n] = '\0';
413
   }
408
   }
414
 
409
 
415
-  if (isSelected) {
416
-    u8g.setColorIndex(1); // black on white
417
-    u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
418
-    u8g.setColorIndex(0); // following text must be white on black
419
-  }
420
-
421
-  u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
422
-  u8g.print(' '); // Indent by 1 char
410
+  lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
423
 
411
 
424
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
412
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
425
-
426
   while((c = *filename) != '\0') {
413
   while((c = *filename) != '\0') {
427
     u8g.print(c);
414
     u8g.print(c);
428
     filename++;
415
     filename++;
429
     n--;
416
     n--;
430
   }
417
   }
431
   while(n--) u8g.print(' ');
418
   while(n--) u8g.print(' ');
432
-
433
-  if (isSelected) u8g.setColorIndex(1); // black on white
434
 }
419
 }
435
 
420
 
436
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
421
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)

Loading…
Cancel
Save