Rewrite menu_list_get_size functions

This commit is contained in:
twinaphex 2014-10-18 02:32:59 +02:00
parent c465d25859
commit 73b070b782
8 changed files with 30 additions and 30 deletions

View File

@ -106,7 +106,7 @@ static int menu_action_ok(menu_file_list_cbs_t *cbs)
const char *path = NULL;
unsigned type = 0;
if (menu_list_get_size() == 0)
if (menu_list_get_size(driver.menu->menu_list) == 0)
return 0;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
@ -208,11 +208,11 @@ static int menu_settings_iterate(unsigned action,
menu_navigation_decrement(driver.menu);
else
menu_navigation_set(driver.menu,
menu_list_get_size() - 1);
menu_list_get_size(driver.menu->menu_list) - 1);
break;
case MENU_ACTION_DOWN:
if ((driver.menu->selection_ptr + 1) < (menu_list_get_size()))
if ((driver.menu->selection_ptr + 1) < (menu_list_get_size(driver.menu->menu_list)))
menu_navigation_increment(driver.menu);
else
menu_navigation_clear(driver.menu, false);
@ -490,7 +490,7 @@ static int menu_load_or_open_zip_iterate(unsigned action)
menu_list_get_last_stack(driver.menu->menu_list,
&menu_path, &menu_label, NULL);
if (menu_list_get_size() == 0)
if (menu_list_get_size(driver.menu->menu_list) == 0)
return 0;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
@ -596,11 +596,11 @@ static int menu_common_iterate(unsigned action)
driver.menu->selection_ptr - scroll_speed);
else
menu_navigation_set(driver.menu,
menu_list_get_size() - 1);
menu_list_get_size(driver.menu->menu_list) - 1);
break;
case MENU_ACTION_DOWN:
if (driver.menu->selection_ptr + scroll_speed < (menu_list_get_size()))
if (driver.menu->selection_ptr + scroll_speed < (menu_list_get_size(driver.menu->menu_list)))
menu_navigation_set(driver.menu,
driver.menu->selection_ptr + scroll_speed);
else
@ -616,7 +616,7 @@ static int menu_common_iterate(unsigned action)
break;
case MENU_ACTION_RIGHT:
if (driver.menu->selection_ptr + fast_scroll_speed < (menu_list_get_size()))
if (driver.menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(driver.menu->menu_list)))
menu_navigation_set(driver.menu,
driver.menu->selection_ptr + fast_scroll_speed);
else

View File

@ -241,12 +241,12 @@ static void glui_frame(void)
if (driver.menu->selection_ptr >= glui->term_height / 2)
begin = driver.menu->selection_ptr - glui->term_height / 2;
end = (driver.menu->selection_ptr + glui->term_height <=
menu_list_get_size()) ?
menu_list_get_size(driver.menu->menu_list)) ?
driver.menu->selection_ptr + glui->term_height :
menu_list_get_size();
menu_list_get_size(driver.menu->menu_list);
/* Do not scroll if all items are visible. */
if (menu_list_get_size() <= glui->term_height)
if (menu_list_get_size(driver.menu->menu_list) <= glui->term_height)
begin = 0;
if (end - begin > glui->term_height)

View File

@ -279,12 +279,12 @@ static void rgui_render(void)
if (driver.menu->selection_ptr >= RGUI_TERM_HEIGHT / 2)
begin = driver.menu->selection_ptr - RGUI_TERM_HEIGHT / 2;
end = (driver.menu->selection_ptr + RGUI_TERM_HEIGHT <=
menu_list_get_size()) ?
menu_list_get_size(driver.menu->menu_list)) ?
driver.menu->selection_ptr + RGUI_TERM_HEIGHT :
menu_list_get_size();
menu_list_get_size(driver.menu->menu_list);
/* Do not scroll if all items are visible. */
if (menu_list_get_size() <= RGUI_TERM_HEIGHT)
if (menu_list_get_size(driver.menu->menu_list) <= RGUI_TERM_HEIGHT)
begin = 0;
if (end - begin > RGUI_TERM_HEIGHT)

