mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-03-06 10:04:47 -07:00
🧑💻 LCD code style
This commit is contained in:
parent
ca1dc3e81e
commit
da7cfd1551
3 changed files with 16 additions and 11 deletions
|
|
@ -454,18 +454,21 @@ void MarlinUI::clear_for_drawing() {
|
|||
// Mark a menu item and set font color if selected.
|
||||
// Return 'false' if the item is not on screen.
|
||||
static bool mark_as_selected(const uint8_t row, const bool sel) {
|
||||
row_y1 = row * (MENU_FONT_HEIGHT) + 1;
|
||||
row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
|
||||
// Menu page has 2px top margin
|
||||
row_y1 = 2 + row * (MENU_LINE_HEIGHT);
|
||||
row_y2 = row_y1 + MENU_FONT_HEIGHT;
|
||||
|
||||
if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return false;
|
||||
// Nothing at all to draw?
|
||||
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
|
||||
|
||||
// Selected or not, draw background and set foreground color
|
||||
if (sel) {
|
||||
#if ENABLED(MENU_HOLLOW_FRAME)
|
||||
u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
|
||||
u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH);
|
||||
u8g.drawHLine(0, row_y1, LCD_PIXEL_WIDTH); // solid line top
|
||||
u8g.drawHLine(0, row_y2, LCD_PIXEL_WIDTH); // solid line bottom
|
||||
#else
|
||||
u8g.setColorIndex(1); // solid outline
|
||||
u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
|
||||
u8g.setColorIndex(1); // solid fill
|
||||
u8g.drawBox(0, row_y1 + 1, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
|
||||
u8g.setColorIndex(0); // inverted text
|
||||
#endif
|
||||
}
|
||||
|
|
@ -473,9 +476,11 @@ void MarlinUI::clear_for_drawing() {
|
|||
else u8g.setColorIndex(1); // solid text
|
||||
#endif
|
||||
|
||||
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
|
||||
// Will text not fit? Return false.
|
||||
if (!PAGE_CONTAINS(row_y1 - 1, row_y2 - MENU_FONT_DESCENT)) return false;
|
||||
|
||||
lcd_moveto(0, row_y2);
|
||||
// Place the cursor at X = 0, Y = row, return true
|
||||
lcd_moveto(0, row_y2 - MENU_FONT_DESCENT);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,4 +75,4 @@
|
|||
|
||||
#include "../common/dwin_color.h"
|
||||
|
||||
#define Color_Bg_Heading 0x3344 // Static Heading
|
||||
#define COLOR_BG_HEADING 0x3344 // Static Heading
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
|||
if (y >= LCD_PIXEL_HEIGHT) return false;
|
||||
|
||||
if (is_static && sel)
|
||||
dwinDrawBox(1, Color_Bg_Heading, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
|
||||
dwinDrawBox(1, COLOR_BG_HEADING, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
|
||||
else {
|
||||
#if ENABLED(MENU_HOLLOW_FRAME)
|
||||
dwinDrawBox(1, COLOR_BG_BLACK, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue