Refactor action_ok

This commit is contained in:
twinaphex 2015-05-17 16:30:54 +02:00
parent cb486c300d
commit 04a2dd469e
4 changed files with 232 additions and 403 deletions

File diff suppressed because it is too large Load Diff

View File

@ -451,6 +451,7 @@ int menu_entry_iterate(unsigned action)
int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
{
menu_displaylist_info_t info = {0};
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
@ -477,7 +478,14 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
case MENU_ACTION_OK:
if (cbs && cbs->action_ok)
return cbs->action_ok(entry->path, entry->label, entry->type, i);
{
info.list = menu_list->menu_stack;
info.type = entry->type;
info.directory_ptr = i;
strlcpy(info.path, entry->path, sizeof(info.path));
strlcpy(info.label, entry->label, sizeof(info.label));
return cbs->action_ok(&info);
}
break;
case MENU_ACTION_START:
if (cbs && cbs->action_start)

View File

@ -716,7 +716,7 @@ static int menu_input_mouse_frame(
return cbs->action_toggle(entry->type, entry->label, MENU_ACTION_RIGHT, true);
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_OK))
return cbs->action_ok(entry->path, entry->label, entry->type, nav->selection_ptr);
return menu_entry_action(entry, nav->selection_ptr, MENU_ACTION_OK);
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION))
{
@ -846,7 +846,7 @@ static int pointer_tap(menu_file_list_cbs_t *cbs,
|| setting->type == ST_FLOAT || setting->type == ST_STRING))
return cbs->action_toggle(entry->type, entry->label, MENU_ACTION_RIGHT, true);
else if (menu->pointer.ptr == menu->navigation.selection_ptr)
return cbs->action_ok(entry->path, entry->label, entry->type, menu->navigation.selection_ptr);
return menu_entry_action(entry, menu->navigation.selection_ptr, MENU_ACTION_OK);
else
menu_navigation_set(&menu->navigation, menu->pointer.ptr, false);

View File

@ -36,8 +36,7 @@ typedef struct menu_file_list_cbs
{
int (*action_iterate)(const char *label, unsigned action);
int (*action_deferred_push)(menu_displaylist_info_t *info);
int (*action_ok)(const char *path, const char *label, unsigned type,
size_t idx);
int (*action_ok)(menu_displaylist_info_t *info);
int (*action_cancel)(const char *path, const char *label, unsigned type,
size_t idx);
int (*action_start)(unsigned type, const char *label, unsigned action);