UI: made authors' list scrollable

pull/239/merge
Silvano Seva 2024-07-12 19:00:59 +02:00
rodzic a6f01c3e55
commit ecea0186a0
4 zmienionych plików z 44 dodań i 20 usunięć

Wyświetl plik

@ -1983,9 +1983,16 @@ void ui_updateFSM(bool *sync_rtx)
else if(msg.keys & KEY_ESC)
_ui_menuBack(MENU_TOP);
break;
// About screen
// About screen, scroll without rollover
case MENU_ABOUT:
if(msg.keys & KEY_ESC)
if(msg.keys & KEY_UP || msg.keys & KNOB_LEFT)
{
if(ui_state.menu_selected > 0)
ui_state.menu_selected -= 1;
}
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
ui_state.menu_selected += 1;
else if(msg.keys & KEY_ESC)
_ui_menuBack(MENU_TOP);
break;
#ifdef CONFIG_RTC
@ -2538,7 +2545,7 @@ bool ui_updateGUI()
break;
// About menu screen
case MENU_ABOUT:
_ui_drawMenuAbout();
_ui_drawMenuAbout(&ui_state);
break;
#ifdef CONFIG_RTC
// Time&Date settings screen

Wyświetl plik

@ -811,7 +811,7 @@ void _ui_drawMenuInfo(ui_state_t* ui_state)
_ui_getInfoValueName);
}
void _ui_drawMenuAbout()
void _ui_drawMenuAbout(ui_state_t* ui_state)
{
gfx_clearScreen();
@ -831,13 +831,18 @@ void _ui_drawMenuAbout()
yellow_fab413, currentLanguage->openRTX);
}
uint8_t line_h = layout.menu_h;
point_t pos = {CONFIG_SCREEN_WIDTH / 7, CONFIG_SCREEN_HEIGHT - (line_h * (author_num - 1)) - 5};
for(int author = 0; author < author_num; author++)
point_t pos = {CONFIG_SCREEN_WIDTH / 7, CONFIG_SCREEN_HEIGHT - (layout.menu_h * 3) - 5};
uint8_t entries_in_screen = (CONFIG_SCREEN_HEIGHT - 1 - pos.y) / layout.menu_h + 1;
uint8_t max_scroll = author_num - entries_in_screen;
if(ui_state->menu_selected >= max_scroll)
ui_state->menu_selected = max_scroll;
for(uint8_t item = 0; item < entries_in_screen; item++)
{
gfx_print(pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "%s", *(&currentLanguage->Niccolo + author));
pos.y += line_h;
uint8_t elem = ui_state->menu_selected + item;
gfx_print(pos, layout.menu_font, TEXT_ALIGN_LEFT, color_white, authors[elem]);
pos.y += layout.menu_h;
}
}

Wyświetl plik

@ -616,9 +616,16 @@ void ui_updateFSM(bool *sync_rtx)
else if(msg.keys & KEY_ESC)
_ui_menuBack(MENU_TOP);
break;
// About screen
// About screen, scroll without rollover
case MENU_ABOUT:
if(msg.keys & KEY_ESC)
if(msg.keys & KEY_UP || msg.keys & KNOB_LEFT)
{
if(ui_state.menu_selected > 0)
ui_state.menu_selected -= 1;
}
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
ui_state.menu_selected += 1;
else if(msg.keys & KEY_ESC)
_ui_menuBack(MENU_TOP);
break;
@ -869,7 +876,7 @@ bool ui_updateGUI()
break;
// About menu screen
case MENU_ABOUT:
_ui_drawMenuAbout();
_ui_drawMenuAbout(&ui_state);
break;
// Display settings screen
case SETTINGS_DISPLAY:

Wyświetl plik

@ -444,7 +444,7 @@ void _ui_drawMenuInfo(ui_state_t* ui_state)
_ui_getInfoValueName);
}
void _ui_drawMenuAbout()
void _ui_drawMenuAbout(ui_state_t* ui_state)
{
gfx_clearScreen();
@ -452,13 +452,18 @@ void _ui_drawMenuAbout()
gfx_print(openrtx_pos, layout.line3_font, TEXT_ALIGN_CENTER, color_white,
"OpenRTX");
uint8_t line_h = layout.menu_h;
point_t pos = {CONFIG_SCREEN_WIDTH / 7, CONFIG_SCREEN_HEIGHT - (line_h * (author_num - 1)) - 5};
for(int author = 0; author < author_num; author++)
point_t pos = {CONFIG_SCREEN_WIDTH / 7, CONFIG_SCREEN_HEIGHT - (layout.menu_h * 3) - 5};
uint8_t entries_in_screen = (CONFIG_SCREEN_HEIGHT - 1 - pos.y) / layout.menu_h + 1;
uint8_t max_scroll = author_num - entries_in_screen;
if(ui_state->menu_selected >= max_scroll)
ui_state->menu_selected = max_scroll;
for(uint8_t item = 0; item < entries_in_screen; item++)
{
gfx_print(pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "%s", authors[author]);
pos.y += line_h;
uint8_t elem = ui_state->menu_selected + item;
gfx_print(pos, layout.menu_font, TEXT_ALIGN_LEFT, color_white, authors[elem]);
pos.y += layout.menu_h;
}
}