Cleanups - start using menu_driver_resolve everywhere in menu

code for safety reasons
This commit is contained in:
twinaphex 2015-02-13 20:04:50 +01:00
parent 8568732234
commit 55844f06d7
7 changed files with 115 additions and 110 deletions

View File

@ -212,7 +212,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu,
if (!info_list) if (!info_list)
return -1; return -1;
info = (core_info_t*)&info_list->list[driver.menu->categories.selection_ptr - 1]; info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1];
if (!info) if (!info)
return -1; return -1;
@ -223,7 +223,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu,
menu_entries_push_cores_list(list, info, g_settings.content_directory, true); menu_entries_push_cores_list(list, info, g_settings.content_directory, true);
menu_list_populate_generic(menu, list, path, label, menu_type); menu_list_populate_generic(list, path, label, menu_type);
return 0; return 0;
} }
@ -476,7 +476,7 @@ int menu_entries_parse_list(
menu_list_sort_on_alt(list); menu_list_sort_on_alt(list);
} }
menu_list_populate_generic(driver.menu, list, dir, label, type); menu_list_populate_generic(list, dir, label, type);
return 0; return 0;
} }
@ -521,7 +521,7 @@ bool menu_entries_init(menu_handle_t *menu)
menu->list_settings = setting_data_new(SL_FLAG_ALL); menu->list_settings = setting_data_new(SL_FLAG_ALL);
menu_list_push_stack(menu->menu_list, "", "Main Menu", MENU_SETTINGS, 0); menu_list_push_stack(menu->menu_list, "", "Main Menu", MENU_SETTINGS, 0);
menu_navigation_clear(menu, true); menu_navigation_clear(true);
menu_entries_push_list(menu, menu->menu_list->selection_buf, menu_entries_push_list(menu, menu->menu_list->selection_buf,
"", "Main Menu", 0, SL_FLAG_MAIN_MENU); "", "Main Menu", 0, SL_FLAG_MAIN_MENU);

View File

