浏览代码

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 9 年前
父节点
当前提交
f708884808
共有 1 个文件被更改,包括 14 次插入29 次删除
  1. 14
    29
      Marlin/dogm_lcd_implementation.h

+ 14
- 29
Marlin/dogm_lcd_implementation.h 查看文件

@@ -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
 
@@ -392,25 +387,15 @@ static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, ch
392 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 392
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
405
-
406 393
   while((c = *filename) != '\0') {
407 394
     u8g.print(c);
408 395
     filename++;
409 396
     n--;
410 397
   }
411 398
   while(n--) u8g.print(' ');
412
-
413
-  if (isSelected) u8g.setColorIndex(1); // black on white
414 399
 }
415 400
 
416 401
 #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)

正在加载...
取消
保存