diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 5081f7c7bd..272d7b0581 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -63,12 +63,473 @@ static const char *OZONE_TAB_TEXTURES_FILES[OZONE_TAB_TEXTURE_LAST] = { "add" }; -/* Forward declaration */ -static void ozone_set_thumbnail_content(void *data, const char *s); +static void ozone_set_thumbnail_content(void *data, const char *s) +{ + ozone_handle_t *ozone = (ozone_handle_t*)data; + + if (!ozone) + return; + + if (ozone->is_playlist) + { + /* Playlist content */ + if (string_is_empty(s)) + { + size_t selection = menu_navigation_get_selection(); + size_t list_size = menu_entries_get_size(); + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + bool playlist_valid = false; + size_t playlist_index = selection; + + /* Get playlist index corresponding + * to the selected entry */ + if (list && + (selection < list_size) && + (list->list[selection].type == FILE_TYPE_RPL_ENTRY)) + { + playlist_valid = true; + playlist_index = list->list[selection].entry_idx; + } + + gfx_thumbnail_set_content_playlist(ozone->thumbnail_path_data, + playlist_valid ? playlist_get_cached() : NULL, playlist_index); + } + } + else if (ozone->is_db_manager_list) + { + /* Database list content */ + if (string_is_empty(s)) + { + menu_entry_t entry; + size_t selection = menu_navigation_get_selection(); + + menu_entry_init(&entry); + entry.label_enabled = false; + entry.rich_label_enabled = false; + entry.value_enabled = false; + entry.sublabel_enabled = false; + menu_entry_get(&entry, 0, selection, NULL, true); + + if (!string_is_empty(entry.path)) + gfx_thumbnail_set_content(ozone->thumbnail_path_data, entry.path); + } + } + else if (string_is_equal(s, "imageviewer")) + { + /* Filebrowser image updates */ + menu_entry_t entry; + size_t selection = menu_navigation_get_selection(); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(selection_buf, selection); + + if (node) + { + menu_entry_init(&entry); + entry.label_enabled = false; + entry.rich_label_enabled = false; + entry.value_enabled = false; + entry.sublabel_enabled = false; + menu_entry_get(&entry, 0, selection, NULL, true); + if (!string_is_empty(entry.path) && !string_is_empty(node->fullpath)) + gfx_thumbnail_set_content_image(ozone->thumbnail_path_data, node->fullpath, entry.path); + } + } + else if (!string_is_empty(s)) + { + /* Annoying leftovers... + * This is required to ensure that thumbnails are + * updated correctly when navigating deeply through + * the sublevels of database manager lists. + * Showing thumbnails on database entries is a + * pointless nuisance and a waste of CPU cycles, IMHO... */ + gfx_thumbnail_set_content(ozone->thumbnail_path_data, s); + } + + ozone_update_content_metadata(ozone); +} + +/* Returns true if specified category is currently + * displayed on screen */ +static bool INLINE ozone_category_onscreen( + ozone_handle_t *ozone, size_t idx) +{ + return (idx >= ozone->first_onscreen_category) && + (idx <= ozone->last_onscreen_category); +} + +/* If current category is on screen, returns its + * index. If current category is off screen, returns + * index of centremost on screen category. */ +static size_t ozone_get_onscreen_category_selection( + ozone_handle_t *ozone) +{ + /* Check whether selected category is already on screen */ + if (ozone_category_onscreen(ozone, ozone->categories_selection_ptr)) + return ozone->categories_selection_ptr; + + /* Return index of centremost category */ + return (ozone->first_onscreen_category >> 1) + + (ozone->last_onscreen_category >> 1); +} + +/* Returns true if specified entry is currently + * displayed on screen */ +static bool INLINE ozone_entry_onscreen( + ozone_handle_t *ozone, size_t idx) +{ + return (idx >= ozone->first_onscreen_entry) && + (idx <= ozone->last_onscreen_entry); +} + +/* If currently selected entry is off screen, + * moves selection to specified on screen target + * > Does nothing if currently selected item is + * already on screen */ +static void ozone_auto_select_onscreen_entry( + ozone_handle_t *ozone, + enum ozone_onscreen_entry_position_type target_entry) +{ + size_t selection = menu_navigation_get_selection(); + + /* Check whether selected item is already on screen */ + if (ozone_entry_onscreen(ozone, selection)) + return; + + /* Update selection index */ + switch (target_entry) + { + case OZONE_ONSCREEN_ENTRY_FIRST: + selection = ozone->first_onscreen_entry; + break; + case OZONE_ONSCREEN_ENTRY_LAST: + selection = ozone->last_onscreen_entry; + break; + case OZONE_ONSCREEN_ENTRY_CENTRE: + default: + selection = (ozone->first_onscreen_entry >> 1) + + (ozone->last_onscreen_entry >> 1); + break; + } + + /* Apply new selection */ + menu_navigation_set_selection(selection); +} + +static bool INLINE ozone_metadata_override_available(ozone_handle_t *ozone) +{ + /* Ugly construct... + * Content metadata display override may be + * toggled if the following are true: + * - We are viewing playlist thumbnails + * - This is *not* an image viewer playlist + * - Both right and left thumbnails are + * enabled/available + * Short circuiting means that in most cases + * only 'ozone->is_playlist' will be evaluated, + * so this isn't too much of a performance hog... */ + return ozone->is_playlist && + ozone->show_thumbnail_bar && + !ozone->selection_core_is_viewer && + (ozone->thumbnails.left.status != GFX_THUMBNAIL_STATUS_MISSING) && + gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_LEFT) && + (ozone->thumbnails.right.status != GFX_THUMBNAIL_STATUS_MISSING) && + gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_RIGHT); +} + + + +static enum menu_action ozone_parse_menu_entry_action( + ozone_handle_t *ozone, enum menu_action action) +{ + uintptr_t tag; + int new_selection; + enum menu_action new_action = action; + file_list_t *selection_buf = NULL; + unsigned horizontal_list_size = 0; + + /* If fullscreen thumbnail view is active, any + * valid menu action will disable it... */ + if (ozone->show_fullscreen_thumbnails) + { + if (action != MENU_ACTION_NOOP) + { + ozone_hide_fullscreen_thumbnails(ozone, true); + + /* ...and any action other than Select/OK + * is ignored + * > We allow pass-through of Select/OK since + * users may want to run content directly + * after viewing fullscreen thumbnails, + * and having to press RetroPad A or the Return + * key twice is navigationally confusing + * > Note that we can only do this for non-pointer + * input + * > Note that we don't do this when viewing a + * file list, since there is no quick menu + * in this case - i.e. content loads directly, + * and a sudden transition from fullscreen + * thumbnail to content is jarring... + * > We also don't do this when viewing a database + * manager list, because the menu transition + * detection becomes too cumbersome... */ + if (ozone->is_file_list || + ozone->is_db_manager_list || + ((action != MENU_ACTION_SELECT) && + (action != MENU_ACTION_OK))) + return MENU_ACTION_NOOP; + } + } + + if (ozone->horizontal_list) + horizontal_list_size = (unsigned)ozone->horizontal_list->size; + + ozone->messagebox_state = false || menu_input_dialog_get_display_kb(); + selection_buf = menu_entries_get_selection_buf_ptr(0); + tag = (uintptr_t)selection_buf; + + /* Scan user inputs */ + switch (action) + { + case MENU_ACTION_START: + ozone->cursor_mode = false; + /* If this is a menu with thumbnails and cursor + * is not in the sidebar, attempt to show + * fullscreen thumbnail view */ + if (ozone->fullscreen_thumbnails_available && + !ozone->cursor_in_sidebar) + { + ozone_show_fullscreen_thumbnails(ozone); + new_action = MENU_ACTION_NOOP; + } + break; + case MENU_ACTION_DOWN: + if (ozone->cursor_in_sidebar) + { + /* If cursor is active, ensure we target + * an on screen category */ + size_t selection = (ozone->cursor_mode) ? + ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr; + + new_selection = (int)(selection + 1); + + if (new_selection >= (int)(ozone->system_tab_end + horizontal_list_size + 1)) + new_selection = 0; + + ozone_sidebar_goto(ozone, new_selection); + + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + ozone->cursor_mode = false; + break; + } + + /* If pointer is active and current selection + * is off screen, auto select *centre* item */ + if (ozone->cursor_mode) + ozone_auto_select_onscreen_entry(ozone, + OZONE_ONSCREEN_ENTRY_CENTRE); + ozone->cursor_mode = false; + break; + case MENU_ACTION_UP: + if (ozone->cursor_in_sidebar) + { + /* If cursor is active, ensure we target + * an on screen category */ + size_t selection = (ozone->cursor_mode) ? + ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr; + + new_selection = (int)selection - 1; + + if (new_selection < 0) + new_selection = horizontal_list_size + ozone->system_tab_end; + + ozone_sidebar_goto(ozone, new_selection); + + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + ozone->cursor_mode = false; + break; + } + + /* If pointer is active and current selection + * is off screen, auto select *centre* item */ + if (ozone->cursor_mode) + ozone_auto_select_onscreen_entry(ozone, + OZONE_ONSCREEN_ENTRY_CENTRE); + ozone->cursor_mode = false; + break; + case MENU_ACTION_LEFT: + ozone->cursor_mode = false; + + if (ozone->cursor_in_sidebar) + { + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + break; + } + else if (ozone->depth > 1) + break; + + ozone_go_to_sidebar(ozone, tag); + + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + break; + case MENU_ACTION_RIGHT: + ozone->cursor_mode = false; + if (!ozone->cursor_in_sidebar) + { + if (ozone->depth == 1) + new_action = MENU_ACTION_NOOP; + break; + } + + ozone_leave_sidebar(ozone, tag); + + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL; + break; + case MENU_ACTION_OK: + ozone->cursor_mode = false; + if (ozone->cursor_in_sidebar) + { + ozone_leave_sidebar(ozone, tag); + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL; + break; + } + break; + case MENU_ACTION_CANCEL: + ozone->cursor_mode = false; + + /* If this is a playlist, handle 'backing out' + * of a search, if required */ + if (ozone->is_playlist) + { + struct string_list *menu_search_terms = menu_driver_search_get_terms(); + + if (menu_search_terms && + (menu_search_terms->size > 0)) + break; + } + + if (ozone->cursor_in_sidebar) + { + /* Go back to main menu tab */ + if (ozone->categories_selection_ptr != 0) + ozone_sidebar_goto(ozone, 0); + + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + break; + } + + if (menu_entries_get_stack_size(0) == 1) + { + ozone_go_to_sidebar(ozone, tag); + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + } + break; + + case MENU_ACTION_SCROLL_UP: + /* Descend alphabet (Z towards A) */ + + /* Ignore if cursor is in sidebar */ + if (ozone->cursor_in_sidebar) + { + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + break; + } + + /* If pointer is active and current selection + * is off screen, auto select *last* item */ + if (ozone->cursor_mode) + ozone_auto_select_onscreen_entry(ozone, + OZONE_ONSCREEN_ENTRY_LAST); + ozone->cursor_mode = false; + break; + case MENU_ACTION_SCROLL_DOWN: + /* Ascend alphabet (A towards Z) */ + + /* > Ignore if cursor is in sidebar */ + if (ozone->cursor_in_sidebar) + { + new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; + break; + } + + /* If pointer is active and current selection + * is off screen, auto select *first* item */ + if (ozone->cursor_mode) + ozone_auto_select_onscreen_entry(ozone, + OZONE_ONSCREEN_ENTRY_FIRST); + ozone->cursor_mode = false; + break; + + case MENU_ACTION_INFO: + /* If we currently viewing a playlist with + * dual thumbnails, toggle the content metadata + * override */ + if (ozone_metadata_override_available(ozone)) + { + ozone_toggle_metadata_override(ozone); + new_action = MENU_ACTION_NOOP; + } + /* ...and since the user is likely to trigger + * 'INFO' actions on invalid playlist entries, + * suppress this action entirely when viewing + * playlists under all other conditions + * > Playlists have no 'INFO' entries - the + * user is just greeted with a useless + * 'no information available' message + * > It is incredibly annoying to inadvertently + * trigger this message when you just want to + * toggle metadata... */ + else if (ozone->is_playlist && ozone->show_thumbnail_bar) + new_action = MENU_ACTION_NOOP; + + ozone->cursor_mode = false; + break; + + default: + /* In all other cases, pass through input + * menu action without intervention */ + break; + } + + return new_action; +} + + +/* Menu entry action callback */ static int ozone_menu_entry_action( void *userdata, menu_entry_t *entry, - size_t i, enum menu_action action); -static bool INLINE ozone_metadata_override_available(ozone_handle_t *ozone); + size_t i, enum menu_action action) +{ + ozone_handle_t *ozone = (ozone_handle_t*)userdata; + menu_entry_t *entry_ptr = entry; + size_t selection = i; + size_t new_selection; + menu_entry_t new_entry; + /* Process input action */ + enum menu_action new_action = ozone_parse_menu_entry_action(ozone, action); + + /* Check whether current selection has changed + * (due to automatic on screen entry selection...) */ + new_selection = menu_navigation_get_selection(); + + if (new_selection != selection) + { + /* Selection has changed - must update + * entry pointer */ + menu_entry_init(&new_entry); + new_entry.path_enabled = false; + new_entry.label_enabled = false; + new_entry.rich_label_enabled = false; + new_entry.value_enabled = false; + new_entry.sublabel_enabled = false; + menu_entry_get(&new_entry, 0, new_selection, NULL, true); + entry_ptr = &new_entry; + } + + /* Call standard generic_menu_entry_action() function */ + return generic_menu_entry_action(userdata, entry_ptr, + new_selection, new_action); +} + static void ozone_free_node(ozone_node_t *node) { @@ -1979,91 +2440,6 @@ static void ozone_draw_footer(ozone_handle_t *ozone, } } -static void ozone_set_thumbnail_content(void *data, const char *s) -{ - ozone_handle_t *ozone = (ozone_handle_t*)data; - - if (!ozone) - return; - - if (ozone->is_playlist) - { - /* Playlist content */ - if (string_is_empty(s)) - { - size_t selection = menu_navigation_get_selection(); - size_t list_size = menu_entries_get_size(); - file_list_t *list = menu_entries_get_selection_buf_ptr(0); - bool playlist_valid = false; - size_t playlist_index = selection; - - /* Get playlist index corresponding - * to the selected entry */ - if (list && - (selection < list_size) && - (list->list[selection].type == FILE_TYPE_RPL_ENTRY)) - { - playlist_valid = true; - playlist_index = list->list[selection].entry_idx; - } - - gfx_thumbnail_set_content_playlist(ozone->thumbnail_path_data, - playlist_valid ? playlist_get_cached() : NULL, playlist_index); - } - } - else if (ozone->is_db_manager_list) - { - /* Database list content */ - if (string_is_empty(s)) - { - menu_entry_t entry; - size_t selection = menu_navigation_get_selection(); - - menu_entry_init(&entry); - entry.label_enabled = false; - entry.rich_label_enabled = false; - entry.value_enabled = false; - entry.sublabel_enabled = false; - menu_entry_get(&entry, 0, selection, NULL, true); - - if (!string_is_empty(entry.path)) - gfx_thumbnail_set_content(ozone->thumbnail_path_data, entry.path); - } - } - else if (string_is_equal(s, "imageviewer")) - { - /* Filebrowser image updates */ - menu_entry_t entry; - size_t selection = menu_navigation_get_selection(); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(selection_buf, selection); - - if (node) - { - menu_entry_init(&entry); - entry.label_enabled = false; - entry.rich_label_enabled = false; - entry.value_enabled = false; - entry.sublabel_enabled = false; - menu_entry_get(&entry, 0, selection, NULL, true); - if (!string_is_empty(entry.path) && !string_is_empty(node->fullpath)) - gfx_thumbnail_set_content_image(ozone->thumbnail_path_data, node->fullpath, entry.path); - } - } - else if (!string_is_empty(s)) - { - /* Annoying leftovers... - * This is required to ensure that thumbnails are - * updated correctly when navigating deeply through - * the sublevels of database manager lists. - * Showing thumbnails on database entries is a - * pointless nuisance and a waste of CPU cycles, IMHO... */ - gfx_thumbnail_set_content(ozone->thumbnail_path_data, s); - } - - ozone_update_content_metadata(ozone); -} - static void ozone_set_thumbnail_system(void *data, char*s, size_t len) { ozone_handle_t *ozone = (ozone_handle_t*)data; @@ -3011,27 +3387,6 @@ static int ozone_list_bind_init(menu_file_list_cbs_t *cbs, return -1; } -static bool INLINE ozone_metadata_override_available(ozone_handle_t *ozone) -{ - /* Ugly construct... - * Content metadata display override may be - * toggled if the following are true: - * - We are viewing playlist thumbnails - * - This is *not* an image viewer playlist - * - Both right and left thumbnails are - * enabled/available - * Short circuiting means that in most cases - * only 'ozone->is_playlist' will be evaluated, - * so this isn't too much of a performance hog... */ - return ozone->is_playlist && - ozone->show_thumbnail_bar && - !ozone->selection_core_is_viewer && - (ozone->thumbnails.left.status != GFX_THUMBNAIL_STATUS_MISSING) && - gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_LEFT) && - (ozone->thumbnails.right.status != GFX_THUMBNAIL_STATUS_MISSING) && - gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_RIGHT); -} - static int ozone_pointer_up(void *userdata, unsigned x, unsigned y, unsigned ptr, enum menu_input_pointer_gesture gesture, @@ -3087,10 +3442,8 @@ static int ozone_pointer_up(void *userdata, if (ptr != selection) menu_navigation_set_selection(ptr); - /* If we are currently in the sidebar, leave it */ - if (ozone->cursor_in_sidebar) - ozone_leave_sidebar(ozone, sidebar_tag); - /* Otherwise perform a MENU_ACTION_SELECT on currently + /* If we are not currently in the sidebar, + * perform a MENU_ACTION_SELECT on currently * active item * > NOTE 1: Cannot perform a 'leave sidebar' operation * and a MENU_ACTION_SELECT at the same time... @@ -3099,8 +3452,12 @@ static int ozone_pointer_up(void *userdata, * registers any change due to the above automatic * 'pointer item' activation, and thus operates * on the correct target entry */ - else - return ozone_menu_entry_action(ozone, entry, selection, MENU_ACTION_SELECT); + if (!ozone->cursor_in_sidebar) + return ozone_menu_entry_action(ozone, entry, + selection, MENU_ACTION_SELECT); + + /* If we currently in the sidebar, leave it */ + ozone_leave_sidebar(ozone, sidebar_tag); } else { @@ -3194,364 +3551,6 @@ static int ozone_pointer_up(void *userdata, return 0; } -/* Returns true if specified entry is currently - * displayed on screen */ -static bool INLINE ozone_entry_onscreen( - ozone_handle_t *ozone, size_t idx) -{ - return (idx >= ozone->first_onscreen_entry) && - (idx <= ozone->last_onscreen_entry); -} - -/* If currently selected entry is off screen, - * moves selection to specified on screen target - * > Does nothing if currently selected item is - * already on screen */ -static void ozone_auto_select_onscreen_entry( - ozone_handle_t *ozone, - enum ozone_onscreen_entry_position_type target_entry) -{ - size_t selection = menu_navigation_get_selection(); - - /* Check whether selected item is already on screen */ - if (ozone_entry_onscreen(ozone, selection)) - return; - - /* Update selection index */ - switch (target_entry) - { - case OZONE_ONSCREEN_ENTRY_FIRST: - selection = ozone->first_onscreen_entry; - break; - case OZONE_ONSCREEN_ENTRY_LAST: - selection = ozone->last_onscreen_entry; - break; - case OZONE_ONSCREEN_ENTRY_CENTRE: - default: - selection = (ozone->first_onscreen_entry >> 1) + - (ozone->last_onscreen_entry >> 1); - break; - } - - /* Apply new selection */ - menu_navigation_set_selection(selection); -} - -/* Returns true if specified category is currently - * displayed on screen */ -static bool INLINE ozone_category_onscreen( - ozone_handle_t *ozone, size_t idx) -{ - return (idx >= ozone->first_onscreen_category) && - (idx <= ozone->last_onscreen_category); -} - -/* If current category is on screen, returns its - * index. If current category is off screen, returns - * index of centremost on screen category. */ -static size_t ozone_get_onscreen_category_selection( - ozone_handle_t *ozone) -{ - /* Check whether selected category is already on screen */ - if (ozone_category_onscreen(ozone, ozone->categories_selection_ptr)) - return ozone->categories_selection_ptr; - - /* Return index of centremost category */ - return (ozone->first_onscreen_category >> 1) + - (ozone->last_onscreen_category >> 1); -} - -static enum menu_action ozone_parse_menu_entry_action( - ozone_handle_t *ozone, enum menu_action action) -{ - uintptr_t tag; - int new_selection; - enum menu_action new_action = action; - file_list_t *selection_buf = NULL; - unsigned horizontal_list_size = 0; - - /* If fullscreen thumbnail view is active, any - * valid menu action will disable it... */ - if (ozone->show_fullscreen_thumbnails) - { - if (action != MENU_ACTION_NOOP) - { - ozone_hide_fullscreen_thumbnails(ozone, true); - - /* ...and any action other than Select/OK - * is ignored - * > We allow pass-through of Select/OK since - * users may want to run content directly - * after viewing fullscreen thumbnails, - * and having to press RetroPad A or the Return - * key twice is navigationally confusing - * > Note that we can only do this for non-pointer - * input - * > Note that we don't do this when viewing a - * file list, since there is no quick menu - * in this case - i.e. content loads directly, - * and a sudden transition from fullscreen - * thumbnail to content is jarring... - * > We also don't do this when viewing a database - * manager list, because the menu transition - * detection becomes too cumbersome... */ - if (ozone->is_file_list || - ozone->is_db_manager_list || - ((action != MENU_ACTION_SELECT) && - (action != MENU_ACTION_OK))) - return MENU_ACTION_NOOP; - } - } - - if (ozone->horizontal_list) - horizontal_list_size = (unsigned)ozone->horizontal_list->size; - - ozone->messagebox_state = false || menu_input_dialog_get_display_kb(); - selection_buf = menu_entries_get_selection_buf_ptr(0); - tag = (uintptr_t)selection_buf; - - /* Scan user inputs */ - switch (action) - { - case MENU_ACTION_START: - ozone->cursor_mode = false; - /* If this is a menu with thumbnails and cursor - * is not in the sidebar, attempt to show - * fullscreen thumbnail view */ - if (ozone->fullscreen_thumbnails_available && - !ozone->cursor_in_sidebar) - { - ozone_show_fullscreen_thumbnails(ozone); - new_action = MENU_ACTION_NOOP; - } - break; - case MENU_ACTION_DOWN: - if (ozone->cursor_in_sidebar) - { - /* If cursor is active, ensure we target - * an on screen category */ - size_t selection = (ozone->cursor_mode) ? - ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr; - - new_selection = (int)(selection + 1); - - if (new_selection >= (int)(ozone->system_tab_end + horizontal_list_size + 1)) - new_selection = 0; - - ozone_sidebar_goto(ozone, new_selection); - - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - ozone->cursor_mode = false; - break; - } - - /* If pointer is active and current selection - * is off screen, auto select *centre* item */ - if (ozone->cursor_mode) - ozone_auto_select_onscreen_entry(ozone, OZONE_ONSCREEN_ENTRY_CENTRE); - - ozone->cursor_mode = false; - break; - case MENU_ACTION_UP: - if (ozone->cursor_in_sidebar) - { - /* If cursor is active, ensure we target - * an on screen category */ - size_t selection = (ozone->cursor_mode) ? - ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr; - - new_selection = (int)selection - 1; - - if (new_selection < 0) - new_selection = horizontal_list_size + ozone->system_tab_end; - - ozone_sidebar_goto(ozone, new_selection); - - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - ozone->cursor_mode = false; - break; - } - - /* If pointer is active and current selection - * is off screen, auto select *centre* item */ - if (ozone->cursor_mode) - ozone_auto_select_onscreen_entry(ozone, OZONE_ONSCREEN_ENTRY_CENTRE); - - ozone->cursor_mode = false; - break; - case MENU_ACTION_LEFT: - ozone->cursor_mode = false; - - if (ozone->cursor_in_sidebar) - { - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - break; - } - else if (ozone->depth > 1) - break; - - ozone_go_to_sidebar(ozone, tag); - - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - break; - case MENU_ACTION_RIGHT: - ozone->cursor_mode = false; - if (!ozone->cursor_in_sidebar) - { - if (ozone->depth == 1) - new_action = MENU_ACTION_NOOP; - break; - } - - ozone_leave_sidebar(ozone, tag); - - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL; - break; - case MENU_ACTION_OK: - ozone->cursor_mode = false; - if (ozone->cursor_in_sidebar) - { - ozone_leave_sidebar(ozone, tag); - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL; - break; - } - break; - case MENU_ACTION_CANCEL: - ozone->cursor_mode = false; - - /* If this is a playlist, handle 'backing out' - * of a search, if required */ - if (ozone->is_playlist) - { - struct string_list *menu_search_terms = menu_driver_search_get_terms(); - - if (menu_search_terms && - (menu_search_terms->size > 0)) - break; - } - - if (ozone->cursor_in_sidebar) - { - /* Go back to main menu tab */ - if (ozone->categories_selection_ptr != 0) - ozone_sidebar_goto(ozone, 0); - - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - break; - } - - if (menu_entries_get_stack_size(0) == 1) - { - ozone_go_to_sidebar(ozone, tag); - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - } - break; - - case MENU_ACTION_SCROLL_UP: - /* Descend alphabet (Z towards A) */ - - /* Ignore if cursor is in sidebar */ - if (ozone->cursor_in_sidebar) - { - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - break; - } - - /* If pointer is active and current selection - * is off screen, auto select *last* item */ - if (ozone->cursor_mode) - ozone_auto_select_onscreen_entry(ozone, OZONE_ONSCREEN_ENTRY_LAST); - - ozone->cursor_mode = false; - break; - case MENU_ACTION_SCROLL_DOWN: - /* Ascend alphabet (A towards Z) */ - - /* > Ignore if cursor is in sidebar */ - if (ozone->cursor_in_sidebar) - { - new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE; - break; - } - - /* If pointer is active and current selection - * is off screen, auto select *first* item */ - if (ozone->cursor_mode) - ozone_auto_select_onscreen_entry(ozone, OZONE_ONSCREEN_ENTRY_FIRST); - - ozone->cursor_mode = false; - break; - - case MENU_ACTION_INFO: - /* If we currently viewing a playlist with - * dual thumbnails, toggle the content metadata - * override */ - if (ozone_metadata_override_available(ozone)) - { - ozone_toggle_metadata_override(ozone); - new_action = MENU_ACTION_NOOP; - } - /* ...and since the user is likely to trigger - * 'INFO' actions on invalid playlist entries, - * suppress this action entirely when viewing - * playlists under all other conditions - * > Playlists have no 'INFO' entries - the - * user is just greeted with a useless - * 'no information available' message - * > It is incredibly annoying to inadvertently - * trigger this message when you just want to - * toggle metadata... */ - else if (ozone->is_playlist && ozone->show_thumbnail_bar) - new_action = MENU_ACTION_NOOP; - - ozone->cursor_mode = false; - break; - - default: - /* In all other cases, pass through input - * menu action without intervention */ - break; - } - - return new_action; -} - -/* Menu entry action callback */ -static int ozone_menu_entry_action( - void *userdata, menu_entry_t *entry, - size_t i, enum menu_action action) -{ - ozone_handle_t *ozone = (ozone_handle_t*)userdata; - menu_entry_t *entry_ptr = entry; - size_t selection = i; - size_t new_selection; - menu_entry_t new_entry; - /* Process input action */ - enum menu_action new_action = ozone_parse_menu_entry_action(ozone, action); - - /* Check whether current selection has changed - * (due to automatic on screen entry selection...) */ - new_selection = menu_navigation_get_selection(); - - if (new_selection != selection) - { - /* Selection has changed - must update - * entry pointer */ - menu_entry_init(&new_entry); - new_entry.path_enabled = false; - new_entry.label_enabled = false; - new_entry.rich_label_enabled = false; - new_entry.value_enabled = false; - new_entry.sublabel_enabled = false; - menu_entry_get(&new_entry, 0, new_selection, NULL, true); - entry_ptr = &new_entry; - } - - /* Call standard generic_menu_entry_action() function */ - return generic_menu_entry_action(userdata, entry_ptr, - new_selection, new_action); -} - ozone_node_t *ozone_alloc_node(void) { ozone_node_t *node = (ozone_node_t*)malloc(sizeof(*node)); diff --git a/menu/drivers/ozone/ozone_theme.c b/menu/drivers/ozone/ozone_theme.c index 4c00a51155..c5ccb98e3f 100644 --- a/menu/drivers/ozone/ozone_theme.c +++ b/menu/drivers/ozone/ozone_theme.c @@ -280,15 +280,11 @@ ozone_theme_t *ozone_themes[] = { &ozone_theme_gruvbox_dark }; -/* TODO/FIXME - all of the public global variables below are - * referenced outside */ - +/* TODO/FIXME - global variables referenced outside */ unsigned ozone_themes_count = sizeof(ozone_themes) / sizeof(ozone_themes[0]); unsigned last_color_theme = 0; - bool last_use_preferred_system_color_theme = false; ozone_theme_t *ozone_default_theme = &ozone_theme_dark; /* also used as a tag for cursor animation */ - /* Enable runtime configuration of framebuffer * opacity */ float last_framebuffer_opacity = -1.0f; @@ -361,7 +357,8 @@ void ozone_set_background_running_opacity( if (!ozone || !ozone->theme->background_libretro_running) return; - background = ozone->theme->background_libretro_running; + background = + ozone->theme->background_libretro_running; /* When content is running, background is a * gradient that from top to bottom transitions @@ -370,8 +367,8 @@ void ozone_set_background_running_opacity( * is 0.900. At this setting: * - Background top has an alpha of 1.0 * - Background bottom has an alpha of 0.75 */ - background_running_alpha_top = framebuffer_opacity / 0.9f; - background_running_alpha_top = (background_running_alpha_top > 1.0f) ? + background_running_alpha_top = framebuffer_opacity / 0.9f; + background_running_alpha_top = (background_running_alpha_top > 1.0f) ? 1.0f : (background_running_alpha_top < 0.0f) ? 0.0f : background_running_alpha_top; @@ -380,10 +377,10 @@ void ozone_set_background_running_opacity( 1.0f : (background_running_alpha_bottom < 0.0f) ? 0.0f : background_running_alpha_bottom; - background[11] = background_running_alpha_top; - background[15] = background_running_alpha_top; - background[3] = background_running_alpha_bottom; - background[7] = background_running_alpha_bottom; + background[11] = background_running_alpha_top; + background[15] = background_running_alpha_top; + background[3] = background_running_alpha_bottom; + background[7] = background_running_alpha_bottom; - last_framebuffer_opacity = framebuffer_opacity; + last_framebuffer_opacity = framebuffer_opacity; }