@ -1422,7 +1422,7 @@ static int action_ok_config_load(const char *path,
menu->msg_force = true; menu->msg_force = true;
if (rarch_replace_config(config)) if (rarch_replace_config(config))
{ {
menu_navigation_clear(menu, false); menu_navigation_clear(false);
return -1; return -1;
} }
@ -2183,19 +2183,17 @@ static int action_toggle_scroll(unsigned type, const char *label,
{ {
case MENU_ACTION_LEFT: case MENU_ACTION_LEFT:
if (menu->selection_ptr > fast_scroll_speed) if (menu->selection_ptr > fast_scroll_speed)
menu_navigation_set(menu, menu_navigation_set(menu->selection_ptr - fast_scroll_speed, true);
menu->selection_ptr - fast_scroll_speed, true);
else else
menu_navigation_clear(menu, false); menu_navigation_clear(false);
break; break;
case MENU_ACTION_RIGHT: case MENU_ACTION_RIGHT:
if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list)))
menu_navigation_set(menu, menu_navigation_set(menu->selection_ptr + fast_scroll_speed, true);
menu->selection_ptr + fast_scroll_speed, true);
else else
{ {
if ((menu_list_get_size(menu->menu_list) > 0)) if ((menu_list_get_size(menu->menu_list) > 0))
menu_navigation_set_last(menu); menu_navigation_set_last();
} }
break; break;
} }
@ -2653,7 +2651,7 @@ static int deferred_push_core_list_deferred(void *data, void *userdata,
menu_list_sort_on_alt(list); menu_list_sort_on_alt(list);
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -2679,7 +2677,7 @@ static int deferred_push_database_manager_list_deferred(void *data, void *userda
menu_list_sort_on_alt(list); menu_list_sort_on_alt(list);
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -2722,7 +2720,7 @@ static int deferred_push_cursor_manager_list_deferred(void *data, void *userdata
menu_list_sort_on_alt(list); menu_list_sort_on_alt(list);
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -2823,7 +2821,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(
menu_list_sort_on_alt(list); menu_list_sort_on_alt(list);
menu_list_populate_generic(menu, list, str_list->elems[0].data, label, type); menu_list_populate_generic(list, str_list->elems[0].data, label, type);
string_list_free(str_list); string_list_free(str_list);
@ -3612,8 +3610,7 @@ static int cb_core_updater_list(void *data_, size_t len)
print_buf_lines(list, data, len, MENU_FILE_DOWNLOAD_CORE); print_buf_lines(list, data, len, MENU_FILE_DOWNLOAD_CORE);
menu_list_populate_generic(menu, menu_list_populate_generic(list, core_updater_list_path,
list, core_updater_list_path,
core_updater_list_label, core_updater_list_type); core_updater_list_label, core_updater_list_type);
return 0; return 0;
@ -3624,10 +3621,6 @@ static int cb_core_updater_list(void *data_, size_t len)
static int deferred_push_core_updater_list(void *data, void *userdata, static int deferred_push_core_updater_list(void *data, void *userdata,
const char *path, const char *label, unsigned type) const char *path, const char *label, unsigned type)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return -1;
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
char url_path[PATH_MAX_LENGTH]; char url_path[PATH_MAX_LENGTH];
@ -3651,7 +3644,7 @@ static int deferred_push_core_updater_list(void *data, void *userdata,
0, 0); 0, 0);
#endif #endif
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -3677,15 +3670,12 @@ static int deferred_push_history_list(void *data, void *userdata,
unsigned i; unsigned i;
size_t list_size = 0; size_t list_size = 0;
file_list_t *list = (file_list_t*)data; file_list_t *list = (file_list_t*)data;
menu_handle_t *menu = menu_driver_resolve();
if (!menu) if (!list)
return -1; return -1;
(void)userdata; (void)userdata;
if (!list || !menu)
return -1;
menu_list_clear(list); menu_list_clear(list);
list_size = content_playlist_size(g_defaults.history); list_size = content_playlist_size(g_defaults.history);
@ -3710,7 +3700,7 @@ static int deferred_push_history_list(void *data, void *userdata,
MENU_FILE_PLAYLIST_ENTRY, 0); MENU_FILE_PLAYLIST_ENTRY, 0);
} }
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -3725,7 +3715,7 @@ static int deferred_push_content_actions(void *data, void *userdata,
(void)userdata; (void)userdata;
if (!list || !menu) if (!list)
return -1; return -1;
menu_list_clear(list); menu_list_clear(list);
@ -3750,7 +3740,7 @@ static int deferred_push_content_actions(void *data, void *userdata,
else else
menu_list_push(list, "Run", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); menu_list_push(list, "Run", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0);
menu_list_populate_generic(menu, list, path, label, type); menu_list_populate_generic(list, path, label, type);
return 0; return 0;
} }
@ -3928,29 +3918,24 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label,
{ {
case MENU_ACTION_UP: case MENU_ACTION_UP:
if (menu->selection_ptr >= scroll_speed) if (menu->selection_ptr >= scroll_speed)
menu_navigation_set(menu, menu_navigation_set(menu->selection_ptr - scroll_speed, true);
menu->selection_ptr - scroll_speed, true);
else else
{ {
if (g_settings.menu.navigation.wraparound.vertical_enable) if (g_settings.menu.navigation.wraparound.vertical_enable)
menu_navigation_set(menu, menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
menu_list_get_size(menu->menu_list) - 1, true);
else else
menu_navigation_set(menu, menu_navigation_set(0, true);
0, true);
} }
break; break;
case MENU_ACTION_DOWN: case MENU_ACTION_DOWN:
if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list))) if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list)))
menu_navigation_set(menu, menu_navigation_set(menu->selection_ptr + scroll_speed, true);
menu->selection_ptr + scroll_speed, true);
else else
{ {
if (g_settings.menu.navigation.wraparound.vertical_enable) if (g_settings.menu.navigation.wraparound.vertical_enable)
menu_navigation_clear(menu, false); menu_navigation_clear(false);
else else
menu_navigation_set(menu, menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
menu_list_get_size(menu->menu_list) - 1, true);
} }
break; break;
} }
@ -3983,7 +3968,7 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path,
return 0; return 0;
if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1) if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1)
menu_navigation_set(menu, menu->mouse.ptr, false); menu_navigation_set(menu->mouse.ptr, false);
if (menu->mouse.left) if (menu->mouse.left)
{ {
@ -4466,10 +4451,10 @@ static int action_iterate_main(const char *label, unsigned action)
ret = cbs->action_up_or_down(type_offset, label_offset, action); ret = cbs->action_up_or_down(type_offset, label_offset, action);
break; break;
case MENU_ACTION_SCROLL_UP: case MENU_ACTION_SCROLL_UP:
menu_navigation_descend_alphabet(menu, &menu->selection_ptr); menu_navigation_descend_alphabet(&menu->selection_ptr);
break; break;
case MENU_ACTION_SCROLL_DOWN: case MENU_ACTION_SCROLL_DOWN:
menu_navigation_ascend_alphabet(menu, &menu->selection_ptr); menu_navigation_ascend_alphabet(&menu->selection_ptr);
break; break;
case MENU_ACTION_CANCEL: case MENU_ACTION_CANCEL:

View File

@ -70,7 +70,7 @@ static void menu_input_search_callback(void *userdata, const char *str)
return; return;
if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx))
menu_navigation_set(menu, idx, true); menu_navigation_set(idx, true);
menu_input_key_end_line(menu); menu_input_key_end_line(menu);
} }

