UI: Add menu_h and menu_font layout parameters

This commit is contained in:
Federico Amedeo Izzo 2021-02-20 16:03:37 +01:00
parent 9c47797ff0
commit 820ac73d08
3 changed files with 26 additions and 13 deletions

View File

@ -119,6 +119,7 @@ typedef struct layout_t
uint16_t line1_h; uint16_t line1_h;
uint16_t line2_h; uint16_t line2_h;
uint16_t line3_h; uint16_t line3_h;
uint16_t menu_h;
uint16_t bottom_h; uint16_t bottom_h;
uint16_t status_v_pad; uint16_t status_v_pad;
uint16_t horizontal_pad; uint16_t horizontal_pad;
@ -134,6 +135,7 @@ typedef struct layout_t
fontSize_t line3_font; fontSize_t line3_font;
fontSize_t bottom_font; fontSize_t bottom_font;
fontSize_t input_font; fontSize_t input_font;
fontSize_t menu_font;
} layout_t; } layout_t;
/** /**

View File

@ -205,6 +205,7 @@ layout_t _ui_calculateLayout()
const uint16_t line1_h = 20; const uint16_t line1_h = 20;
const uint16_t line2_h = 20; const uint16_t line2_h = 20;
const uint16_t line3_h = 40; const uint16_t line3_h = 40;
const uint16_t menu_h = 16;
const uint16_t bottom_h = 20; const uint16_t bottom_h = 20;
const uint16_t bottom_pad = top_pad; const uint16_t bottom_pad = top_pad;
const uint16_t status_v_pad = 2; const uint16_t status_v_pad = 2;
@ -223,6 +224,8 @@ layout_t _ui_calculateLayout()
const fontSize_t bottom_font = FONT_SIZE_8PT; const fontSize_t bottom_font = FONT_SIZE_8PT;
// TimeDate/Frequency input font // TimeDate/Frequency input font
const fontSize_t input_font = FONT_SIZE_12PT; const fontSize_t input_font = FONT_SIZE_12PT;
// Menu font
const fontSize_t menu_font = FONT_SIZE_8PT;
// Radioddity GD-77 // Radioddity GD-77
#elif SCREEN_HEIGHT > 63 #elif SCREEN_HEIGHT > 63
@ -233,6 +236,7 @@ layout_t _ui_calculateLayout()
const uint16_t line1_h = 10; const uint16_t line1_h = 10;
const uint16_t line2_h = 10; const uint16_t line2_h = 10;
const uint16_t line3_h = 16; const uint16_t line3_h = 16;
const uint16_t menu_h = 10;
const uint16_t bottom_h = 8; const uint16_t bottom_h = 8;
const uint16_t bottom_pad = 0; const uint16_t bottom_pad = 0;
const uint16_t status_v_pad = 1; const uint16_t status_v_pad = 1;
@ -250,6 +254,8 @@ layout_t _ui_calculateLayout()
const fontSize_t bottom_font = FONT_SIZE_6PT; const fontSize_t bottom_font = FONT_SIZE_6PT;
// TimeDate/Frequency input font // TimeDate/Frequency input font
const fontSize_t input_font = FONT_SIZE_8PT; const fontSize_t input_font = FONT_SIZE_8PT;
// Menu font
const fontSize_t menu_font = FONT_SIZE_6PT;
// Radioddity RD-5R // Radioddity RD-5R
#elif SCREEN_HEIGHT > 47 #elif SCREEN_HEIGHT > 47
@ -260,6 +266,7 @@ layout_t _ui_calculateLayout()
const uint16_t line1_h = 0; const uint16_t line1_h = 0;
const uint16_t line2_h = 10; const uint16_t line2_h = 10;
const uint16_t line3_h = 18; const uint16_t line3_h = 18;
const uint16_t menu_h = 10;
const uint16_t bottom_h = 0; const uint16_t bottom_h = 0;
const uint16_t bottom_pad = 0; const uint16_t bottom_pad = 0;
const uint16_t status_v_pad = 1; const uint16_t status_v_pad = 1;
@ -274,6 +281,8 @@ layout_t _ui_calculateLayout()
const fontSize_t line3_font = FONT_SIZE_12PT; const fontSize_t line3_font = FONT_SIZE_12PT;
// TimeDate/Frequency input font // TimeDate/Frequency input font
const fontSize_t input_font = FONT_SIZE_8PT; const fontSize_t input_font = FONT_SIZE_8PT;
// Menu font
const fontSize_t menu_font = FONT_SIZE_6PT;
// Not present on this resolution // Not present on this resolution
const fontSize_t line1_font = 0; const fontSize_t line1_font = 0;
const fontSize_t bottom_font = 0; const fontSize_t bottom_font = 0;
@ -296,6 +305,7 @@ layout_t _ui_calculateLayout()
line1_h, line1_h,
line2_h, line2_h,
line3_h, line3_h,
menu_h,
bottom_h, bottom_h,
status_v_pad, status_v_pad,
horizontal_pad, horizontal_pad,
@ -310,7 +320,8 @@ layout_t _ui_calculateLayout()
line2_font, line2_font,
line3_font, line3_font,
bottom_font, bottom_font,
input_font input_font,
menu_font
}; };
return new_layout; return new_layout;
} }

View File

@ -29,7 +29,7 @@ void _ui_drawMenuList(uint8_t selected, int (*getCurrentEntry)(char *buf, uint8_
{ {
point_t pos = layout.line1_pos; point_t pos = layout.line1_pos;
// Number of menu entries that fit in the screen height // Number of menu entries that fit in the screen height
uint8_t entries_in_screen = (SCREEN_HEIGHT - 1 - pos.y) / layout.top_h + 1; uint8_t entries_in_screen = (SCREEN_HEIGHT - 1 - pos.y) / layout.menu_h + 1;
uint8_t scroll = 0; uint8_t scroll = 0;
char entry_buf[MAX_ENTRY_LEN] = ""; char entry_buf[MAX_ENTRY_LEN] = "";
color_t text_color = color_white; color_t text_color = color_white;
@ -47,11 +47,11 @@ void _ui_drawMenuList(uint8_t selected, int (*getCurrentEntry)(char *buf, uint8_
{ {
text_color = color_black; text_color = color_black;
// Draw rectangle under selected item, compensating for text height // Draw rectangle under selected item, compensating for text height
point_t rect_pos = {0, pos.y - layout.top_h + 3}; point_t rect_pos = {0, pos.y - layout.menu_h + 3};
gfx_drawRect(rect_pos, SCREEN_WIDTH, layout.top_h, color_white, true); gfx_drawRect(rect_pos, SCREEN_WIDTH, layout.menu_h, color_white, true);
} }
gfx_print(pos, entry_buf, layout.top_font, TEXT_ALIGN_LEFT, text_color); gfx_print(pos, entry_buf, layout.menu_font, TEXT_ALIGN_LEFT, text_color);
pos.y += layout.top_h; pos.y += layout.menu_h;
} }
} }
} }
@ -62,7 +62,7 @@ void _ui_drawMenuListValue(ui_state_t* ui_state, uint8_t selected,
{ {
point_t pos = layout.line1_pos; point_t pos = layout.line1_pos;
// Number of menu entries that fit in the screen height // Number of menu entries that fit in the screen height
uint8_t entries_in_screen = (SCREEN_HEIGHT - 1 - pos.y) / layout.top_h + 1; uint8_t entries_in_screen = (SCREEN_HEIGHT - 1 - pos.y) / layout.menu_h + 1;
uint8_t scroll = 0; uint8_t scroll = 0;
char entry_buf[MAX_ENTRY_LEN] = ""; char entry_buf[MAX_ENTRY_LEN] = "";
char value_buf[MAX_ENTRY_LEN] = ""; char value_buf[MAX_ENTRY_LEN] = "";
@ -90,12 +90,12 @@ void _ui_drawMenuListValue(ui_state_t* ui_state, uint8_t selected,
text_color = color_white; text_color = color_white;
full_rect = false; full_rect = false;
} }
point_t rect_pos = {0, pos.y - layout.top_h + 3}; point_t rect_pos = {0, pos.y - layout.menu_h + 3};
gfx_drawRect(rect_pos, SCREEN_WIDTH, layout.top_h, color_white, full_rect); gfx_drawRect(rect_pos, SCREEN_WIDTH, layout.menu_h, color_white, full_rect);
} }
gfx_print(pos, entry_buf, layout.top_font, TEXT_ALIGN_LEFT, text_color); gfx_print(pos, entry_buf, layout.menu_font, TEXT_ALIGN_LEFT, text_color);
gfx_print(pos, value_buf, layout.top_font, TEXT_ALIGN_RIGHT, text_color); gfx_print(pos, value_buf, layout.menu_font, TEXT_ALIGN_RIGHT, text_color);
pos.y += layout.top_h; pos.y += layout.menu_h;
} }
} }
} }
@ -403,7 +403,7 @@ void _ui_drawMenuAbout()
gfx_clearScreen(); gfx_clearScreen();
ui_drawSplashScreen(false); ui_drawSplashScreen(false);
char author_buf[MAX_ENTRY_LEN] = ""; char author_buf[MAX_ENTRY_LEN] = "";
uint8_t line_h = layout.top_h; uint8_t line_h = layout.menu_h;
point_t pos = {SCREEN_WIDTH / 7, SCREEN_HEIGHT - (line_h * (author_num - 1)) - 5}; point_t pos = {SCREEN_WIDTH / 7, SCREEN_HEIGHT - (line_h * (author_num - 1)) - 5};
for(int author = 0; author < author_num; author++) for(int author = 0; author < author_num; author++)
{ {