Kaynağa Gözat

Merge pull request #1464 from AnHardt/iss1448-Menu

Unified menu selection - by hilighting - made first column avilable
Scott Lahteine 10 yıl önce
ebeveyn
işleme
b65c5d8ec6
1 değiştirilmiş dosya ile 14 ekleme ve 29 silme
  1. 14
    29
      Marlin/dogm_lcd_implementation.h

+ 14
- 29
Marlin/dogm_lcd_implementation.h Dosyayı Görüntüle

@@ -283,12 +283,8 @@ static void lcd_implementation_status_screen() {
283 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 288
     u8g.setColorIndex(1);  // black on white
293 289
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
294 290
     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
296 292
   else {
297 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 304
   while((c = pgm_read_byte(pstr))) {
304 305
     u8g.print(c);
@@ -306,29 +307,23 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
306 307
     n--;
307 308
   }
308 309
   while(n--) u8g.print(' ');
309
-  
310 310
   u8g.print(post_char);
311 311
   u8g.print(' ');
312
-  u8g.setColorIndex(1);  // restore settings to black on white
313 312
 }
314 313
 
315 314
 static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
316 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 321
     u8g.print(c);
324 322
     pstr++;
325 323
     n--;
326 324
   }
327
-
328 325
   u8g.print(':');
329
-
330 326
   while(n--) u8g.print(' ');
331
-
332 327
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
333 328
 }
334 329
 
@@ -412,25 +407,15 @@ static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, ch
412 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 412
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
425
-
426 413
   while((c = *filename) != '\0') {
427 414
     u8g.print(c);
428 415
     filename++;
429 416
     n--;
430 417
   }
431 418
   while(n--) u8g.print(' ');
432
-
433
-  if (isSelected) u8g.setColorIndex(1); // black on white
434 419
 }
435 420
 
436 421
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)

Loading…
İptal
Kaydet