From 5f6b006a1bea4be2afad9a4cd0c42209b09084f4 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Sun, 20 Aug 2023 18:07:58 +0200 Subject: [PATCH] Added hide delay to context menu --- src/menu/components.h | 1 + src/menu/components/context_menu.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/menu/components.h b/src/menu/components.h index 6ebf2463..858b9763 100644 --- a/src/menu/components.h +++ b/src/menu/components.h @@ -40,6 +40,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected); typedef struct { int count; int selected; + bool hide_pending; struct { const char *text; void (*action) (menu_t *menu); diff --git a/src/menu/components/context_menu.c b/src/menu/components/context_menu.c index 00229f85..205e1386 100644 --- a/src/menu/components/context_menu.c +++ b/src/menu/components/context_menu.c @@ -6,6 +6,7 @@ void component_context_menu_init (component_context_menu_t *cm) { cm->selected = -1; cm->count = 0; + cm->hide_pending = false; for (int i = 0; (cm->list[i].text) != NULL; i++) { cm->count += 1; } @@ -21,11 +22,11 @@ bool component_context_menu_process (menu_t *menu, component_context_menu_t *cm) } if (menu->actions.back) { - cm->selected = -1; + cm->hide_pending = true; } else if (menu->actions.enter) { if (cm->list[cm->selected].action) { cm->list[cm->selected].action(menu); - cm->selected = -1; + cm->hide_pending = true; } } else if (menu->actions.go_up) { cm->selected -= 1; @@ -89,4 +90,9 @@ void component_context_menu_draw (component_context_menu_t *cm) { rdpq_paragraph_render(layout, VISIBLE_AREA_X0, VISIBLE_AREA_Y0); rdpq_paragraph_free(layout); + + if (cm->hide_pending) { + cm->hide_pending = false; + cm->selected = -1; + } }