|
|
@ -353,8 +353,9 @@ static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_SCREEN_TICK: |
|
|
|
case GUI_EVENT_SCREEN_TICK: |
|
|
|
|
|
|
|
// long text sliding animation
|
|
|
|
if (tickNow - menu->change_time >= pdMS_TO_TICKS(500)) { |
|
|
|
if (tickNow - menu->change_time >= pdMS_TO_TICKS(500)) { |
|
|
|
uint32_t textlen = strlen(options[menu->pos]) * 6; |
|
|
|
const uint32_t textlen = strlen(options[menu->pos]) * 6; |
|
|
|
if (textlen >= FBW - 2) { |
|
|
|
if (textlen >= FBW - 2) { |
|
|
|
if (textlen - menu->text_slide > FBW - 2) { |
|
|
|
if (textlen - menu->text_slide > FBW - 2) { |
|
|
|
menu->text_slide += 1; |
|
|
|
menu->text_slide += 1; |
|
|
@ -373,12 +374,13 @@ static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb |
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_PAINT: |
|
|
|
case GUI_EVENT_PAINT: |
|
|
|
for (int i = 0; i < menu->len; i++) { |
|
|
|
for (int i = 0; i < menu->len; i++) { |
|
|
|
bool current = menu->pos == i; |
|
|
|
// is the row currently rendered the selected row?
|
|
|
|
fbcolor_t color = !current; |
|
|
|
const bool is_selected = menu->pos == i; |
|
|
|
fbpos_t y = 27 + i * 10; |
|
|
|
const fbcolor_t color = !is_selected; // text color - black if selected, because it's inverted
|
|
|
|
|
|
|
|
const fbpos_t y = 27 + i * 10; |
|
|
|
fb_rect(0, y, FBW, 10, !color); |
|
|
|
fb_rect(0, y, FBW, 10, !color); |
|
|
|
fb_text(1 - (current ? menu->text_slide : 0), y + 1, options[i], FONT_5X7, color); |
|
|
|
fb_text(1 - (is_selected ? menu->text_slide : 0), y + 1, options[i], FONT_5X7, color); |
|
|
|
// ensure the text doesnt escape the screen
|
|
|
|
// ensure the text doesn't touch the edge (looks ugly)
|
|
|
|
fb_vline(FBW - 1, y, 10, !color); |
|
|
|
fb_vline(FBW - 1, y, 10, !color); |
|
|
|
fb_vline(0, y, 10, !color); |
|
|
|
fb_vline(0, y, 10, !color); |
|
|
|
} |
|
|
|
} |
|
|
|