View File

@ -28,16 +28,19 @@
* *
* Ensure it doesn't overflow. * Ensure it doesn't overflow.
**/ **/
static void menu_entries_refresh(menu_handle_t *menu, file_list_t *list) static void menu_entries_refresh(file_list_t *list)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
if (!list) if (!list)
return; return;
if (menu->selection_ptr >= menu_list_get_size(menu->menu_list) if (menu->selection_ptr >= menu_list_get_size(menu->menu_list)
&& menu_list_get_size(menu->menu_list)) && menu_list_get_size(menu->menu_list))
menu_navigation_set(menu, menu_list_get_size(menu->menu_list) - 1, true); menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
else if (!menu_list_get_size(menu->menu_list)) else if (!menu_list_get_size(menu->menu_list))
menu_navigation_clear(menu, true); menu_navigation_clear(true);
} }
/** /**
@ -94,15 +97,16 @@ static void menu_entries_build_scroll_indices(file_list_t *list)
size_t i; size_t i;
int current; int current;
bool current_is_dir; bool current_is_dir;
menu_handle_t *menu = menu_driver_resolve();
if (!driver.menu || !list) if (!menu || !list)
return; return;
driver.menu->scroll.indices.size = 0; menu->scroll.indices.size = 0;
if (!list->size) if (!list->size)
return; return;
driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = 0; menu->scroll.indices.list[menu->scroll.indices.size++] = 0;
current = menu_entries_list_get_first_char(list, 0); current = menu_entries_list_get_first_char(list, 0);
current_is_dir = menu_entries_list_elem_is_dir(list, 0); current_is_dir = menu_entries_list_elem_is_dir(list, 0);
@ -113,13 +117,13 @@ static void menu_entries_build_scroll_indices(file_list_t *list)
bool is_dir = menu_entries_list_elem_is_dir(list, i); bool is_dir = menu_entries_list_elem_is_dir(list, i);
if ((current_is_dir && !is_dir) || (first > current)) if ((current_is_dir && !is_dir) || (first > current))
driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = i; menu->scroll.indices.list[menu->scroll.indices.size++] = i;
current = first; current = first;
current_is_dir = is_dir; current_is_dir = is_dir;
} }
driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = menu->scroll.indices.list[menu->scroll.indices.size++] =
list->size - 1; list->size - 1;
} }
@ -228,16 +232,16 @@ void menu_list_flush_stack(menu_list_t *list,
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
unsigned type = 0; unsigned type = 0;
menu_handle_t *menu = menu_driver_resolve();
if (!driver.menu || !list) if (!menu || !list)
return; return;
driver.menu->need_refresh = true; menu->need_refresh = true;
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
while (type != final_type) while (type != final_type)
{ {
menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); menu_list_pop(list->menu_stack, &menu->selection_ptr);
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
} }
} }
@ -248,23 +252,24 @@ void menu_list_flush_stack_by_needle(menu_list_t *list,
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
unsigned type = 0; unsigned type = 0;
menu_handle_t *menu = menu_driver_resolve();
if (!driver.menu || !list) if (!menu || !list)
return; return;
driver.menu->need_refresh = true; menu->need_refresh = true;
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
while (strcmp(needle, label) != 0) while (strcmp(needle, label) != 0)
{ {
menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); menu_list_pop(list->menu_stack, &menu->selection_ptr);
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
} }
} }
void menu_list_pop_stack(menu_list_t *list) void menu_list_pop_stack(menu_list_t *list)
{ {
if (!list) menu_handle_t *menu = menu_driver_resolve();
if (!menu || !list)
return; return;
if (file_list_get_size(list->menu_stack) <= 1) if (file_list_get_size(list->menu_stack) <= 1)
@ -273,8 +278,8 @@ void menu_list_pop_stack(menu_list_t *list)
if (driver.menu_ctx->list_cache) if (driver.menu_ctx->list_cache)
driver.menu_ctx->list_cache(false, 0); driver.menu_ctx->list_cache(false, 0);
menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); menu_list_pop(list->menu_stack, &menu->selection_ptr);
driver.menu->need_refresh = true; menu->need_refresh = true;
} }
void menu_list_pop_stack_by_needle(menu_list_t *list, void menu_list_pop_stack_by_needle(menu_list_t *list,
@ -283,16 +288,17 @@ void menu_list_pop_stack_by_needle(menu_list_t *list,
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
unsigned type = 0; unsigned type = 0;
menu_handle_t *menu = menu_driver_resolve();
if (!driver.menu || !list) if (!menu || !list)
return; return;
driver.menu->need_refresh = true; menu->need_refresh = true;
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
while (strcmp(needle, label) == 0) while (strcmp(needle, label) == 0)
{ {
menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); menu_list_pop(list->menu_stack, &menu->selection_ptr);
file_list_get_last(list->menu_stack, &path, &label, &type); file_list_get_last(list->menu_stack, &path, &label, &type);
} }
} }
@ -363,26 +369,28 @@ void menu_list_push_refresh(file_list_t *list,
const char *path, const char *label, const char *path, const char *label,
unsigned type, size_t directory_ptr) unsigned type, size_t directory_ptr)
{ {
if (!list) menu_handle_t *menu = menu_driver_resolve();
if (!menu || !list)
return; return;
menu_list_push(list, path, label, type, directory_ptr); menu_list_push(list, path, label, type, directory_ptr);
menu_navigation_clear(driver.menu, true); menu_navigation_clear(true);
driver.menu->need_refresh = true; menu->need_refresh = true;
} }
void menu_list_push_stack(menu_list_t *list, void menu_list_push_stack(menu_list_t *list, const char *path, const char *label,
const char *path, const char *label,
unsigned type, size_t directory_ptr) unsigned type, size_t directory_ptr)
{ {
if (list) if (list)
menu_list_push(list->menu_stack, path, label, type, directory_ptr); menu_list_push(list->menu_stack, path, label, type, directory_ptr);
} }
int menu_list_push_stack_refresh(menu_list_t *list, int menu_list_push_stack_refresh(menu_list_t *list, const char *path, const char *label,
const char *path, const char *label,
unsigned type, size_t directory_ptr) unsigned type, size_t directory_ptr)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return -1;
if (!list) if (!list)
return -1; return -1;
@ -390,8 +398,8 @@ int menu_list_push_stack_refresh(menu_list_t *list,
driver.menu_ctx->list_cache(false, 0); driver.menu_ctx->list_cache(false, 0);
menu_list_push_stack(list, path, label, type, directory_ptr); menu_list_push_stack(list, path, label, type, directory_ptr);
menu_navigation_clear(driver.menu, true); menu_navigation_clear(true);
driver.menu->need_refresh = true; menu->need_refresh = true;
return 0; return 0;
} }
@ -413,18 +421,18 @@ void menu_list_sort_on_alt(file_list_t *list)
file_list_sort_on_alt(list); file_list_sort_on_alt(list);
} }
int menu_list_populate_generic(void *data, int menu_list_populate_generic(file_list_t *list, const char *path,
file_list_t *list, const char *path,
const char *label, unsigned type) const char *label, unsigned type)
{ {
menu_handle_t *menu = (menu_handle_t*)data; menu_handle_t *menu = menu_driver_resolve();
if (!menu) if (!menu)
return -1; return -1;
driver.menu->scroll.indices.size = 0; menu->scroll.indices.size = 0;
menu_entries_build_scroll_indices(list); menu_entries_build_scroll_indices(list);
menu_entries_refresh(menu, list); menu_entries_refresh(list);
if (driver.menu_ctx && driver.menu_ctx->populate_entries) if (driver.menu_ctx && driver.menu_ctx->populate_entries)
driver.menu_ctx->populate_entries(path, label, type); driver.menu_ctx->populate_entries(path, label, type);

View File

@ -94,7 +94,7 @@ void menu_list_get_alt_at_offset(const file_list_t *list, size_t idx,
void menu_list_set_alt_at_offset(file_list_t *list, size_t idx, void menu_list_set_alt_at_offset(file_list_t *list, size_t idx,
const char *alt); const char *alt);
int menu_list_populate_generic(void *data, file_list_t *list, int menu_list_populate_generic(file_list_t *list,
const char *path, const char *label, unsigned type); const char *path, const char *label, unsigned type);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -24,13 +24,16 @@
/** /**
* menu_navigation_clear: * menu_navigation_clear:
* @menu : menu handle
* @pending_push : pending push ? * @pending_push : pending push ?
* *
* Clears the navigation pointer. * Clears the navigation pointer.
**/ **/
void menu_navigation_clear(menu_handle_t *menu, bool pending_push) void menu_navigation_clear(bool pending_push)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu->selection_ptr = 0; menu->selection_ptr = 0;
if (driver.menu_ctx && driver.menu_ctx->navigation_clear) if (driver.menu_ctx && driver.menu_ctx->navigation_clear)
@ -39,12 +42,15 @@ void menu_navigation_clear(menu_handle_t *menu, bool pending_push)
/** /**
* menu_navigation_decrement: * menu_navigation_decrement:
* @menu : menu handle
* *
* Decrement the navigation pointer. * Decrement the navigation pointer.
**/ **/
void menu_navigation_decrement(menu_handle_t *menu) void menu_navigation_decrement(void)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu->selection_ptr--; menu->selection_ptr--;
if (driver.menu_ctx && driver.menu_ctx->navigation_decrement) if (driver.menu_ctx && driver.menu_ctx->navigation_decrement)
@ -53,12 +59,15 @@ void menu_navigation_decrement(menu_handle_t *menu)
/** /**
* menu_navigation_increment: * menu_navigation_increment:
* @menu : menu handle
* *
* Increment the navigation pointer. * Increment the navigation pointer.
**/ **/
void menu_navigation_increment(menu_handle_t *menu) void menu_navigation_increment(void)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu->selection_ptr++; menu->selection_ptr++;
if (driver.menu_ctx && driver.menu_ctx->navigation_increment) if (driver.menu_ctx && driver.menu_ctx->navigation_increment)
@ -67,14 +76,17 @@ void menu_navigation_increment(menu_handle_t *menu)
/** /**
* menu_navigation_set: * menu_navigation_set:
* @menu : menu handle
* @idx : index to set navigation pointer to. * @idx : index to set navigation pointer to.
* @scroll : should we scroll when needed? * @scroll : should we scroll when needed?
* *
* Sets navigation pointer to index @idx. * Sets navigation pointer to index @idx.
**/ **/
void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll) void menu_navigation_set(size_t idx, bool scroll)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu->selection_ptr = idx; menu->selection_ptr = idx;
if (driver.menu_ctx && driver.menu_ctx->navigation_set) if (driver.menu_ctx && driver.menu_ctx->navigation_set)
@ -83,12 +95,15 @@ void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll)
/** /**
* menu_navigation_set_last: * menu_navigation_set_last:
* @menu : menu handle
* *
* Sets navigation pointer to last index. * Sets navigation pointer to last index.
**/ **/
void menu_navigation_set_last(menu_handle_t *menu) void menu_navigation_set_last(void)
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1; menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1;
if (driver.menu_ctx && driver.menu_ctx->navigation_set_last) if (driver.menu_ctx && driver.menu_ctx->navigation_set_last)
@ -97,7 +112,6 @@ void menu_navigation_set_last(menu_handle_t *menu)
/** /**
* menu_navigation_descend_alphabet: * menu_navigation_descend_alphabet:
* @menu : menu handle
* @ptr_out : Amount of indices to 'scroll' to get * @ptr_out : Amount of indices to 'scroll' to get
* to the next entry. * to the next entry.
* *
@ -106,10 +120,13 @@ void menu_navigation_set_last(menu_handle_t *menu)
* If navigation points to an entry called 'Beta', * If navigation points to an entry called 'Beta',
* navigation pointer will be set to an entry called 'Alpha'. * navigation pointer will be set to an entry called 'Alpha'.
**/ **/
void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) void menu_navigation_descend_alphabet(size_t *ptr_out)
{ {
size_t i = 0; size_t i = 0;
size_t ptr = *ptr_out; size_t ptr = *ptr_out;
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
if (!menu->scroll.indices.size) if (!menu->scroll.indices.size)
return; return;
@ -129,7 +146,6 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out)
/** /**
* menu_navigation_ascends_alphabet: * menu_navigation_ascends_alphabet:
* @menu : menu handle
* @ptr_out : Amount of indices to 'scroll' to get * @ptr_out : Amount of indices to 'scroll' to get
* to the next entry. * to the next entry.
* *
@ -138,10 +154,13 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out)
* If navigation points to an entry called 'Alpha', * If navigation points to an entry called 'Alpha',
* navigation pointer will be set to an entry called 'Beta'. * navigation pointer will be set to an entry called 'Beta'.
**/ **/
void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) void menu_navigation_ascend_alphabet(size_t *ptr_out)
{ {
size_t i = 0; size_t i = 0;
size_t ptr = *ptr_out; size_t ptr = *ptr_out;
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
if (!menu->scroll.indices.size) if (!menu->scroll.indices.size)
return; return;

View File

@ -25,50 +25,44 @@ extern "C" {
/** /**
* menu_navigation_clear: * menu_navigation_clear:
* @menu : menu handle
* @pending_push : pending push ? * @pending_push : pending push ?
* *
* Clears the navigation pointer. * Clears the navigation pointer.
**/ **/
void menu_navigation_clear(menu_handle_t *menu, bool pending_push); void menu_navigation_clear(bool pending_push);
/** /**
* menu_navigation_decrement: * menu_navigation_decrement:
* @menu : menu handle
* *
* Decrement the navigation pointer. * Decrement the navigation pointer.
**/ **/
void menu_navigation_decrement(menu_handle_t *menu); void menu_navigation_decrement(void);
/** /**
* menu_navigation_increment: * menu_navigation_increment:
* @menu : menu handle
* *
* Increment the navigation pointer. * Increment the navigation pointer.
**/ **/
void menu_navigation_increment(menu_handle_t *menu); void menu_navigation_increment(void);
/** /**
* menu_navigation_set: * menu_navigation_set:
* @menu : menu handle
* @idx : index to set navigation pointer to. * @idx : index to set navigation pointer to.
* @scroll : should we scroll when needed? * @scroll : should we scroll when needed?
* *
* Sets navigation pointer to index @idx. * Sets navigation pointer to index @idx.
**/ **/
void menu_navigation_set(menu_handle_t *menu, size_t i, bool scroll); void menu_navigation_set(size_t i, bool scroll);
/** /**
* menu_navigation_set_last: * menu_navigation_set_last:
* @menu : menu handle
* *
* Sets navigation pointer to last index. * Sets navigation pointer to last index.
**/ **/
void menu_navigation_set_last(menu_handle_t *menu); void menu_navigation_set_last(void);
/** /**
* menu_navigation_descend_alphabet: * menu_navigation_descend_alphabet:
* @menu : menu handle
* @ptr_out : Amount of indices to 'scroll' to get * @ptr_out : Amount of indices to 'scroll' to get
* to the next entry. * to the next entry.
* *
@ -77,11 +71,10 @@ void menu_navigation_set_last(menu_handle_t *menu);
* If navigation points to an entry called 'Beta', * If navigation points to an entry called 'Beta',
* navigation pointer will be set to an entry called 'Alpha'. * navigation pointer will be set to an entry called 'Alpha'.
**/ **/
void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out); void menu_navigation_descend_alphabet(size_t *ptr_out);
/** /**
* menu_navigation_ascends_alphabet: * menu_navigation_ascends_alphabet:
* @menu : menu handle
* @ptr_out : Amount of indices to 'scroll' to get * @ptr_out : Amount of indices to 'scroll' to get
* to the next entry. * to the next entry.
* *
@ -90,7 +83,7 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out);
* If navigation points to an entry called 'Alpha', * If navigation points to an entry called 'Alpha',
* navigation pointer will be set to an entry called 'Beta'. * navigation pointer will be set to an entry called 'Beta'.
**/ **/
void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out); void menu_navigation_ascend_alphabet(size_t *ptr_out);
#ifdef __cplusplus #ifdef __cplusplus
} }