View File

@ -355,7 +355,7 @@ static void xmb_selection_pointer_changed(void)
return;
current = driver.menu->selection_ptr;
end = menu_list_get_size();
end = menu_list_get_size(driver.menu->menu_list);
for (i = 0; i < end; i++)
{
@ -394,7 +394,7 @@ static void xmb_populate_entries(void *data, const char *path,
if (!xmb)
return;
xmb->depth = menu_list_get_stack_size();
xmb->depth = menu_list_get_stack_size(driver.menu->menu_list);
if (xmb->depth > xmb->old_depth)
{
@ -407,7 +407,7 @@ static void xmb_populate_entries(void *data, const char *path,
current = driver.menu->selection_ptr;
end = menu_list_get_size();
end = menu_list_get_size(driver.menu->menu_list);
for (i = 0; i < end; i++)
{
@ -479,7 +479,7 @@ static void xmb_frame(void)
xmb_draw_text(title_msg, xmb->title_margin_left,
gl->win_height - xmb->title_margin_top/2, 1, 1);
end = menu_list_get_size();
end = menu_list_get_size(driver.menu->menu_list);
current = driver.menu->selection_ptr;
for (i = 0; i < end; i++)

View File

@ -31,10 +31,10 @@ void menu_entries_refresh(file_list_t *list)
* selection_ptr to suddendly be out of range.
* Ensure it doesn't overflow. */
if (driver.menu->selection_ptr >= menu_list_get_size()
&& menu_list_get_size())
menu_navigation_set(driver.menu, menu_list_get_size() - 1);
else if (!menu_list_get_size())
if (driver.menu->selection_ptr >= menu_list_get_size(driver.menu->menu_list)
&& menu_list_get_size(driver.menu->menu_list))
menu_navigation_set(driver.menu, menu_list_get_size(driver.menu->menu_list) - 1);
else if (!menu_list_get_size(driver.menu->menu_list))
menu_navigation_clear(driver.menu, true);
}

View File

@ -67,11 +67,11 @@ void *menu_list_new(void)
return list;
}
size_t menu_list_get_stack_size(void)
size_t menu_list_get_stack_size(menu_list_t *list)
{
if (!driver.menu)
if (!list)
return 0;
return file_list_get_size(driver.menu->menu_list->menu_stack);
return file_list_get_size(list->menu_stack);
}
void menu_list_get_at_offset(const file_list_t *list, size_t index,
@ -80,11 +80,11 @@ void menu_list_get_at_offset(const file_list_t *list, size_t index,
file_list_get_at_offset(list, index, path, label, file_type);
}
size_t menu_list_get_size(void)
size_t menu_list_get_size(menu_list_t *list)
{
if (!driver.menu)
if (!list)
return 0;
return file_list_get_size(driver.menu->menu_list->selection_buf);
return file_list_get_size(list->selection_buf);
}
void menu_list_get_last(const file_list_t *list,

View File

@ -53,11 +53,11 @@ void menu_list_get_at_offset(const file_list_t *list, size_t index,
void *menu_list_get_actiondata_at_offset(const file_list_t *list, size_t index);
size_t menu_list_get_stack_size(void);
size_t menu_list_get_stack_size(menu_list_t *list);
void menu_list_sort_on_alt(file_list_t *list);
size_t menu_list_get_size(void);
size_t menu_list_get_size(menu_list_t *list);
void *menu_list_get_last_stack_actiondata(const menu_list_t *list);

View File

@ -58,7 +58,7 @@ void menu_navigation_set(menu_handle_t *menu, size_t i)
void menu_navigation_set_last(menu_handle_t *menu)
{
menu->selection_ptr = menu_list_get_size() - 1;
menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1;
if (driver.menu_ctx && driver.menu_ctx->navigation_set_last)
driver.menu_ctx->navigation_set_last(menu);