Create menu_entries_get_size

This commit is contained in:
twinaphex 2015-10-17 19:21:18 +02:00
parent d3a7742b6f
commit 6e2e32970e
9 changed files with 21 additions and 27 deletions

View File

@ -27,15 +27,12 @@ static int action_bind_down_generic(unsigned type, const char *label)
{ {
size_t scroll_accel = 0; size_t scroll_accel = 0;
unsigned scroll_speed = 0; unsigned scroll_speed = 0;
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return -1; return -1;
scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1;
if (menu_list_get_size(menu_list) <= 0) if (menu_entries_get_size() <= 0)
return 0; return 0;
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &scroll_speed); menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &scroll_speed);

View File

@ -126,9 +126,6 @@ static int action_right_scroll(unsigned type, const char *label,
size_t selection; size_t selection;
size_t scroll_accel = 0; size_t scroll_accel = 0;
unsigned scroll_speed = 0, fast_scroll_speed = 0; unsigned scroll_speed = 0, fast_scroll_speed = 0;
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false; return false;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
@ -137,7 +134,7 @@ static int action_right_scroll(unsigned type, const char *label,
scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1;
fast_scroll_speed = 4 + 4 * scroll_speed; fast_scroll_speed = 4 + 4 * scroll_speed;
if (selection + fast_scroll_speed < (menu_list_get_size(menu_list))) if (selection + fast_scroll_speed < (menu_entries_get_size()))
{ {
size_t idx = selection + fast_scroll_speed; size_t idx = selection + fast_scroll_speed;
bool scroll = true; bool scroll = true;
@ -146,7 +143,7 @@ static int action_right_scroll(unsigned type, const char *label,
} }
else else
{ {
if ((menu_list_get_size(menu_list) > 0)) if ((menu_entries_get_size() > 0))
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL);
} }

View File

@ -27,15 +27,12 @@ static int action_bind_up_generic(unsigned type, const char *label)
{ {
size_t scroll_accel = 0; size_t scroll_accel = 0;
unsigned scroll_speed = 0; unsigned scroll_speed = 0;
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return -1; return -1;
scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1;
if (menu_list_get_size(menu_list) <= 0) if (menu_entries_get_size() <= 0)
return 0; return 0;
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, &scroll_speed); menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, &scroll_speed);

View File

@ -212,13 +212,12 @@ int generic_menu_iterate(enum menu_action action)
uint32_t label_hash = 0; uint32_t label_hash = 0;
uint32_t hash = 0; uint32_t hash = 0;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
menu_entries_get_last_stack(NULL, &label, NULL, NULL); menu_entries_get_last_stack(NULL, &label, NULL, NULL);
if (!menu || !menu_list) if (!menu)
return 0; return 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0; return 0;
@ -275,7 +274,7 @@ int generic_menu_iterate(enum menu_action action)
* *
* We need to fix this entire mess, mouse controls should not rely on a * We need to fix this entire mess, mouse controls should not rely on a
* hack like this in order to work. */ * hack like this in order to work. */
selection = max(min(selection, menu_list_get_size(menu_list)-1), 0); selection = max(min(selection, (menu_entries_get_size() - 1)), 0);
menu_entry_get(&entry, selection, NULL, false); menu_entry_get(&entry, selection, NULL, false);
ret = menu_entry_action(&entry, selection, (enum menu_action)action); ret = menu_entry_action(&entry, selection, (enum menu_action)action);

View File

@ -1403,7 +1403,6 @@ static void xmb_render(void)
xmb_handle_t *xmb = NULL; xmb_handle_t *xmb = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu) if (!menu)
return; return;
@ -1422,7 +1421,7 @@ static void xmb_render(void)
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return; return;
end = menu_list_get_size(menu_list); end = menu_entries_get_size();
if (settings->menu.pointer.enable || settings->menu.mouse.enable) if (settings->menu.pointer.enable || settings->menu.mouse.enable)
{ {

View File

@ -78,8 +78,7 @@ size_t menu_entries_get_start(void)
/* Returns the last index (+1) of the menu entry list. */ /* Returns the last index (+1) of the menu entry list. */
size_t menu_entries_get_end(void) size_t menu_entries_get_end(void)
{ {
menu_entries_t *entries = menu_entries_get_ptr(); return menu_entries_get_size();
return menu_list_get_size(entries->menu_list);
} }
/* Get an entry from the top of the menu stack */ /* Get an entry from the top of the menu stack */
@ -324,3 +323,11 @@ size_t menu_entries_get_stack_size(void)
return 0; return 0;
return menu_list_get_stack_size(menu_list); return menu_list_get_stack_size(menu_list);
} }
size_t menu_entries_get_size(void)
{
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return 0;
return menu_list_get_size(menu_list);
}

View File

@ -143,6 +143,8 @@ void menu_entries_flush_stack(const char *needle, unsigned final_type);
size_t menu_entries_get_stack_size(void); size_t menu_entries_get_stack_size(void);
size_t menu_entries_get_size(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -942,7 +942,6 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
unsigned header_height; unsigned header_height;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
*input_mouse = MOUSE_ACTION_NONE; *input_mouse = MOUSE_ACTION_NONE;
@ -981,7 +980,7 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
{ {
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE); BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE);
} }
else if (menu_input->mouse.ptr <= menu_list_get_size(menu_list)-1) else if (menu_input->mouse.ptr <= (menu_entries_get_size() - 1))
{ {
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION); BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION);
} }
@ -1080,7 +1079,6 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
unsigned header_height; unsigned header_height;
size_t selection; size_t selection;
int ret = 0; int ret = 0;
menu_list_t *menu_list = menu_list_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -1142,7 +1140,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
menu_entries_pop_stack(&selection); menu_entries_pop_stack(&selection);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
} }
else if (menu_input->pointer.ptr <= menu_list_get_size(menu_list)-1) else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
{ {
menu_input->pointer.oldpressed[0] = false; menu_input->pointer.oldpressed[0] = false;
ret = pointer_tap(cbs, entry, action); ret = pointer_tap(cbs, entry, action);

View File

@ -58,11 +58,9 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr(); size_t menu_list_size = menu_entries_get_size();
size_t menu_list_size = menu_list_get_size(menu_list);
size_t selection = nav->selection_ptr; size_t selection = nav->selection_ptr;
(void)menu_list;
(void)settings; (void)settings;
switch (state) switch (state)