some comments

calib-gui
Ondřej Hruška 1 year ago
parent edd003a541
commit 088b047b39
  1. 14
      Core/Src/app_gui.c

@ -353,8 +353,9 @@ static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb
break;
case GUI_EVENT_SCREEN_TICK:
// long text sliding animation
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 - menu->text_slide > FBW - 2) {
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:
for (int i = 0; i < menu->len; i++) {
bool current = menu->pos == i;
fbcolor_t color = !current;
fbpos_t y = 27 + i * 10;
// is the row currently rendered the selected row?
const bool is_selected = menu->pos == i;
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_text(1 - (current ? menu->text_slide : 0), y + 1, options[i], FONT_5X7, color);
// ensure the text doesnt escape the screen
fb_text(1 - (is_selected ? menu->text_slide : 0), y + 1, options[i], FONT_5X7, color);
// ensure the text doesn't touch the edge (looks ugly)
fb_vline(FBW - 1, y, 10, !color);
fb_vline(0, y, 10, !color);
}

Loading…
Cancel
Save