diff --git a/menu/menu_entries_cbs_toggle.c b/menu/menu_entries_cbs_toggle.c index e56ba7016a..d6b12e4481 100644 --- a/menu/menu_entries_cbs_toggle.c +++ b/menu/menu_entries_cbs_toggle.c @@ -159,34 +159,29 @@ static int action_toggle_scroll(unsigned type, const char *label, unsigned action, bool wraparound) { unsigned scroll_speed = 0, fast_scroll_speed = 0; - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) + menu_list_t *menu_list = menu_list_get_ptr(); + menu_navigation_t *nav = menu_navigation_get_ptr(); + if (!nav || !menu_list) return -1; - scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1; + scroll_speed = (max(nav->scroll.acceleration, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; switch (action) { case MENU_ACTION_LEFT: - if (menu->navigation.selection_ptr > fast_scroll_speed) - menu_navigation_set(&menu->navigation, - menu->navigation.selection_ptr - fast_scroll_speed, true); + if (nav->selection_ptr > fast_scroll_speed) + menu_navigation_set(nav, nav->selection_ptr - fast_scroll_speed, true); else - menu_navigation_clear(&menu->navigation, false); + menu_navigation_clear(nav, false); break; case MENU_ACTION_RIGHT: - if (menu->navigation.selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) - { - menu_navigation_set(&menu->navigation, - menu->navigation.selection_ptr + fast_scroll_speed, true); - } + if (nav->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu_list))) + menu_navigation_set(nav, nav->selection_ptr + fast_scroll_speed, true); else { - if ((menu_list_get_size(menu->menu_list) > 0)) - { - menu_navigation_set_last(&menu->navigation); - } + if ((menu_list_get_size(menu_list) > 0)) + menu_navigation_set_last(nav); } break; } diff --git a/menu/menu_list.c b/menu/menu_list.c index 7ca660c147..e48342b9d9 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -22,8 +22,7 @@ #include #include - -static menu_list_t *menu_list_get_ptr(void) +menu_list_t *menu_list_get_ptr(void) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) diff --git a/menu/menu_list.h b/menu/menu_list.h index c83c348d85..f92005f26f 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -40,6 +40,8 @@ typedef struct menu_entry unsigned spacing; } menu_entry_t; +menu_list_t *menu_list_get_ptr(void); + void menu_list_free(menu_list_t *menu_list); menu_list_t *menu_list_new(void);