(Ozone) Remember selection per main tabs (#14526)

This commit is contained in:
sonninnos 2022-10-17 17:04:54 +03:00 committed by GitHub
parent 840c4481ab
commit 0cebebbfdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,6 +114,7 @@
#endif
#define OZONE_WIGGLE_DURATION 15
#define OZONE_TAB_MAX_LENGTH 255
/* Returns true if specified entry is currently
* displayed on screen */
@ -455,6 +456,7 @@ struct ozone_handle
size_t categories_selection_ptr; /* active tab id */
size_t categories_active_idx_old;
size_t playlist_index;
size_t tab_selection[OZONE_TAB_MAX_LENGTH];
size_t selection; /* currently selected entry */
size_t selection_old; /* previously selected entry (for fancy animation) */
@ -3770,6 +3772,9 @@ static void ozone_go_to_sidebar(ozone_handle_t *ozone,
ozone->cursor_in_sidebar_old = ozone->cursor_in_sidebar;
ozone->cursor_in_sidebar = true;
/* Remember last selection per tab */
ozone->tab_selection[ozone->categories_selection_ptr] = ozone->selection;
/* Cursor animation */
ozone->animations.cursor_alpha = 0.0f;
@ -4007,6 +4012,22 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
}
}
static void ozone_navigation_pointer_changed(void *data);
static void ozone_tab_set_selection(void *data)
{
ozone_handle_t *ozone = (ozone_handle_t*)data;
if (ozone)
{
size_t tab_selection = ozone->tab_selection[ozone->categories_selection_ptr];
if (tab_selection)
{
menu_navigation_set_selection(tab_selection);
ozone_navigation_pointer_changed(ozone);
}
}
}
static void ozone_leave_sidebar(ozone_handle_t *ozone,
bool ozone_collapse_sidebar,
@ -4020,6 +4041,9 @@ static void ozone_leave_sidebar(ozone_handle_t *ozone,
ozone->cursor_in_sidebar_old = ozone->cursor_in_sidebar;
ozone->cursor_in_sidebar = false;
/* Restore last selection per tab */
ozone_tab_set_selection(ozone);
/* Cursor animation */
ozone->animations.cursor_alpha = 0.0f;
@ -7941,6 +7965,9 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->tabs[++ozone->system_tab_end] = OZONE_SYSTEM_TAB_CONTENTLESS_CORES;
#endif
for (i = 0; i < OZONE_TAB_MAX_LENGTH; i++)
ozone->tab_selection[i] = 0;
menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL);
gfx_display_set_width(width);