From 1614519874dc697fef1daf69acd380641775f83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 09:55:16 +0700 Subject: [PATCH 01/78] Clone xmb to stripe menu --- .vscode/c_cpp_properties.json | 251 +- Makefile.common | 11 + configuration.c | 5 + file_path_special.c | 4 + griffin/griffin.c | 4 + menu/drivers/stripes.c | 5205 +++++++++++++++++ menu/menu_driver.c | 3 + menu/menu_driver.h | 1 + pkg/apple/RetroArch.xcodeproj/project.pbxproj | 4 +- qb/config.libs.sh | 2 + qb/config.params.sh | 1 + 11 files changed, 5365 insertions(+), 126 deletions(-) create mode 100755 menu/drivers/stripes.c diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 81c2529184..c6f4ffd0eb 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,125 +1,128 @@ -{ - "configurations": [ - { - "name": "Mac", - "includePath": [ - "/usr/include", - "/usr/local/include", - "${workspaceRoot}" - ], - "defines": [], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ - "/usr/include", - "/usr/local/include", - "${workspaceRoot}" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - }, - "macFrameworkPath": [ - "/System/Library/Frameworks", - "/Library/Frameworks" - ] - }, - { - "name": "Linux", - "includePath": [ - "/usr/include", - "/usr/local/include", - "${workspaceRoot}" - ], - "defines": [], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ - "/usr/include", - "/usr/local/include", - "${workspaceRoot}" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - } - }, - { - "name": "Win32", - "includePath": [ - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", - "${workspaceRoot}" - ], - "defines": [ - "_DEBUG", - "UNICODE" - ], - "intelliSenseMode": "msvc-x64", - "browse": { - "path": [ - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", - "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", - "${workspaceRoot}" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - } - }, - { - "name": "msys2-mingw32", - "includePath": [ - "C:/msys64/mingw32/include", - "C:/msys64/mingw32/i686-w64-mingw32/include", - "${workspaceRoot}/libretro-common/include", - "${workspaceRoot}/include", - "${workspaceRoot}" - ], - "defines": [ - "_DEBUG", - "UNICODE" - ], - "intelliSenseMode": "msvc-x64", - "browse": { - "path": [ - "C:/msys64/mingw32/include", - "C:/msys64/mingw32/i686-w64-mingw32/include", - "${workspaceRoot}/libretro-common/include", - "${workspaceRoot}/include", - "${workspaceRoot}" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - } - }, - { - "name": "msys2-mingw64", - "includePath": [ - "C:/msys64/mingw64/include", - "C:/msys64/mingw64/x86_64-w64-mingw32/include", - "${workspaceRoot}/libretro-common/include", - "${workspaceRoot}/include", - "${workspaceRoot}" - ], - "defines": [ - "_DEBUG", - "UNICODE" - ], - "intelliSenseMode": "msvc-x64", - "browse": { - "path": [ - "C:/msys64/mingw64/include", - "C:/msys64/mingw64/x86_64-w64-mingw32/include", - "${workspaceRoot}/libretro-common/include", - "${workspaceRoot}/include", - "${workspaceRoot}" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - } - } - ], - "version": 3 +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c11", + "cppStandard": "c++17" + }, + { + "name": "Linux", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "Win32", + "includePath": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw32", + "includePath": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw64", + "includePath": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 3 } \ No newline at end of file diff --git a/Makefile.common b/Makefile.common index 972d61e34e..7163289e68 100644 --- a/Makefile.common +++ b/Makefile.common @@ -724,11 +724,16 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1) ifeq ($(HAVE_XMB),) HAVE_XMB = 1 endif + + ifeq ($(HAVE_STRIPES),) + HAVE_STRIPES = 1 + endif else HAVE_ZARCH ?= 0 HAVE_MATERIALUI ?= 0 #HAVE_NUKLEAR ?= 0 HAVE_XMB ?= 0 + HAVE_STRIPES ?= 0 endif ifeq ($(HAVE_RGUI), 1) @@ -760,6 +765,12 @@ ifeq ($(HAVE_XMB), 1) HAVE_MENU_COMMON = 1 endif +ifeq ($(HAVE_STRIPES), 1) + OBJ += menu/drivers/stripes.o + DEFINES += -DHAVE_STRIPES + HAVE_MENU_COMMON = 1 +endif + ifeq ($(HAVE_LAKKA), 1) DEFINES += -DHAVE_LAKKA endif diff --git a/configuration.c b/configuration.c index 9f0eed8a04..f3a2f5b6f3 100644 --- a/configuration.c +++ b/configuration.c @@ -271,6 +271,7 @@ enum menu_driver_enum MENU_XUI, MENU_MATERIALUI, MENU_XMB, + MENU_STRIPES, MENU_NUKLEAR, MENU_NULL }; @@ -502,6 +503,8 @@ static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_NULL; static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XUI; #elif defined(HAVE_MATERIALUI) && defined(RARCH_MOBILE) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_MATERIALUI; +#elif defined(HAVE_STRIPES) && !defined(_XBOX) +static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB; #elif defined(HAVE_XMB) && !defined(_XBOX) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB; #elif defined(HAVE_RGUI) @@ -995,6 +998,8 @@ const char *config_get_default_menu(void) return "glui"; case MENU_XMB: return "xmb"; + case MENU_STRIPES: + return "stripes"; case MENU_NUKLEAR: return "nuklear"; case MENU_NULL: diff --git a/file_path_special.c b/file_path_special.c index e58d10032f..2f1a002567 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -130,6 +130,10 @@ bool fill_pathname_application_data(char *s, size_t len) const char* xmb_theme_ident(void); #endif +#ifdef HAVE_STRIPES +const char* stripes_theme_ident(void); +#endif + void fill_pathname_application_special(char *s, size_t len, enum application_special_type type) { diff --git a/griffin/griffin.c b/griffin/griffin.c index bb0d9121f6..e79c991044 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1220,6 +1220,10 @@ MENU #include "../menu/drivers/xmb.c" #endif +#ifdef HAVE_STRIPES +#include "../menu/drivers/stripes.c" +#endif + #ifdef HAVE_MATERIALUI #include "../menu/drivers/materialui.c" #endif diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c new file mode 100755 index 0000000000..520cf87812 --- /dev/null +++ b/menu/drivers/stripes.c @@ -0,0 +1,5205 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2014-2017 - Jean-André Santoni + * Copyright (C) 2016-2017 - Brad Parker + * Copyright (C) 2018 - Alfredo Monclús + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#include "../../frontend/frontend_driver.h" + +#include "menu_generic.h" + +#include "../menu_driver.h" +#include "../menu_animation.h" + +#include "../../core_info.h" +#include "../../core.h" +#include "../menu_entries.h" +#include "../widgets/menu_entry.h" +#include "../widgets/menu_input_dialog.h" +#include "../widgets/menu_osk.h" +#include "../widgets/menu_filebrowser.h" + +#include "../menu_event.h" + +#include "../../verbosity.h" +#include "../../configuration.h" +#include "../../playlist.h" +#include "../../retroarch.h" + +#include "../../tasks/tasks_internal.h" + +#include "../../cheevos/badges.h" +#include "../../content.h" + +#define STRIPES_RIBBON_ROWS 64 +#define STRIPES_RIBBON_COLS 64 +#define STRIPES_RIBBON_VERTICES 2*STRIPES_RIBBON_COLS*STRIPES_RIBBON_ROWS-2*STRIPES_RIBBON_COLS + +#ifndef STRIPES_DELAY +#define STRIPES_DELAY 10 +#endif + +#define BATTERY_LEVEL_CHECK_INTERVAL (30 * 1000000) + +#if 0 +#define STRIPES_DEBUG +#endif + +/* NOTE: If you change this you HAVE to update + * stripes_alloc_node() and stripes_copy_node() */ +typedef struct +{ + float alpha; + float label_alpha; + float zoom; + float x; + float y; + uintptr_t icon; + uintptr_t content_icon; + char *fullpath; +} stripes_node_t; + +enum +{ + STRIPES_TEXTURE_MAIN_MENU = 0, + STRIPES_TEXTURE_SETTINGS, + STRIPES_TEXTURE_HISTORY, + STRIPES_TEXTURE_FAVORITES, + STRIPES_TEXTURE_MUSICS, +#ifdef HAVE_FFMPEG + STRIPES_TEXTURE_MOVIES, +#endif +#ifdef HAVE_NETWORKING + STRIPES_TEXTURE_NETPLAY, + STRIPES_TEXTURE_ROOM, +/* stub these out until we have the icons + STRIPES_TEXTURE_ROOM_LAN, + STRIPES_TEXTURE_ROOM_MITM,*/ +#endif +#ifdef HAVE_IMAGEVIEWER + STRIPES_TEXTURE_IMAGES, +#endif + STRIPES_TEXTURE_SETTING, + STRIPES_TEXTURE_SUBSETTING, + STRIPES_TEXTURE_ARROW, + STRIPES_TEXTURE_RUN, + STRIPES_TEXTURE_CLOSE, + STRIPES_TEXTURE_RESUME, + STRIPES_TEXTURE_SAVESTATE, + STRIPES_TEXTURE_LOADSTATE, + STRIPES_TEXTURE_UNDO, + STRIPES_TEXTURE_CORE_INFO, + STRIPES_TEXTURE_WIFI, + STRIPES_TEXTURE_CORE_OPTIONS, + STRIPES_TEXTURE_INPUT_REMAPPING_OPTIONS, + STRIPES_TEXTURE_CHEAT_OPTIONS, + STRIPES_TEXTURE_DISK_OPTIONS, + STRIPES_TEXTURE_SHADER_OPTIONS, + STRIPES_TEXTURE_ACHIEVEMENT_LIST, + STRIPES_TEXTURE_SCREENSHOT, + STRIPES_TEXTURE_RELOAD, + STRIPES_TEXTURE_RENAME, + STRIPES_TEXTURE_FILE, + STRIPES_TEXTURE_FOLDER, + STRIPES_TEXTURE_ZIP, + STRIPES_TEXTURE_FAVORITE, + STRIPES_TEXTURE_ADD_FAVORITE, + STRIPES_TEXTURE_MUSIC, + STRIPES_TEXTURE_IMAGE, + STRIPES_TEXTURE_MOVIE, + STRIPES_TEXTURE_CORE, + STRIPES_TEXTURE_RDB, + STRIPES_TEXTURE_CURSOR, + STRIPES_TEXTURE_SWITCH_ON, + STRIPES_TEXTURE_SWITCH_OFF, + STRIPES_TEXTURE_CLOCK, + STRIPES_TEXTURE_BATTERY_FULL, + STRIPES_TEXTURE_BATTERY_CHARGING, + STRIPES_TEXTURE_POINTER, + STRIPES_TEXTURE_ADD, + STRIPES_TEXTURE_KEY, + STRIPES_TEXTURE_KEY_HOVER, + STRIPES_TEXTURE_DIALOG_SLICE, + STRIPES_TEXTURE_LAST +}; + +enum +{ + STRIPES_SYSTEM_TAB_MAIN = 0, + STRIPES_SYSTEM_TAB_SETTINGS, + STRIPES_SYSTEM_TAB_HISTORY, + STRIPES_SYSTEM_TAB_FAVORITES, + STRIPES_SYSTEM_TAB_MUSIC, +#ifdef HAVE_FFMPEG + STRIPES_SYSTEM_TAB_VIDEO, +#endif +#ifdef HAVE_IMAGEVIEWER + STRIPES_SYSTEM_TAB_IMAGES, +#endif +#ifdef HAVE_NETWORKING + STRIPES_SYSTEM_TAB_NETPLAY, +#endif + STRIPES_SYSTEM_TAB_ADD, + + /* End of this enum - use the last one to determine num of possible tabs */ + STRIPES_SYSTEM_TAB_MAX_LENGTH +}; + +typedef struct stripes_handle +{ + bool mouse_show; + + uint8_t system_tab_end; + uint8_t tabs[STRIPES_SYSTEM_TAB_MAX_LENGTH]; + + int depth; + int old_depth; + int icon_size; + int cursor_size; + + size_t categories_selection_ptr; + size_t categories_selection_ptr_old; + size_t selection_ptr_old; + + unsigned categories_active_idx; + unsigned categories_active_idx_old; + uintptr_t thumbnail; + uintptr_t left_thumbnail; + uintptr_t savestate_thumbnail; + + float x; + float alpha; + float thumbnail_width; + float thumbnail_height; + float left_thumbnail_width; + float left_thumbnail_height; + float savestate_thumbnail_width; + float savestate_thumbnail_height; + float above_subitem_offset; + float above_item_offset; + float active_item_factor; + float under_item_offset; + float shadow_offset; + float font_size; + float font2_size; + + float margins_screen_left; + float margins_screen_top; + float margins_setting_left; + float margins_title_left; + float margins_title_top; + float margins_title_bottom; + float margins_label_left; + float margins_label_top; + float icon_spacing_horizontal; + float icon_spacing_vertical; + float items_active_alpha; + float items_active_zoom; + float items_passive_alpha; + float items_passive_zoom; + float margins_dialog; + float margins_slice; + float textures_arrow_alpha; + float categories_x_pos; + float categories_passive_alpha; + float categories_passive_zoom; + float categories_active_zoom; + float categories_active_alpha; + + uint64_t frame_count; + + char title_name[255]; + char *box_message; + char *thumbnail_system; + char *thumbnail_content; + char *savestate_thumbnail_file_path; + char *thumbnail_file_path; + char *left_thumbnail_file_path; + char *bg_file_path; + + file_list_t *selection_buf_old; + file_list_t *horizontal_list; + + struct + { + menu_texture_item bg; + menu_texture_item list[STRIPES_TEXTURE_LAST]; + } textures; + + stripes_node_t main_menu_node; +#ifdef HAVE_IMAGEVIEWER + stripes_node_t images_tab_node; +#endif + stripes_node_t music_tab_node; +#ifdef HAVE_FFMPEG + stripes_node_t video_tab_node; +#endif + stripes_node_t settings_tab_node; + stripes_node_t history_tab_node; + stripes_node_t favorites_tab_node; + stripes_node_t add_tab_node; + stripes_node_t netplay_tab_node; + + font_data_t *font; + font_data_t *font2; + video_font_raster_block_t raster_block; + video_font_raster_block_t raster_block2; +} stripes_handle_t; + +float stripes_scale_mod[8] = { + 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static float stripes_coord_shadow[] = { + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, 0 +}; + +static float stripes_coord_black[] = { + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, 0 +}; + +static float stripes_coord_white[] = { + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, 1 +}; + +static float stripes_item_color[] = { + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, + 1, 1, 1, 1 +}; + + +float stripes_stripes_gradient_dark_purple[16] = { + 20/255.0, 13/255.0, 20/255.0, 1.0, + 20/255.0, 13/255.0, 20/255.0, 1.0, + 92/255.0, 44/255.0, 92/255.0, 1.0, + 148/255.0, 90/255.0, 148/255.0, 1.0, +}; + +float stripes_gradient_midnight_blue[16] = { + 44/255.0, 62/255.0, 80/255.0, 1.0, + 44/255.0, 62/255.0, 80/255.0, 1.0, + 44/255.0, 62/255.0, 80/255.0, 1.0, + 44/255.0, 62/255.0, 80/255.0, 1.0, +}; + +float stripes_gradient_golden[16] = { + 174/255.0, 123/255.0, 44/255.0, 1.0, + 205/255.0, 174/255.0, 84/255.0, 1.0, + 58/255.0, 43/255.0, 24/255.0, 1.0, + 58/255.0, 43/255.0, 24/255.0, 1.0, +}; + +float stripes_gradient_legacy_red[16] = { + 171/255.0, 70/255.0, 59/255.0, 1.0, + 171/255.0, 70/255.0, 59/255.0, 1.0, + 190/255.0, 80/255.0, 69/255.0, 1.0, + 190/255.0, 80/255.0, 69/255.0, 1.0, +}; + +float stripes_gradient_electric_blue[16] = { + 1/255.0, 2/255.0, 67/255.0, 1.0, + 1/255.0, 73/255.0, 183/255.0, 1.0, + 1/255.0, 93/255.0, 194/255.0, 1.0, + 3/255.0, 162/255.0, 254/255.0, 1.0, +}; + +float stripes_gradient_apple_green[16] = { + 102/255.0, 134/255.0, 58/255.0, 1.0, + 122/255.0, 131/255.0, 52/255.0, 1.0, + 82/255.0, 101/255.0, 35/255.0, 1.0, + 63/255.0, 95/255.0, 30/255.0, 1.0, +}; + +float stripes_gradient_undersea[16] = { + 23/255.0, 18/255.0, 41/255.0, 1.0, + 30/255.0, 72/255.0, 114/255.0, 1.0, + 52/255.0, 88/255.0, 110/255.0, 1.0, + 69/255.0, 125/255.0, 140/255.0, 1.0, + +}; + +float stripes_gradient_volcanic_red[16] = { + 1.0, 0.0, 0.1, 1.00, + 1.0, 0.1, 0.0, 1.00, + 0.1, 0.0, 0.1, 1.00, + 0.1, 0.0, 0.1, 1.00, +}; + +float stripes_gradient_dark[16] = { + 0.1, 0.1, 0.1, 1.00, + 0.1, 0.1, 0.1, 1.00, + 0.0, 0.0, 0.0, 1.00, + 0.0, 0.0, 0.0, 1.00, +}; + +float stripes_gradient_light[16] = { + 1.0, 1.0, 1.0, 1.00, + 1.0, 1.0, 1.0, 1.00, + 1.0, 1.0, 1.0, 1.00, + 1.0, 1.0, 1.0, 1.00, +}; + +float stripes_gradient_morning_blue[16] = { + 221/255.0, 241/255.0, 254/255.0, 1.00, + 135/255.0, 206/255.0, 250/255.0, 1.00, + 1.0, 1.0, 1.0, 1.00, + 170/255.0, 200/255.0, 252/255.0, 1.00, +}; + +static void stripes_calculate_visible_range(const stripes_handle_t *stripes, + unsigned height, size_t list_size, unsigned current, + unsigned *first, unsigned *last); + +const char* stripes_theme_ident(void) +{ + settings_t *settings = config_get_ptr(); + switch (settings->uints.menu_xmb_theme) + { + case XMB_ICON_THEME_FLATUI: + return "flatui"; + case XMB_ICON_THEME_RETROACTIVE: + return "retroactive"; + case XMB_ICON_THEME_RETROSYSTEM: + return "retrosystem"; + case XMB_ICON_THEME_PIXEL: + return "pixel"; + case XMB_ICON_THEME_NEOACTIVE: + return "neoactive"; + case XMB_ICON_THEME_SYSTEMATIC: + return "systematic"; + case XMB_ICON_THEME_DOTART: + return "dot-art"; + case XMB_ICON_THEME_CUSTOM: + return "custom"; + case XMB_ICON_THEME_MONOCHROME_INVERTED: + return "monochrome-inverted"; + case XMB_ICON_THEME_MONOCHROME: + default: + break; + } + + return "monochrome"; +} + +/* NOTE: This exists because calloc()ing stripes_node_t is expensive + * when you can have big lists like MAME and fba playlists */ +static stripes_node_t *stripes_alloc_node(void) +{ + stripes_node_t *node = (stripes_node_t*)malloc(sizeof(*node)); + + node->alpha = node->label_alpha = 0; + node->zoom = node->x = node->y = 0; + node->icon = node->content_icon = 0; + node->fullpath = NULL; + + return node; +} + +static void stripes_free_node(stripes_node_t *node) +{ + if (!node) + return; + + if (node->fullpath) + free(node->fullpath); + + node->fullpath = NULL; + + free(node); +} + +/** + * @brief frees all stripes_node_t in a file_list_t + * + * file_list_t asumes userdata holds a simple structure and + * free()'s it. Can't change this at the time because other + * code depends on this behavior. + * + * @param list + * @param actiondata whether to free actiondata too + */ +static void stripes_free_list_nodes(file_list_t *list, bool actiondata) +{ + unsigned i, size = file_list_get_size(list); + + for (i = 0; i < size; ++i) + { + stripes_free_node((stripes_node_t*)file_list_get_userdata_at_offset(list, i)); + + /* file_list_set_userdata() doesn't accept NULL */ + list->list[i].userdata = NULL; + + if (actiondata) + file_list_free_actiondata(list, i); + } +} + +static stripes_node_t *stripes_copy_node(const stripes_node_t *old_node) +{ + stripes_node_t *new_node = (stripes_node_t*)malloc(sizeof(*new_node)); + + *new_node = *old_node; + new_node->fullpath = old_node->fullpath ? strdup(old_node->fullpath) : NULL; + + return new_node; +} + +static const char *stripes_thumbnails_ident(char pos) +{ + char folder = 0; + settings_t *settings = config_get_ptr(); + + if (pos == 'R') + folder = settings->uints.menu_thumbnails; + if (pos == 'L') + folder = settings->uints.menu_left_thumbnails; + + switch (folder) + { + case 1: + return "Named_Snaps"; + case 2: + return "Named_Titles"; + case 3: + return "Named_Boxarts"; + case 0: + default: + break; + } + + return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF); +} + +static float *stripes_gradient_ident(video_frame_info_t *video_info) +{ + switch (video_info->xmb_color_theme) + { + case XMB_THEME_DARK_PURPLE: + return &stripes_stripes_gradient_dark_purple[0]; + case XMB_THEME_MIDNIGHT_BLUE: + return &stripes_gradient_midnight_blue[0]; + case XMB_THEME_GOLDEN: + return &stripes_gradient_golden[0]; + case XMB_THEME_ELECTRIC_BLUE: + return &stripes_gradient_electric_blue[0]; + case XMB_THEME_APPLE_GREEN: + return &stripes_gradient_apple_green[0]; + case XMB_THEME_UNDERSEA: + return &stripes_gradient_undersea[0]; + case XMB_THEME_VOLCANIC_RED: + return &stripes_gradient_volcanic_red[0]; + case XMB_THEME_DARK: + return &stripes_gradient_dark[0]; + case XMB_THEME_LIGHT: + return &stripes_gradient_light[0]; + case XMB_THEME_MORNING_BLUE: + return &stripes_gradient_morning_blue[0]; + case XMB_THEME_LEGACY_RED: + default: + break; + } + + return &stripes_gradient_legacy_red[0]; +} + +static size_t stripes_list_get_selection(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes) + return 0; + + return stripes->categories_selection_ptr; +} + +static size_t stripes_list_get_size(void *data, enum menu_list_type type) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + switch (type) + { + case MENU_LIST_PLAIN: + return menu_entries_get_stack_size(0); + case MENU_LIST_HORIZONTAL: + if (stripes && stripes->horizontal_list) + return file_list_get_size(stripes->horizontal_list); + break; + case MENU_LIST_TABS: + return stripes->system_tab_end; + } + + return 0; +} + +static void *stripes_list_get_entry(void *data, + enum menu_list_type type, unsigned i) +{ + size_t list_size = 0; + stripes_handle_t *stripes = (stripes_handle_t*)data; + + switch (type) + { + case MENU_LIST_PLAIN: + { + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + list_size = menu_entries_get_stack_size(0); + if (i < list_size) + return (void*)&menu_stack->list[i]; + } + break; + case MENU_LIST_HORIZONTAL: + if (stripes && stripes->horizontal_list) + list_size = file_list_get_size(stripes->horizontal_list); + if (i < list_size) + return (void*)&stripes->horizontal_list->list[i]; + break; + default: + break; + } + + return NULL; +} + +static INLINE float stripes_item_y(const stripes_handle_t *stripes, int i, size_t current) +{ + float iy = stripes->icon_spacing_vertical; + + if (i < (int)current) + if (stripes->depth > 1) + iy *= (i - (int)current + stripes->above_subitem_offset); + else + iy *= (i - (int)current + stripes->above_item_offset); + else + iy *= (i - (int)current + stripes->under_item_offset); + + if (i == (int)current) + iy = stripes->icon_spacing_vertical * stripes->active_item_factor; + + return iy; +} + +static void stripes_draw_icon( + video_frame_info_t *video_info, + int icon_size, + math_matrix_4x4 *mymat, + uintptr_t texture, + float x, + float y, + unsigned width, + unsigned height, + float alpha, + float rotation, + float scale_factor, + float *color, + float shadow_offset) +{ + menu_display_ctx_draw_t draw; + struct video_coords coords; + + if ( + (x < (-icon_size / 2.0f)) || + (x > width) || + (y < (icon_size / 2.0f)) || + (y > height + icon_size) + ) + return; + + coords.vertices = 4; + coords.vertex = NULL; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + + draw.width = icon_size; + draw.height = icon_size; + draw.rotation = rotation; + draw.scale_factor = scale_factor; +#if defined(VITA) || defined(WIIU) + draw.width *= scale_factor; + draw.height *= scale_factor; +#endif + draw.coords = &coords; + draw.matrix_data = mymat; + draw.texture = texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + + if (video_info->xmb_shadows_enable) + { + menu_display_set_alpha(stripes_coord_shadow, color[3] * 0.35f); + + coords.color = stripes_coord_shadow; + draw.x = x + shadow_offset; + draw.y = height - y - shadow_offset; + +#if defined(VITA) || defined(WIIU) + if(scale_factor < 1) + { + draw.x = draw.x + (icon_size-draw.width)/2; + draw.y = draw.y + (icon_size-draw.width)/2; + } +#endif + menu_display_draw(&draw, video_info); + } + + coords.color = (const float*)color; + draw.x = x; + draw.y = height - y; + +#if defined(VITA) || defined(WIIU) + if(scale_factor < 1) + { + draw.x = draw.x + (icon_size-draw.width)/2; + draw.y = draw.y + (icon_size-draw.width)/2; + } +#endif + menu_display_draw(&draw, video_info); +} + +static void stripes_draw_thumbnail( + video_frame_info_t *video_info, + stripes_handle_t *stripes, float *color, + unsigned width, unsigned height, + float x, float y, + float w, float h, uintptr_t texture) +{ + menu_display_ctx_rotate_draw_t rotate_draw; + menu_display_ctx_draw_t draw; + struct video_coords coords; + math_matrix_4x4 mymat; + + rotate_draw.matrix = &mymat; + rotate_draw.rotation = 0; + rotate_draw.scale_x = 1; + rotate_draw.scale_y = 1; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + + coords.vertices = 4; + coords.vertex = NULL; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + + draw.width = w; + draw.height = h; + draw.coords = &coords; + draw.matrix_data = &mymat; + draw.texture = texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + + if (video_info->xmb_shadows_enable) + { + menu_display_set_alpha(stripes_coord_shadow, color[3] * 0.35f); + + coords.color = stripes_coord_shadow; + draw.x = x + stripes->shadow_offset; + draw.y = height - y - stripes->shadow_offset; + + menu_display_draw(&draw, video_info); + } + + coords.color = (const float*)color; + draw.x = x; + draw.y = height - y; + + menu_display_set_alpha(color, 1.0f); + + menu_display_draw(&draw, video_info); +} + +static void stripes_draw_text( + video_frame_info_t *video_info, + stripes_handle_t *stripes, + const char *str, float x, + float y, float scale_factor, float alpha, + enum text_alignment text_align, + unsigned width, unsigned height, font_data_t* font) +{ + uint32_t color; + uint8_t a8; + settings_t *settings; + + if (alpha > stripes->alpha) + alpha = stripes->alpha; + + a8 = 255 * alpha; + + /* Avoid drawing 100% transparent text */ + if (a8 == 0) + return; + + settings = config_get_ptr(); + color = FONT_COLOR_RGBA( + settings->uints.menu_font_color_red, + settings->uints.menu_font_color_green, + settings->uints.menu_font_color_blue, a8); + + menu_display_draw_text(font, str, x, y, + width, height, color, text_align, scale_factor, + video_info->xmb_shadows_enable, + stripes->shadow_offset); +} + +static void stripes_messagebox(void *data, const char *message) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes || string_is_empty(message)) + return; + + stripes->box_message = strdup(message); +} + +static void stripes_render_keyboard(stripes_handle_t *stripes, + video_frame_info_t *video_info, + const char *grid[], unsigned id) +{ + unsigned i; + int ptr_width, ptr_height; + unsigned width = video_info->width; + unsigned height = video_info->height; + float dark[16] = { + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + }; + + float white[16]= { + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + }; + + menu_display_draw_quad( + video_info, + 0, height/2.0, width, height/2.0, + width, height, + &dark[0]); + + ptr_width = width / 11; + ptr_height = height / 10; + + if (ptr_width >= ptr_height) + ptr_width = ptr_height; + + for (i = 0; i < 44; i++) + { + int line_y = (i / 11) * height / 10.0; + + if (i == id) + { + uintptr_t texture = stripes->textures.list[STRIPES_TEXTURE_KEY_HOVER]; + + menu_display_blend_begin(video_info); + + menu_display_draw_texture( + video_info, + width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width, + height/2.0 + ptr_height*1.5 + line_y, + ptr_width, ptr_height, + width, height, + &white[0], + texture); + + menu_display_blend_end(video_info); + } + + menu_display_draw_text(stripes->font, grid[i], + width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width + ptr_width/2.0, + height/2.0 + ptr_height + line_y + stripes->font->size / 3, + width, height, 0xffffffff, TEXT_ALIGN_CENTER, 1.0f, + false, 0); + } +} + +/* Returns the OSK key at a given position */ +static int stripes_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) +{ + unsigned i; + int ptr_width, ptr_height; + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes) + return -1; + + ptr_width = width / 11; + ptr_height = height / 10; + + if (ptr_width >= ptr_height) + ptr_width = ptr_height; + + for (i = 0; i < 44; i++) + { + int line_y = (i / 11)*height/10.0; + int ptr_x = width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width; + int ptr_y = height/2.0 + ptr_height*1.5 + line_y - ptr_height; + + if (x > ptr_x && x < ptr_x + ptr_width + && y > ptr_y && y < ptr_y + ptr_height) + return i; + } + + return -1; +} + +static void stripes_render_messagebox_internal( + video_frame_info_t *video_info, + stripes_handle_t *stripes, const char *message, float* stripes_coord_white) +{ + unsigned i, y_position; + int x, y, longest = 0, longest_width = 0; + float line_height = 0; + unsigned width = video_info->width; + unsigned height = video_info->height; + struct string_list *list = !string_is_empty(message) + ? string_split(message, "\n") : NULL; + + if (!list || !stripes || !stripes->font) + { + if (list) + string_list_free(list); + return; + } + + if (list->elems == 0) + goto end; + + line_height = stripes->font->size * 1.2; + + y_position = height / 2; + if (menu_input_dialog_get_display_kb()) + y_position = height / 4; + + x = width / 2; + y = y_position - (list->size-1) * line_height / 2; + + /* find the longest line width */ + for (i = 0; i < list->size; i++) + { + const char *msg = list->elems[i].data; + int len = (int)utf8len(msg); + + if (len > longest) + { + longest = len; + longest_width = font_driver_get_message_width( + stripes->font, msg, strlen(msg), 1); + } + } + + menu_display_blend_begin(video_info); + + menu_display_draw_texture_slice( + video_info, + x - longest_width/2 - stripes->margins_dialog, + y + stripes->margins_slice - stripes->margins_dialog, + 256, 256, + longest_width + stripes->margins_dialog * 2, + line_height * list->size + stripes->margins_dialog * 2, + width, height, + &stripes_coord_white[0], + stripes->margins_slice, 1.0, + stripes->textures.list[STRIPES_TEXTURE_DIALOG_SLICE]); + + for (i = 0; i < list->size; i++) + { + const char *msg = list->elems[i].data; + + if (msg) + menu_display_draw_text(stripes->font, msg, + x - longest_width/2.0, + y + (i+0.75) * line_height, + width, height, 0x444444ff, TEXT_ALIGN_LEFT, 1.0f, false, 0); + } + + if (menu_input_dialog_get_display_kb()) + stripes_render_keyboard(stripes, + video_info, + menu_event_get_osk_grid(), + menu_event_get_osk_ptr()); + +end: + string_list_free(list); +} + +static void stripes_update_thumbnail_path(void *data, unsigned i, char pos) +{ + menu_entry_t entry; + unsigned entry_type = 0; + char new_path[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + stripes_handle_t *stripes = (stripes_handle_t*)data; + playlist_t *playlist = NULL; + const char *dir_thumbnails = settings->paths.directory_thumbnails; + + menu_entry_init(&entry); + + if (!stripes || string_is_empty(dir_thumbnails)) + goto end; + + menu_entry_get(&entry, 0, i, NULL, true); + + entry_type = menu_entry_get_type_new(&entry); + + if (entry_type == FILE_TYPE_IMAGEVIEWER || entry_type == FILE_TYPE_IMAGE) + { + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(selection_buf, i); + + if (!string_is_empty(node->fullpath) && + (pos == 'R' || (pos == 'L' && string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))))) + { + if (!string_is_empty(entry.path)) + fill_pathname_join( + new_path, + node->fullpath, + entry.path, + sizeof(new_path)); + + goto end; + } + } + else if (filebrowser_get_type() != FILEBROWSER_NONE) + { + stripes->thumbnail = 0; + goto end; + } + + menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); + + if (playlist) + { + const char *core_name = NULL; + playlist_get_index(playlist, i, + NULL, NULL, NULL, &core_name, NULL, NULL); + + if (string_is_equal(core_name, "imageviewer")) + { + if (pos == 'R' || (pos == 'L' && string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))) + { + if (!string_is_empty(entry.label)) + strlcpy(new_path, entry.label, + sizeof(new_path)); + goto end; + } + else + { + stripes->left_thumbnail = 0; + goto end; + } + } + } + + /* Append thumbnail system directory */ + if (!string_is_empty(stripes->thumbnail_system)) + fill_pathname_join( + new_path, + dir_thumbnails, + stripes->thumbnail_system, + sizeof(new_path)); + + if (!string_is_empty(new_path)) + { + char *tmp_new2 = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + + tmp_new2[0] = '\0'; + + /* Append Named_Snaps/Named_Boxarts/Named_Titles */ + if (pos == 'R') + fill_pathname_join(tmp_new2, new_path, + stripes_thumbnails_ident('R'), PATH_MAX_LENGTH * sizeof(char)); + if (pos == 'L') + fill_pathname_join(tmp_new2, new_path, + stripes_thumbnails_ident('L'), PATH_MAX_LENGTH * sizeof(char)); + + strlcpy(new_path, tmp_new2, + PATH_MAX_LENGTH * sizeof(char)); + free(tmp_new2); + } + + /* Scrub characters that are not cross-platform and/or violate the + * No-Intro filename standard: + * http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip + * Replace these characters in the entry name with underscores. + */ + if (!string_is_empty(stripes->thumbnail_content)) + { + char *scrub_char_pointer = NULL; + char *tmp_new = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + char *tmp = strdup(stripes->thumbnail_content); + + tmp_new[0] = '\0'; + + while((scrub_char_pointer = strpbrk(tmp, "&*/:`\"<>?\\|"))) + *scrub_char_pointer = '_'; + + /* Look for thumbnail file with this scrubbed filename */ + + fill_pathname_join(tmp_new, + new_path, + tmp, PATH_MAX_LENGTH * sizeof(char)); + + if (!string_is_empty(tmp_new)) + strlcpy(new_path, + tmp_new, sizeof(new_path)); + + free(tmp_new); + free(tmp); + } + + /* Append png extension */ + if (!string_is_empty(new_path)) + strlcat(new_path, + file_path_str(FILE_PATH_PNG_EXTENSION), + sizeof(new_path)); + +end: + if (stripes && !string_is_empty(new_path)) + { + if (pos == 'R') + stripes->thumbnail_file_path = strdup(new_path); + if (pos == 'L') + stripes->left_thumbnail_file_path = strdup(new_path); + } + + menu_entry_free(&entry); +} + +static void stripes_update_savestate_thumbnail_path(void *data, unsigned i) +{ + menu_entry_t entry; + settings_t *settings = config_get_ptr(); + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes) + return; + + menu_entry_init(&entry); + menu_entry_get(&entry, 0, i, NULL, true); + + if (!string_is_empty(stripes->savestate_thumbnail_file_path)) + free(stripes->savestate_thumbnail_file_path); + stripes->savestate_thumbnail_file_path = NULL; + + if (!string_is_empty(entry.label)) + { + if ( (settings->bools.savestate_thumbnail_enable) + && ((string_is_equal(entry.label, "state_slot")) + || (string_is_equal(entry.label, "loadstate")) + || (string_is_equal(entry.label, "savestate")))) + { + size_t path_size = 8024 * sizeof(char); + char *path = (char*)malloc(8204 * sizeof(char)); + global_t *global = global_get_ptr(); + + path[0] = '\0'; + + if (global) + { + int state_slot = settings->ints.state_slot; + + if (state_slot > 0) + snprintf(path, path_size, "%s%d", + global->name.savestate, state_slot); + else if (state_slot < 0) + fill_pathname_join_delim(path, + global->name.savestate, "auto", '.', path_size); + else + strlcpy(path, global->name.savestate, path_size); + } + + strlcat(path, file_path_str(FILE_PATH_PNG_EXTENSION), path_size); + + if (filestream_exists(path)) + { + if (!string_is_empty(stripes->savestate_thumbnail_file_path)) + free(stripes->savestate_thumbnail_file_path); + stripes->savestate_thumbnail_file_path = strdup(path); + } + + free(path); + } + } + + menu_entry_free(&entry); +} + +static void stripes_update_thumbnail_image(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!stripes) + return; + + if (!(string_is_empty(stripes->thumbnail_file_path))) + { + if (filestream_exists(stripes->thumbnail_file_path)) + task_push_image_load(stripes->thumbnail_file_path, + menu_display_handle_thumbnail_upload, NULL); + else + stripes->thumbnail = 0; + + free(stripes->thumbnail_file_path); + stripes->thumbnail_file_path = NULL; + } + + if (!(string_is_empty(stripes->left_thumbnail_file_path))) + { + if (filestream_exists(stripes->left_thumbnail_file_path)) + task_push_image_load(stripes->left_thumbnail_file_path, + menu_display_handle_left_thumbnail_upload, NULL); + else + stripes->left_thumbnail = 0; + + free(stripes->left_thumbnail_file_path); + stripes->left_thumbnail_file_path = NULL; + } +} + +static void stripes_set_thumbnail_system(void *data, char*s, size_t len) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!stripes) + return; + + if (!string_is_empty(stripes->thumbnail_system)) + free(stripes->thumbnail_system); + stripes->thumbnail_system = strdup(s); +} + +static void stripes_reset_thumbnail_content(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!stripes) + return; + if (!string_is_empty(stripes->thumbnail_content)) + free(stripes->thumbnail_content); + stripes->thumbnail_content = NULL; +} + +static void stripes_set_thumbnail_content(void *data, char *s, size_t len) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!stripes) + return; + if (!string_is_empty(stripes->thumbnail_content)) + free(stripes->thumbnail_content); + stripes->thumbnail_content = strdup(s); +} + +static void stripes_update_savestate_thumbnail_image(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!stripes) + return; + + if (!string_is_empty(stripes->savestate_thumbnail_file_path) + && filestream_exists(stripes->savestate_thumbnail_file_path)) + task_push_image_load(stripes->savestate_thumbnail_file_path, + menu_display_handle_savestate_thumbnail_upload, NULL); + else + stripes->savestate_thumbnail = 0; +} + +static unsigned stripes_get_system_tab(stripes_handle_t *stripes, unsigned i) +{ + if (i <= stripes->system_tab_end) + { + return stripes->tabs[i]; + } + return UINT_MAX; +} + +static void stripes_selection_pointer_changed( + stripes_handle_t *stripes, bool allow_animations) +{ + unsigned i, end, height; + menu_animation_ctx_tag tag; + menu_entry_t entry; + size_t num = 0; + int threshold = 0; + menu_list_t *menu_list = NULL; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + const char *thumb_ident = stripes_thumbnails_ident('R'); + const char *lft_thumb_ident= stripes_thumbnails_ident('L'); + + menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list); + menu_entry_init(&entry); + + if (!stripes) + goto end; + + menu_entry_get(&entry, 0, selection, NULL, true); + + end = (unsigned)menu_entries_get_size(); + threshold = stripes->icon_size * 10; + + video_driver_get_size(NULL, &height); + + tag = (uintptr_t)selection_buf; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num); + + for (i = 0; i < end; i++) + { + float iy, real_iy; + float ia = stripes->items_passive_alpha; + float iz = stripes->items_passive_zoom; + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(selection_buf, i); + + if (!node) + continue; + + iy = stripes_item_y(stripes, i, selection); + real_iy = iy + stripes->margins_screen_top; + + if (i == selection) + { + unsigned depth = (unsigned)stripes_list_get_size(stripes, MENU_LIST_PLAIN); + unsigned stripes_system_tab = stripes_get_system_tab(stripes, (unsigned)stripes->categories_selection_ptr); + unsigned entry_type = menu_entry_get_type_new(&entry); + + ia = stripes->items_active_alpha; + iz = stripes->items_active_zoom; + if (!string_is_equal(thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)) || !string_is_equal(lft_thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + if ((stripes_system_tab > STRIPES_SYSTEM_TAB_SETTINGS && depth == 1) || + (stripes_system_tab < STRIPES_SYSTEM_TAB_SETTINGS && depth == 4)) + { + if (!string_is_empty(entry.path)) + stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); + if (!string_is_equal(thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'R'); + stripes_update_thumbnail_image(stripes); + } + if (!string_is_equal(lft_thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'L'); + stripes_update_thumbnail_image(stripes); + } + } + else if (((entry_type == FILE_TYPE_IMAGE || entry_type == FILE_TYPE_IMAGEVIEWER || + entry_type == FILE_TYPE_RDB || entry_type == FILE_TYPE_RDB_ENTRY) + && stripes_system_tab <= STRIPES_SYSTEM_TAB_SETTINGS)) + { + if (!string_is_empty(entry.path)) + stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); + if (!string_is_equal(thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'R'); + stripes_update_thumbnail_image(stripes); + } + else if (!string_is_equal(lft_thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'L'); + stripes_update_thumbnail_image(stripes); + } + } + else if (filebrowser_get_type() != FILEBROWSER_NONE) + { + stripes_reset_thumbnail_content(stripes); + if (!string_is_equal(thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'R'); + stripes_update_thumbnail_image(stripes); + } + else if (!string_is_equal(lft_thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + stripes_update_thumbnail_path(stripes, i, 'L'); + stripes_update_thumbnail_image(stripes); + } + } + } + stripes_update_savestate_thumbnail_path(stripes, i); + stripes_update_savestate_thumbnail_image(stripes); + } + + if ( (!allow_animations) + || (real_iy < -threshold + || real_iy > height+threshold)) + { + node->alpha = node->label_alpha = ia; + node->y = iy; + node->zoom = iz; + } + else + { + menu_animation_ctx_entry_t anim_entry; + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = ia; + anim_entry.subject = &node->alpha; + anim_entry.easing_enum = EASING_OUT_QUAD; + anim_entry.tag = tag; + anim_entry.cb = NULL; + + menu_animation_push(&anim_entry); + + anim_entry.subject = &node->label_alpha; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = iz; + anim_entry.subject = &node->zoom; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = iy; + anim_entry.subject = &node->y; + + menu_animation_push(&anim_entry); + } + } + +end: + menu_entry_free(&entry); +} + +static void stripes_list_open_old(stripes_handle_t *stripes, + file_list_t *list, int dir, size_t current) +{ + unsigned i, height = 0; + int threshold = stripes->icon_size * 10; + size_t end = 0; + + end = file_list_get_size(list); + + video_driver_get_size(NULL, &height); + + for (i = 0; i < end; i++) + { + float ia = 0; + float real_y; + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + if (i == current) + ia = stripes->items_active_alpha; + if (dir == -1) + ia = 0; + + real_y = node->y + stripes->margins_screen_top; + + if (real_y < -threshold || real_y > height+threshold) + { + node->alpha = ia; + node->label_alpha = 0; + node->x = stripes->icon_size * dir * -2; + } + else + { + menu_animation_ctx_entry_t anim_entry; + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = ia; + anim_entry.subject = &node->alpha; + anim_entry.easing_enum = EASING_OUT_QUAD; + anim_entry.tag = (uintptr_t)list; + anim_entry.cb = NULL; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = 0; + anim_entry.subject = &node->label_alpha; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = stripes->icon_size * dir * -2; + anim_entry.subject = &node->x; + + menu_animation_push(&anim_entry); + } + } +} + +static void stripes_list_open_new(stripes_handle_t *stripes, + file_list_t *list, int dir, size_t current) +{ + unsigned i, height; + unsigned stripes_system_tab = 0; + size_t skip = 0; + int threshold = stripes->icon_size * 10; + size_t end = file_list_get_size(list); + + video_driver_get_size(NULL, &height); + + for (i = 0; i < end; i++) + { + float ia; + float real_y; + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + if (dir == 1 || (dir == -1 && i != current)) + node->alpha = 0; + + if (dir == 1 || dir == -1) + node->label_alpha = 0; + + node->x = stripes->icon_size * dir * 2; + node->y = stripes_item_y(stripes, i, current); + node->zoom = stripes->categories_passive_zoom; + + real_y = node->y + stripes->margins_screen_top; + + if (i == current) + node->zoom = stripes->categories_active_zoom; + + ia = stripes->items_passive_alpha; + if (i == current) + ia = stripes->items_active_alpha; + + if (real_y < -threshold || real_y > height+threshold) + { + node->alpha = node->label_alpha = ia; + node->x = 0; + } + else + { + menu_animation_ctx_entry_t anim_entry; + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = ia; + anim_entry.subject = &node->alpha; + anim_entry.easing_enum = EASING_OUT_QUAD; + anim_entry.tag = (uintptr_t)list; + anim_entry.cb = NULL; + + menu_animation_push(&anim_entry); + + anim_entry.subject = &node->label_alpha; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = 0; + anim_entry.subject = &node->x; + + menu_animation_push(&anim_entry); + } + } + + stripes->old_depth = stripes->depth; + menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &skip); + + stripes_system_tab = stripes_get_system_tab(stripes, + (unsigned)stripes->categories_selection_ptr); + + if (stripes_system_tab <= STRIPES_SYSTEM_TAB_SETTINGS) + { + if (stripes->depth < 4) + stripes_reset_thumbnail_content(stripes); + stripes_update_thumbnail_path(stripes, 0, 'R'); + stripes_update_thumbnail_image(stripes); + stripes_update_thumbnail_path(stripes, 0, 'L'); + stripes_update_thumbnail_image(stripes); + } +} + +static stripes_node_t *stripes_node_allocate_userdata( + stripes_handle_t *stripes, unsigned i) +{ + stripes_node_t *tmp = NULL; + stripes_node_t *node = stripes_alloc_node(); + + if (!node) + { + RARCH_ERR("XMB node could not be allocated.\n"); + return NULL; + } + + node->alpha = stripes->categories_passive_alpha; + node->zoom = stripes->categories_passive_zoom; + + if ((i + stripes->system_tab_end) == stripes->categories_active_idx) + { + node->alpha = stripes->categories_active_alpha; + node->zoom = stripes->categories_active_zoom; + } + + tmp = (stripes_node_t*)file_list_get_userdata_at_offset( + stripes->horizontal_list, i); + stripes_free_node(tmp); + + file_list_set_userdata(stripes->horizontal_list, i, node); + + return node; +} + +static stripes_node_t* stripes_get_userdata_from_horizontal_list( + stripes_handle_t *stripes, unsigned i) +{ + return (stripes_node_t*) + file_list_get_userdata_at_offset(stripes->horizontal_list, i); +} + +static void stripes_push_animations(stripes_node_t *node, + uintptr_t tag, float ia, float ix) +{ + menu_animation_ctx_entry_t anim_entry; + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = ia; + anim_entry.subject = &node->alpha; + anim_entry.easing_enum = EASING_OUT_QUAD; + anim_entry.tag = tag; + anim_entry.cb = NULL; + + menu_animation_push(&anim_entry); + + anim_entry.subject = &node->label_alpha; + + menu_animation_push(&anim_entry); + + anim_entry.target_value = ix; + anim_entry.subject = &node->x; + + menu_animation_push(&anim_entry); +} + +static void stripes_list_switch_old(stripes_handle_t *stripes, + file_list_t *list, int dir, size_t current) +{ + unsigned i, first, last, height; + size_t end = file_list_get_size(list); + float ix = -stripes->icon_spacing_horizontal * dir; + float ia = 0; + + first = 0; + last = end > 0 ? end - 1 : 0; + + video_driver_get_size(NULL, &height); + stripes_calculate_visible_range(stripes, height, end, + current, &first, &last); + + for (i = 0; i < end; i++) + { + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + if (i >= first && i <= last) + stripes_push_animations(node, (uintptr_t)list, ia, ix); + else + { + node->alpha = node->label_alpha = ia; + node->x = ix; + } + } +} + +static void stripes_list_switch_new(stripes_handle_t *stripes, + file_list_t *list, int dir, size_t current) +{ + unsigned i, first, last, height; + size_t end = 0; + settings_t *settings = config_get_ptr(); + + if (settings->bools.menu_dynamic_wallpaper_enable) + { + size_t path_size = PATH_MAX_LENGTH * sizeof(char); + char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *tmp = string_replace_substring(stripes->title_name, "/", " "); + + path[0] = '\0'; + + if (tmp) + { + fill_pathname_join_noext( + path, + settings->paths.directory_dynamic_wallpapers, + tmp, + path_size); + free(tmp); + } + + strlcat(path, + file_path_str(FILE_PATH_PNG_EXTENSION), + path_size); + + if (!filestream_exists(path)) + fill_pathname_application_special(path, path_size, + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if(!string_is_equal(path, stripes->bg_file_path)) + { + if(filestream_exists(path)) + { + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + if (!string_is_empty(stripes->bg_file_path)) + free(stripes->bg_file_path); + stripes->bg_file_path = strdup(path); + } + } + + free(path); + } + + end = file_list_get_size(list); + + first = 0; + last = end > 0 ? end - 1 : 0; + + video_driver_get_size(NULL, &height); + stripes_calculate_visible_range(stripes, height, end, current, &first, &last); + + for (i = 0; i < end; i++) + { + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, i); + float ia = stripes->items_passive_alpha; + + if (!node) + continue; + + node->x = stripes->icon_spacing_horizontal * dir; + node->alpha = 0; + node->label_alpha = 0; + + if (i == current) + ia = stripes->items_active_alpha; + + if (i >= first && i <= last) + stripes_push_animations(node, (uintptr_t)list, ia, 0); + else + { + node->x = 0; + node->alpha = node->label_alpha = ia; + } + } +} + +static void stripes_set_title(stripes_handle_t *stripes) +{ + if (stripes->categories_selection_ptr <= stripes->system_tab_end) + { + menu_entries_get_title(stripes->title_name, sizeof(stripes->title_name)); + } + else + { + const char *path = NULL; + menu_entries_get_at_offset( + stripes->horizontal_list, + stripes->categories_selection_ptr - (stripes->system_tab_end + 1), + &path, NULL, NULL, NULL, NULL); + + if (!path) + return; + + fill_pathname_base_noext( + stripes->title_name, path, sizeof(stripes->title_name)); + } +} + +static stripes_node_t* stripes_get_node(stripes_handle_t *stripes, unsigned i) +{ + switch (stripes_get_system_tab(stripes, i)) + { + case STRIPES_SYSTEM_TAB_SETTINGS: + return &stripes->settings_tab_node; +#ifdef HAVE_IMAGEVIEWER + case STRIPES_SYSTEM_TAB_IMAGES: + return &stripes->images_tab_node; +#endif + case STRIPES_SYSTEM_TAB_MUSIC: + return &stripes->music_tab_node; +#ifdef HAVE_FFMPEG + case STRIPES_SYSTEM_TAB_VIDEO: + return &stripes->video_tab_node; +#endif + case STRIPES_SYSTEM_TAB_HISTORY: + return &stripes->history_tab_node; + case STRIPES_SYSTEM_TAB_FAVORITES: + return &stripes->favorites_tab_node; +#ifdef HAVE_NETWORKING + case STRIPES_SYSTEM_TAB_NETPLAY: + return &stripes->netplay_tab_node; +#endif + case STRIPES_SYSTEM_TAB_ADD: + return &stripes->add_tab_node; + default: + if (i > stripes->system_tab_end) + return stripes_get_userdata_from_horizontal_list( + stripes, i - (stripes->system_tab_end + 1)); + } + + return &stripes->main_menu_node; +} + +static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) +{ + unsigned j; + size_t list_size = stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; + + for (j = 0; j <= list_size; j++) + { + menu_animation_ctx_entry_t entry; + float ia = stripes->categories_passive_alpha; + float iz = stripes->categories_passive_zoom; + stripes_node_t *node = stripes_get_node(stripes, j); + + if (!node) + continue; + + if (j == stripes->categories_active_idx) + { + ia = stripes->categories_active_alpha; + iz = stripes->categories_active_zoom; + } + + entry.duration = STRIPES_DELAY; + entry.target_value = ia; + entry.subject = &node->alpha; + entry.easing_enum = EASING_OUT_QUAD; + /* TODO/FIXME - integer conversion resulted in change of sign */ + entry.tag = -1; + entry.cb = NULL; + + menu_animation_push(&entry); + + entry.target_value = iz; + entry.subject = &node->zoom; + + menu_animation_push(&entry); + } +} + +static void stripes_list_switch(stripes_handle_t *stripes) +{ + menu_animation_ctx_entry_t anim_entry; + int dir = -1; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + settings_t *settings = config_get_ptr(); + + if (stripes->categories_selection_ptr > stripes->categories_selection_ptr_old) + dir = 1; + + stripes->categories_active_idx += dir; + + stripes_list_switch_horizontal_list(stripes); + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = stripes->icon_spacing_horizontal + * -(float)stripes->categories_selection_ptr; + anim_entry.subject = &stripes->categories_x_pos; + anim_entry.easing_enum = EASING_OUT_QUAD; + /* TODO/FIXME - integer conversion resulted in change of sign */ + anim_entry.tag = -1; + anim_entry.cb = NULL; + + if (anim_entry.subject) + menu_animation_push(&anim_entry); + + dir = -1; + if (stripes->categories_selection_ptr > stripes->categories_selection_ptr_old) + dir = 1; + + stripes_list_switch_old(stripes, stripes->selection_buf_old, + dir, stripes->selection_ptr_old); + + /* Check if we are to have horizontal animations. */ + if (settings->bools.menu_horizontal_animation) + stripes_list_switch_new(stripes, selection_buf, dir, selection); + stripes->categories_active_idx_old = (unsigned)stripes->categories_selection_ptr; + + if (!string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + menu_entry_t entry; + + menu_entry_init(&entry); + menu_entry_get(&entry, 0, selection, NULL, true); + + if (!string_is_empty(entry.path)) + stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); + + menu_entry_free(&entry); + + stripes_update_thumbnail_path(stripes, 0, 'R'); + stripes_update_thumbnail_image(stripes); + } + if (!string_is_equal(stripes_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + menu_entry_t entry; + + menu_entry_init(&entry); + menu_entry_get(&entry, 0, selection, NULL, true); + + if (!string_is_empty(entry.path)) + stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); + + menu_entry_free(&entry); + + stripes_update_thumbnail_path(stripes, 0, 'L'); + stripes_update_thumbnail_image(stripes); + } +} + +static void stripes_list_open_horizontal_list(stripes_handle_t *stripes) +{ + unsigned j; + size_t list_size = stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; + + for (j = 0; j <= list_size; j++) + { + menu_animation_ctx_entry_t anim_entry; + float ia = 0; + stripes_node_t *node = stripes_get_node(stripes, j); + + if (!node) + continue; + + if (j == stripes->categories_active_idx) + ia = stripes->categories_active_alpha; + else if (stripes->depth <= 1) + ia = stripes->categories_passive_alpha; + + anim_entry.duration = STRIPES_DELAY; + anim_entry.target_value = ia; + anim_entry.subject = &node->alpha; + anim_entry.easing_enum = EASING_OUT_QUAD; + /* TODO/FIXME - integer conversion resulted in change of sign */ + anim_entry.tag = -1; + anim_entry.cb = NULL; + + if (anim_entry.subject) + menu_animation_push(&anim_entry); + } +} + +static void stripes_context_destroy_horizontal_list(stripes_handle_t *stripes) +{ + unsigned i; + size_t list_size = stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL); + + for (i = 0; i < list_size; i++) + { + const char *path = NULL; + stripes_node_t *node = stripes_get_userdata_from_horizontal_list(stripes, i); + + if (!node) + continue; + + file_list_get_at_offset(stripes->horizontal_list, i, + &path, NULL, NULL, NULL); + + if (!path || !strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION))) + continue; + + video_driver_texture_unload(&node->icon); + video_driver_texture_unload(&node->content_icon); + } +} + +static void stripes_init_horizontal_list(stripes_handle_t *stripes) +{ + menu_displaylist_info_t info; + settings_t *settings = config_get_ptr(); + + menu_displaylist_info_init(&info); + + info.list = stripes->horizontal_list; + info.path = strdup( + settings->paths.directory_playlist); + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST)); + info.exts = strdup( + file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); + info.type_default = FILE_TYPE_PLAIN; + info.enum_idx = MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST; + + if (!string_is_empty(info.path)) + { + if (menu_displaylist_ctl(DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL, &info)) + { + size_t i; + for (i = 0; i < stripes->horizontal_list->size; i++) + stripes_node_allocate_userdata(stripes, (unsigned)i); + menu_displaylist_process(&info); + } + } + + menu_displaylist_info_free(&info); +} + +static void stripes_toggle_horizontal_list(stripes_handle_t *stripes) +{ + unsigned i; + size_t list_size = stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; + + for (i = 0; i <= list_size; i++) + { + stripes_node_t *node = stripes_get_node(stripes, i); + + if (!node) + continue; + + node->alpha = 0; + node->zoom = stripes->categories_passive_zoom; + + if (i == stripes->categories_active_idx) + { + node->alpha = stripes->categories_active_alpha; + node->zoom = stripes->categories_active_zoom; + } + else if (stripes->depth <= 1) + node->alpha = stripes->categories_passive_alpha; + } +} + +static void stripes_context_reset_horizontal_list( + stripes_handle_t *stripes) +{ + unsigned i; + int depth; /* keep this integer */ + size_t list_size = + stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL); + + stripes->categories_x_pos = + stripes->icon_spacing_horizontal * + -(float)stripes->categories_selection_ptr; + + depth = (stripes->depth > 1) ? 2 : 1; + stripes->x = stripes->icon_size * -(depth*2-2); + + for (i = 0; i < list_size; i++) + { + const char *path = NULL; + stripes_node_t *node = + stripes_get_userdata_from_horizontal_list(stripes, i); + + if (!node) + { + node = stripes_node_allocate_userdata(stripes, i); + if (!node) + continue; + } + + + file_list_get_at_offset(stripes->horizontal_list, i, + &path, NULL, NULL, NULL); + + if (!path) + continue; + + if (!strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION))) + continue; + + { + struct texture_image ti; + char sysname[256]; + char *iconpath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + char *texturepath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + char *content_texturepath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + + iconpath[0] = sysname[0] = + texturepath[0] = content_texturepath[0] = '\0'; + + fill_pathname_base_noext(sysname, path, sizeof(sysname)); + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + fill_pathname_join_concat(texturepath, iconpath, sysname, + file_path_str(FILE_PATH_PNG_EXTENSION), + PATH_MAX_LENGTH * sizeof(char)); + + ti.width = 0; + ti.height = 0; + ti.pixels = NULL; + ti.supports_rgba = video_driver_supports_rgba(); + + if (image_texture_load(&ti, texturepath)) + { + if(ti.pixels) + { + video_driver_texture_unload(&node->icon); + video_driver_texture_load(&ti, + TEXTURE_FILTER_MIPMAP_LINEAR, &node->icon); + } + + image_texture_free(&ti); + } + + strlcat(iconpath, sysname, PATH_MAX_LENGTH * sizeof(char)); + fill_pathname_join_delim(content_texturepath, iconpath, + file_path_str(FILE_PATH_CONTENT_BASENAME), '-', + PATH_MAX_LENGTH * sizeof(char)); + + if (image_texture_load(&ti, content_texturepath)) + { + if(ti.pixels) + { + video_driver_texture_unload(&node->content_icon); + video_driver_texture_load(&ti, + TEXTURE_FILTER_MIPMAP_LINEAR, &node->content_icon); + } + + image_texture_free(&ti); + } + + free(iconpath); + free(texturepath); + free(content_texturepath); + } + } + + stripes_toggle_horizontal_list(stripes); +} + +static void stripes_refresh_horizontal_list(stripes_handle_t *stripes) +{ + stripes_context_destroy_horizontal_list(stripes); + if (stripes->horizontal_list) + { + stripes_free_list_nodes(stripes->horizontal_list, false); + file_list_free(stripes->horizontal_list); + } + stripes->horizontal_list = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); + + stripes->horizontal_list = (file_list_t*) + calloc(1, sizeof(file_list_t)); + + if (stripes->horizontal_list) + stripes_init_horizontal_list(stripes); + + stripes_context_reset_horizontal_list(stripes); +} + +static int stripes_environ(enum menu_environ_cb type, void *data, void *userdata) +{ + stripes_handle_t *stripes = (stripes_handle_t*)userdata; + + switch (type) + { + case MENU_ENVIRON_ENABLE_MOUSE_CURSOR: + if (!stripes) + return -1; + stripes->mouse_show = true; + break; + case MENU_ENVIRON_DISABLE_MOUSE_CURSOR: + if (!stripes) + return -1; + stripes->mouse_show = false; + break; + case MENU_ENVIRON_RESET_HORIZONTAL_LIST: + if (!stripes) + return -1; + + stripes_refresh_horizontal_list(stripes); + break; + default: + return -1; + } + + return 0; +} + +static void stripes_list_open(stripes_handle_t *stripes) +{ + menu_animation_ctx_entry_t entry; + + int dir = 0; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + stripes->depth = (int)stripes_list_get_size(stripes, MENU_LIST_PLAIN); + + if (stripes->depth > stripes->old_depth) + dir = 1; + else if (stripes->depth < stripes->old_depth) + dir = -1; + + stripes_list_open_horizontal_list(stripes); + + stripes_list_open_old(stripes, stripes->selection_buf_old, + dir, stripes->selection_ptr_old); + stripes_list_open_new(stripes, selection_buf, + dir, selection); + + + entry.duration = STRIPES_DELAY; + entry.target_value = stripes->icon_size * -(stripes->depth*2-2); + entry.subject = &stripes->x; + entry.easing_enum = EASING_OUT_QUAD; + /* TODO/FIXME - integer conversion resulted in change of sign */ + entry.tag = -1; + entry.cb = NULL; + + switch (stripes->depth) + { + case 1: + menu_animation_push(&entry); + + entry.target_value = 0; + entry.subject = &stripes->textures_arrow_alpha; + + menu_animation_push(&entry); + break; + case 2: + menu_animation_push(&entry); + + entry.target_value = 1; + entry.subject = &stripes->textures_arrow_alpha; + + menu_animation_push(&entry); + break; + } + + stripes->old_depth = stripes->depth; +} + +static void stripes_populate_entries(void *data, + const char *path, + const char *label, unsigned k) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes) + return; + + if (menu_driver_ctl(RARCH_MENU_CTL_IS_PREVENT_POPULATE, NULL)) + { + stripes_selection_pointer_changed(stripes, false); + menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); + if (!string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + stripes_update_thumbnail_image(stripes); + stripes_update_savestate_thumbnail_image(stripes); + if (!string_is_equal(stripes_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + stripes_update_thumbnail_image(stripes); + return; + } + + stripes_set_title(stripes); + + if (stripes->categories_selection_ptr != stripes->categories_active_idx_old) + stripes_list_switch(stripes); + else + stripes_list_open(stripes); +} + +static uintptr_t stripes_icon_get_id(stripes_handle_t *stripes, + stripes_node_t *core_node, stripes_node_t *node, + enum msg_hash_enums enum_idx, unsigned type, bool active) +{ + switch (enum_idx) + { + case MENU_ENUM_LABEL_CORE_OPTIONS: + case MENU_ENUM_LABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE: + return stripes->textures.list[STRIPES_TEXTURE_CORE_OPTIONS]; + case MENU_ENUM_LABEL_ADD_TO_FAVORITES: + case MENU_ENUM_LABEL_ADD_TO_FAVORITES_PLAYLIST: + return stripes->textures.list[STRIPES_TEXTURE_ADD_FAVORITE]; + case MENU_ENUM_LABEL_RESET_CORE_ASSOCIATION: + return stripes->textures.list[STRIPES_TEXTURE_RENAME]; + case MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_INPUT_REMAPPING_OPTIONS]; + case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_CHEAT_OPTIONS]; + case MENU_ENUM_LABEL_DISK_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_DISK_OPTIONS]; + case MENU_ENUM_LABEL_SHADER_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_SHADER_OPTIONS]; + case MENU_ENUM_LABEL_ACHIEVEMENT_LIST: + return stripes->textures.list[STRIPES_TEXTURE_ACHIEVEMENT_LIST]; + case MENU_ENUM_LABEL_ACHIEVEMENT_LIST_HARDCORE: + return stripes->textures.list[STRIPES_TEXTURE_ACHIEVEMENT_LIST]; + case MENU_ENUM_LABEL_SAVE_STATE: + return stripes->textures.list[STRIPES_TEXTURE_SAVESTATE]; + case MENU_ENUM_LABEL_LOAD_STATE: + return stripes->textures.list[STRIPES_TEXTURE_LOADSTATE]; + case MENU_ENUM_LABEL_PARENT_DIRECTORY: + case MENU_ENUM_LABEL_UNDO_LOAD_STATE: + case MENU_ENUM_LABEL_UNDO_SAVE_STATE: + return stripes->textures.list[STRIPES_TEXTURE_UNDO]; + case MENU_ENUM_LABEL_TAKE_SCREENSHOT: + return stripes->textures.list[STRIPES_TEXTURE_SCREENSHOT]; + case MENU_ENUM_LABEL_DELETE_ENTRY: + return stripes->textures.list[STRIPES_TEXTURE_CLOSE]; + case MENU_ENUM_LABEL_RESTART_CONTENT: + return stripes->textures.list[STRIPES_TEXTURE_RELOAD]; + case MENU_ENUM_LABEL_RENAME_ENTRY: + return stripes->textures.list[STRIPES_TEXTURE_RENAME]; + case MENU_ENUM_LABEL_RESUME_CONTENT: + return stripes->textures.list[STRIPES_TEXTURE_RESUME]; + case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: + case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: + return stripes->textures.list[STRIPES_TEXTURE_SAVESTATE]; + case MENU_ENUM_LABEL_FAVORITES: + case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: + return stripes->textures.list[STRIPES_TEXTURE_FOLDER]; + case MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR: + return stripes->textures.list[STRIPES_TEXTURE_RDB]; + default: + break; + } + + switch(type) + { + case FILE_TYPE_DIRECTORY: + return stripes->textures.list[STRIPES_TEXTURE_FOLDER]; + case FILE_TYPE_PLAIN: + case FILE_TYPE_IN_CARCHIVE: + return stripes->textures.list[STRIPES_TEXTURE_FILE]; + case FILE_TYPE_RPL_ENTRY: + if (core_node) + return core_node->content_icon; + + switch (stripes_get_system_tab(stripes, + (unsigned)stripes->categories_selection_ptr)) + { + case STRIPES_SYSTEM_TAB_FAVORITES: + return stripes->textures.list[STRIPES_TEXTURE_FAVORITE]; + case STRIPES_SYSTEM_TAB_MUSIC: + return stripes->textures.list[STRIPES_TEXTURE_MUSIC]; +#ifdef HAVE_IMAGEVIEWER + case STRIPES_SYSTEM_TAB_IMAGES: + return stripes->textures.list[STRIPES_TEXTURE_IMAGE]; +#endif +#ifdef HAVE_FFMPEG + case STRIPES_SYSTEM_TAB_VIDEO: + return stripes->textures.list[STRIPES_TEXTURE_MOVIE]; +#endif + default: + break; + } + return stripes->textures.list[STRIPES_TEXTURE_FILE]; + case FILE_TYPE_CARCHIVE: + return stripes->textures.list[STRIPES_TEXTURE_ZIP]; + case FILE_TYPE_MUSIC: + return stripes->textures.list[STRIPES_TEXTURE_MUSIC]; + case FILE_TYPE_IMAGE: + case FILE_TYPE_IMAGEVIEWER: + return stripes->textures.list[STRIPES_TEXTURE_IMAGE]; + case FILE_TYPE_MOVIE: + return stripes->textures.list[STRIPES_TEXTURE_MOVIE]; + case FILE_TYPE_CORE: + case FILE_TYPE_DIRECT_LOAD: + return stripes->textures.list[STRIPES_TEXTURE_CORE]; + case FILE_TYPE_RDB: + return stripes->textures.list[STRIPES_TEXTURE_RDB]; + case FILE_TYPE_CURSOR: + return stripes->textures.list[STRIPES_TEXTURE_CURSOR]; + case FILE_TYPE_PLAYLIST_ENTRY: + case MENU_SETTING_ACTION_RUN: + return stripes->textures.list[STRIPES_TEXTURE_RUN]; + case MENU_SETTING_ACTION_CLOSE: + return stripes->textures.list[STRIPES_TEXTURE_CLOSE]; + case MENU_SETTING_ACTION_SAVESTATE: + return stripes->textures.list[STRIPES_TEXTURE_SAVESTATE]; + case MENU_SETTING_ACTION_LOADSTATE: + return stripes->textures.list[STRIPES_TEXTURE_LOADSTATE]; + case FILE_TYPE_RDB_ENTRY: + case MENU_SETTING_ACTION_CORE_INFORMATION: + return stripes->textures.list[STRIPES_TEXTURE_CORE_INFO]; + case MENU_SETTING_ACTION_CORE_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_CORE_OPTIONS]; + case MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_INPUT_REMAPPING_OPTIONS]; + case MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_CHEAT_OPTIONS]; + case MENU_SETTING_ACTION_CORE_DISK_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_DISK_OPTIONS]; + case MENU_SETTING_ACTION_CORE_SHADER_OPTIONS: + return stripes->textures.list[STRIPES_TEXTURE_SHADER_OPTIONS]; + case MENU_SETTING_ACTION_SCREENSHOT: + return stripes->textures.list[STRIPES_TEXTURE_SCREENSHOT]; + case MENU_SETTING_ACTION_DELETE_ENTRY: + return stripes->textures.list[STRIPES_TEXTURE_CLOSE]; + case MENU_SETTING_ACTION_RESET: + return stripes->textures.list[STRIPES_TEXTURE_RELOAD]; + case MENU_SETTING_ACTION: + if (stripes->depth == 3) + return stripes->textures.list[STRIPES_TEXTURE_SUBSETTING]; + return stripes->textures.list[STRIPES_TEXTURE_SETTING]; + case MENU_SETTING_GROUP: + return stripes->textures.list[STRIPES_TEXTURE_SETTING]; + case MENU_INFO_MESSAGE: + return stripes->textures.list[STRIPES_TEXTURE_CORE_INFO]; + case MENU_WIFI: + return stripes->textures.list[STRIPES_TEXTURE_WIFI]; +#ifdef HAVE_NETWORKING + case MENU_ROOM: + return stripes->textures.list[STRIPES_TEXTURE_ROOM]; +#if 0 + /* stub these out until we have the icons */ + case MENU_ROOM_LAN: + return stripes->textures.list[STRIPES_TEXTURE_ROOM_LAN]; + case MENU_ROOM_MITM: + return stripes->textures.list[STRIPES_TEXTURE_ROOM_MITM]; +#endif +#endif + } + +#ifdef HAVE_CHEEVOS + if ( + (type >= MENU_SETTINGS_CHEEVOS_START) && + (type < MENU_SETTINGS_NETPLAY_ROOMS_START) + ) + { + int new_id = type - MENU_SETTINGS_CHEEVOS_START; + if (get_badge_texture(new_id) != 0) + return get_badge_texture(new_id); + /* Should be replaced with placeholder badge icon. */ + return stripes->textures.list[STRIPES_TEXTURE_SUBSETTING]; + } +#endif + + return stripes->textures.list[STRIPES_TEXTURE_SUBSETTING]; +} + +static void stripes_calculate_visible_range(const stripes_handle_t *stripes, + unsigned height, size_t list_size, unsigned current, + unsigned *first, unsigned *last) +{ + unsigned j; + float base_y = stripes->margins_screen_top; + + *first = 0; + *last = list_size ? list_size - 1 : 0; + + if (current) + { + for (j = current; j-- > 0; ) + { + float bottom = stripes_item_y(stripes, j, current) + + base_y + stripes->icon_size; + + if (bottom < 0) + break; + + *first = j; + } + } + + for (j = current+1; j < list_size; j++) + { + float top = stripes_item_y(stripes, j, current) + base_y; + + if (top > height) + break; + + *last = j; + } +} + +static int stripes_draw_item( + video_frame_info_t *video_info, + menu_entry_t *entry, + math_matrix_4x4 *mymat, + stripes_handle_t *stripes, + stripes_node_t *core_node, + file_list_t *list, + float *color, + const char *thumb_ident, + const char *left_thumb_ident, + uint64_t frame_count, + size_t i, + size_t current, + unsigned width, + unsigned height + ) +{ + float icon_x, icon_y, label_offset; + menu_animation_ctx_ticker_t ticker; + char tmp[255]; + char *ticker_str = NULL; + unsigned entry_type = 0; + const float half_size = stripes->icon_size / 2.0f; + uintptr_t texture_switch = 0; + bool do_draw_text = false; + unsigned ticker_limit = 35 * stripes_scale_mod[0]; + stripes_node_t * node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, i); + settings_t *settings = config_get_ptr(); + + if (!node) + goto iterate; + + tmp[0] = '\0'; + + icon_y = stripes->margins_screen_top + node->y + half_size; + + if (icon_y < half_size) + goto iterate; + + if (icon_y > height + stripes->icon_size) + goto end; + + icon_x = node->x + stripes->margins_screen_left + + stripes->icon_spacing_horizontal - half_size; + + if (icon_x < -half_size || icon_x > width) + goto iterate; + + entry_type = menu_entry_get_type_new(entry); + + if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY) + { + char entry_path[PATH_MAX_LENGTH] = {0}; + strlcpy(entry_path, entry->path, sizeof(entry_path)); + + fill_short_pathname_representation(entry_path, entry_path, + sizeof(entry_path)); + + if (!string_is_empty(entry_path)) + { + if (!string_is_empty(entry->path)) + free(entry->path); + entry->path = strdup(entry_path); + } + } + + if (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)) || + (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))) + { + if (stripes->textures.list[STRIPES_TEXTURE_SWITCH_OFF]) + texture_switch = stripes->textures.list[STRIPES_TEXTURE_SWITCH_OFF]; + else + do_draw_text = true; + } + else if (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)) || + (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON)))) + { + if (stripes->textures.list[STRIPES_TEXTURE_SWITCH_ON]) + texture_switch = stripes->textures.list[STRIPES_TEXTURE_SWITCH_ON]; + else + do_draw_text = true; + } + else + { + if (!string_is_empty(entry->value)) + { + if ( + string_is_equal(entry->value, "...") || + string_is_equal(entry->value, "(COMP)") || + string_is_equal(entry->value, "(CORE)") || + string_is_equal(entry->value, "(MOVIE)") || + string_is_equal(entry->value, "(MUSIC)") || + string_is_equal(entry->value, "(DIR)") || + string_is_equal(entry->value, "(RDB)") || + string_is_equal(entry->value, "(CURSOR)")|| + string_is_equal(entry->value, "(CFILE)") || + string_is_equal(entry->value, "(FILE)") || + string_is_equal(entry->value, "(IMAGE)") + ) + { + } + else + do_draw_text = true; + } + else + do_draw_text = true; + + } + + if (string_is_empty(entry->value)) + { + if (stripes->savestate_thumbnail || + (!string_is_equal + (thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)) + && stripes->thumbnail) || + (!string_is_equal + (left_thumb_ident, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)) + && stripes->left_thumbnail + && settings->bools.menu_xmb_vertical_thumbnails) + ) + ticker_limit = 40 * stripes_scale_mod[1]; + else + ticker_limit = 70 * stripes_scale_mod[2]; + } + + if (!string_is_empty(entry->path)) + ticker_str = menu_entry_get_rich_label(entry); + + ticker.s = tmp; + ticker.len = ticker_limit; + ticker.idx = frame_count / 20; + ticker.str = ticker_str; + ticker.selected = (i == current); + + if (ticker.str) + menu_animation_ticker(&ticker); + + label_offset = stripes->margins_label_top; + if (i == current && width > 320 && height > 240 + && !string_is_empty(entry->sublabel)) + { + char entry_sublabel[255] = {0}; + + label_offset = - stripes->margins_label_top; + + word_wrap(entry_sublabel, entry->sublabel, 50 * stripes_scale_mod[3], true); + + stripes_draw_text(video_info, stripes, entry_sublabel, + node->x + stripes->margins_screen_left + + stripes->icon_spacing_horizontal + stripes->margins_label_left, + stripes->margins_screen_top + node->y + stripes->margins_label_top*3.5, + 1, node->label_alpha, TEXT_ALIGN_LEFT, + width, height, stripes->font2); + } + + stripes_draw_text(video_info, stripes, tmp, + node->x + stripes->margins_screen_left + + stripes->icon_spacing_horizontal + stripes->margins_label_left, + stripes->margins_screen_top + node->y + label_offset, + 1, node->label_alpha, TEXT_ALIGN_LEFT, + width, height, stripes->font); + + tmp[0] = '\0'; + + ticker.s = tmp; + ticker.len = 35 * stripes_scale_mod[7]; + ticker.idx = frame_count / 20; + ticker.selected = (i == current); + + if (!string_is_empty(entry->value)) + { + ticker.str = entry->value; + menu_animation_ticker(&ticker); + } + + if (do_draw_text) + stripes_draw_text(video_info, stripes, tmp, + node->x + + + stripes->margins_screen_left + + stripes->icon_spacing_horizontal + + stripes->margins_label_left + + stripes->margins_setting_left, + stripes->margins_screen_top + node->y + stripes->margins_label_top, + 1, + node->label_alpha, + TEXT_ALIGN_LEFT, + width, height, stripes->font); + + + menu_display_set_alpha(color, MIN(node->alpha, stripes->alpha)); + + if (color[3] != 0) + { + math_matrix_4x4 mymat_tmp; + menu_display_ctx_rotate_draw_t rotate_draw; + uintptr_t texture = stripes_icon_get_id(stripes, core_node, node, + entry->enum_idx, entry_type, (i == current)); + float x = icon_x; + float y = icon_y; + float rotation = 0; + float scale_factor = node->zoom; + + rotate_draw.matrix = &mymat_tmp; + rotate_draw.rotation = rotation; + rotate_draw.scale_x = scale_factor; + rotate_draw.scale_y = scale_factor; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + + stripes_draw_icon(video_info, + stripes->icon_size, + &mymat_tmp, + texture, + x, + y, + width, + height, + 1.0, + rotation, + scale_factor, + &color[0], + stripes->shadow_offset); + } + + menu_display_set_alpha(color, MIN(node->alpha, stripes->alpha)); + + if (texture_switch != 0 && color[3] != 0) + stripes_draw_icon(video_info, + stripes->icon_size, + mymat, + texture_switch, + node->x + stripes->margins_screen_left + + stripes->icon_spacing_horizontal + + stripes->icon_size / 2.0 + stripes->margins_setting_left, + stripes->margins_screen_top + node->y + stripes->icon_size / 2.0, + width, height, + node->alpha, + 0, + 1, + &color[0], + stripes->shadow_offset); + +iterate: + if (!string_is_empty(ticker_str)) + free(ticker_str); + return 0; + +end: + if (!string_is_empty(ticker_str)) + free(ticker_str); + return -1; +} + +static void stripes_draw_items( + video_frame_info_t *video_info, + stripes_handle_t *stripes, + file_list_t *list, + size_t current, size_t cat_selection_ptr, float *color, + unsigned width, unsigned height) +{ + size_t i; + unsigned first, last; + math_matrix_4x4 mymat; + menu_display_ctx_rotate_draw_t rotate_draw; + stripes_node_t *core_node = NULL; + size_t end = 0; + uint64_t frame_count = stripes ? stripes->frame_count : 0; + const char *thumb_ident = stripes_thumbnails_ident('R'); + const char *left_thumb_ident= stripes_thumbnails_ident('L'); + + if (!list || !list->size || !stripes) + return; + + if (cat_selection_ptr > stripes->system_tab_end) + core_node = stripes_get_userdata_from_horizontal_list( + stripes, (unsigned)(cat_selection_ptr - (stripes->system_tab_end + 1))); + + end = file_list_get_size(list); + + rotate_draw.matrix = &mymat; + rotate_draw.rotation = 0; + rotate_draw.scale_x = 1; + rotate_draw.scale_y = 1; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + + menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); + + if (list == stripes->selection_buf_old) + { + stripes_node_t *node = (stripes_node_t*) + file_list_get_userdata_at_offset(list, current); + + if (node && (uint8_t)(255 * node->alpha) == 0) + return; + + i = 0; + } + + first = i; + last = end - 1; + + stripes_calculate_visible_range(stripes, height, end, current, &first, &last); + + menu_display_blend_begin(video_info); + + for (i = first; i <= last; i++) + { + int ret; + menu_entry_t entry; + menu_entry_init(&entry); + menu_entry_get(&entry, 0, i, list, true); + ret = stripes_draw_item(video_info, + &entry, + &mymat, + stripes, core_node, + list, color, thumb_ident, left_thumb_ident, + frame_count, + i, current, + width, height); + menu_entry_free(&entry); + if (ret == -1) + break; + } + + menu_display_blend_end(video_info); +} + +static void stripes_render(void *data, bool is_idle) +{ + size_t i; + float delta_time; + menu_animation_ctx_delta_t delta; + settings_t *settings = config_get_ptr(); + stripes_handle_t *stripes = (stripes_handle_t*)data; + unsigned end = (unsigned)menu_entries_get_size(); + bool mouse_enable = settings->bools.menu_mouse_enable; + bool pointer_enable = settings->bools.menu_pointer_enable; + + if (!stripes) + return; + + menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time); + + delta.current = delta_time; + + if (menu_animation_get_ideal_delta_time(&delta)) + menu_animation_update(delta.ideal); + + if (pointer_enable || mouse_enable) + { + size_t selection = menu_navigation_get_selection(); + int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS); + int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS) + + (stripes->cursor_size/2); + unsigned first = 0, last = end; + unsigned height; + + video_driver_get_size(NULL, &height); + + if (height) + stripes_calculate_visible_range(stripes, height, + end, selection, &first, &last); + + for (i = first; i <= last; i++) + { + float item_y1 = stripes->margins_screen_top + + stripes_item_y(stripes, (int)i, selection); + float item_y2 = item_y1 + stripes->icon_size; + + if (pointer_enable) + { + if (pointer_y > item_y1 && pointer_y < item_y2) + menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &i); + } + + if (mouse_enable) + { + if (mouse_y > item_y1 && mouse_y < item_y2) + menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i); + } + } + } + + menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); + + if (i >= end) + { + i = 0; + menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &i); + } + + menu_animation_ctl(MENU_ANIMATION_CTL_CLEAR_ACTIVE, NULL); +} + +static bool stripes_shader_pipeline_active(video_frame_info_t *video_info) +{ + if (string_is_not_equal(menu_driver_ident(), "stripes")) + return false; + if (video_info->menu_shader_pipeline == XMB_SHADER_PIPELINE_WALLPAPER) + return false; + return true; +} + +static void stripes_draw_bg( + stripes_handle_t *stripes, + video_frame_info_t *video_info, + unsigned width, + unsigned height, + float alpha, + uintptr_t texture_id, + float *stripes_coord_black, + float *stripes_coord_white) +{ + menu_display_ctx_draw_t draw; + + bool running = video_info->libretro_running; + + draw.x = 0; + draw.y = 0; + draw.texture = texture_id; + draw.width = width; + draw.height = height; + draw.color = &stripes_coord_black[0]; + draw.vertex = NULL; + draw.tex_coord = NULL; + draw.vertex_count = 4; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + draw.pipeline.active = stripes_shader_pipeline_active(video_info); + + menu_display_blend_begin(video_info); + menu_display_set_viewport(video_info->width, video_info->height); + +#ifdef HAVE_SHADERPIPELINE + if (video_info->menu_shader_pipeline > XMB_SHADER_PIPELINE_WALLPAPER + && + (video_info->xmb_color_theme != XMB_THEME_WALLPAPER)) + { + draw.color = stripes_gradient_ident(video_info); + + if (running) + menu_display_set_alpha(draw.color, stripes_coord_black[3]); + else + menu_display_set_alpha(draw.color, stripes_coord_white[3]); + + menu_display_draw_gradient(&draw, video_info); + + draw.pipeline.id = VIDEO_SHADER_MENU_2; + + switch (video_info->menu_shader_pipeline) + { + case XMB_SHADER_PIPELINE_RIBBON: + draw.pipeline.id = VIDEO_SHADER_MENU; + break; + case XMB_SHADER_PIPELINE_SIMPLE_SNOW: + draw.pipeline.id = VIDEO_SHADER_MENU_3; + break; + case XMB_SHADER_PIPELINE_SNOW: + draw.pipeline.id = VIDEO_SHADER_MENU_4; + break; + case XMB_SHADER_PIPELINE_BOKEH: + draw.pipeline.id = VIDEO_SHADER_MENU_5; + break; + case XMB_SHADER_PIPELINE_SNOWFLAKE: + draw.pipeline.id = VIDEO_SHADER_MENU_6; + break; + default: + break; + } + + menu_display_draw_pipeline(&draw, video_info); + } + else +#endif + { + uintptr_t texture = draw.texture; + + if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER) + draw.color = stripes_gradient_ident(video_info); + + if (running) + menu_display_set_alpha(draw.color, stripes_coord_black[3]); + else + menu_display_set_alpha(draw.color, stripes_coord_white[3]); + + if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER) + menu_display_draw_gradient(&draw, video_info); + + { + float override_opacity = video_info->menu_wallpaper_opacity; + bool add_opacity = false; + + draw.texture = texture; + menu_display_set_alpha(draw.color, stripes_coord_white[3]); + + if (draw.texture) + draw.color = &stripes_coord_white[0]; + + if (running || video_info->xmb_color_theme == XMB_THEME_WALLPAPER) + add_opacity = true; + + menu_display_draw_bg(&draw, video_info, add_opacity, override_opacity); + } + } + + menu_display_draw(&draw, video_info); + menu_display_blend_end(video_info); +} + +static void stripes_draw_dark_layer( + stripes_handle_t *stripes, + video_frame_info_t *video_info, + unsigned width, + unsigned height) +{ + menu_display_ctx_draw_t draw; + struct video_coords coords; + float black[16] = { + 0, 0, 0, 1, + 0, 0, 0, 1, + 0, 0, 0, 1, + 0, 0, 0, 1, + }; + + menu_display_set_alpha(black, MIN(stripes->alpha, 0.75)); + + coords.vertices = 4; + coords.vertex = NULL; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + coords.color = &black[0]; + + draw.x = 0; + draw.y = 0; + draw.width = width; + draw.height = height; + draw.coords = &coords; + draw.matrix_data = NULL; + draw.texture = menu_display_white_texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + + menu_display_blend_begin(video_info); + menu_display_draw(&draw, video_info); + menu_display_blend_end(video_info); +} + +static void stripes_frame(void *data, video_frame_info_t *video_info) +{ + math_matrix_4x4 mymat; + unsigned i; + menu_display_ctx_rotate_draw_t rotate_draw; + char msg[1024]; + char title_msg[255]; + char title_truncated[255]; + size_t selection = 0; + size_t percent_width = 0; + const int min_thumb_size = 50; + bool render_background = false; + file_list_t *selection_buf = NULL; + unsigned width = video_info->width; + unsigned height = video_info->height; + const float under_thumb_margin = 0.96; + float scale_factor = 0.0f; + float pseudo_font_length = 0.0f; + stripes_handle_t *stripes = (stripes_handle_t*)data; + settings_t *settings = config_get_ptr(); + + if (!stripes) + return; + + scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100); + pseudo_font_length = stripes->icon_spacing_horizontal * 4 - stripes->icon_size / 4; + + stripes->frame_count++; + + msg[0] = '\0'; + title_msg[0] = '\0'; + title_truncated[0] = '\0'; + + font_driver_bind_block(stripes->font, &stripes->raster_block); + font_driver_bind_block(stripes->font2, &stripes->raster_block2); + + stripes->raster_block.carr.coords.vertices = 0; + stripes->raster_block2.carr.coords.vertices = 0; + + menu_display_set_alpha(stripes_coord_black, MIN( + (float)video_info->xmb_alpha_factor/100, stripes->alpha)); + menu_display_set_alpha(stripes_coord_white, stripes->alpha); + + stripes_draw_bg( + stripes, + video_info, + width, + height, + stripes->alpha, + stripes->textures.bg, + stripes_coord_black, + stripes_coord_white); + + selection = menu_navigation_get_selection(); + + strlcpy(title_truncated, + stripes->title_name, sizeof(title_truncated)); + + if (selection > 1) + { + /* skip 25 utf8 multi-byte chars */ + char *end = title_truncated; + + for(i = 0; i < 25 && *end; i++) + { + end++; + while((*end & 0xC0) == 0x80) + end++; + } + + *end = '\0'; + } + + /* Title text */ + stripes_draw_text(video_info, stripes, + title_truncated, stripes->margins_title_left, + stripes->margins_title_top, + 1, 1, TEXT_ALIGN_LEFT, + width, height, stripes->font); + + if (settings->bools.menu_core_enable && + menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0) + stripes_draw_text(video_info, stripes, title_msg, stripes->margins_title_left, + height - stripes->margins_title_bottom, 1, 1, TEXT_ALIGN_LEFT, + width, height, stripes->font); + + rotate_draw.matrix = &mymat; + rotate_draw.rotation = 0; + rotate_draw.scale_x = 1; + rotate_draw.scale_y = 1; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + menu_display_blend_begin(video_info); + + /* Save State thumbnail, right side */ + if (stripes->savestate_thumbnail) + { + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + stripes->margins_screen_left * stripes_scale_mod[5] + + stripes->icon_spacing_horizontal + pseudo_font_length, + stripes->margins_screen_top + stripes->icon_size + + stripes->savestate_thumbnail_height * stripes_scale_mod[4], + stripes->savestate_thumbnail_width * stripes_scale_mod[4], + stripes->savestate_thumbnail_height * stripes_scale_mod[4], + stripes->savestate_thumbnail); + } + + /* Right thumbnail big size */ + if (!settings->bools.menu_xmb_vertical_thumbnails || + (settings->bools.menu_xmb_vertical_thumbnails && !stripes->left_thumbnail)) + { + /* Do not draw the right thumbnail if there is no space available */ + + if (((stripes->margins_screen_top + + stripes->icon_size + min_thumb_size) <= height) && + ((stripes->margins_screen_left * stripes_scale_mod[5] + + stripes->icon_spacing_horizontal + + pseudo_font_length + min_thumb_size) <= width)) + { + if (stripes->thumbnail + && !string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + /* Limit thumbnail width */ + + float thumb_width = 0.0f; + float thumb_height = 0.0f; + float thumb_max_width = (float)width - (stripes->icon_size / 6) + - (stripes->margins_screen_left * stripes_scale_mod[5]) - + stripes->icon_spacing_horizontal - pseudo_font_length; + + #ifdef STRIPES_DEBUG + RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", + stripes->thumbnail_width, stripes->thumbnail_height); + RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); + #endif + + if (stripes->thumbnail_width * stripes_scale_mod[4] > thumb_max_width) + { + thumb_width = (stripes->thumbnail_width * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); + thumb_height = (stripes->thumbnail_height * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); + } + else + { + thumb_width = stripes->thumbnail_width * stripes_scale_mod[4]; + thumb_height = stripes->thumbnail_height * stripes_scale_mod[4]; + } + + /* Limit thumbnail height to screen height + margin. */ + + if (stripes->margins_screen_top + stripes->icon_size + thumb_height >= + ((float)height * under_thumb_margin)) + { + thumb_width = thumb_width * + ((((float)height * under_thumb_margin) - + stripes->margins_screen_top - stripes->icon_size) / + thumb_height); + thumb_height = thumb_height * + ((((float)height * under_thumb_margin) - + stripes->margins_screen_top - stripes->icon_size) / + thumb_height); + } + + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + (float)width - (stripes->icon_size / 6) - thumb_max_width + + ((thumb_max_width - thumb_width) / 2), + stripes->margins_screen_top + stripes->icon_size + thumb_height, + thumb_width, thumb_height, + stripes->thumbnail); + } + } + } + + /* Left thumbnail in the left margin */ + /* Do not draw the left thumbnail if there is no space available */ + if (!settings->bools.menu_xmb_vertical_thumbnails && + (stripes->margins_screen_top + stripes->icon_size * + (!(stripes->depth == 1)? 2.1 : 1) + min_thumb_size) + <= (float)height) + { + /* Left Thumbnail in the left margin */ + + if (stripes->left_thumbnail + && !string_is_equal(stripes_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + /* Limit left thumbnail width */ + + float left_thumb_width = 0.0f; + float left_thumb_height = 0.0f; + float thumb_max_width = stripes->icon_size * 3.4; + + #ifdef STRIPES_DEBUG + RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n", + stripes->left_thumbnail_width, stripes->left_thumbnail_height); + RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height); + #endif + + if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) + { + left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + } + else + { + left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; + left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; + } + + /* Limit left thumbnail height to screen height + margin. */ + if (stripes->margins_screen_top + stripes->icon_size * + (!(stripes->depth == 1)? 2.1 : 1) + + left_thumb_height >= + ((float)height - (96.0 * scale_factor))) + { + left_thumb_width = left_thumb_width * + ((((float)height - (96.0 * scale_factor)) + - stripes->margins_screen_top - + (stripes->icon_size * (!(stripes->depth == 1)? 2.1 : 1))) / + left_thumb_height); + + left_thumb_height = left_thumb_height * + ((((float)height - (96.0 * scale_factor)) + - stripes->margins_screen_top - + (stripes->icon_size * (!(stripes->depth == 1)? 2.1 : 1))) / + left_thumb_height); + } + else + { + left_thumb_width = left_thumb_width; + left_thumb_height = left_thumb_height; + } + + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + (stripes->icon_size / 6) + + ((thumb_max_width - left_thumb_width) / 2), + stripes->margins_screen_top + stripes->icon_size * + (!(stripes->depth == 1)? 2.1 : 1) + left_thumb_height, + left_thumb_width, left_thumb_height, + stripes->left_thumbnail); + } + } + + /* No Right Thumbnail, draw only the left one big size */ + if (settings->bools.menu_xmb_vertical_thumbnails && !stripes->thumbnail) + { + /* Do not draw the left thumbnail if there is no space available */ + + if (((stripes->margins_screen_top + + stripes->icon_size + min_thumb_size) <= height) && + ((stripes->margins_screen_left * stripes_scale_mod[5] + + stripes->icon_spacing_horizontal + + pseudo_font_length + min_thumb_size) <= width)) + { + if (stripes->left_thumbnail + && !string_is_equal(stripes_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + /* Limit left thumbnail width */ + + float left_thumb_width = 0.0f; + float left_thumb_height = 0.0f; + float thumb_max_width = (float)width - (stripes->icon_size / 6) + - (stripes->margins_screen_left * stripes_scale_mod[5]) - + stripes->icon_spacing_horizontal - pseudo_font_length; + + #ifdef STRIPES_DEBUG + RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", + stripes->thumbnail_width, stripes->thumbnail_height); + RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); + #endif + + if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) + { + left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + } + else + { + left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; + left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; + } + + /* Limit left thumbnail height to screen height + margin. */ + + if (stripes->margins_screen_top + stripes->icon_size + left_thumb_height >= + ((float)height * under_thumb_margin)) + { + left_thumb_width = left_thumb_width * + ((((float)height * under_thumb_margin) - + stripes->margins_screen_top - stripes->icon_size) / + left_thumb_height); + left_thumb_height = left_thumb_height * + ((((float)height * under_thumb_margin) - + stripes->margins_screen_top - stripes->icon_size) / + left_thumb_height); + } + + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + (float)width - (stripes->icon_size / 6) - thumb_max_width + + ((thumb_max_width - left_thumb_width) / 2), + stripes->margins_screen_top + stripes->icon_size + left_thumb_height, + left_thumb_width, left_thumb_height, + stripes->left_thumbnail); + } + } + } + + /* Clock image */ + menu_display_set_alpha(stripes_coord_white, MIN(stripes->alpha, 1.00f)); + + if (video_info->battery_level_enable) + { + char msg[12]; + static retro_time_t last_time = 0; + bool charging = false; + retro_time_t current_time = cpu_features_get_time_usec(); + int percent = 0; + enum frontend_powerstate state = get_last_powerstate(&percent); + + if (state == FRONTEND_POWERSTATE_CHARGING) + charging = true; + + if (current_time - last_time >= BATTERY_LEVEL_CHECK_INTERVAL) + { + last_time = current_time; + task_push_get_powerstate(); + } + + *msg = '\0'; + + if (percent > 0) + { + size_t x_pos = stripes->icon_size / 6; + size_t x_pos_icon = stripes->margins_title_left; + + if (stripes_coord_white[3] != 0) + stripes_draw_icon(video_info, + stripes->icon_size, + &mymat, + stripes->textures.list[charging + ? STRIPES_TEXTURE_BATTERY_CHARGING : STRIPES_TEXTURE_BATTERY_FULL], + width - (stripes->icon_size / 2) - x_pos_icon, + stripes->icon_size, + width, + height, + 1, + 0, + 1, + &stripes_coord_white[0], + stripes->shadow_offset); + + snprintf(msg, sizeof(msg), "%d%%", percent); + + percent_width = (unsigned) + font_driver_get_message_width( + stripes->font, msg, (unsigned)strlen(msg), 1); + + stripes_draw_text(video_info, stripes, msg, + width - stripes->margins_title_left - x_pos, + stripes->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT, + width, height, stripes->font); + } + } + + if (video_info->timedate_enable) + { + menu_display_ctx_datetime_t datetime; + char timedate[255]; + int x_pos = 0; + + if (stripes_coord_white[3] != 0) + { + int x_pos = 0; + + if (percent_width) + x_pos = percent_width + (stripes->icon_size / 2.5); + + stripes_draw_icon(video_info, + stripes->icon_size, + &mymat, + stripes->textures.list[STRIPES_TEXTURE_CLOCK], + width - stripes->icon_size - x_pos, + stripes->icon_size, + width, + height, + 1, + 0, + 1, + &stripes_coord_white[0], + stripes->shadow_offset); + } + + timedate[0] = '\0'; + + datetime.s = timedate; + datetime.len = sizeof(timedate); + datetime.time_mode = 4; + + menu_display_timedate(&datetime); + + if (percent_width) + x_pos = percent_width + (stripes->icon_size / 2.5); + + stripes_draw_text(video_info, stripes, timedate, + width - stripes->margins_title_left - stripes->icon_size / 4 - x_pos, + stripes->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT, + width, height, stripes->font); + } + + /* Arrow image */ + menu_display_set_alpha(stripes_coord_white, + MIN(stripes->textures_arrow_alpha, stripes->alpha)); + + if (stripes_coord_white[3] != 0) + stripes_draw_icon(video_info, + stripes->icon_size, + &mymat, + stripes->textures.list[STRIPES_TEXTURE_ARROW], + stripes->x + stripes->margins_screen_left + + stripes->icon_spacing_horizontal - + stripes->icon_size / 2.0 + stripes->icon_size, + stripes->margins_screen_top + + stripes->icon_size / 2.0 + stripes->icon_spacing_vertical + * stripes->active_item_factor, + width, + height, + stripes->textures_arrow_alpha, + 0, + 1, + &stripes_coord_white[0], + stripes->shadow_offset); + + menu_display_blend_begin(video_info); + + /* Horizontal tab icons */ + for (i = 0; i <= stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; i++) + { + stripes_node_t *node = stripes_get_node(stripes, i); + + if (!node) + continue; + + menu_display_set_alpha(stripes_item_color, MIN(node->alpha, stripes->alpha)); + + if (stripes_item_color[3] != 0) + { + menu_display_ctx_rotate_draw_t rotate_draw; + math_matrix_4x4 mymat; + uintptr_t texture = node->icon; + float x = stripes->x + stripes->categories_x_pos + + stripes->margins_screen_left + + stripes->icon_spacing_horizontal + * (i + 1) - stripes->icon_size / 2.0; + float y = stripes->margins_screen_top + + stripes->icon_size / 2.0; + float rotation = 0; + float scale_factor = node->zoom; + + rotate_draw.matrix = &mymat; + rotate_draw.rotation = rotation; + rotate_draw.scale_x = scale_factor; + rotate_draw.scale_y = scale_factor; + rotate_draw.scale_z = 1; + rotate_draw.scale_enable = true; + + menu_display_rotate_z(&rotate_draw, video_info); + + stripes_draw_icon(video_info, + stripes->icon_size, + &mymat, + texture, + x, + y, + width, + height, + 1.0, + rotation, + scale_factor, + &stripes_item_color[0], + stripes->shadow_offset); + } + } + + /* Right side 2 thumbnails on top of each other */ + /* here to be displayed above the horizontal icons */ + if (stripes->left_thumbnail && stripes->thumbnail && settings->bools.menu_xmb_vertical_thumbnails) + { + /* Do not draw the right thumbnail if there is no space available */ + if (((stripes->margins_screen_top + + stripes->icon_size + min_thumb_size) <= height) && + ((stripes->margins_screen_left * stripes_scale_mod[5] + + stripes->icon_spacing_horizontal + + pseudo_font_length + min_thumb_size) <= width)) + { + if (stripes->thumbnail && + !string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + /* Limit right thumbnail width */ + + float thumb_width = 0.0f; + float thumb_height = 0.0f; + float thumb_max_width = (float)width - (stripes->icon_size / 6) - + (stripes->margins_screen_left * stripes_scale_mod[5]) - + stripes->icon_spacing_horizontal - pseudo_font_length; + + #ifdef STRIPES_DEBUG + RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", + stripes->thumbnail_width, stripes->thumbnail_height); + RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); + #endif + + if (stripes->thumbnail_width * stripes_scale_mod[4] > thumb_max_width) + { + thumb_width = (stripes->thumbnail_width * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); + thumb_height = (stripes->thumbnail_height * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); + } + else + { + thumb_width = stripes->thumbnail_width * stripes_scale_mod[4]; + thumb_height = stripes->thumbnail_height * stripes_scale_mod[4]; + } + + /* Limit right thumbnail height to usable area. */ + + if (thumb_height >= + ((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) + { + thumb_width = thumb_width * + ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / + thumb_height); + thumb_height = thumb_height * + ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / + thumb_height); + } + + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + (float)width - (stripes->icon_size / 6) - thumb_max_width + + ((thumb_max_width - thumb_width) / 2), + stripes->icon_size + ((((float)height / 2 - + (stripes->icon_size + (stripes->icon_size/12))) - thumb_height) / 2) + + thumb_height, + thumb_width, thumb_height, + stripes->thumbnail); + } + } + + /* Do not draw the left thumbnail if there is no space available */ + + if (((stripes->margins_screen_top + + stripes->icon_size + min_thumb_size) <= height) && + ((stripes->margins_screen_left * stripes_scale_mod[5] + + stripes->icon_spacing_horizontal + + pseudo_font_length + min_thumb_size) <= width)) + { + if (stripes->left_thumbnail && + !string_is_equal(stripes_thumbnails_ident('L'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + { + /* Limit left thumbnail width */ + + float left_thumb_width = 0.0f; + float left_thumb_height = 0.0f; + float thumb_max_width = (float)width - (stripes->icon_size / 6) - + (stripes->margins_screen_left * stripes_scale_mod[5]) - + stripes->icon_spacing_horizontal - pseudo_font_length; + + #ifdef STRIPES_DEBUG + RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n", + stripes->left_thumbnail_width, stripes->left_thumbnail_height); + RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height); + #endif + + if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) + { + left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * + (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); + } + else + { + left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; + left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; + } + + /* Limit left thumbnail height to usable area. */ + + if (left_thumb_height >= + ((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) + { + left_thumb_width = left_thumb_width * + ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / + left_thumb_height); + left_thumb_height = left_thumb_height * + ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / + left_thumb_height); + } + + stripes_draw_thumbnail(video_info, + stripes, &stripes_coord_white[0], width, height, + (float)width - (stripes->icon_size / 6) - thumb_max_width + + ((thumb_max_width - left_thumb_width) / 2), + stripes->icon_size + + (((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) + + (((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) - + left_thumb_height) / 2) + left_thumb_height, + left_thumb_width, left_thumb_height, + stripes->left_thumbnail); + } + } + } + + menu_display_blend_end(video_info); + + /* Vertical icons */ + if (stripes) + stripes_draw_items( + video_info, + stripes, + stripes->selection_buf_old, + stripes->selection_ptr_old, + (stripes_list_get_size(stripes, MENU_LIST_PLAIN) > 1) + ? stripes->categories_selection_ptr : + stripes->categories_selection_ptr_old, + &stripes_item_color[0], + width, + height); + + selection_buf = menu_entries_get_selection_buf_ptr(0); + + if (stripes) + stripes_draw_items( + video_info, + stripes, + selection_buf, + selection, + stripes->categories_selection_ptr, + &stripes_item_color[0], + width, + height); + + font_driver_flush(video_info->width, video_info->height, stripes->font, + video_info); + font_driver_bind_block(stripes->font, NULL); + + font_driver_flush(video_info->width, video_info->height, stripes->font2, + video_info); + font_driver_bind_block(stripes->font2, NULL); + + if (menu_input_dialog_get_display_kb()) + { + const char *str = menu_input_dialog_get_buffer(); + const char *label = menu_input_dialog_get_label_buffer(); + + snprintf(msg, sizeof(msg), "%s\n%s", label, str); + render_background = true; + } + + if (!string_is_empty(stripes->box_message)) + { + strlcpy(msg, stripes->box_message, + sizeof(msg)); + free(stripes->box_message); + stripes->box_message = NULL; + render_background = true; + } + + if (render_background) + { + stripes_draw_dark_layer(stripes, video_info, width, height); + stripes_render_messagebox_internal( + video_info, stripes, msg, &stripes_coord_white[0]); + } + + /* Cursor image */ + if (stripes->mouse_show) + { + menu_display_set_alpha(stripes_coord_white, MIN(stripes->alpha, 1.00f)); + menu_display_draw_cursor( + video_info, + &stripes_coord_white[0], + stripes->cursor_size, + stripes->textures.list[STRIPES_TEXTURE_POINTER], + menu_input_mouse_state(MENU_MOUSE_X_AXIS), + menu_input_mouse_state(MENU_MOUSE_Y_AXIS), + width, + height); + } + + menu_display_unset_viewport(video_info->width, video_info->height); +} + +static void stripes_layout_ps3(stripes_handle_t *stripes, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + + float scale_factor = + (settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100); + + stripes->above_subitem_offset = 1.5; + stripes->above_item_offset = -1.0; + stripes->active_item_factor = 3.0; + stripes->under_item_offset = 5.0; + + stripes->categories_active_zoom = 1.0; + stripes->categories_passive_zoom = 0.5; + stripes->items_active_zoom = 1.0; + stripes->items_passive_zoom = 0.5; + + stripes->categories_active_alpha = 1.0; + stripes->categories_passive_alpha = 0.85; + stripes->items_active_alpha = 1.0; + stripes->items_passive_alpha = 0.85; + + stripes->shadow_offset = 2.0; + + new_font_size = 32.0 * scale_factor; + stripes->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + + + stripes->thumbnail_width = 1024.0 * scale_factor; + stripes->left_thumbnail_width = 1024.0 * scale_factor; + stripes->savestate_thumbnail_width= 460.0 * scale_factor; + stripes->cursor_size = 64.0 * scale_factor; + + stripes->icon_spacing_horizontal = 200.0 * scale_factor; + stripes->icon_spacing_vertical = 64.0 * scale_factor; + + stripes->margins_screen_top = (256+32) * scale_factor; + stripes->margins_screen_left = 336.0 * scale_factor; + + stripes->margins_title_left = 60 * scale_factor; + stripes->margins_title_top = 60 * scale_factor + new_font_size / 3; + stripes->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + + stripes->margins_label_left = 85.0 * scale_factor; + stripes->margins_label_top = new_font_size / 3.0; + + stripes->margins_setting_left = 600.0 * scale_factor * stripes_scale_mod[6]; + stripes->margins_dialog = 48 * scale_factor; + + stripes->margins_slice = 16; + + stripes->icon_size = 128.0 * scale_factor; + stripes->font_size = new_font_size; + +#ifdef STRIPES_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", stripes->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", stripes->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", stripes->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", stripes->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", stripes->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", stripes->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", stripes->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", stripes->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", stripes->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", stripes->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", stripes->icon_size); +#endif + + menu_display_set_header_height(new_header_height); +} + +static void stripes_layout_psp(stripes_handle_t *stripes, int width) +{ + unsigned new_font_size, new_header_height; + settings_t *settings = config_get_ptr(); + float scale_factor = + ((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; +#ifdef _3DS + scale_factor = + settings->uints.menu_xmb_scale_factor / 400.0; +#endif + + stripes->above_subitem_offset = 1.5; + stripes->above_item_offset = -1.0; + stripes->active_item_factor = 2.0; + stripes->under_item_offset = 3.0; + + stripes->categories_active_zoom = 1.0; + stripes->categories_passive_zoom = 1.0; + stripes->items_active_zoom = 1.0; + stripes->items_passive_zoom = 1.0; + + stripes->categories_active_alpha = 1.0; + stripes->categories_passive_alpha = 0.85; + stripes->items_active_alpha = 1.0; + stripes->items_passive_alpha = 0.85; + + stripes->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + stripes->font2_size = 24.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + stripes->margins_screen_top = (256+32) * scale_factor; + + stripes->thumbnail_width = 460.0 * scale_factor; + stripes->left_thumbnail_width = 400.0 * scale_factor; + stripes->savestate_thumbnail_width= 460.0 * scale_factor; + stripes->cursor_size = 64.0; + + stripes->icon_spacing_horizontal = 250.0 * scale_factor; + stripes->icon_spacing_vertical = 108.0 * scale_factor; + + stripes->margins_screen_left = 136.0 * scale_factor; + stripes->margins_title_left = 60 * scale_factor; + stripes->margins_title_top = 60 * scale_factor + new_font_size / 3; + stripes->margins_title_bottom = 60 * scale_factor - new_font_size / 3; + stripes->margins_label_left = 85.0 * scale_factor; + stripes->margins_label_top = new_font_size / 3.0; + stripes->margins_setting_left = 600.0 * scale_factor; + stripes->margins_dialog = 48 * scale_factor; + stripes->margins_slice = 16; + stripes->icon_size = 128.0 * scale_factor; + stripes->font_size = new_font_size; + +#ifdef STRIPES_DEBUG + RARCH_LOG("[XMB] margin screen left: %.2f\n", stripes->margins_screen_left); + RARCH_LOG("[XMB] margin screen top: %.2f\n", stripes->margins_screen_top); + RARCH_LOG("[XMB] margin title left: %.2f\n", stripes->margins_title_left); + RARCH_LOG("[XMB] margin title top: %.2f\n", stripes->margins_title_top); + RARCH_LOG("[XMB] margin title bott: %.2f\n", stripes->margins_title_bottom); + RARCH_LOG("[XMB] margin label left: %.2f\n", stripes->margins_label_left); + RARCH_LOG("[XMB] margin label top: %.2f\n", stripes->margins_label_top); + RARCH_LOG("[XMB] margin sett left: %.2f\n", stripes->margins_setting_left); + RARCH_LOG("[XMB] icon spacing hor: %.2f\n", stripes->icon_spacing_horizontal); + RARCH_LOG("[XMB] icon spacing ver: %.2f\n", stripes->icon_spacing_vertical); + RARCH_LOG("[XMB] icon size: %.2f\n", stripes->icon_size); +#endif + + menu_display_set_header_height(new_header_height); +} + +static void stripes_layout(stripes_handle_t *stripes) +{ + unsigned width, height, i, current, end; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + + video_driver_get_size(&width, &height); + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (width > 320 && height > 240) + stripes_layout_ps3(stripes, width); + else + stripes_layout_psp(stripes, width); + + current = (unsigned)selection; + end = (unsigned)menu_entries_get_size(); + + for (i = 0; i < end; i++) + { + float ia = stripes->items_passive_alpha; + float iz = stripes->items_passive_zoom; + stripes_node_t *node = (stripes_node_t*)file_list_get_userdata_at_offset( + selection_buf, i); + + if (!node) + continue; + + if (i == current) + { + ia = stripes->items_active_alpha; + iz = stripes->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = ia; + node->zoom = iz; + node->y = stripes_item_y(stripes, i, current); + } + + if (stripes->depth <= 1) + return; + + current = (unsigned)stripes->selection_ptr_old; + end = (unsigned)file_list_get_size(stripes->selection_buf_old); + + for (i = 0; i < end; i++) + { + float ia = 0; + float iz = stripes->items_passive_zoom; + stripes_node_t *node = (stripes_node_t*)file_list_get_userdata_at_offset( + stripes->selection_buf_old, i); + + if (!node) + continue; + + if (i == current) + { + ia = stripes->items_active_alpha; + iz = stripes->items_active_alpha; + } + + node->alpha = ia; + node->label_alpha = 0; + node->zoom = iz; + node->y = stripes_item_y(stripes, i, current); + node->x = stripes->icon_size * 1 * -2; + } +} + +static void stripes_ribbon_set_vertex(float *ribbon_verts, + unsigned idx, unsigned row, unsigned col) +{ + ribbon_verts[idx++] = ((float)col) / (STRIPES_RIBBON_COLS-1) * 2.0f - 1.0f; + ribbon_verts[idx++] = ((float)row) / (STRIPES_RIBBON_ROWS-1) * 2.0f - 1.0f; +} + +static void stripes_init_ribbon(stripes_handle_t * stripes) +{ + video_coords_t coords; + unsigned r, c, col; + unsigned i = 0; + video_coord_array_t *ca = menu_display_get_coords_array(); + unsigned vertices_total = STRIPES_RIBBON_VERTICES; + float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); + float *ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float)); + + /* Set up vertices */ + for (r = 0; r < STRIPES_RIBBON_ROWS - 1; r++) + { + for (c = 0; c < STRIPES_RIBBON_COLS; c++) + { + col = r % 2 ? STRIPES_RIBBON_COLS - c - 1 : c; + stripes_ribbon_set_vertex(ribbon_verts, i, r, col); + stripes_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col); + i += 4; + } + } + + coords.color = dummy; + coords.vertex = ribbon_verts; + coords.tex_coord = dummy; + coords.lut_tex_coord = dummy; + coords.vertices = vertices_total; + + video_coord_array_append(ca, &coords, coords.vertices); + + free(dummy); + free(ribbon_verts); +} + + + +static void *stripes_init(void **userdata, bool video_is_threaded) +{ + unsigned width, height; + int i; + stripes_handle_t *stripes = NULL; + settings_t *settings = config_get_ptr(); + menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu)); + float scale_value = settings->uints.menu_xmb_scale_factor; + + /* scaling multiplier formulas made from these values: */ + /* stripes_scale 50 = {2.5, 2.5, 2, 1.7, 2.5, 4, 2.4, 2.5} */ + /* stripes_scale 75 = { 2, 1.6, 1.6, 1.4, 1.5, 2.3, 1.9, 1.3} */ + if (scale_value < 100) + { + /* text length & word wrap (base 35 apply to file browser, 1st column) */ + stripes_scale_mod[0] = -0.03 * scale_value + 4.083; + /* playlist text length when thumbnail is ON (small, base 40) */ + stripes_scale_mod[1] = -0.03 * scale_value + 3.95; + /* playlist text length when thumbnail is OFF (large, base 70) */ + stripes_scale_mod[2] = -0.02 * scale_value + 3.033; + /* sub-label length & word wrap */ + stripes_scale_mod[3] = -0.014 * scale_value + 2.416; + /* thumbnail size & vertical margin from top */ + stripes_scale_mod[4] = -0.03 * scale_value + 3.916; + /* thumbnail horizontal left margin (horizontal positioning) */ + stripes_scale_mod[5] = -0.06 * scale_value + 6.933; + /* margin before 2nd column start (shaders parameters, cheats...) */ + stripes_scale_mod[6] = -0.028 * scale_value + 3.866; + /* text length & word wrap (base 35 apply to 2nd column in cheats, shaders, etc) */ + stripes_scale_mod[7] = 134.179 * pow(scale_value, -1.0778); + + for (i = 0; i < 8; i++) + if (stripes_scale_mod[i] < 1) + stripes_scale_mod[i] = 1; + } + + if (!menu) + goto error; + + if (!menu_display_init_first_driver(video_is_threaded)) + goto error; + + video_driver_get_size(&width, &height); + + stripes = (stripes_handle_t*)calloc(1, sizeof(stripes_handle_t)); + + if (!stripes) + goto error; + + *userdata = stripes; + + stripes->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t)); + + if (!stripes->selection_buf_old) + goto error; + + stripes->categories_active_idx = 0; + stripes->categories_active_idx_old = 0; + stripes->x = 0; + stripes->categories_x_pos = 0; + stripes->textures_arrow_alpha = 0; + stripes->depth = 1; + stripes->old_depth = 1; + stripes->alpha = 0; + + stripes->system_tab_end = 0; + stripes->tabs[stripes->system_tab_end] = STRIPES_SYSTEM_TAB_MAIN; + if (settings->bools.menu_content_show_settings && !settings->bools.kiosk_mode_enable) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_SETTINGS; + if (settings->bools.menu_content_show_favorites) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_FAVORITES; + if (settings->bools.menu_content_show_history) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_HISTORY; +#ifdef HAVE_IMAGEVIEWER + if (settings->bools.menu_content_show_images) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_IMAGES; +#endif + if (settings->bools.menu_content_show_music) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_MUSIC; +#ifdef HAVE_FFMPEG + if (settings->bools.menu_content_show_video) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_VIDEO; +#endif +#ifdef HAVE_NETWORKING + if (settings->bools.menu_content_show_netplay) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_NETPLAY; +#endif +#ifdef HAVE_LIBRETRODB + if (settings->bools.menu_content_show_add && !settings->bools.kiosk_mode_enable) + stripes->tabs[++stripes->system_tab_end] = STRIPES_SYSTEM_TAB_ADD; +#endif + + menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); + + /* TODO/FIXME - we don't use framebuffer at all + * for XMB, we should refactor this dependency + * away. */ + + menu_display_set_width(width); + menu_display_set_height(height); + + menu_display_allocate_white_texture(); + + stripes->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t)); + + if (stripes->horizontal_list) + stripes_init_horizontal_list(stripes); + + stripes_init_ribbon(stripes); + + return menu; + +error: + if (menu) + free(menu); + + if (stripes) + { + if (stripes->selection_buf_old) + free(stripes->selection_buf_old); + stripes->selection_buf_old = NULL; + if (stripes->horizontal_list) + { + stripes_free_list_nodes(stripes->horizontal_list, false); + file_list_free(stripes->horizontal_list); + } + stripes->horizontal_list = NULL; + } + return NULL; +} + +static void stripes_free(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (stripes) + { + if (stripes->selection_buf_old) + { + stripes_free_list_nodes(stripes->selection_buf_old, false); + file_list_free(stripes->selection_buf_old); + } + + if (stripes->horizontal_list) + { + stripes_free_list_nodes(stripes->horizontal_list, false); + file_list_free(stripes->horizontal_list); + } + + stripes->selection_buf_old = NULL; + stripes->horizontal_list = NULL; + + video_coord_array_free(&stripes->raster_block.carr); + video_coord_array_free(&stripes->raster_block2.carr); + + if (!string_is_empty(stripes->box_message)) + free(stripes->box_message); + if (!string_is_empty(stripes->thumbnail_system)) + free(stripes->thumbnail_system); + if (!string_is_empty(stripes->thumbnail_content)) + free(stripes->thumbnail_content); + if (!string_is_empty(stripes->savestate_thumbnail_file_path)) + free(stripes->savestate_thumbnail_file_path); + if (!string_is_empty(stripes->thumbnail_file_path)) + free(stripes->thumbnail_file_path); + if (!string_is_empty(stripes->left_thumbnail_file_path)) + free(stripes->left_thumbnail_file_path); + if (!string_is_empty(stripes->bg_file_path)) + free(stripes->bg_file_path); + } + + font_driver_bind_block(NULL, NULL); +} + +static void stripes_context_bg_destroy(stripes_handle_t *stripes) +{ + if (!stripes) + return; + video_driver_texture_unload(&stripes->textures.bg); + video_driver_texture_unload(&menu_display_white_texture); +} + +static bool stripes_load_image(void *userdata, void *data, enum menu_image_type type) +{ + stripes_handle_t *stripes = (stripes_handle_t*)userdata; + + if (!stripes || !data) + return false; + + switch (type) + { + case MENU_IMAGE_NONE: + break; + case MENU_IMAGE_WALLPAPER: + stripes_context_bg_destroy(stripes); + video_driver_texture_unload(&stripes->textures.bg); + video_driver_texture_load(data, + TEXTURE_FILTER_MIPMAP_LINEAR, + &stripes->textures.bg); + menu_display_allocate_white_texture(); + break; + case MENU_IMAGE_THUMBNAIL: + { + struct texture_image *img = (struct texture_image*)data; + stripes->thumbnail_height = stripes->thumbnail_width + * (float)img->height / (float)img->width; + video_driver_texture_unload(&stripes->thumbnail); + video_driver_texture_load(data, + TEXTURE_FILTER_MIPMAP_LINEAR, &stripes->thumbnail); + } + break; + case MENU_IMAGE_LEFT_THUMBNAIL: + { + struct texture_image *img = (struct texture_image*)data; + stripes->left_thumbnail_height = stripes->left_thumbnail_width + * (float)img->height / (float)img->width; + video_driver_texture_unload(&stripes->left_thumbnail); + video_driver_texture_load(data, + TEXTURE_FILTER_MIPMAP_LINEAR, &stripes->left_thumbnail); + } + break; + case MENU_IMAGE_SAVESTATE_THUMBNAIL: + { + struct texture_image *img = (struct texture_image*)data; + stripes->savestate_thumbnail_height = stripes->savestate_thumbnail_width + * (float)img->height / (float)img->width; + video_driver_texture_unload(&stripes->savestate_thumbnail); + video_driver_texture_load(data, + TEXTURE_FILTER_MIPMAP_LINEAR, &stripes->savestate_thumbnail); + } + break; + } + + return true; +} + +static const char *stripes_texture_path(unsigned id) +{ + switch (id) + { + case STRIPES_TEXTURE_MAIN_MENU: +#if defined(HAVE_LAKKA) + return "lakka.png"; +#else + return "retroarch.png"; +#endif + case STRIPES_TEXTURE_SETTINGS: + return "settings.png"; + case STRIPES_TEXTURE_HISTORY: + return "history.png"; + case STRIPES_TEXTURE_FAVORITES: + return "favorites.png"; + case STRIPES_TEXTURE_ADD_FAVORITE: + return "add-favorite.png"; + case STRIPES_TEXTURE_MUSICS: + return "musics.png"; +#ifdef HAVE_FFMPEG + case STRIPES_TEXTURE_MOVIES: + return "movies.png"; +#endif +#ifdef HAVE_IMAGEVIEWER + case STRIPES_TEXTURE_IMAGES: + return "images.png"; +#endif + case STRIPES_TEXTURE_SETTING: + return "setting.png"; + case STRIPES_TEXTURE_SUBSETTING: + return "subsetting.png"; + case STRIPES_TEXTURE_ARROW: + return "arrow.png"; + case STRIPES_TEXTURE_RUN: + return "run.png"; + case STRIPES_TEXTURE_CLOSE: + return "close.png"; + case STRIPES_TEXTURE_RESUME: + return "resume.png"; + case STRIPES_TEXTURE_CLOCK: + return "clock.png"; + case STRIPES_TEXTURE_BATTERY_FULL: + return "battery-full.png"; + case STRIPES_TEXTURE_BATTERY_CHARGING: + return "battery-charging.png"; + case STRIPES_TEXTURE_POINTER: + return "pointer.png"; + case STRIPES_TEXTURE_SAVESTATE: + return "savestate.png"; + case STRIPES_TEXTURE_LOADSTATE: + return "loadstate.png"; + case STRIPES_TEXTURE_UNDO: + return "undo.png"; + case STRIPES_TEXTURE_CORE_INFO: + return "core-infos.png"; + case STRIPES_TEXTURE_WIFI: + return "wifi.png"; + case STRIPES_TEXTURE_CORE_OPTIONS: + return "core-options.png"; + case STRIPES_TEXTURE_INPUT_REMAPPING_OPTIONS: + return "core-input-remapping-options.png"; + case STRIPES_TEXTURE_CHEAT_OPTIONS: + return "core-cheat-options.png"; + case STRIPES_TEXTURE_DISK_OPTIONS: + return "core-disk-options.png"; + case STRIPES_TEXTURE_SHADER_OPTIONS: + return "core-shader-options.png"; + case STRIPES_TEXTURE_ACHIEVEMENT_LIST: + return "achievement-list.png"; + case STRIPES_TEXTURE_SCREENSHOT: + return "screenshot.png"; + case STRIPES_TEXTURE_RELOAD: + return "reload.png"; + case STRIPES_TEXTURE_RENAME: + return "rename.png"; + case STRIPES_TEXTURE_FILE: + return "file.png"; + case STRIPES_TEXTURE_FOLDER: + return "folder.png"; + case STRIPES_TEXTURE_ZIP: + return "zip.png"; + case STRIPES_TEXTURE_MUSIC: + return "music.png"; + case STRIPES_TEXTURE_FAVORITE: + return "favorites-content.png"; + case STRIPES_TEXTURE_IMAGE: + return "image.png"; + case STRIPES_TEXTURE_MOVIE: + return "movie.png"; + case STRIPES_TEXTURE_CORE: + return "core.png"; + case STRIPES_TEXTURE_RDB: + return "database.png"; + case STRIPES_TEXTURE_CURSOR: + return "cursor.png"; + case STRIPES_TEXTURE_SWITCH_ON: + return "on.png"; + case STRIPES_TEXTURE_SWITCH_OFF: + return "off.png"; + case STRIPES_TEXTURE_ADD: + return "add.png"; +#ifdef HAVE_NETWORKING + case STRIPES_TEXTURE_NETPLAY: + return "netplay.png"; + case STRIPES_TEXTURE_ROOM: + return "room.png"; + /* stub these out until we have the icons + case STRIPES_TEXTURE_ROOM_LAN: + return "room_lan.png"; + case STRIPES_TEXTURE_ROOM_MITM: + return "room_mitm.png"; + */ +#endif + case STRIPES_TEXTURE_KEY: + return "key.png"; + case STRIPES_TEXTURE_KEY_HOVER: + return "key-hover.png"; + case STRIPES_TEXTURE_DIALOG_SLICE: + return "dialog-slice.png"; + + } + + return NULL; +} + +static void stripes_context_reset_textures( + stripes_handle_t *stripes, const char *iconpath) +{ + unsigned i; + + for (i = 0; i < STRIPES_TEXTURE_LAST; i++) + menu_display_reset_textures_list(stripes_texture_path(i), iconpath, &stripes->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + + menu_display_allocate_white_texture(); + + stripes->main_menu_node.icon = stripes->textures.list[STRIPES_TEXTURE_MAIN_MENU]; + stripes->main_menu_node.alpha = stripes->categories_active_alpha; + stripes->main_menu_node.zoom = stripes->categories_active_zoom; + + stripes->settings_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_SETTINGS]; + stripes->settings_tab_node.alpha = stripes->categories_active_alpha; + stripes->settings_tab_node.zoom = stripes->categories_active_zoom; + + stripes->history_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_HISTORY]; + stripes->history_tab_node.alpha = stripes->categories_active_alpha; + stripes->history_tab_node.zoom = stripes->categories_active_zoom; + + stripes->favorites_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_FAVORITES]; + stripes->favorites_tab_node.alpha = stripes->categories_active_alpha; + stripes->favorites_tab_node.zoom = stripes->categories_active_zoom; + + stripes->music_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_MUSICS]; + stripes->music_tab_node.alpha = stripes->categories_active_alpha; + stripes->music_tab_node.zoom = stripes->categories_active_zoom; + +#ifdef HAVE_FFMPEG + stripes->video_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_MOVIES]; + stripes->video_tab_node.alpha = stripes->categories_active_alpha; + stripes->video_tab_node.zoom = stripes->categories_active_zoom; +#endif + +#ifdef HAVE_IMAGEVIEWER + stripes->images_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_IMAGES]; + stripes->images_tab_node.alpha = stripes->categories_active_alpha; + stripes->images_tab_node.zoom = stripes->categories_active_zoom; +#endif + + stripes->add_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_ADD]; + stripes->add_tab_node.alpha = stripes->categories_active_alpha; + stripes->add_tab_node.zoom = stripes->categories_active_zoom; + +#ifdef HAVE_NETWORKING + stripes->netplay_tab_node.icon = stripes->textures.list[STRIPES_TEXTURE_NETPLAY]; + stripes->netplay_tab_node.alpha = stripes->categories_active_alpha; + stripes->netplay_tab_node.zoom = stripes->categories_active_zoom; +#endif +} + +static void stripes_context_reset_background(const char *iconpath) +{ + char *path = NULL; + settings_t *settings = config_get_ptr(); + const char *path_menu_wp = settings->paths.path_menu_wallpaper; + + if (!string_is_empty(path_menu_wp)) + path = strdup(path_menu_wp); + else if (!string_is_empty(iconpath)) + { + path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + path[0] = '\0'; + + fill_pathname_join(path, iconpath, "bg.png", + PATH_MAX_LENGTH * sizeof(char)); + } + + if (filestream_exists(path)) + task_push_image_load(path, + menu_display_handle_wallpaper_upload, NULL); + + if (path) + free(path); +} + +static void stripes_context_reset(void *data, bool is_threaded) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (stripes) + { + char bg_file_path[PATH_MAX_LENGTH] = {0}; + char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + iconpath[0] = '\0'; + + fill_pathname_application_special(bg_file_path, + sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG); + + if (!string_is_empty(bg_file_path)) + { + if (!string_is_empty(stripes->bg_file_path)) + free(stripes->bg_file_path); + stripes->bg_file_path = strdup(bg_file_path); + } + + fill_pathname_application_special(iconpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); + + stripes_layout(stripes); + stripes->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + stripes->font_size, + is_threaded); + stripes->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, + stripes->font2_size, + is_threaded); + stripes_context_reset_textures(stripes, iconpath); + stripes_context_reset_background(iconpath); + stripes_context_reset_horizontal_list(stripes); + + if (!string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + stripes_update_thumbnail_image(stripes); + if (!string_is_equal(stripes_thumbnails_ident('R'), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) + stripes_update_thumbnail_image(stripes); + stripes_update_savestate_thumbnail_image(stripes); + + free(iconpath); + } +} + +static void stripes_navigation_clear(void *data, bool pending_push) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + if (!pending_push) + stripes_selection_pointer_changed(stripes, true); +} + +static void stripes_navigation_pointer_changed(void *data) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + stripes_selection_pointer_changed(stripes, true); +} + +static void stripes_navigation_set(void *data, bool scroll) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + stripes_selection_pointer_changed(stripes, true); +} + +static void stripes_navigation_alphabet(void *data, size_t *unused) +{ + stripes_handle_t *stripes = (stripes_handle_t*)data; + stripes_selection_pointer_changed(stripes, true); +} + +static void stripes_list_insert(void *userdata, + file_list_t *list, + const char *path, + const char *fullpath, + const char *unused, + size_t list_size, + unsigned entry_type) +{ + int current = 0; + int i = (int)list_size; + stripes_node_t *node = NULL; + stripes_handle_t *stripes = (stripes_handle_t*)userdata; + size_t selection = menu_navigation_get_selection(); + + if (!stripes || !list) + return; + + node = (stripes_node_t*)file_list_get_userdata_at_offset(list, i); + + if (!node) + node = stripes_alloc_node(); + + if (!node) + { + RARCH_ERR("XMB node could not be allocated.\n"); + return; + } + + current = (int)selection; + + if (!string_is_empty(fullpath)) + { + if (node->fullpath) + free(node->fullpath); + + node->fullpath = strdup(fullpath); + } + + node->alpha = stripes->items_passive_alpha; + node->zoom = stripes->items_passive_zoom; + node->label_alpha = node->alpha; + node->y = stripes_item_y(stripes, i, current); + node->x = 0; + + if (i == current) + { + node->alpha = stripes->items_active_alpha; + node->label_alpha = stripes->items_active_alpha; + node->zoom = stripes->items_active_alpha; + } + + file_list_set_userdata(list, i, node); +} + +static void stripes_list_clear(file_list_t *list) +{ + menu_animation_ctx_tag tag = (uintptr_t)list; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + + stripes_free_list_nodes(list, false); +} + +static void stripes_list_free(file_list_t *list, size_t a, size_t b) +{ + stripes_list_clear(list); +} + +static void stripes_list_deep_copy(const file_list_t *src, file_list_t *dst, + size_t first, size_t last) +{ + size_t i, j = 0; + menu_animation_ctx_tag tag = (uintptr_t)dst; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); + + /* use true here because file_list_copy() doesn't free actiondata */ + stripes_free_list_nodes(dst, true); + + file_list_clear(dst); + file_list_reserve(dst, (last + 1) - first); + + for (i = first; i <= last; ++i) + { + struct item_file *d = &dst->list[j]; + struct item_file *s = &src->list[i]; + + void *src_udata = s->userdata; + void *src_adata = s->actiondata; + + *d = *s; + d->alt = string_is_empty(d->alt) ? NULL : strdup(d->alt); + d->path = string_is_empty(d->path) ? NULL : strdup(d->path); + d->label = string_is_empty(d->label) ? NULL : strdup(d->label); + + if (src_udata) + file_list_set_userdata(dst, j, (void*)stripes_copy_node((const stripes_node_t*)src_udata)); + + if (src_adata) + { + void *data = malloc(sizeof(menu_file_list_cbs_t)); + memcpy(data, src_adata, sizeof(menu_file_list_cbs_t)); + file_list_set_actiondata(dst, j, data); + } + + ++j; + } + + dst->size = j; +} + +static void stripes_list_cache(void *data, enum menu_list_type type, unsigned action) +{ + size_t stack_size, list_size; + stripes_handle_t *stripes = (stripes_handle_t*)data; + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + size_t selection = menu_navigation_get_selection(); + settings_t *settings = config_get_ptr(); + + if (!stripes) + return; + + /* Check whether to enable the horizontal animation. */ + if (settings->bools.menu_horizontal_animation) + { + unsigned first = 0, last = 0; + unsigned height = 0; + video_driver_get_size(NULL, &height); + + /* FIXME: this shouldn't be happening at all */ + if (selection >= selection_buf->size) + selection = selection_buf->size ? selection_buf->size - 1 : 0; + + stripes->selection_ptr_old = selection; + + stripes_calculate_visible_range(stripes, height, selection_buf->size, + stripes->selection_ptr_old, &first, &last); + + stripes_list_deep_copy(selection_buf, stripes->selection_buf_old, first, last); + + stripes->selection_ptr_old -= first; + last -= first; + first = 0; + } + else + stripes->selection_ptr_old = 0; + + list_size = stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; + + switch (type) + { + case MENU_LIST_PLAIN: + break; + case MENU_LIST_HORIZONTAL: + stripes->categories_selection_ptr_old = stripes->categories_selection_ptr; + + switch (action) + { + case MENU_ACTION_LEFT: + if (stripes->categories_selection_ptr == 0) + { + stripes->categories_selection_ptr = list_size; + stripes->categories_active_idx = (unsigned)(list_size - 1); + } + else + stripes->categories_selection_ptr--; + break; + default: + if (stripes->categories_selection_ptr == list_size) + { + stripes->categories_selection_ptr = 0; + stripes->categories_active_idx = 1; + } + else + stripes->categories_selection_ptr++; + break; + } + + stack_size = menu_stack->size; + + if (menu_stack->list[stack_size - 1].label) + free(menu_stack->list[stack_size - 1].label); + menu_stack->list[stack_size - 1].label = NULL; + + switch (stripes_get_system_tab(stripes, (unsigned)stripes->categories_selection_ptr)) + { + case STRIPES_SYSTEM_TAB_MAIN: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)); + menu_stack->list[stack_size - 1].type = + MENU_SETTINGS; + break; + case STRIPES_SYSTEM_TAB_SETTINGS: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_SETTINGS_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_SETTINGS_TAB; + break; +#ifdef HAVE_IMAGEVIEWER + case STRIPES_SYSTEM_TAB_IMAGES: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_IMAGES_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_IMAGES_TAB; + break; +#endif + case STRIPES_SYSTEM_TAB_MUSIC: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_MUSIC_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_MUSIC_TAB; + break; +#ifdef HAVE_FFMPEG + case STRIPES_SYSTEM_TAB_VIDEO: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_VIDEO_TAB; + break; +#endif + case STRIPES_SYSTEM_TAB_HISTORY: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_HISTORY_TAB; + break; + case STRIPES_SYSTEM_TAB_FAVORITES: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_FAVORITES_TAB; + break; +#ifdef HAVE_NETWORKING + case STRIPES_SYSTEM_TAB_NETPLAY: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_NETPLAY_TAB; + break; +#endif + case STRIPES_SYSTEM_TAB_ADD: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_ADD_TAB; + break; + default: + menu_stack->list[stack_size - 1].label = + strdup(msg_hash_to_str(MENU_ENUM_LABEL_HORIZONTAL_MENU)); + menu_stack->list[stack_size - 1].type = + MENU_SETTING_HORIZONTAL_MENU; + break; + } + break; + default: + break; + } +} + + +static void stripes_context_destroy(void *data) +{ + unsigned i; + stripes_handle_t *stripes = (stripes_handle_t*)data; + + if (!stripes) + return; + + for (i = 0; i < STRIPES_TEXTURE_LAST; i++) + video_driver_texture_unload(&stripes->textures.list[i]); + + video_driver_texture_unload(&stripes->thumbnail); + video_driver_texture_unload(&stripes->left_thumbnail); + video_driver_texture_unload(&stripes->savestate_thumbnail); + + stripes_context_destroy_horizontal_list(stripes); + stripes_context_bg_destroy(stripes); + + menu_display_font_free(stripes->font); + menu_display_font_free(stripes->font2); + + stripes->font = NULL; + stripes->font2 = NULL; +} + +static void stripes_toggle(void *userdata, bool menu_on) +{ + menu_animation_ctx_entry_t entry; + bool tmp = false; + stripes_handle_t *stripes = (stripes_handle_t*)userdata; + + if (!stripes) + return; + + stripes->depth = (int)stripes_list_get_size(stripes, MENU_LIST_PLAIN); + + if (!menu_on) + { + stripes->alpha = 0; + return; + } + + entry.duration = STRIPES_DELAY * 2; + entry.target_value = 1.0f; + entry.subject = &stripes->alpha; + entry.easing_enum = EASING_OUT_QUAD; + /* TODO/FIXME - integer conversion resulted in change of sign */ + entry.tag = -1; + entry.cb = NULL; + + menu_animation_push(&entry); + + tmp = !menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL); + + if (tmp) + menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); + else + menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); + + stripes_toggle_horizontal_list(stripes); +} + +static int stripes_deferred_push_content_actions(menu_displaylist_info_t *info) +{ + if (!menu_displaylist_ctl( + DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS, info)) + return -1; + menu_displaylist_process(info); + menu_displaylist_info_free(info); + return 0; +} + +static int stripes_list_bind_init_compare_label(menu_file_list_cbs_t *cbs) +{ + if (cbs && cbs->enum_idx != MSG_UNKNOWN) + { + switch (cbs->enum_idx) + { + case MENU_ENUM_LABEL_CONTENT_ACTIONS: + cbs->action_deferred_push = stripes_deferred_push_content_actions; + break; + default: + return -1; + } + } + + return 0; +} + +static int stripes_list_bind_init(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx) +{ + if (stripes_list_bind_init_compare_label(cbs) == 0) + return 0; + + return -1; +} + +static int stripes_list_push(void *data, void *userdata, + menu_displaylist_info_t *info, unsigned type) +{ + menu_displaylist_ctx_parse_entry_t entry; + int ret = -1; + int i = 0; + core_info_list_t *list = NULL; + menu_handle_t *menu = (menu_handle_t*)data; + + switch (type) + { + case DISPLAYLIST_LOAD_CONTENT_LIST: + { + settings_t *settings = config_get_ptr(); + + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), + msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), + MENU_ENUM_LABEL_FAVORITES, + MENU_SETTING_ACTION, 0, 0); + + core_info_get_list(&list); + if (core_info_list_num_info_files(list)) + { + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST), + msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST), + MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST, + MENU_SETTING_ACTION, 0, 0); + } + +#ifdef HAVE_LIBRETRODB + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_COLLECTION_LIST), + msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST), + MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST, + MENU_SETTING_ACTION, 0, 0); +#endif + + if (frontend_driver_parse_drive_list(info->list, true) != 0) + menu_entries_append_enum(info->list, "/", + msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), + MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR, + MENU_SETTING_ACTION, 0, 0); + + if (!settings->bools.kiosk_mode_enable) + { + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_MENU_FILE_BROWSER_SETTINGS), + MENU_ENUM_LABEL_MENU_FILE_BROWSER_SETTINGS, + MENU_SETTING_ACTION, 0, 0); + } + + info->need_push = true; + info->need_refresh = true; + ret = 0; + } + break; + case DISPLAYLIST_MAIN_MENU: + { + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = runloop_get_system_info(); + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + + entry.data = menu; + entry.info = info; + entry.parse_type = PARSE_ACTION; + entry.add_empty_entry = false; + + if (!string_is_empty(system->info.library_name) && + !string_is_equal(system->info.library_name, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))) + { + entry.enum_idx = MENU_ENUM_LABEL_CONTENT_SETTINGS; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + + if (system->load_no_content) + { + entry.enum_idx = MENU_ENUM_LABEL_START_CORE; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + +#ifndef HAVE_DYNAMIC + if (frontend_driver_has_fork()) +#endif + { + if (settings->bools.menu_show_load_core) + { + entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + } + + if (settings->bools.menu_show_load_content) + { + const struct retro_subsystem_info* subsystem = NULL; + + entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + + subsystem = system->subsystem.data; + + if (subsystem) + { + for (i = 0; i < system->subsystem.size; i++, subsystem++) + { + char s[PATH_MAX_LENGTH]; + if (content_get_subsystem() == i) + { + if (content_get_subsystem_rom_id() < subsystem->num_roms) + { + snprintf(s, sizeof(s), + "Load %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + else + { + snprintf(s, sizeof(s), + "Start %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), + MENU_ENUM_LABEL_SUBSYSTEM_LOAD, + MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0); + } + } + else + { + snprintf(s, sizeof(s), + "Load %s %s", + subsystem->desc, + i == content_get_subsystem() + ? "\u2605" : " "); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + } + } + } + + entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); +#if defined(HAVE_NETWORKING) + { + settings_t *settings = config_get_ptr(); + if (settings->bools.menu_show_online_updater && !settings->bools.kiosk_mode_enable) + { + entry.enum_idx = MENU_ENUM_LABEL_ONLINE_UPDATER; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + } +#endif + if (!settings->bools.menu_content_show_settings && !string_is_empty(settings->paths.menu_content_show_settings_password)) + { + entry.enum_idx = MENU_ENUM_LABEL_XMB_MAIN_MENU_ENABLE_SETTINGS; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + + if (settings->bools.kiosk_mode_enable && !string_is_empty(settings->paths.kiosk_mode_password)) + { + entry.enum_idx = MENU_ENUM_LABEL_MENU_DISABLE_KIOSK_MODE; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + + if (settings->bools.menu_show_information) + { + entry.enum_idx = MENU_ENUM_LABEL_INFORMATION_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + +#ifndef HAVE_DYNAMIC + entry.enum_idx = MENU_ENUM_LABEL_RESTART_RETROARCH; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); +#endif + + if (settings->bools.menu_show_configurations && !settings->bools.kiosk_mode_enable) + { + entry.enum_idx = MENU_ENUM_LABEL_CONFIGURATIONS_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + + if (settings->bools.menu_show_help) + { + entry.enum_idx = MENU_ENUM_LABEL_HELP_LIST; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + +#if !defined(IOS) + if (settings->bools.menu_show_quit_retroarch) + { + entry.enum_idx = MENU_ENUM_LABEL_QUIT_RETROARCH; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } +#endif + + if (settings->bools.menu_show_reboot) + { + entry.enum_idx = MENU_ENUM_LABEL_REBOOT; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + } + + entry.enum_idx = MENU_ENUM_LABEL_SHUTDOWN; + menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + info->need_push = true; + ret = 0; + } + break; + } + return ret; +} + +static bool stripes_menu_init_list(void *data) +{ + menu_displaylist_info_t info; + + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + + menu_displaylist_info_init(&info); + + info.label = strdup( + msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)); + info.exts = + strdup(file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT)); + info.type_default = FILE_TYPE_PLAIN; + info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU; + + menu_entries_append_enum(menu_stack, info.path, + info.label, + MENU_ENUM_LABEL_MAIN_MENU, + info.type, info.flags, 0); + + info.list = selection_buf; + + if (!menu_displaylist_ctl(DISPLAYLIST_MAIN_MENU, &info)) + goto error; + + info.need_push = true; + + if (!menu_displaylist_process(&info)) + goto error; + + menu_displaylist_info_free(&info); + return true; + +error: + menu_displaylist_info_free(&info); + return false; +} + +static int stripes_pointer_tap(void *userdata, + unsigned x, unsigned y, unsigned ptr, + menu_file_list_cbs_t *cbs, + menu_entry_t *entry, unsigned action) +{ + unsigned header_height = menu_display_get_header_height(); + + if (y < header_height) + { + size_t selection = menu_navigation_get_selection(); + return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); + } + else if (ptr <= (menu_entries_get_size() - 1)) + { + size_t selection = menu_navigation_get_selection(); + if (ptr == selection && cbs && cbs->action_select) + return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT); + + menu_navigation_set_selection(ptr); + menu_driver_navigation_set(false); + } + + return 0; +} + +menu_ctx_driver_t menu_ctx_stripes = { + NULL, + stripes_messagebox, + generic_menu_iterate, + stripes_render, + stripes_frame, + stripes_init, + stripes_free, + stripes_context_reset, + stripes_context_destroy, + stripes_populate_entries, + stripes_toggle, + stripes_navigation_clear, + stripes_navigation_pointer_changed, + stripes_navigation_pointer_changed, + stripes_navigation_set, + stripes_navigation_pointer_changed, + stripes_navigation_alphabet, + stripes_navigation_alphabet, + stripes_menu_init_list, + stripes_list_insert, + NULL, + stripes_list_free, + stripes_list_clear, + stripes_list_cache, + stripes_list_push, + stripes_list_get_selection, + stripes_list_get_size, + stripes_list_get_entry, + NULL, + stripes_list_bind_init, + stripes_load_image, + "stripes", + stripes_environ, + stripes_pointer_tap, + stripes_update_thumbnail_path, + stripes_update_thumbnail_image, + stripes_set_thumbnail_system, + stripes_set_thumbnail_content, + stripes_osk_ptr_at_pos, + stripes_update_savestate_thumbnail_path, + stripes_update_savestate_thumbnail_image +}; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index dde5ee212b..0912114c17 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -81,6 +81,9 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = { #if defined(HAVE_XMB) &menu_ctx_xmb, #endif +#if defined(HAVE_STRIPES) + &menu_ctx_stripes, +#endif #if defined(HAVE_RGUI) &menu_ctx_rgui, #endif diff --git a/menu/menu_driver.h b/menu/menu_driver.h index b61131a33d..d36214da0a 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -771,6 +771,7 @@ extern menu_ctx_driver_t menu_ctx_rgui; extern menu_ctx_driver_t menu_ctx_mui; extern menu_ctx_driver_t menu_ctx_nuklear; extern menu_ctx_driver_t menu_ctx_xmb; +extern menu_ctx_driver_t menu_ctx_stripes; extern menu_ctx_driver_t menu_ctx_zarch; extern menu_ctx_driver_t menu_ctx_null; diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 3b4f0dd4be..6c0637f444 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -539,7 +539,7 @@ "-DHAVE_MATERIALUI", "-DHAVE_HID", "-DHAVE_XMB", - "-DHAVE_SEGA", + "-DHAVE_STRIPES", "-DHAVE_SHADERPIPELINE", "-DHAVE_MMAP", "-DHAVE_LIBRETRODB", @@ -600,7 +600,7 @@ "-DHAVE_MATERIALUI", "-DHAVE_HID", "-DHAVE_XMB", - "-DHAVE_SEGA", + "-DHAVE_STRIPES", "-DHAVE_SHADERPIPELINE", "-DHAVE_MMAP", "-DHAVE_LIBRETRODB", diff --git a/qb/config.libs.sh b/qb/config.libs.sh index e0c3382d5b..d5894d2fc6 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -477,6 +477,7 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" if [ "$HAVE_RGUI" = 'no' ]; then HAVE_MATERIALUI=no HAVE_XMB=no + HAVE_STRIPES=no HAVE_ZARCH=no die : 'Notice: RGUI not available, MaterialUI, XMB and ZARCH will also be disabled.' elif [ "$HAVE_OPENGL" = 'no' ] && [ "$HAVE_OPENGLES" = 'no' ] && [ "$HAVE_VULKAN" = 'no' ]; then @@ -489,6 +490,7 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" else HAVE_MATERIALUI=no HAVE_XMB=no + HAVE_STRIPES=no HAVE_ZARCH=no die : 'Notice: Hardware rendering context not available, XMB, MaterialUI and ZARCH will also be disabled.' fi diff --git a/qb/config.params.sh b/qb/config.params.sh index 94135f94f6..6c120234b5 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -9,6 +9,7 @@ HAVE_LIBRETRODB=yes # Libretrodb support HAVE_RGUI=yes # RGUI menu HAVE_MATERIALUI=auto # MaterialUI menu HAVE_XMB=auto # XMB menu +HAVE_STRIPES=auto # Stripes menu HAVE_ZARCH=no # Zarch menu HAVE_NUKLEAR=no # Nuklear menu HAVE_RUNAHEAD=yes # Runahead support From fcda6f7d9628fd467f046150e8c0756158e43184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 10:01:14 +0700 Subject: [PATCH 02/78] [stripes] Remove gradients --- menu/drivers/stripes.c | 121 +---------------------------------------- 1 file changed, 2 insertions(+), 119 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 520cf87812..e1f0a2c01a 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -315,85 +315,6 @@ static float stripes_item_color[] = { 1, 1, 1, 1 }; - -float stripes_stripes_gradient_dark_purple[16] = { - 20/255.0, 13/255.0, 20/255.0, 1.0, - 20/255.0, 13/255.0, 20/255.0, 1.0, - 92/255.0, 44/255.0, 92/255.0, 1.0, - 148/255.0, 90/255.0, 148/255.0, 1.0, -}; - -float stripes_gradient_midnight_blue[16] = { - 44/255.0, 62/255.0, 80/255.0, 1.0, - 44/255.0, 62/255.0, 80/255.0, 1.0, - 44/255.0, 62/255.0, 80/255.0, 1.0, - 44/255.0, 62/255.0, 80/255.0, 1.0, -}; - -float stripes_gradient_golden[16] = { - 174/255.0, 123/255.0, 44/255.0, 1.0, - 205/255.0, 174/255.0, 84/255.0, 1.0, - 58/255.0, 43/255.0, 24/255.0, 1.0, - 58/255.0, 43/255.0, 24/255.0, 1.0, -}; - -float stripes_gradient_legacy_red[16] = { - 171/255.0, 70/255.0, 59/255.0, 1.0, - 171/255.0, 70/255.0, 59/255.0, 1.0, - 190/255.0, 80/255.0, 69/255.0, 1.0, - 190/255.0, 80/255.0, 69/255.0, 1.0, -}; - -float stripes_gradient_electric_blue[16] = { - 1/255.0, 2/255.0, 67/255.0, 1.0, - 1/255.0, 73/255.0, 183/255.0, 1.0, - 1/255.0, 93/255.0, 194/255.0, 1.0, - 3/255.0, 162/255.0, 254/255.0, 1.0, -}; - -float stripes_gradient_apple_green[16] = { - 102/255.0, 134/255.0, 58/255.0, 1.0, - 122/255.0, 131/255.0, 52/255.0, 1.0, - 82/255.0, 101/255.0, 35/255.0, 1.0, - 63/255.0, 95/255.0, 30/255.0, 1.0, -}; - -float stripes_gradient_undersea[16] = { - 23/255.0, 18/255.0, 41/255.0, 1.0, - 30/255.0, 72/255.0, 114/255.0, 1.0, - 52/255.0, 88/255.0, 110/255.0, 1.0, - 69/255.0, 125/255.0, 140/255.0, 1.0, - -}; - -float stripes_gradient_volcanic_red[16] = { - 1.0, 0.0, 0.1, 1.00, - 1.0, 0.1, 0.0, 1.00, - 0.1, 0.0, 0.1, 1.00, - 0.1, 0.0, 0.1, 1.00, -}; - -float stripes_gradient_dark[16] = { - 0.1, 0.1, 0.1, 1.00, - 0.1, 0.1, 0.1, 1.00, - 0.0, 0.0, 0.0, 1.00, - 0.0, 0.0, 0.0, 1.00, -}; - -float stripes_gradient_light[16] = { - 1.0, 1.0, 1.0, 1.00, - 1.0, 1.0, 1.0, 1.00, - 1.0, 1.0, 1.0, 1.00, - 1.0, 1.0, 1.0, 1.00, -}; - -float stripes_gradient_morning_blue[16] = { - 221/255.0, 241/255.0, 254/255.0, 1.00, - 135/255.0, 206/255.0, 250/255.0, 1.00, - 1.0, 1.0, 1.0, 1.00, - 170/255.0, 200/255.0, 252/255.0, 1.00, -}; - static void stripes_calculate_visible_range(const stripes_handle_t *stripes, unsigned height, size_t list_size, unsigned current, unsigned *first, unsigned *last); @@ -518,38 +439,6 @@ static const char *stripes_thumbnails_ident(char pos) return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF); } -static float *stripes_gradient_ident(video_frame_info_t *video_info) -{ - switch (video_info->xmb_color_theme) - { - case XMB_THEME_DARK_PURPLE: - return &stripes_stripes_gradient_dark_purple[0]; - case XMB_THEME_MIDNIGHT_BLUE: - return &stripes_gradient_midnight_blue[0]; - case XMB_THEME_GOLDEN: - return &stripes_gradient_golden[0]; - case XMB_THEME_ELECTRIC_BLUE: - return &stripes_gradient_electric_blue[0]; - case XMB_THEME_APPLE_GREEN: - return &stripes_gradient_apple_green[0]; - case XMB_THEME_UNDERSEA: - return &stripes_gradient_undersea[0]; - case XMB_THEME_VOLCANIC_RED: - return &stripes_gradient_volcanic_red[0]; - case XMB_THEME_DARK: - return &stripes_gradient_dark[0]; - case XMB_THEME_LIGHT: - return &stripes_gradient_light[0]; - case XMB_THEME_MORNING_BLUE: - return &stripes_gradient_morning_blue[0]; - case XMB_THEME_LEGACY_RED: - default: - break; - } - - return &stripes_gradient_legacy_red[0]; -} - static size_t stripes_list_get_selection(void *data) { stripes_handle_t *stripes = (stripes_handle_t*)data; @@ -2922,15 +2811,13 @@ static void stripes_draw_bg( && (video_info->xmb_color_theme != XMB_THEME_WALLPAPER)) { - draw.color = stripes_gradient_ident(video_info); + draw.color = &stripes_coord_white[0]; if (running) menu_display_set_alpha(draw.color, stripes_coord_black[3]); else menu_display_set_alpha(draw.color, stripes_coord_white[3]); - menu_display_draw_gradient(&draw, video_info); - draw.pipeline.id = VIDEO_SHADER_MENU_2; switch (video_info->menu_shader_pipeline) @@ -2961,17 +2848,13 @@ static void stripes_draw_bg( { uintptr_t texture = draw.texture; - if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER) - draw.color = stripes_gradient_ident(video_info); + draw.color = &stripes_coord_white[0]; if (running) menu_display_set_alpha(draw.color, stripes_coord_black[3]); else menu_display_set_alpha(draw.color, stripes_coord_white[3]); - if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER) - menu_display_draw_gradient(&draw, video_info); - { float override_opacity = video_info->menu_wallpaper_opacity; bool add_opacity = false; From 7601b740cc8a9fcd01a7e97a6f3c0210a000099e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 10:41:02 +0700 Subject: [PATCH 03/78] [stripes] Remove ribbon --- menu/drivers/xmb.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 362709187e..88b0044c9e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3960,42 +3960,6 @@ static void xmb_ribbon_set_vertex(float *ribbon_verts, ribbon_verts[idx++] = ((float)row) / (XMB_RIBBON_ROWS-1) * 2.0f - 1.0f; } -static void xmb_init_ribbon(xmb_handle_t * xmb) -{ - video_coords_t coords; - unsigned r, c, col; - unsigned i = 0; - video_coord_array_t *ca = menu_display_get_coords_array(); - unsigned vertices_total = XMB_RIBBON_VERTICES; - float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); - float *ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float)); - - /* Set up vertices */ - for (r = 0; r < XMB_RIBBON_ROWS - 1; r++) - { - for (c = 0; c < XMB_RIBBON_COLS; c++) - { - col = r % 2 ? XMB_RIBBON_COLS - c - 1 : c; - xmb_ribbon_set_vertex(ribbon_verts, i, r, col); - xmb_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col); - i += 4; - } - } - - coords.color = dummy; - coords.vertex = ribbon_verts; - coords.tex_coord = dummy; - coords.lut_tex_coord = dummy; - coords.vertices = vertices_total; - - video_coord_array_append(ca, &coords, coords.vertices); - - free(dummy); - free(ribbon_verts); -} - - - static void *xmb_init(void **userdata, bool video_is_threaded) { unsigned width, height; @@ -4104,8 +4068,6 @@ static void *xmb_init(void **userdata, bool video_is_threaded) if (xmb->horizontal_list) xmb_init_horizontal_list(xmb); - xmb_init_ribbon(xmb); - return menu; error: From 061fe25c33d441d0d9d9da3ee025fe4cb476e75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 13:16:01 +0700 Subject: [PATCH 04/78] [stripes] Compute y position for the tabs icons --- menu/drivers/stripes.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index e1f0a2c01a..0367ba254c 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -234,6 +234,9 @@ typedef struct stripes_handle float margins_slice; float textures_arrow_alpha; float categories_x_pos; + float categories_active_y; + float categories_before_y; + float categories_after_y; float categories_passive_alpha; float categories_passive_zoom; float categories_active_zoom; @@ -1702,6 +1705,7 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) menu_animation_ctx_entry_t entry; float ia = stripes->categories_passive_alpha; float iz = stripes->categories_passive_zoom; + float iy = stripes->categories_before_y; stripes_node_t *node = stripes_get_node(stripes, j); if (!node) @@ -1711,6 +1715,15 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) { ia = stripes->categories_active_alpha; iz = stripes->categories_active_zoom; + iy = stripes->categories_active_y; + } + else if (j < stripes->categories_active_idx) + { + iy = stripes->categories_before_y; + } + else if (j > stripes->categories_active_idx) + { + iy = stripes->categories_after_y; } entry.duration = STRIPES_DELAY; @@ -1727,6 +1740,11 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) entry.subject = &node->zoom; menu_animation_push(&entry); + + entry.target_value = iy; + entry.subject = &node->y; + + menu_animation_push(&entry); } } @@ -3381,7 +3399,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) stripes->margins_screen_left + stripes->icon_spacing_horizontal * (i + 1) - stripes->icon_size / 2.0; - float y = stripes->margins_screen_top + float y = node->y + stripes->icon_size / 2.0; float rotation = 0; float scale_factor = node->zoom; @@ -3624,7 +3642,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_unset_viewport(video_info->width, video_info->height); } -static void stripes_layout_ps3(stripes_handle_t *stripes, int width) +static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) { unsigned new_font_size, new_header_height; settings_t *settings = config_get_ptr(); @@ -3639,6 +3657,11 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width) stripes->categories_active_zoom = 1.0; stripes->categories_passive_zoom = 0.5; + + stripes->categories_active_y = height / 2; + stripes->categories_before_y = 64; + stripes->categories_after_y = height - 64; + stripes->items_active_zoom = 1.0; stripes->items_passive_zoom = 0.5; @@ -3777,7 +3800,7 @@ static void stripes_layout(stripes_handle_t *stripes) /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width > 320 && height > 240) - stripes_layout_ps3(stripes, width); + stripes_layout_ps3(stripes, width, height); else stripes_layout_psp(stripes, width); From 5a22d1cd8ecf2e0cde16e8743e601711e6628a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 13:21:33 +0700 Subject: [PATCH 05/78] [stripes] Comment out draw_items for now --- menu/drivers/stripes.c | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 0367ba254c..06dc09c601 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -3565,31 +3565,31 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_blend_end(video_info); /* Vertical icons */ - if (stripes) - stripes_draw_items( - video_info, - stripes, - stripes->selection_buf_old, - stripes->selection_ptr_old, - (stripes_list_get_size(stripes, MENU_LIST_PLAIN) > 1) - ? stripes->categories_selection_ptr : - stripes->categories_selection_ptr_old, - &stripes_item_color[0], - width, - height); +// if (stripes) +// stripes_draw_items( +// video_info, +// stripes, +// stripes->selection_buf_old, +// stripes->selection_ptr_old, +// (stripes_list_get_size(stripes, MENU_LIST_PLAIN) > 1) +// ? stripes->categories_selection_ptr : +// stripes->categories_selection_ptr_old, +// &stripes_item_color[0], +// width, +// height); - selection_buf = menu_entries_get_selection_buf_ptr(0); +// selection_buf = menu_entries_get_selection_buf_ptr(0); - if (stripes) - stripes_draw_items( - video_info, - stripes, - selection_buf, - selection, - stripes->categories_selection_ptr, - &stripes_item_color[0], - width, - height); +// if (stripes) +// stripes_draw_items( +// video_info, +// stripes, +// selection_buf, +// selection, +// stripes->categories_selection_ptr, +// &stripes_item_color[0], +// width, +// height); font_driver_flush(video_info->width, video_info->height, stripes->font, video_info); From 7a7cb730c54c783b5bb7ada3e0d501695ded871f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 13:26:20 +0700 Subject: [PATCH 06/78] [stripes] Remove pipeline --- menu/drivers/stripes.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 06dc09c601..f32d778504 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -2824,45 +2824,6 @@ static void stripes_draw_bg( menu_display_blend_begin(video_info); menu_display_set_viewport(video_info->width, video_info->height); -#ifdef HAVE_SHADERPIPELINE - if (video_info->menu_shader_pipeline > XMB_SHADER_PIPELINE_WALLPAPER - && - (video_info->xmb_color_theme != XMB_THEME_WALLPAPER)) - { - draw.color = &stripes_coord_white[0]; - - if (running) - menu_display_set_alpha(draw.color, stripes_coord_black[3]); - else - menu_display_set_alpha(draw.color, stripes_coord_white[3]); - - draw.pipeline.id = VIDEO_SHADER_MENU_2; - - switch (video_info->menu_shader_pipeline) - { - case XMB_SHADER_PIPELINE_RIBBON: - draw.pipeline.id = VIDEO_SHADER_MENU; - break; - case XMB_SHADER_PIPELINE_SIMPLE_SNOW: - draw.pipeline.id = VIDEO_SHADER_MENU_3; - break; - case XMB_SHADER_PIPELINE_SNOW: - draw.pipeline.id = VIDEO_SHADER_MENU_4; - break; - case XMB_SHADER_PIPELINE_BOKEH: - draw.pipeline.id = VIDEO_SHADER_MENU_5; - break; - case XMB_SHADER_PIPELINE_SNOWFLAKE: - draw.pipeline.id = VIDEO_SHADER_MENU_6; - break; - default: - break; - } - - menu_display_draw_pipeline(&draw, video_info); - } - else -#endif { uintptr_t texture = draw.texture; From 65626c188af2246c4856705cc78c995655902e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 13:31:19 +0700 Subject: [PATCH 07/78] [stripes] Remove most of draw_frame --- menu/drivers/stripes.c | 515 ----------------------------------------- 1 file changed, 515 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index f32d778504..8987c29dd2 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -2948,37 +2948,6 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) selection = menu_navigation_get_selection(); - strlcpy(title_truncated, - stripes->title_name, sizeof(title_truncated)); - - if (selection > 1) - { - /* skip 25 utf8 multi-byte chars */ - char *end = title_truncated; - - for(i = 0; i < 25 && *end; i++) - { - end++; - while((*end & 0xC0) == 0x80) - end++; - } - - *end = '\0'; - } - - /* Title text */ - stripes_draw_text(video_info, stripes, - title_truncated, stripes->margins_title_left, - stripes->margins_title_top, - 1, 1, TEXT_ALIGN_LEFT, - width, height, stripes->font); - - if (settings->bools.menu_core_enable && - menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0) - stripes_draw_text(video_info, stripes, title_msg, stripes->margins_title_left, - height - stripes->margins_title_bottom, 1, 1, TEXT_ALIGN_LEFT, - width, height, stripes->font); - rotate_draw.matrix = &mymat; rotate_draw.rotation = 0; rotate_draw.scale_x = 1; @@ -2989,357 +2958,6 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_rotate_z(&rotate_draw, video_info); menu_display_blend_begin(video_info); - /* Save State thumbnail, right side */ - if (stripes->savestate_thumbnail) - { - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - stripes->margins_screen_left * stripes_scale_mod[5] + - stripes->icon_spacing_horizontal + pseudo_font_length, - stripes->margins_screen_top + stripes->icon_size + - stripes->savestate_thumbnail_height * stripes_scale_mod[4], - stripes->savestate_thumbnail_width * stripes_scale_mod[4], - stripes->savestate_thumbnail_height * stripes_scale_mod[4], - stripes->savestate_thumbnail); - } - - /* Right thumbnail big size */ - if (!settings->bools.menu_xmb_vertical_thumbnails || - (settings->bools.menu_xmb_vertical_thumbnails && !stripes->left_thumbnail)) - { - /* Do not draw the right thumbnail if there is no space available */ - - if (((stripes->margins_screen_top + - stripes->icon_size + min_thumb_size) <= height) && - ((stripes->margins_screen_left * stripes_scale_mod[5] + - stripes->icon_spacing_horizontal + - pseudo_font_length + min_thumb_size) <= width)) - { - if (stripes->thumbnail - && !string_is_equal(stripes_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - /* Limit thumbnail width */ - - float thumb_width = 0.0f; - float thumb_height = 0.0f; - float thumb_max_width = (float)width - (stripes->icon_size / 6) - - (stripes->margins_screen_left * stripes_scale_mod[5]) - - stripes->icon_spacing_horizontal - pseudo_font_length; - - #ifdef STRIPES_DEBUG - RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", - stripes->thumbnail_width, stripes->thumbnail_height); - RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); - #endif - - if (stripes->thumbnail_width * stripes_scale_mod[4] > thumb_max_width) - { - thumb_width = (stripes->thumbnail_width * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); - thumb_height = (stripes->thumbnail_height * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); - } - else - { - thumb_width = stripes->thumbnail_width * stripes_scale_mod[4]; - thumb_height = stripes->thumbnail_height * stripes_scale_mod[4]; - } - - /* Limit thumbnail height to screen height + margin. */ - - if (stripes->margins_screen_top + stripes->icon_size + thumb_height >= - ((float)height * under_thumb_margin)) - { - thumb_width = thumb_width * - ((((float)height * under_thumb_margin) - - stripes->margins_screen_top - stripes->icon_size) / - thumb_height); - thumb_height = thumb_height * - ((((float)height * under_thumb_margin) - - stripes->margins_screen_top - stripes->icon_size) / - thumb_height); - } - - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - (float)width - (stripes->icon_size / 6) - thumb_max_width + - ((thumb_max_width - thumb_width) / 2), - stripes->margins_screen_top + stripes->icon_size + thumb_height, - thumb_width, thumb_height, - stripes->thumbnail); - } - } - } - - /* Left thumbnail in the left margin */ - /* Do not draw the left thumbnail if there is no space available */ - if (!settings->bools.menu_xmb_vertical_thumbnails && - (stripes->margins_screen_top + stripes->icon_size * - (!(stripes->depth == 1)? 2.1 : 1) + min_thumb_size) - <= (float)height) - { - /* Left Thumbnail in the left margin */ - - if (stripes->left_thumbnail - && !string_is_equal(stripes_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - /* Limit left thumbnail width */ - - float left_thumb_width = 0.0f; - float left_thumb_height = 0.0f; - float thumb_max_width = stripes->icon_size * 3.4; - - #ifdef STRIPES_DEBUG - RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n", - stripes->left_thumbnail_width, stripes->left_thumbnail_height); - RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height); - #endif - - if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) - { - left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - } - else - { - left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; - left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; - } - - /* Limit left thumbnail height to screen height + margin. */ - if (stripes->margins_screen_top + stripes->icon_size * - (!(stripes->depth == 1)? 2.1 : 1) + - left_thumb_height >= - ((float)height - (96.0 * scale_factor))) - { - left_thumb_width = left_thumb_width * - ((((float)height - (96.0 * scale_factor)) - - stripes->margins_screen_top - - (stripes->icon_size * (!(stripes->depth == 1)? 2.1 : 1))) / - left_thumb_height); - - left_thumb_height = left_thumb_height * - ((((float)height - (96.0 * scale_factor)) - - stripes->margins_screen_top - - (stripes->icon_size * (!(stripes->depth == 1)? 2.1 : 1))) / - left_thumb_height); - } - else - { - left_thumb_width = left_thumb_width; - left_thumb_height = left_thumb_height; - } - - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - (stripes->icon_size / 6) + - ((thumb_max_width - left_thumb_width) / 2), - stripes->margins_screen_top + stripes->icon_size * - (!(stripes->depth == 1)? 2.1 : 1) + left_thumb_height, - left_thumb_width, left_thumb_height, - stripes->left_thumbnail); - } - } - - /* No Right Thumbnail, draw only the left one big size */ - if (settings->bools.menu_xmb_vertical_thumbnails && !stripes->thumbnail) - { - /* Do not draw the left thumbnail if there is no space available */ - - if (((stripes->margins_screen_top + - stripes->icon_size + min_thumb_size) <= height) && - ((stripes->margins_screen_left * stripes_scale_mod[5] + - stripes->icon_spacing_horizontal + - pseudo_font_length + min_thumb_size) <= width)) - { - if (stripes->left_thumbnail - && !string_is_equal(stripes_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - /* Limit left thumbnail width */ - - float left_thumb_width = 0.0f; - float left_thumb_height = 0.0f; - float thumb_max_width = (float)width - (stripes->icon_size / 6) - - (stripes->margins_screen_left * stripes_scale_mod[5]) - - stripes->icon_spacing_horizontal - pseudo_font_length; - - #ifdef STRIPES_DEBUG - RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", - stripes->thumbnail_width, stripes->thumbnail_height); - RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); - #endif - - if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) - { - left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - } - else - { - left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; - left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; - } - - /* Limit left thumbnail height to screen height + margin. */ - - if (stripes->margins_screen_top + stripes->icon_size + left_thumb_height >= - ((float)height * under_thumb_margin)) - { - left_thumb_width = left_thumb_width * - ((((float)height * under_thumb_margin) - - stripes->margins_screen_top - stripes->icon_size) / - left_thumb_height); - left_thumb_height = left_thumb_height * - ((((float)height * under_thumb_margin) - - stripes->margins_screen_top - stripes->icon_size) / - left_thumb_height); - } - - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - (float)width - (stripes->icon_size / 6) - thumb_max_width + - ((thumb_max_width - left_thumb_width) / 2), - stripes->margins_screen_top + stripes->icon_size + left_thumb_height, - left_thumb_width, left_thumb_height, - stripes->left_thumbnail); - } - } - } - - /* Clock image */ - menu_display_set_alpha(stripes_coord_white, MIN(stripes->alpha, 1.00f)); - - if (video_info->battery_level_enable) - { - char msg[12]; - static retro_time_t last_time = 0; - bool charging = false; - retro_time_t current_time = cpu_features_get_time_usec(); - int percent = 0; - enum frontend_powerstate state = get_last_powerstate(&percent); - - if (state == FRONTEND_POWERSTATE_CHARGING) - charging = true; - - if (current_time - last_time >= BATTERY_LEVEL_CHECK_INTERVAL) - { - last_time = current_time; - task_push_get_powerstate(); - } - - *msg = '\0'; - - if (percent > 0) - { - size_t x_pos = stripes->icon_size / 6; - size_t x_pos_icon = stripes->margins_title_left; - - if (stripes_coord_white[3] != 0) - stripes_draw_icon(video_info, - stripes->icon_size, - &mymat, - stripes->textures.list[charging - ? STRIPES_TEXTURE_BATTERY_CHARGING : STRIPES_TEXTURE_BATTERY_FULL], - width - (stripes->icon_size / 2) - x_pos_icon, - stripes->icon_size, - width, - height, - 1, - 0, - 1, - &stripes_coord_white[0], - stripes->shadow_offset); - - snprintf(msg, sizeof(msg), "%d%%", percent); - - percent_width = (unsigned) - font_driver_get_message_width( - stripes->font, msg, (unsigned)strlen(msg), 1); - - stripes_draw_text(video_info, stripes, msg, - width - stripes->margins_title_left - x_pos, - stripes->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT, - width, height, stripes->font); - } - } - - if (video_info->timedate_enable) - { - menu_display_ctx_datetime_t datetime; - char timedate[255]; - int x_pos = 0; - - if (stripes_coord_white[3] != 0) - { - int x_pos = 0; - - if (percent_width) - x_pos = percent_width + (stripes->icon_size / 2.5); - - stripes_draw_icon(video_info, - stripes->icon_size, - &mymat, - stripes->textures.list[STRIPES_TEXTURE_CLOCK], - width - stripes->icon_size - x_pos, - stripes->icon_size, - width, - height, - 1, - 0, - 1, - &stripes_coord_white[0], - stripes->shadow_offset); - } - - timedate[0] = '\0'; - - datetime.s = timedate; - datetime.len = sizeof(timedate); - datetime.time_mode = 4; - - menu_display_timedate(&datetime); - - if (percent_width) - x_pos = percent_width + (stripes->icon_size / 2.5); - - stripes_draw_text(video_info, stripes, timedate, - width - stripes->margins_title_left - stripes->icon_size / 4 - x_pos, - stripes->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT, - width, height, stripes->font); - } - - /* Arrow image */ - menu_display_set_alpha(stripes_coord_white, - MIN(stripes->textures_arrow_alpha, stripes->alpha)); - - if (stripes_coord_white[3] != 0) - stripes_draw_icon(video_info, - stripes->icon_size, - &mymat, - stripes->textures.list[STRIPES_TEXTURE_ARROW], - stripes->x + stripes->margins_screen_left + - stripes->icon_spacing_horizontal - - stripes->icon_size / 2.0 + stripes->icon_size, - stripes->margins_screen_top + - stripes->icon_size / 2.0 + stripes->icon_spacing_vertical - * stripes->active_item_factor, - width, - height, - stripes->textures_arrow_alpha, - 0, - 1, - &stripes_coord_white[0], - stripes->shadow_offset); - - menu_display_blend_begin(video_info); - /* Horizontal tab icons */ for (i = 0; i <= stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + stripes->system_tab_end; i++) @@ -3390,139 +3008,6 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) } } - /* Right side 2 thumbnails on top of each other */ - /* here to be displayed above the horizontal icons */ - if (stripes->left_thumbnail && stripes->thumbnail && settings->bools.menu_xmb_vertical_thumbnails) - { - /* Do not draw the right thumbnail if there is no space available */ - if (((stripes->margins_screen_top + - stripes->icon_size + min_thumb_size) <= height) && - ((stripes->margins_screen_left * stripes_scale_mod[5] + - stripes->icon_spacing_horizontal + - pseudo_font_length + min_thumb_size) <= width)) - { - if (stripes->thumbnail && - !string_is_equal(stripes_thumbnails_ident('R'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - /* Limit right thumbnail width */ - - float thumb_width = 0.0f; - float thumb_height = 0.0f; - float thumb_max_width = (float)width - (stripes->icon_size / 6) - - (stripes->margins_screen_left * stripes_scale_mod[5]) - - stripes->icon_spacing_horizontal - pseudo_font_length; - - #ifdef STRIPES_DEBUG - RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", - stripes->thumbnail_width, stripes->thumbnail_height); - RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height); - #endif - - if (stripes->thumbnail_width * stripes_scale_mod[4] > thumb_max_width) - { - thumb_width = (stripes->thumbnail_width * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); - thumb_height = (stripes->thumbnail_height * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->thumbnail_width * stripes_scale_mod[4])); - } - else - { - thumb_width = stripes->thumbnail_width * stripes_scale_mod[4]; - thumb_height = stripes->thumbnail_height * stripes_scale_mod[4]; - } - - /* Limit right thumbnail height to usable area. */ - - if (thumb_height >= - ((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) - { - thumb_width = thumb_width * - ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / - thumb_height); - thumb_height = thumb_height * - ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / - thumb_height); - } - - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - (float)width - (stripes->icon_size / 6) - thumb_max_width + - ((thumb_max_width - thumb_width) / 2), - stripes->icon_size + ((((float)height / 2 - - (stripes->icon_size + (stripes->icon_size/12))) - thumb_height) / 2) + - thumb_height, - thumb_width, thumb_height, - stripes->thumbnail); - } - } - - /* Do not draw the left thumbnail if there is no space available */ - - if (((stripes->margins_screen_top + - stripes->icon_size + min_thumb_size) <= height) && - ((stripes->margins_screen_left * stripes_scale_mod[5] + - stripes->icon_spacing_horizontal + - pseudo_font_length + min_thumb_size) <= width)) - { - if (stripes->left_thumbnail && - !string_is_equal(stripes_thumbnails_ident('L'), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - /* Limit left thumbnail width */ - - float left_thumb_width = 0.0f; - float left_thumb_height = 0.0f; - float thumb_max_width = (float)width - (stripes->icon_size / 6) - - (stripes->margins_screen_left * stripes_scale_mod[5]) - - stripes->icon_spacing_horizontal - pseudo_font_length; - - #ifdef STRIPES_DEBUG - RARCH_LOG("[XMB left thumbnail] width: %.2f, height: %.2f\n", - stripes->left_thumbnail_width, stripes->left_thumbnail_height); - RARCH_LOG("[XMB left thumbnail] w: %.2f, h: %.2f\n", width, height); - #endif - - if (stripes->left_thumbnail_width * stripes_scale_mod[4] > thumb_max_width) - { - left_thumb_width = (stripes->left_thumbnail_width * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - left_thumb_height = (stripes->left_thumbnail_height * stripes_scale_mod[4]) * - (thumb_max_width / (stripes->left_thumbnail_width * stripes_scale_mod[4])); - } - else - { - left_thumb_width = stripes->left_thumbnail_width * stripes_scale_mod[4]; - left_thumb_height = stripes->left_thumbnail_height * stripes_scale_mod[4]; - } - - /* Limit left thumbnail height to usable area. */ - - if (left_thumb_height >= - ((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) - { - left_thumb_width = left_thumb_width * - ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / - left_thumb_height); - left_thumb_height = left_thumb_height * - ((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) / - left_thumb_height); - } - - stripes_draw_thumbnail(video_info, - stripes, &stripes_coord_white[0], width, height, - (float)width - (stripes->icon_size / 6) - thumb_max_width + - ((thumb_max_width - left_thumb_width) / 2), - stripes->icon_size + - (((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) + - (((((float)height - ((stripes->icon_size / 6) * 2) - stripes->icon_size) / 2) - - left_thumb_height) / 2) + left_thumb_height, - left_thumb_width, left_thumb_height, - stripes->left_thumbnail); - } - } - } - menu_display_blend_end(video_info); /* Vertical icons */ From d1695c043c834f9e736f673befffdffda995bb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 13:38:51 +0700 Subject: [PATCH 08/78] [stripes] Compute categories y position --- menu/drivers/stripes.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 8987c29dd2..246bc9106c 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -234,9 +234,13 @@ typedef struct stripes_handle float margins_slice; float textures_arrow_alpha; float categories_x_pos; + float categories_angle; float categories_active_y; float categories_before_y; float categories_after_y; + float categories_active_x; + float categories_before_x; + float categories_after_x; float categories_passive_alpha; float categories_passive_zoom; float categories_active_zoom; @@ -1705,6 +1709,7 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) menu_animation_ctx_entry_t entry; float ia = stripes->categories_passive_alpha; float iz = stripes->categories_passive_zoom; + float ix = stripes->categories_before_x; float iy = stripes->categories_before_y; stripes_node_t *node = stripes_get_node(stripes, j); @@ -1715,14 +1720,17 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) { ia = stripes->categories_active_alpha; iz = stripes->categories_active_zoom; + ix = stripes->categories_active_x; iy = stripes->categories_active_y; } else if (j < stripes->categories_active_idx) { + ix = stripes->categories_before_x; iy = stripes->categories_before_y; } else if (j > stripes->categories_active_idx) { + ix = stripes->categories_after_x; iy = stripes->categories_after_y; } @@ -3104,10 +3112,16 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) stripes->categories_active_zoom = 1.0; stripes->categories_passive_zoom = 0.5; + stripes->categories_angle = 400; + stripes->categories_active_y = height / 2; stripes->categories_before_y = 64; stripes->categories_after_y = height - 64; + stripes->categories_active_x = stripes->categories_angle / 2; + stripes->categories_before_x = stripes->categories_angle - 22; + stripes->categories_after_x = 22; + stripes->items_active_zoom = 1.0; stripes->items_passive_zoom = 0.5; From 34966e2ffcb45a5591317c7f728a828d88785ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 15:22:32 +0700 Subject: [PATCH 09/78] [stripes] Compute and animate category width --- menu/drivers/stripes.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 246bc9106c..777b53a476 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -87,6 +87,7 @@ typedef struct float zoom; float x; float y; + float width; uintptr_t icon; uintptr_t content_icon; char *fullpath; @@ -243,8 +244,10 @@ typedef struct stripes_handle float categories_after_x; float categories_passive_alpha; float categories_passive_zoom; + float categories_passive_width; float categories_active_zoom; float categories_active_alpha; + float categories_active_width; uint64_t frame_count; @@ -1709,6 +1712,7 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) menu_animation_ctx_entry_t entry; float ia = stripes->categories_passive_alpha; float iz = stripes->categories_passive_zoom; + float iw = stripes->categories_passive_width; float ix = stripes->categories_before_x; float iy = stripes->categories_before_y; stripes_node_t *node = stripes_get_node(stripes, j); @@ -1720,6 +1724,7 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) { ia = stripes->categories_active_alpha; iz = stripes->categories_active_zoom; + iw = stripes->categories_active_width; ix = stripes->categories_active_x; iy = stripes->categories_active_y; } @@ -1753,6 +1758,11 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) entry.subject = &node->y; menu_animation_push(&entry); + + entry.target_value = iw; + entry.subject = &node->width; + + menu_animation_push(&entry); } } @@ -1772,7 +1782,7 @@ static void stripes_list_switch(stripes_handle_t *stripes) stripes_list_switch_horizontal_list(stripes); anim_entry.duration = STRIPES_DELAY; - anim_entry.target_value = stripes->icon_spacing_horizontal + anim_entry.target_value = stripes->categories_passive_width * -(float)stripes->categories_selection_ptr; anim_entry.subject = &stripes->categories_x_pos; anim_entry.easing_enum = EASING_OUT_QUAD; @@ -1952,7 +1962,7 @@ static void stripes_context_reset_horizontal_list( stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL); stripes->categories_x_pos = - stripes->icon_spacing_horizontal * + stripes->categories_passive_width * -(float)stripes->categories_selection_ptr; depth = (stripes->depth > 1) ? 2 : 1; @@ -2919,6 +2929,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) const float under_thumb_margin = 0.96; float scale_factor = 0.0f; float pseudo_font_length = 0.0f; + float stack_width = 285; stripes_handle_t *stripes = (stripes_handle_t*)data; settings_t *settings = config_get_ptr(); @@ -2982,12 +2993,9 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_ctx_rotate_draw_t rotate_draw; math_matrix_4x4 mymat; uintptr_t texture = node->icon; - float x = stripes->x + stripes->categories_x_pos + - stripes->margins_screen_left + - stripes->icon_spacing_horizontal - * (i + 1) - stripes->icon_size / 2.0; - float y = node->y - + stripes->icon_size / 2.0; + float x = stack_width + stripes->categories_x_pos + node->x + node->width / 2.0 + - stripes->icon_size / 2.0; + float y = node->y + stripes->icon_size / 2.0; float rotation = 0; float scale_factor = node->zoom; @@ -3014,6 +3022,8 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) &stripes_item_color[0], stripes->shadow_offset); } + + stack_width += node->width; } menu_display_blend_end(video_info); @@ -3122,6 +3132,9 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) stripes->categories_before_x = stripes->categories_angle - 22; stripes->categories_after_x = 22; + stripes->categories_passive_width = 128; + stripes->categories_active_width = 1200; + stripes->items_active_zoom = 1.0; stripes->items_passive_zoom = 0.5; From 3f32a7f1b7582e4062de5032613dac7bee4c9b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 15:37:29 +0700 Subject: [PATCH 10/78] [stripes] Remove useless ribbon stuff --- menu/drivers/stripes.c | 45 ------------------------------------------ 1 file changed, 45 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 777b53a476..fe40341016 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -3332,49 +3332,6 @@ static void stripes_layout(stripes_handle_t *stripes) } } -static void stripes_ribbon_set_vertex(float *ribbon_verts, - unsigned idx, unsigned row, unsigned col) -{ - ribbon_verts[idx++] = ((float)col) / (STRIPES_RIBBON_COLS-1) * 2.0f - 1.0f; - ribbon_verts[idx++] = ((float)row) / (STRIPES_RIBBON_ROWS-1) * 2.0f - 1.0f; -} - -static void stripes_init_ribbon(stripes_handle_t * stripes) -{ - video_coords_t coords; - unsigned r, c, col; - unsigned i = 0; - video_coord_array_t *ca = menu_display_get_coords_array(); - unsigned vertices_total = STRIPES_RIBBON_VERTICES; - float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); - float *ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float)); - - /* Set up vertices */ - for (r = 0; r < STRIPES_RIBBON_ROWS - 1; r++) - { - for (c = 0; c < STRIPES_RIBBON_COLS; c++) - { - col = r % 2 ? STRIPES_RIBBON_COLS - c - 1 : c; - stripes_ribbon_set_vertex(ribbon_verts, i, r, col); - stripes_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col); - i += 4; - } - } - - coords.color = dummy; - coords.vertex = ribbon_verts; - coords.tex_coord = dummy; - coords.lut_tex_coord = dummy; - coords.vertices = vertices_total; - - video_coord_array_append(ca, &coords, coords.vertices); - - free(dummy); - free(ribbon_verts); -} - - - static void *stripes_init(void **userdata, bool video_is_threaded) { unsigned width, height; @@ -3483,8 +3440,6 @@ static void *stripes_init(void **userdata, bool video_is_threaded) if (stripes->horizontal_list) stripes_init_horizontal_list(stripes); - stripes_init_ribbon(stripes); - return menu; error: From f2e71615fb0ddcfe22a1361b6b0c8a03c8ee04c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 15:42:26 +0700 Subject: [PATCH 11/78] [stripes] Remove useless thumbnail stuff --- menu/drivers/stripes.c | 124 ----------------------------------------- 1 file changed, 124 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index fe40341016..b2ff0ed6bb 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -602,60 +602,6 @@ static void stripes_draw_icon( menu_display_draw(&draw, video_info); } -static void stripes_draw_thumbnail( - video_frame_info_t *video_info, - stripes_handle_t *stripes, float *color, - unsigned width, unsigned height, - float x, float y, - float w, float h, uintptr_t texture) -{ - menu_display_ctx_rotate_draw_t rotate_draw; - menu_display_ctx_draw_t draw; - struct video_coords coords; - math_matrix_4x4 mymat; - - rotate_draw.matrix = &mymat; - rotate_draw.rotation = 0; - rotate_draw.scale_x = 1; - rotate_draw.scale_y = 1; - rotate_draw.scale_z = 1; - rotate_draw.scale_enable = true; - - menu_display_rotate_z(&rotate_draw, video_info); - - coords.vertices = 4; - coords.vertex = NULL; - coords.tex_coord = NULL; - coords.lut_tex_coord = NULL; - - draw.width = w; - draw.height = h; - draw.coords = &coords; - draw.matrix_data = &mymat; - draw.texture = texture; - draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - draw.pipeline.id = 0; - - if (video_info->xmb_shadows_enable) - { - menu_display_set_alpha(stripes_coord_shadow, color[3] * 0.35f); - - coords.color = stripes_coord_shadow; - draw.x = x + stripes->shadow_offset; - draw.y = height - y - stripes->shadow_offset; - - menu_display_draw(&draw, video_info); - } - - coords.color = (const float*)color; - draw.x = x; - draw.y = height - y; - - menu_display_set_alpha(color, 1.0f); - - menu_display_draw(&draw, video_info); -} - static void stripes_draw_text( video_frame_info_t *video_info, stripes_handle_t *stripes, @@ -1211,76 +1157,6 @@ static void stripes_selection_pointer_changed( iy = stripes_item_y(stripes, i, selection); real_iy = iy + stripes->margins_screen_top; - if (i == selection) - { - unsigned depth = (unsigned)stripes_list_get_size(stripes, MENU_LIST_PLAIN); - unsigned stripes_system_tab = stripes_get_system_tab(stripes, (unsigned)stripes->categories_selection_ptr); - unsigned entry_type = menu_entry_get_type_new(&entry); - - ia = stripes->items_active_alpha; - iz = stripes->items_active_zoom; - if (!string_is_equal(thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)) || !string_is_equal(lft_thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - if ((stripes_system_tab > STRIPES_SYSTEM_TAB_SETTINGS && depth == 1) || - (stripes_system_tab < STRIPES_SYSTEM_TAB_SETTINGS && depth == 4)) - { - if (!string_is_empty(entry.path)) - stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); - if (!string_is_equal(thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'R'); - stripes_update_thumbnail_image(stripes); - } - if (!string_is_equal(lft_thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'L'); - stripes_update_thumbnail_image(stripes); - } - } - else if (((entry_type == FILE_TYPE_IMAGE || entry_type == FILE_TYPE_IMAGEVIEWER || - entry_type == FILE_TYPE_RDB || entry_type == FILE_TYPE_RDB_ENTRY) - && stripes_system_tab <= STRIPES_SYSTEM_TAB_SETTINGS)) - { - if (!string_is_empty(entry.path)) - stripes_set_thumbnail_content(stripes, entry.path, 0 /* will be ignored */); - if (!string_is_equal(thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'R'); - stripes_update_thumbnail_image(stripes); - } - else if (!string_is_equal(lft_thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'L'); - stripes_update_thumbnail_image(stripes); - } - } - else if (filebrowser_get_type() != FILEBROWSER_NONE) - { - stripes_reset_thumbnail_content(stripes); - if (!string_is_equal(thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'R'); - stripes_update_thumbnail_image(stripes); - } - else if (!string_is_equal(lft_thumb_ident, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))) - { - stripes_update_thumbnail_path(stripes, i, 'L'); - stripes_update_thumbnail_image(stripes); - } - } - } - stripes_update_savestate_thumbnail_path(stripes, i); - stripes_update_savestate_thumbnail_image(stripes); - } - if ( (!allow_animations) || (real_iy < -threshold || real_iy > height+threshold)) From a6e9107bd042b77e3b9ca0033eb010ddf448520d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 18:58:11 +0700 Subject: [PATCH 12/78] Add menu_display_draw_polygon --- menu/menu_driver.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ menu/menu_driver.h | 8 ++++++++ 2 files changed, 58 insertions(+) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 0912114c17..d19d97ef03 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -711,6 +711,56 @@ void menu_display_draw_quad( menu_disp->blend_end(video_info); } +void menu_display_draw_polygon( + video_frame_info_t *video_info, + int x1, int y1, + int x2, int y2, + int x3, int y3, + int x4, int y4, + unsigned width, unsigned height, + float *color) +{ + menu_display_ctx_draw_t draw; + struct video_coords coords; + + float vertex[8]; + + vertex[0] = x1 / (float)width; + vertex[1] = y1 / (float)height; + vertex[2] = x2 / (float)width; + vertex[3] = y2 / (float)height; + vertex[4] = x3 / (float)width; + vertex[5] = y3 / (float)height; + vertex[6] = x4 / (float)width; + vertex[7] = y4 / (float)height; + + coords.vertices = 4; + coords.vertex = &vertex[0]; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + coords.color = color; + + if (menu_disp && menu_disp->blend_begin) + menu_disp->blend_begin(video_info); + + draw.x = 0; + draw.y = 0; + draw.width = width; + draw.height = height; + draw.coords = &coords; + draw.matrix_data = NULL; + draw.texture = menu_display_white_texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; + draw.scale_factor = 1.0f; + draw.rotation = 0.0f; + + menu_display_draw(&draw, video_info); + + if (menu_disp && menu_disp->blend_end) + menu_disp->blend_end(video_info); +} + void menu_display_draw_texture( video_frame_info_t *video_info, int x, int y, unsigned w, unsigned h, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index d36214da0a..1bfaab22bb 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -692,6 +692,14 @@ void menu_display_draw_quad( int x, int y, unsigned w, unsigned h, unsigned width, unsigned height, float *color); +void menu_display_draw_polygon( + video_frame_info_t *video_info, + int x1, int y1, + int x2, int y2, + int x3, int y3, + int x4, int y4, + unsigned width, unsigned height, + float *color); void menu_display_draw_texture( video_frame_info_t *video_info, int x, int y, unsigned w, unsigned h, From 2ef382455457299884c6209432ad3d81a6201556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 18:58:57 +0700 Subject: [PATCH 13/78] [stripe] Draw the stripes --- menu/drivers/stripes.c | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index b2ff0ed6bb..da90b28521 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -1635,6 +1635,11 @@ static void stripes_list_switch_horizontal_list(stripes_handle_t *stripes) menu_animation_push(&entry); + entry.target_value = ix; + entry.subject = &node->x; + + menu_animation_push(&entry); + entry.target_value = iw; entry.subject = &node->width; @@ -2853,6 +2858,43 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_rotate_z(&rotate_draw, video_info); menu_display_blend_begin(video_info); + float mycolor[16]= { + 0.50, 1.00, 1.00, 1.00, + 0.00, 0.50, 1.00, 1.00, + 0.50, 1.00, 1.00, 1.00, + 0.00, 0.50, 1.00, 1.00, + }; + + /* Horizontal stripes */ + for (i = 0; i <= stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + + stripes->system_tab_end; i++) + { + stripes_node_t *node = stripes_get_node(stripes, i); + + if (!node) + continue; + + menu_display_draw_polygon( + video_info, + stripes->categories_x_pos + stack_width, + 0, + stripes->categories_x_pos + stack_width + node->width, + 0, + stripes->categories_x_pos + stack_width + stripes->categories_angle, + video_info->height, + stripes->categories_x_pos + stack_width + stripes->categories_angle + node->width, + video_info->height, + + video_info->width, video_info->height, + &mycolor[0]); + + menu_display_blend_begin(video_info); + + stack_width += node->width; + } + + stack_width = 285; + /* Horizontal tab icons */ for (i = 0; i <= stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + stripes->system_tab_end; i++) @@ -2869,7 +2911,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_ctx_rotate_draw_t rotate_draw; math_matrix_4x4 mymat; uintptr_t texture = node->icon; - float x = stack_width + stripes->categories_x_pos + node->x + node->width / 2.0 + float x = stripes->categories_x_pos + stack_width + node->x + node->width / 2.0 - stripes->icon_size / 2.0; float y = node->y + stripes->icon_size / 2.0; float rotation = 0; From cef847721542158c490eb9c37812c7c9209ba3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 20:47:49 +0700 Subject: [PATCH 14/78] [stripes] Rainbow colors --- menu/drivers/stripes.c | 55 +++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index da90b28521..02394096e0 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -325,6 +325,42 @@ static float stripes_item_color[] = { 1, 1, 1, 1 }; +static float HueToRGB(float v1, float v2, float vH) +{ + if (vH < 0) + vH += 1; + + if (vH > 1) + vH -= 1; + + if ((6 * vH) < 1) + return (v1 + (v2 - v1) * 6 * vH); + + if ((2 * vH) < 1) + return v2; + + if ((3 * vH) < 2) + return (v1 + (v2 - v1) * ((2.0f / 3) - vH) * 6); + + return v1; +} + +static void HSLToRGB(float H, float S, float L, float *rgb) { + if (S == 0) + rgb[0] = rgb[1] = rgb[2] = L; + else + { + float v1, v2; + + v2 = (L < 0.5) ? (L * (1 + S)) : ((L + S) - (L * S)); + v1 = 2 * L - v2; + + rgb[0] = HueToRGB(v1, v2, H + (1.0f / 3)); + rgb[1] = HueToRGB(v1, v2, H); + rgb[2] = HueToRGB(v1, v2, H - (1.0f / 3)); + } +} + static void stripes_calculate_visible_range(const stripes_handle_t *stripes, unsigned height, size_t list_size, unsigned current, unsigned *first, unsigned *last); @@ -2858,13 +2894,6 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) menu_display_rotate_z(&rotate_draw, video_info); menu_display_blend_begin(video_info); - float mycolor[16]= { - 0.50, 1.00, 1.00, 1.00, - 0.00, 0.50, 1.00, 1.00, - 0.50, 1.00, 1.00, 1.00, - 0.00, 0.50, 1.00, 1.00, - }; - /* Horizontal stripes */ for (i = 0; i <= stripes_list_get_size(stripes, MENU_LIST_HORIZONTAL) + stripes->system_tab_end; i++) @@ -2874,6 +2903,15 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) if (!node) continue; + float rgb[3]; + HSLToRGB(0.05*(float)i,0.5,0.5, &rgb[0]) ; + float color[16] = { + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + }; + menu_display_draw_polygon( video_info, stripes->categories_x_pos + stack_width, @@ -2884,9 +2922,8 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) video_info->height, stripes->categories_x_pos + stack_width + stripes->categories_angle + node->width, video_info->height, - video_info->width, video_info->height, - &mycolor[0]); + &color[0]); menu_display_blend_begin(video_info); From 4af704babe892e64fc3c14cc6f9023b6fd26457a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 20:55:53 +0700 Subject: [PATCH 15/78] [stripe] Use scale_factor to look nice of different screens --- menu/drivers/stripes.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 02394096e0..58bcb8b8c3 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -3077,24 +3077,24 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) stripes->categories_active_zoom = 1.0; stripes->categories_passive_zoom = 0.5; - stripes->categories_angle = 400; + stripes->categories_angle = 400 * scale_factor; stripes->categories_active_y = height / 2; - stripes->categories_before_y = 64; - stripes->categories_after_y = height - 64; + stripes->categories_before_y = 64 * scale_factor; + stripes->categories_after_y = height - 64 * scale_factor; stripes->categories_active_x = stripes->categories_angle / 2; - stripes->categories_before_x = stripes->categories_angle - 22; - stripes->categories_after_x = 22; + stripes->categories_before_x = stripes->categories_angle - 22 * scale_factor; + stripes->categories_after_x = 22 * scale_factor; - stripes->categories_passive_width = 128; - stripes->categories_active_width = 1200; + stripes->categories_passive_width = 128 * scale_factor; + stripes->categories_active_width = 1200 * scale_factor; stripes->items_active_zoom = 1.0; stripes->items_passive_zoom = 0.5; stripes->categories_active_alpha = 1.0; - stripes->categories_passive_alpha = 0.85; + stripes->categories_passive_alpha = 1.0; stripes->items_active_alpha = 1.0; stripes->items_passive_alpha = 0.85; From 1189d84543ee5e219d14441b03eb33dd4b524533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 21:48:55 +0700 Subject: [PATCH 16/78] [stripes] Implement draw_bg --- menu/drivers/stripes.c | 78 ++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 52 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 58bcb8b8c3..6353ecf824 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -2733,59 +2733,37 @@ static void stripes_draw_bg( stripes_handle_t *stripes, video_frame_info_t *video_info, unsigned width, - unsigned height, - float alpha, - uintptr_t texture_id, - float *stripes_coord_black, - float *stripes_coord_white) + unsigned height) { menu_display_ctx_draw_t draw; + struct video_coords coords; - bool running = video_info->libretro_running; + float rgb[3]; + HSLToRGB(0.0,0.5,0.5, &rgb[0]) ; + float color[16] = { + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 1, + }; - draw.x = 0; - draw.y = 0; - draw.texture = texture_id; - draw.width = width; - draw.height = height; - draw.color = &stripes_coord_black[0]; - draw.vertex = NULL; - draw.tex_coord = NULL; - draw.vertex_count = 4; - draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - draw.pipeline.id = 0; - draw.pipeline.active = stripes_shader_pipeline_active(video_info); + coords.vertices = 4; + coords.vertex = NULL; + coords.tex_coord = NULL; + coords.lut_tex_coord = NULL; + coords.color = &color[0]; + + draw.x = 0; + draw.y = 0; + draw.width = width; + draw.height = height; + draw.coords = &coords; + draw.matrix_data = NULL; + draw.texture = menu_display_white_texture; + draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; menu_display_blend_begin(video_info); - menu_display_set_viewport(video_info->width, video_info->height); - - { - uintptr_t texture = draw.texture; - - draw.color = &stripes_coord_white[0]; - - if (running) - menu_display_set_alpha(draw.color, stripes_coord_black[3]); - else - menu_display_set_alpha(draw.color, stripes_coord_white[3]); - - { - float override_opacity = video_info->menu_wallpaper_opacity; - bool add_opacity = false; - - draw.texture = texture; - menu_display_set_alpha(draw.color, stripes_coord_white[3]); - - if (draw.texture) - draw.color = &stripes_coord_white[0]; - - if (running || video_info->xmb_color_theme == XMB_THEME_WALLPAPER) - add_opacity = true; - - menu_display_draw_bg(&draw, video_info, add_opacity, override_opacity); - } - } - menu_display_draw(&draw, video_info); menu_display_blend_end(video_info); } @@ -2876,11 +2854,7 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) stripes, video_info, width, - height, - stripes->alpha, - stripes->textures.bg, - stripes_coord_black, - stripes_coord_white); + height); selection = menu_navigation_get_selection(); From 3a1e95428417b469e4d1ec599b93f5a780afbeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 8 Apr 2018 21:55:11 +0700 Subject: [PATCH 17/78] [stripe] Fix icon sizes --- menu/drivers/stripes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 6353ecf824..adce62e543 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -3049,7 +3049,7 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) stripes->under_item_offset = 5.0; stripes->categories_active_zoom = 1.0; - stripes->categories_passive_zoom = 0.5; + stripes->categories_passive_zoom = 0.25; stripes->categories_angle = 400 * scale_factor; @@ -3102,7 +3102,7 @@ static void stripes_layout_ps3(stripes_handle_t *stripes, int width, int height) stripes->margins_slice = 16; - stripes->icon_size = 128.0 * scale_factor; + stripes->icon_size = 256.0 * scale_factor; stripes->font_size = new_font_size; #ifdef STRIPES_DEBUG From 617793df40b704500a71acef7481741e893525b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Wed, 11 Apr 2018 21:17:37 +0700 Subject: [PATCH 18/78] [stripes] Better tab colors --- .vscode/c_cpp_properties.json | 3 ++- menu/drivers/stripes.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index c6f4ffd0eb..561af49173 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,7 +5,8 @@ "includePath": [ "/usr/include", "/usr/local/include", - "${workspaceRoot}" + "${workspaceRoot}", + "${workspaceRoot}/libretro-common/include" ], "defines": [], "intelliSenseMode": "clang-x64", diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index adce62e543..a66e092e23 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -2878,12 +2878,12 @@ static void stripes_frame(void *data, video_frame_info_t *video_info) continue; float rgb[3]; - HSLToRGB(0.05*(float)i,0.5,0.5, &rgb[0]) ; + HSLToRGB(0.07*(float)i,0.5,0.5, &rgb[0]) ; float color[16] = { - rgb[0], rgb[1], rgb[2], 1, - rgb[0], rgb[1], rgb[2], 1, - rgb[0], rgb[1], rgb[2], 1, - rgb[0], rgb[1], rgb[2], 1, + rgb[0], rgb[1], rgb[2], 0.55, + rgb[0], rgb[1], rgb[2], 0.55, + rgb[0], rgb[1], rgb[2], 0.55, + rgb[0], rgb[1], rgb[2], 0.55, }; menu_display_draw_polygon( From 5f7abb068bd6caafe913255900627253cdf14802 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 2 May 2018 23:04:10 -0400 Subject: [PATCH 19/78] Qt: initial grid layout work --- Makefile.common | 3 +- ui/drivers/qt/flowlayout.cpp | 200 +++++++++++++++++++++++++++++++++ ui/drivers/qt/flowlayout.h | 89 +++++++++++++++ ui/drivers/qt/ui_qt_window.cpp | 164 +++++++++++++++++++++++++-- ui/drivers/ui_qt.cpp | 3 + ui/drivers/ui_qt.h | 18 +++ 6 files changed, 466 insertions(+), 11 deletions(-) create mode 100644 ui/drivers/qt/flowlayout.cpp create mode 100644 ui/drivers/qt/flowlayout.h diff --git a/Makefile.common b/Makefile.common index dce6b77e31..c522edea25 100644 --- a/Makefile.common +++ b/Makefile.common @@ -332,7 +332,8 @@ OBJ += ui/drivers/ui_qt.o \ ui/drivers/qt/ui_qt_window.o \ ui/drivers/qt/ui_qt_browser_window.o \ ui/drivers/qt/ui_qt_load_core_window.o \ - ui/drivers/qt/ui_qt_msg_window.o + ui/drivers/qt/ui_qt_msg_window.o \ + ui/drivers/qt/flowlayout.o MOC_HEADERS += ui/drivers/ui_qt.h \ ui/drivers/qt/ui_qt_load_core_window.h diff --git a/ui/drivers/qt/flowlayout.cpp b/ui/drivers/qt/flowlayout.cpp new file mode 100644 index 0000000000..0dd3a1f606 --- /dev/null +++ b/ui/drivers/qt/flowlayout.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include "flowlayout.h" +FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) + : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) +{ + setContentsMargins(margin, margin, margin, margin); +} + +FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) + : m_hSpace(hSpacing), m_vSpace(vSpacing) +{ + setContentsMargins(margin, margin, margin, margin); +} + +FlowLayout::~FlowLayout() +{ + QLayoutItem *item; + while ((item = takeAt(0))) + delete item; +} + +void FlowLayout::addItem(QLayoutItem *item) +{ + itemList.append(item); +} + +int FlowLayout::horizontalSpacing() const +{ + if (m_hSpace >= 0) { + return m_hSpace; + } else { + return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); + } +} + +int FlowLayout::verticalSpacing() const +{ + if (m_vSpace >= 0) { + return m_vSpace; + } else { + return smartSpacing(QStyle::PM_LayoutVerticalSpacing); + } +} + +int FlowLayout::count() const +{ + return itemList.size(); +} + +QLayoutItem *FlowLayout::itemAt(int index) const +{ + return itemList.value(index); +} + +QLayoutItem *FlowLayout::takeAt(int index) +{ + if (index >= 0 && index < itemList.size()) + return itemList.takeAt(index); + else + return 0; +} + +Qt::Orientations FlowLayout::expandingDirections() const +{ + return 0; +} + +bool FlowLayout::hasHeightForWidth() const +{ + return true; +} + +int FlowLayout::heightForWidth(int width) const +{ + int height = doLayout(QRect(0, 0, width, 0), true); + return height; +} + +void FlowLayout::setGeometry(const QRect &rect) +{ + QLayout::setGeometry(rect); + doLayout(rect, false); +} + +QSize FlowLayout::sizeHint() const +{ + return minimumSize(); +} + +QSize FlowLayout::minimumSize() const +{ + QSize size; + QLayoutItem *item; + foreach (item, itemList) + size = size.expandedTo(item->minimumSize()); + + size += QSize(2*margin(), 2*margin()); + return size; +} + +int FlowLayout::doLayout(const QRect &rect, bool testOnly) const +{ + int left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); + int x = effectiveRect.x(); + int y = effectiveRect.y(); + int lineHeight = 0; + + QLayoutItem *item; + foreach (item, itemList) { + QWidget *wid = item->widget(); + int spaceX = horizontalSpacing(); + if (spaceX == -1) + spaceX = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); + int spaceY = verticalSpacing(); + if (spaceY == -1) + spaceY = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); + int nextX = x + item->sizeHint().width() + spaceX; + if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { + x = effectiveRect.x(); + y = y + lineHeight + spaceY; + nextX = x + item->sizeHint().width() + spaceX; + lineHeight = 0; + } + + if (!testOnly) + item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); + + x = nextX; + lineHeight = qMax(lineHeight, item->sizeHint().height()); + } + return y + lineHeight - rect.y() + bottom; +} +int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const +{ + QObject *parent = this->parent(); + if (!parent) { + return -1; + } else if (parent->isWidgetType()) { + QWidget *pw = static_cast(parent); + return pw->style()->pixelMetric(pm, 0, pw); + } else { + return static_cast(parent)->spacing(); + } +} diff --git a/ui/drivers/qt/flowlayout.h b/ui/drivers/qt/flowlayout.h new file mode 100644 index 0000000000..436ba5e4c6 --- /dev/null +++ b/ui/drivers/qt/flowlayout.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* bparker: Removed C++11 override keyword from original source */ + +#ifndef FLOWLAYOUT_H +#define FLOWLAYOUT_H + +#include +#include +#include + +class FlowLayout : public QLayout +{ +public: + explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); + explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); + ~FlowLayout(); + + void addItem(QLayoutItem *item); + int horizontalSpacing() const; + int verticalSpacing() const; + Qt::Orientations expandingDirections() const; + bool hasHeightForWidth() const; + int heightForWidth(int) const; + int count() const; + QLayoutItem *itemAt(int index) const; + QSize minimumSize() const; + void setGeometry(const QRect &rect); + QSize sizeHint() const; + QLayoutItem *takeAt(int index); + +private: + int doLayout(const QRect &rect, bool testOnly) const; + int smartSpacing(QStyle::PixelMetric pm) const; + + QList itemList; + int m_hSpace; + int m_vSpace; +}; + +#endif // FLOWLAYOUT_H diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 12e59b2065..1261950f71 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -33,6 +33,7 @@ #include "../ui_qt.h" #include "ui_qt_load_core_window.h" #include "ui_qt_themes.h" +#include "flowlayout.h" extern "C" { #include "../../../version.h" @@ -487,13 +488,30 @@ MainWindow::MainWindow(QWidget *parent) : ,m_historyPlaylistsItem(NULL) ,m_folderIcon() ,m_customThemeString() + ,m_gridLayout(new FlowLayout()) + ,m_gridWidget(new QWidget(this)) + ,m_gridScrollArea(new QScrollArea(m_gridWidget)) + ,m_gridItems() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); QString configDir = QFileInfo(path_get(RARCH_PATH_CONFIG)).dir().absolutePath(); QToolButton *searchResetButton = NULL; + QWidget *gridLayoutWidget = new QWidget(); int i = 0; + m_gridWidget->setLayout(new QVBoxLayout()); + + gridLayoutWidget->setLayout(m_gridLayout); + + m_gridScrollArea->setAlignment(Qt::AlignCenter); + m_gridScrollArea->setFrameShape(QFrame::NoFrame); + m_gridScrollArea->setWidgetResizable(true); + m_gridScrollArea->setWidget(gridLayoutWidget); + + m_gridWidget->layout()->addWidget(m_gridScrollArea); + m_gridWidget->layout()->setAlignment(Qt::AlignCenter); + m_tableWidget->setAlternatingRowColors(true); m_logWidget->setObjectName("logWidget"); @@ -658,6 +676,7 @@ MainWindow::~MainWindow() delete m_thumbnailPixmap2; if (m_thumbnailPixmap3) delete m_thumbnailPixmap3; + removeGridItems(); } void MainWindow::showWelcomeScreen() @@ -2512,7 +2531,8 @@ void MainWindow::onCurrentListItemChanged(QListWidgetItem *current, QListWidgetI if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)) return; - initContentTableWidget(); + //initContentTableWidget(); + initContentGridLayout(); setCoreActions(); } @@ -2521,6 +2541,16 @@ TableWidget* MainWindow::contentTableWidget() return m_tableWidget; } +QWidget* MainWindow::contentGridWidget() +{ + return m_gridWidget; +} + +FlowLayout* MainWindow::contentGridLayout() +{ + return m_gridLayout; +} + void MainWindow::onBrowserDownloadsClicked() { settings_t *settings = config_get_ptr(); @@ -2700,6 +2730,98 @@ void MainWindow::onLoadCoreClicked(const QStringList &extensionFilters) m_loadCoreWindow->initCoreList(extensionFilters); } +void MainWindow::removeGridItems() +{ + if (m_gridItems.count() > 0) + { + QMutableListIterator items(m_gridItems); + + while (items.hasNext()) + { + GridItem *item = items.next(); + + if (item) + { + items.remove(); + + m_gridLayout->removeWidget(item->widget); + + delete item->widget; + delete item; + } + } + } +} + +void MainWindow::addPlaylistItemsToGrid(QString pathString) +{ + QList > items = getPlaylistItems(pathString); + settings_t *settings = config_get_ptr(); + int i = 0; + + for (i = 0; i < items.count(); i++) + { + const QHash &hash = items.at(i); + GridItem *item = new GridItem(); + ThumbnailLabel *label = NULL; + QPixmap pixmap; + QString thumbnailFileNameNoExt; + QLabel *newLabel = NULL; + + thumbnailFileNameNoExt = hash["label_noext"]; + thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); + + item->hash = hash; + item->widget = new ThumbnailWidget(); + item->widget->setFixedSize(item->widget->sizeHint()); + item->widget->setLayout(new QVBoxLayout()); + item->widget->setStyleSheet("background-color: #555555"); + + label = new ThumbnailLabel(item->widget); + + pixmap = QPixmap(QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"); + + label->setPixmap(pixmap); + + item->widget->layout()->addWidget(label); + + newLabel = new QLabel(hash.value("label"), item->widget); + newLabel->setAlignment(Qt::AlignCenter); + + item->widget->layout()->addWidget(newLabel); + qobject_cast(item->widget->layout())->setStretchFactor(label, 1); + + m_gridLayout->addWidget(item->widget); + m_gridItems.append(item); + } +} + +void MainWindow::initContentGridLayout() +{ + QListWidgetItem *item = m_listWidget->currentItem(); + QString path; + + if (!item) + return; + + removeGridItems(); + + path = item->data(Qt::UserRole).toString(); + + if (path == ALL_PLAYLISTS_TOKEN) + { + settings_t *settings = config_get_ptr(); + QDir playlistDir(settings->paths.directory_playlist); + + foreach (QString playlist, m_playlistFiles) + { + addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist)); + } + } + else + addPlaylistItemsToGrid(path); +} + void MainWindow::initContentTableWidget() { QListWidgetItem *item = m_listWidget->currentItem(); @@ -2759,14 +2881,14 @@ void MainWindow::initContentTableWidget() onSearchEnterPressed(); } -void MainWindow::addPlaylistItemsToTable(QString pathString) +QList > MainWindow::getPlaylistItems(QString pathString) { QByteArray pathArray; + QList > items; const char *pathData = NULL; playlist_t *playlist = NULL; unsigned playlistSize = 0; unsigned i = 0; - int oldRowCount = m_tableWidget->rowCount(); pathArray.append(pathString); pathData = pathArray.constData(); @@ -2774,8 +2896,6 @@ void MainWindow::addPlaylistItemsToTable(QString pathString) playlist = playlist_init(pathData, COLLECTION_SIZE); playlistSize = playlist_get_size(playlist); - m_tableWidget->setRowCount(oldRowCount + playlistSize); - for (i = 0; i < playlistSize; i++) { const char *path = NULL; @@ -2784,7 +2904,6 @@ void MainWindow::addPlaylistItemsToTable(QString pathString) const char *core_name = NULL; const char *crc32 = NULL; const char *db_name = NULL; - QTableWidgetItem *labelItem = NULL; QHash hash; playlist_get_index(playlist, i, @@ -2822,15 +2941,40 @@ void MainWindow::addPlaylistItemsToTable(QString pathString) hash["db_name"].remove(file_path_str(FILE_PATH_LPL_EXTENSION)); } - labelItem = new QTableWidgetItem(hash["label"]); + items.append(hash); + } + + playlist_free(playlist); + playlist = NULL; + + return items; +} + +void MainWindow::addPlaylistItemsToTable(QString pathString) +{ + QList > items = getPlaylistItems(pathString); + int i = 0; + int oldRowCount = m_tableWidget->rowCount(); + + m_tableWidget->setRowCount(oldRowCount + items.count()); + + for (i = 0; i < items.count(); i++) + { + const char *path = NULL; + const char *label = NULL; + const char *core_path = NULL; + const char *core_name = NULL; + const char *crc32 = NULL; + const char *db_name = NULL; + QTableWidgetItem *labelItem = NULL; + const QHash &hash = items.at(i); + + labelItem = new QTableWidgetItem(hash.value("label")); labelItem->setData(Qt::UserRole, QVariant::fromValue >(hash)); labelItem->setFlags(labelItem->flags() & ~Qt::ItemIsEditable); m_tableWidget->setItem(oldRowCount + i, 0, labelItem); } - - playlist_free(playlist); - playlist = NULL; } void MainWindow::keyPressEvent(QKeyEvent *event) diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 6a5272b39b..e800e4920b 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -256,6 +256,9 @@ static void* ui_companion_qt_init(void) layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); + layout->addWidget(mainwindow->contentGridWidget()); + + mainwindow->contentTableWidget()->hide(); widget->setLayout(layout); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 5ebd251212..725196ecb0 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -57,6 +57,14 @@ class QStyle; class QScrollArea; class LoadCoreWindow; class MainWindow; +class ThumbnailWidget; +class FlowLayout; + +struct GridItem +{ + ThumbnailWidget *widget; + QHash hash; +}; class ThumbnailWidget : public QWidget { @@ -223,6 +231,8 @@ public: TreeView* dirTreeView(); QListWidget* playlistListWidget(); TableWidget* contentTableWidget(); + FlowLayout* contentGridLayout(); + QWidget* contentGridWidget(); QWidget* searchWidget(); QLineEdit* searchLineEdit(); QComboBox* launchWithComboBox(); @@ -259,6 +269,7 @@ public slots: void onBrowserUpClicked(); void onBrowserStartClicked(); void initContentTableWidget(); + void initContentGridLayout(); void onViewClosedDocksAboutToShow(); void onShowHiddenDockWidgetAction(); void setCoreActions(); @@ -288,6 +299,7 @@ private slots: void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); void addPlaylistItemsToTable(QString path); + void addPlaylistItemsToGrid(QString path); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); void onTabWidgetIndexChanged(int index); @@ -303,6 +315,8 @@ private: void getPlaylistFiles(); bool isCoreLoaded(); bool isContentLessCore(); + void removeGridItems(); + QList > getPlaylistItems(QString pathString); LoadCoreWindow *m_loadCoreWindow; QTimer *m_timer; @@ -344,6 +358,10 @@ private: QListWidgetItem *m_historyPlaylistsItem; QIcon m_folderIcon; QString m_customThemeString; + FlowLayout *m_gridLayout; + QWidget *m_gridWidget; + QScrollArea *m_gridScrollArea; + QList m_gridItems; protected: void closeEvent(QCloseEvent *event); From f79ba4885a33a30cd7ed4377ba01e5a4c1f610c6 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 00:49:43 -0400 Subject: [PATCH 20/78] Qt: threaded grid image loading --- Makefile.common | 4 ++-- qb/config.libs.sh | 4 +++- ui/drivers/qt/ui_qt_window.cpp | 41 ++++++++++++++++++++++++++++++---- ui/drivers/ui_qt.h | 12 ++++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/Makefile.common b/Makefile.common index c522edea25..44d9185717 100644 --- a/Makefile.common +++ b/Makefile.common @@ -338,9 +338,9 @@ OBJ += ui/drivers/ui_qt.o \ MOC_HEADERS += ui/drivers/ui_qt.h \ ui/drivers/qt/ui_qt_load_core_window.h -DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) -DHAVE_MAIN +DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) -DHAVE_MAIN #DEFINES += $(QT5WEBENGINE_CFLAGS) -LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) +LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) $(QT5CONCURRENT_LIBS) #LIBS += $(QT5WEBENGINE_LIBS) NEED_CXX_LINKER = 1 diff --git a/qb/config.libs.sh b/qb/config.libs.sh index e36974ceef..509dc480fb 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -276,14 +276,16 @@ if [ "$HAVE_QT" != 'no' ] && [ "$MOC_PATH" != 'none' ]; then check_pkgconf QT5CORE Qt5Core 5.2 check_pkgconf QT5GUI Qt5Gui 5.2 check_pkgconf QT5WIDGETS Qt5Widgets 5.2 + check_pkgconf QT5CONCURRENT Qt5Concurrent 5.2 #check_pkgconf QT5WEBENGINE Qt5WebEngine 5.4 check_val '' QT5CORE -lQt5Core QT5CORE check_val '' QT5GUI -lQt5Gui QT5GUI check_val '' QT5WIDGETS -lQt5Widgets QT5WIDGETS + check_val '' QT5CONCURRENT -lQt5Widgets QT5CONCURRENT #check_val '' QT5WEBENGINE -lQt5WebEngine QT5WEBENGINE - if [ "$HAVE_QT5CORE" = "no" ] || [ "$HAVE_QT5GUI" = "no" ] || [ "$HAVE_QT5WIDGETS" = "no" ]; then + if [ "$HAVE_QT5CORE" = "no" ] || [ "$HAVE_QT5GUI" = "no" ] || [ "$HAVE_QT5WIDGETS" = "no" ] || [ "$HAVE_QT5CONCURRENT" = "no" ]; then die : 'Notice: Not building Qt support, required libraries were not found.' HAVE_QT=no else diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 1261950f71..be9edf4ca2 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "../ui_qt.h" #include "ui_qt_load_core_window.h" @@ -101,6 +102,16 @@ static void scan_finished_handler(void *task_data, void *user_data, const char * } #endif +GridItem::GridItem() : + widget(NULL) + ,label(NULL) + ,hash() + ,image() + ,pixmap() + ,imageWatcher() +{ +} + TreeView::TreeView(QWidget *parent) : QTreeView(parent) { @@ -2753,6 +2764,29 @@ void MainWindow::removeGridItems() } } +void MainWindow::onDeferredImageLoaded() +{ + const QFutureWatcher *watcher = static_cast*>(sender()); + GridItem *item = watcher->result(); + + if (!item->image.isNull()) + item->label->setPixmap(QPixmap::fromImage(item->image)); +} + +void MainWindow::loadImageDeferred(GridItem *item, QString path) +{ + connect(&item->imageWatcher, SIGNAL(finished()), this, SLOT(onDeferredImageLoaded()), Qt::QueuedConnection); + item->imageWatcher.setFuture(QtConcurrent::run(this, &MainWindow::doDeferredImageLoad, item, path)); +} + +GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) +{ + /* this runs in another thread */ + item->image = QImage(path); + + return item; +} + void MainWindow::addPlaylistItemsToGrid(QString pathString) { QList > items = getPlaylistItems(pathString); @@ -2764,7 +2798,6 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) const QHash &hash = items.at(i); GridItem *item = new GridItem(); ThumbnailLabel *label = NULL; - QPixmap pixmap; QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; @@ -2779,9 +2812,7 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) label = new ThumbnailLabel(item->widget); - pixmap = QPixmap(QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"); - - label->setPixmap(pixmap); + item->label = label; item->widget->layout()->addWidget(label); @@ -2793,6 +2824,8 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) m_gridLayout->addWidget(item->widget); m_gridItems.append(item); + + loadImageDeferred(item, QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"); } } diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 725196ecb0..888c6ac2f3 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include extern "C" { #include @@ -58,12 +60,19 @@ class QScrollArea; class LoadCoreWindow; class MainWindow; class ThumbnailWidget; +class ThumbnailLabel; class FlowLayout; struct GridItem { + GridItem(); + ThumbnailWidget *widget; + ThumbnailLabel *label; QHash hash; + QImage image; + QPixmap pixmap; + QFutureWatcher imageWatcher; }; class ThumbnailWidget : public QWidget @@ -255,6 +264,7 @@ public: bool setCustomThemeFile(QString filePath); void setCustomThemeString(QString qss); const QString& customThemeString() const; + GridItem* doDeferredImageLoad(GridItem *item, QString path); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -309,6 +319,7 @@ private slots: void onFileBrowserTreeContextMenuRequested(const QPoint &pos); void onPlaylistWidgetContextMenuRequested(const QPoint &pos); void onStopClicked(); + void onDeferredImageLoaded(); private: void setCurrentCoreLabel(); @@ -316,6 +327,7 @@ private: bool isCoreLoaded(); bool isContentLessCore(); void removeGridItems(); + void loadImageDeferred(GridItem *item, QString path); QList > getPlaylistItems(QString pathString); LoadCoreWindow *m_loadCoreWindow; From 8752996018c211f8c986f88e750a9bb34e90d202 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 02:47:40 -0400 Subject: [PATCH 21/78] Qt: add grid zoom slider --- ui/drivers/qt/ui_qt_window.cpp | 45 +++++++++++++++++++++++++++++++--- ui/drivers/ui_qt.h | 6 +++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index be9edf4ca2..396ec9e498 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -499,30 +499,51 @@ MainWindow::MainWindow(QWidget *parent) : ,m_historyPlaylistsItem(NULL) ,m_folderIcon() ,m_customThemeString() - ,m_gridLayout(new FlowLayout()) + ,m_gridLayout(NULL) ,m_gridWidget(new QWidget(this)) ,m_gridScrollArea(new QScrollArea(m_gridWidget)) ,m_gridItems() + ,m_gridLayoutWidget(new QWidget()) + ,m_zoomSlider(NULL) + ,m_lastZoomSliderValue(0) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); QString configDir = QFileInfo(path_get(RARCH_PATH_CONFIG)).dir().absolutePath(); QToolButton *searchResetButton = NULL; - QWidget *gridLayoutWidget = new QWidget(); + QWidget *zoomWidget = new QWidget(); + QHBoxLayout *zoomLayout = new QHBoxLayout(); int i = 0; + m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); + + m_zoomSlider->setMinimum(0); + m_zoomSlider->setMaximum(100); + m_zoomSlider->setValue(50); + + m_lastZoomSliderValue = m_zoomSlider->value(); + m_gridWidget->setLayout(new QVBoxLayout()); - gridLayoutWidget->setLayout(m_gridLayout); + m_gridLayout = new FlowLayout(m_gridLayoutWidget); m_gridScrollArea->setAlignment(Qt::AlignCenter); m_gridScrollArea->setFrameShape(QFrame::NoFrame); m_gridScrollArea->setWidgetResizable(true); - m_gridScrollArea->setWidget(gridLayoutWidget); + m_gridScrollArea->setWidget(m_gridLayoutWidget); m_gridWidget->layout()->addWidget(m_gridScrollArea); m_gridWidget->layout()->setAlignment(Qt::AlignCenter); + m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred)); + + zoomWidget->setLayout(zoomLayout); + zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); + zoomLayout->addWidget(new QLabel("Zoom:")); + zoomLayout->addWidget(m_zoomSlider); + + m_gridWidget->layout()->addWidget(zoomWidget); + m_tableWidget->setAlternatingRowColors(true); m_logWidget->setObjectName("logWidget"); @@ -644,6 +665,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_dirTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileBrowserTreeContextMenuRequested(const QPoint&))); connect(m_listWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onPlaylistWidgetContextMenuRequested(const QPoint&))); connect(m_launchWithComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLaunchWithComboBoxIndexChanged(int))); + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onZoomValueChanged(int))); /* make sure these use an auto connection so it will be queued if called from a different thread (some facilities in RA log messages from other threads) */ connect(this, SIGNAL(gotLogMessage(const QString&)), this, SLOT(onGotLogMessage(const QString&)), Qt::AutoConnection); @@ -687,9 +709,20 @@ MainWindow::~MainWindow() delete m_thumbnailPixmap2; if (m_thumbnailPixmap3) delete m_thumbnailPixmap3; + removeGridItems(); } +void MainWindow::onZoomValueChanged(int value) +{ + foreach(GridItem *item, m_gridItems) + { + item->widget->setFixedSize(QSize(value * 5.12f, value * 5.12f)); + } + + m_lastZoomSliderValue = value; +} + void MainWindow::showWelcomeScreen() { const QString welcomeText = QStringLiteral("" @@ -2853,6 +2886,10 @@ void MainWindow::initContentGridLayout() } else addPlaylistItemsToGrid(path); + + QTimer::singleShot(0, this, [this]() { + m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); + }); } void MainWindow::initContentTableWidget() diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 888c6ac2f3..1c104c3d36 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -29,6 +29,7 @@ #include #include #include +#include #include extern "C" { @@ -57,6 +58,7 @@ class QCheckBox; class QFormLayout; class QStyle; class QScrollArea; +class QSlider; class LoadCoreWindow; class MainWindow; class ThumbnailWidget; @@ -320,6 +322,7 @@ private slots: void onPlaylistWidgetContextMenuRequested(const QPoint &pos); void onStopClicked(); void onDeferredImageLoaded(); + void onZoomValueChanged(int value); private: void setCurrentCoreLabel(); @@ -374,6 +377,9 @@ private: QWidget *m_gridWidget; QScrollArea *m_gridScrollArea; QList m_gridItems; + QWidget *m_gridLayoutWidget; + QSlider *m_zoomSlider; + int m_lastZoomSliderValue; protected: void closeEvent(QCloseEvent *event); From 5fa0d75bd784dae24418942e380f7b3ad637e93d Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 16:12:48 -0400 Subject: [PATCH 22/78] adjust zoom factors --- ui/drivers/qt/ui_qt_window.cpp | 13 ++++++++----- ui/drivers/ui_qt.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 396ec9e498..e11af15c70 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -517,8 +517,8 @@ MainWindow::MainWindow(QWidget *parent) : m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); - m_zoomSlider->setMinimum(0); - m_zoomSlider->setMaximum(100); + m_zoomSlider->setMinimum(20); + m_zoomSlider->setMaximum(400); m_zoomSlider->setValue(50); m_lastZoomSliderValue = m_zoomSlider->value(); @@ -2887,9 +2887,12 @@ void MainWindow::initContentGridLayout() else addPlaylistItemsToGrid(path); - QTimer::singleShot(0, this, [this]() { - m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); - }); + QTimer::singleShot(0, this, SLOT(onContentGridInited())); +} + +void MainWindow::onContentGridInited() +{ + m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); } void MainWindow::initContentTableWidget() diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 1c104c3d36..6bd22e7821 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -323,6 +323,7 @@ private slots: void onStopClicked(); void onDeferredImageLoaded(); void onZoomValueChanged(int value); + void onContentGridInited(); private: void setCurrentCoreLabel(); From 758d484874fbacf3881d33a93c6daf14dd5e5d87 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 16:31:46 -0400 Subject: [PATCH 23/78] Qt: use primary screen size divided by 8 for grid item size --- ui/drivers/qt/ui_qt_window.cpp | 4 ++++ ui/drivers/ui_qt.cpp | 8 +++++++- ui/drivers/ui_qt.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index e11af15c70..c89db53d6d 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2823,6 +2823,8 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) void MainWindow::addPlaylistItemsToGrid(QString pathString) { QList > items = getPlaylistItems(pathString); + QScreen *screen = qApp->primaryScreen(); + QSize screenSize = screen->size(); settings_t *settings = config_get_ptr(); int i = 0; @@ -2833,12 +2835,14 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) ThumbnailLabel *label = NULL; QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; + QSize thumbnailWidgetSizeHint(screenSize.width() / 8, screenSize.height() / 8); thumbnailFileNameNoExt = hash["label_noext"]; thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); item->hash = hash; item->widget = new ThumbnailWidget(); + item->widget->setSizeHint(thumbnailWidgetSizeHint); item->widget->setFixedSize(item->widget->sizeHint()); item->widget->setLayout(new QVBoxLayout()); item->widget->setStyleSheet("background-color: #555555"); diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index e800e4920b..842bacd396 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -57,6 +57,7 @@ typedef struct ui_companion_qt ThumbnailWidget::ThumbnailWidget(QWidget *parent) : QWidget(parent) + ,m_sizeHint(QSize(256, 256)) { } @@ -80,7 +81,12 @@ void ThumbnailWidget::resizeEvent(QResizeEvent *event) QSize ThumbnailWidget::sizeHint() const { - return QSize(256, 256); + return m_sizeHint; +} + +void ThumbnailWidget::setSizeHint(QSize size) +{ + m_sizeHint = size; } ThumbnailLabel::ThumbnailLabel(QWidget *parent) : diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 6bd22e7821..c771143526 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -83,6 +83,9 @@ class ThumbnailWidget : public QWidget public: ThumbnailWidget(QWidget *parent = 0); QSize sizeHint() const; + void setSizeHint(QSize size); +private: + QSize m_sizeHint; protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); From c42ad9fbb931b19340dc16a78ca4ad1391b06565 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 16:37:36 -0400 Subject: [PATCH 24/78] Qt: respect current zoom level when changing playlists --- ui/drivers/qt/ui_qt_window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index c89db53d6d..620b5e6232 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2897,6 +2897,8 @@ void MainWindow::initContentGridLayout() void MainWindow::onContentGridInited() { m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); + + onZoomValueChanged(m_zoomSlider->value()); } void MainWindow::initContentTableWidget() From c10e65e99e9e9be3a7a08d1b152f2fea18f076c4 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 16:46:19 -0400 Subject: [PATCH 25/78] Qt: support image playlist in grid layout --- ui/drivers/qt/ui_qt_window.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 620b5e6232..2020601da3 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2836,6 +2836,32 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; QSize thumbnailWidgetSizeHint(screenSize.width() / 8, screenSize.height() / 8); + QByteArray extension; + QString extensionStr; + QString imagePath; + int lastIndex = -1; + + lastIndex = hash["path"].lastIndexOf('.'); + + if (lastIndex >= 0) + { + extensionStr = hash["path"].mid(lastIndex + 1); + + if (!extensionStr.isEmpty()) + { + extension = extensionStr.toLower().toUtf8(); + } + } + + if (!extension.isEmpty() && m_imageFormats.contains(extension)) + { + /* use thumbnail widgets to show regular image files */ + imagePath = hash["path"]; + } + else + { + imagePath = QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"; + } thumbnailFileNameNoExt = hash["label_noext"]; thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); @@ -2862,7 +2888,7 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) m_gridLayout->addWidget(item->widget); m_gridItems.append(item); - loadImageDeferred(item, QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"); + loadImageDeferred(item, imagePath); } } From 6cab8cf13933b10326757062efa915efee3ffcbb Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 17:35:13 -0400 Subject: [PATCH 26/78] Qt: fix some grid images not drawing properly --- ui/drivers/qt/ui_qt_window.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 2020601da3..8961ff71a4 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2803,7 +2803,10 @@ void MainWindow::onDeferredImageLoaded() GridItem *item = watcher->result(); if (!item->image.isNull()) + { item->label->setPixmap(QPixmap::fromImage(item->image)); + item->label->update(); + } } void MainWindow::loadImageDeferred(GridItem *item, QString path) From 0f2262f065d76fe62c393a781e6e7d6b9805d744 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 18:55:12 -0400 Subject: [PATCH 27/78] Qt: fix thumbnail image loading --- ui/drivers/qt/ui_qt_window.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 8961ff71a4..5fab5440fc 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2863,12 +2863,11 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) } else { + thumbnailFileNameNoExt = hash["label_noext"]; + thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); imagePath = QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"; } - thumbnailFileNameNoExt = hash["label_noext"]; - thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); - item->hash = hash; item->widget = new ThumbnailWidget(); item->widget->setSizeHint(thumbnailWidgetSizeHint); From e372bb5320335131a7aca07d3c97542e9249fcf5 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 22:10:45 -0400 Subject: [PATCH 28/78] Qt: cut maximum zoom slider value in half --- ui/drivers/qt/ui_qt_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 5fab5440fc..f0d0a8e497 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -518,7 +518,7 @@ MainWindow::MainWindow(QWidget *parent) : m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); m_zoomSlider->setMinimum(20); - m_zoomSlider->setMaximum(400); + m_zoomSlider->setMaximum(200); m_zoomSlider->setValue(50); m_lastZoomSliderValue = m_zoomSlider->value(); From fc3251b6a9cdf1650b809899336ae3236ee2dee6 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 3 May 2018 23:58:15 -0400 Subject: [PATCH 29/78] Qt: use non-linear scale for zoom slider --- ui/drivers/qt/ui_qt_window.cpp | 37 ++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index f0d0a8e497..a54c2363c4 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -54,6 +54,7 @@ extern "C" { #include #include #include +#include } #define TIMER_MSEC 1000 /* periodic timer for gathering statistics */ @@ -85,6 +86,24 @@ enum CoreSelection CORE_SELECTION_LOAD_CORE }; +static double lerp(double x, double y, double a, double b, double d) { + return a + (b - a) * ((double)(d - x) / (double)(y - x)); +} + +/* https://stackoverflow.com/questions/7246622/how-to-create-a-slider-with-a-non-linear-scale */ +static double expScale(double inputValue, double midValue, double maxValue) +{ + double returnValue = 0; + double M = maxValue / midValue; + double C = log(pow(M - 1, 2)); + double B = maxValue / (exp(C) - 1); + double A = -1 * B; + + returnValue = A + B * exp(C * inputValue); + + return returnValue; +} + #ifdef HAVE_LIBRETRODB static void scan_finished_handler(void *task_data, void *user_data, const char *err) { @@ -513,12 +532,15 @@ MainWindow::MainWindow(QWidget *parent) : QToolButton *searchResetButton = NULL; QWidget *zoomWidget = new QWidget(); QHBoxLayout *zoomLayout = new QHBoxLayout(); + QLabel *zoomLabel = new QLabel("Zoom:", zoomWidget); int i = 0; + zoomLabel->setObjectName("zoomLabel"); + m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); - m_zoomSlider->setMinimum(20); - m_zoomSlider->setMaximum(200); + m_zoomSlider->setMinimum(0); + m_zoomSlider->setMaximum(100); m_zoomSlider->setValue(50); m_lastZoomSliderValue = m_zoomSlider->value(); @@ -539,7 +561,7 @@ MainWindow::MainWindow(QWidget *parent) : zoomWidget->setLayout(zoomLayout); zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); - zoomLayout->addWidget(new QLabel("Zoom:")); + zoomLayout->addWidget(zoomLabel); zoomLayout->addWidget(m_zoomSlider); m_gridWidget->layout()->addWidget(zoomWidget); @@ -717,7 +739,14 @@ void MainWindow::onZoomValueChanged(int value) { foreach(GridItem *item, m_gridItems) { - item->widget->setFixedSize(QSize(value * 5.12f, value * 5.12f)); + int newSize = 0; + + if (value < 50) + newSize = expScale(lerp(0, 49, 25, 49, value) / 50.0, 102, 256); + else + newSize = expScale(value / 100.0, 256, 1024); + + item->widget->setFixedSize(QSize(newSize, newSize)); } m_lastZoomSliderValue = value; From a082ea7d76edba8b946321efd370899901430f57 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 4 May 2018 12:05:53 -0400 Subject: [PATCH 30/78] Qt: remove zoom layout margins --- ui/drivers/qt/ui_qt_window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index a54c2363c4..f4e12045b3 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -560,6 +560,7 @@ MainWindow::MainWindow(QWidget *parent) : m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred)); zoomWidget->setLayout(zoomLayout); + zoomLayout->setContentsMargins(0, 0, 0, 0); zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); zoomLayout->addWidget(zoomLabel); zoomLayout->addWidget(m_zoomSlider); From 8e7e530747e73ea6f80ce6722f2968e123b4a70b Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 5 May 2018 17:02:03 -0400 Subject: [PATCH 31/78] Qt: fix crash on switching playlists quickly --- ui/drivers/qt/ui_qt_window.cpp | 31 ++++++++++++++++++++++++++++++- ui/drivers/ui_qt.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index f4e12045b3..b263402e9b 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -128,6 +128,7 @@ GridItem::GridItem() : ,image() ,pixmap() ,imageWatcher() + ,mutex() { } @@ -738,8 +739,12 @@ MainWindow::~MainWindow() void MainWindow::onZoomValueChanged(int value) { + if (m_gridItems.count() == 0) + return; + foreach(GridItem *item, m_gridItems) { + QMutexLocker lock(&item->mutex); int newSize = 0; if (value < 50) @@ -2816,11 +2821,16 @@ void MainWindow::removeGridItems() if (item) { + item->mutex.lock(); + items.remove(); m_gridLayout->removeWidget(item->widget); delete item->widget; + + item->mutex.unlock(); + delete item; } } @@ -2830,13 +2840,25 @@ void MainWindow::removeGridItems() void MainWindow::onDeferredImageLoaded() { const QFutureWatcher *watcher = static_cast*>(sender()); - GridItem *item = watcher->result(); + GridItem *item = NULL; + + if (!watcher) + return; + + item = watcher->result(); + + if (!item) + return; + + item->mutex.lock(); if (!item->image.isNull()) { item->label->setPixmap(QPixmap::fromImage(item->image)); item->label->update(); } + + item->mutex.unlock(); } void MainWindow::loadImageDeferred(GridItem *item, QString path) @@ -2848,8 +2870,15 @@ void MainWindow::loadImageDeferred(GridItem *item, QString path) GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) { /* this runs in another thread */ + if (!item) + return NULL; + + item->mutex.lock(); + item->image = QImage(path); + item->mutex.unlock(); + return item; } diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index c771143526..91099e6e65 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -75,6 +75,7 @@ struct GridItem QImage image; QPixmap pixmap; QFutureWatcher imageWatcher; + QMutex mutex; }; class ThumbnailWidget : public QWidget From d55b1a0ad40255cef1339a00a78c06348500a7b3 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 5 May 2018 22:57:29 -0400 Subject: [PATCH 32/78] Qt: only check for pending events of the main thread --- ui/drivers/qt/ui_qt_application.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/drivers/qt/ui_qt_application.cpp b/ui/drivers/qt/ui_qt_application.cpp index e8a73a6e9f..f52059395d 100644 --- a/ui/drivers/qt/ui_qt_application.cpp +++ b/ui/drivers/qt/ui_qt_application.cpp @@ -15,6 +15,7 @@ */ #include +#include extern "C" { #include "../../ui_companion_driver.h" @@ -144,13 +145,18 @@ static void* ui_application_qt_initialize(void) static bool ui_application_qt_pending_events(void) { - return QApplication::hasPendingEvents(); + QAbstractEventDispatcher *dispatcher = QApplication::eventDispatcher(); + + if (dispatcher) + return dispatcher->hasPendingEvents(); + + return false; } static void ui_application_qt_process_events(void) { - if(ui_application_qt_pending_events()) - QApplication::processEvents(); + if (ui_application_qt_pending_events()) + QApplication::processEvents(); } static void ui_application_qt_quit(void) From de71a4dee79df72a600d5c3270125b7bc6cbc360 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 6 May 2018 01:36:47 -0400 Subject: [PATCH 33/78] Qt: general performance improvements, fix crash on switching playlists quickly in grid view, prevent initial loading of grid items from blocking --- ui/drivers/qt/flowlayout.cpp | 187 +++++++++++++---------- ui/drivers/qt/flowlayout.h | 48 +++--- ui/drivers/qt/ui_qt_load_core_window.cpp | 5 +- ui/drivers/qt/ui_qt_window.cpp | 158 ++++++++++++------- ui/drivers/ui_qt.h | 12 +- 5 files changed, 253 insertions(+), 157 deletions(-) diff --git a/ui/drivers/qt/flowlayout.cpp b/ui/drivers/qt/flowlayout.cpp index 0dd3a1f606..6719c13f5c 100644 --- a/ui/drivers/qt/flowlayout.cpp +++ b/ui/drivers/qt/flowlayout.cpp @@ -48,153 +48,184 @@ ** ****************************************************************************/ +/* Original work Copyright (C) 2016 The Qt Company Ltd. + * Modified work Copyright (C) 2018 - Brad Parker + */ #include #include "flowlayout.h" + FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) - : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) + : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) { - setContentsMargins(margin, margin, margin, margin); + setContentsMargins(margin, margin, margin, margin); } FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) - : m_hSpace(hSpacing), m_vSpace(vSpacing) + : m_hSpace(hSpacing), m_vSpace(vSpacing) { - setContentsMargins(margin, margin, margin, margin); + setContentsMargins(margin, margin, margin, margin); } FlowLayout::~FlowLayout() { - QLayoutItem *item; - while ((item = takeAt(0))) - delete item; + QLayoutItem *item; + + while ((item = takeAt(0))) + delete item; } void FlowLayout::addItem(QLayoutItem *item) { - itemList.append(item); + itemList.append(item); } int FlowLayout::horizontalSpacing() const { - if (m_hSpace >= 0) { - return m_hSpace; - } else { - return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); - } + if (m_hSpace >= 0) + return m_hSpace; + else + return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); } int FlowLayout::verticalSpacing() const { - if (m_vSpace >= 0) { - return m_vSpace; - } else { - return smartSpacing(QStyle::PM_LayoutVerticalSpacing); - } + if (m_vSpace >= 0) + return m_vSpace; + else + return smartSpacing(QStyle::PM_LayoutVerticalSpacing); } int FlowLayout::count() const { - return itemList.size(); + return itemList.size(); } -QLayoutItem *FlowLayout::itemAt(int index) const +QLayoutItem* FlowLayout::itemAt(int index) const { - return itemList.value(index); + return itemList.value(index); } -QLayoutItem *FlowLayout::takeAt(int index) +QLayoutItem* FlowLayout::takeAt(int index) { - if (index >= 0 && index < itemList.size()) - return itemList.takeAt(index); - else - return 0; + if (index >= 0 && index < itemList.size()) + return itemList.takeAt(index); + else + return NULL; } Qt::Orientations FlowLayout::expandingDirections() const { - return 0; + return 0; } bool FlowLayout::hasHeightForWidth() const { - return true; + return true; } int FlowLayout::heightForWidth(int width) const { - int height = doLayout(QRect(0, 0, width, 0), true); - return height; + int height = doLayout(QRect(0, 0, width, 0), true); + return height; } void FlowLayout::setGeometry(const QRect &rect) { - QLayout::setGeometry(rect); - doLayout(rect, false); + QLayout::setGeometry(rect); + doLayout(rect, false); } QSize FlowLayout::sizeHint() const { - return minimumSize(); + return minimumSize(); } QSize FlowLayout::minimumSize() const { - QSize size; - QLayoutItem *item; - foreach (item, itemList) - size = size.expandedTo(item->minimumSize()); + QSize size; + int i = 0; - size += QSize(2*margin(), 2*margin()); - return size; + if (itemList.isEmpty()) + return size; + + for (i = 0; i < itemList.count(); i++) + { + const QLayoutItem *item = itemList.at(i); + size = size.expandedTo(item->minimumSize()); + } + + size += QSize(2 * margin(), 2 * margin()); + return size; } int FlowLayout::doLayout(const QRect &rect, bool testOnly) const { - int left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); - int x = effectiveRect.x(); - int y = effectiveRect.y(); - int lineHeight = 0; + QRect effectiveRect; + int left = 0, top = 0, right = 0, bottom = 0; + int x = 0; + int y = 0; + int lineHeight = 0; + int i = 0; - QLayoutItem *item; - foreach (item, itemList) { - QWidget *wid = item->widget(); - int spaceX = horizontalSpacing(); - if (spaceX == -1) - spaceX = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); - int spaceY = verticalSpacing(); - if (spaceY == -1) - spaceY = wid->style()->layoutSpacing( - QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); - int nextX = x + item->sizeHint().width() + spaceX; - if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { - x = effectiveRect.x(); - y = y + lineHeight + spaceY; - nextX = x + item->sizeHint().width() + spaceX; - lineHeight = 0; - } + getContentsMargins(&left, &top, &right, &bottom); + effectiveRect = rect.adjusted(+left, +top, -right, -bottom); + x = effectiveRect.x(); + y = effectiveRect.y(); - if (!testOnly) - item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); + if (itemList.isEmpty()) + return y + lineHeight - rect.y() + bottom; - x = nextX; - lineHeight = qMax(lineHeight, item->sizeHint().height()); - } - return y + lineHeight - rect.y() + bottom; + for (i = 0; i < itemList.count(); i++) + { + QLayoutItem *item = itemList.at(i); + const QWidget *wid = item->widget(); + int spaceX = horizontalSpacing(); + int spaceY = 0; + int nextX = 0; + + if (spaceX == -1) + spaceX = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); + + spaceY = verticalSpacing(); + + if (spaceY == -1) + spaceY = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); + + nextX = x + item->sizeHint().width() + spaceX; + + if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) + { + x = effectiveRect.x(); + y = y + lineHeight + spaceY; + nextX = x + item->sizeHint().width() + spaceX; + lineHeight = 0; + } + + if (!testOnly) + item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); + + x = nextX; + lineHeight = qMax(lineHeight, item->sizeHint().height()); + } + + return y + lineHeight - rect.y() + bottom; } + int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const { - QObject *parent = this->parent(); - if (!parent) { - return -1; - } else if (parent->isWidgetType()) { - QWidget *pw = static_cast(parent); - return pw->style()->pixelMetric(pm, 0, pw); - } else { - return static_cast(parent)->spacing(); - } + const QObject *parentObj = parent(); + + if (!parentObj) + return -1; + else if (parentObj->isWidgetType()) + { + const QWidget *pw = static_cast(parentObj); + return pw->style()->pixelMetric(pm, 0, pw); + } + else + return static_cast(parentObj)->spacing(); } diff --git a/ui/drivers/qt/flowlayout.h b/ui/drivers/qt/flowlayout.h index 436ba5e4c6..282a43df94 100644 --- a/ui/drivers/qt/flowlayout.h +++ b/ui/drivers/qt/flowlayout.h @@ -48,7 +48,13 @@ ** ****************************************************************************/ -/* bparker: Removed C++11 override keyword from original source */ +/* Original work Copyright (C) 2016 The Qt Company Ltd. + * Modified work Copyright (C) 2018 - Brad Parker + */ + +/* bparker: Removed C++11 override keyword from original source + * Changed QList to QVector + */ #ifndef FLOWLAYOUT_H #define FLOWLAYOUT_H @@ -60,30 +66,30 @@ class FlowLayout : public QLayout { public: - explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); - explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); - ~FlowLayout(); + explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); + explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); + ~FlowLayout(); - void addItem(QLayoutItem *item); - int horizontalSpacing() const; - int verticalSpacing() const; - Qt::Orientations expandingDirections() const; - bool hasHeightForWidth() const; - int heightForWidth(int) const; - int count() const; - QLayoutItem *itemAt(int index) const; - QSize minimumSize() const; - void setGeometry(const QRect &rect); - QSize sizeHint() const; - QLayoutItem *takeAt(int index); + void addItem(QLayoutItem *item); + int horizontalSpacing() const; + int verticalSpacing() const; + Qt::Orientations expandingDirections() const; + bool hasHeightForWidth() const; + int heightForWidth(int) const; + int count() const; + QLayoutItem* itemAt(int index) const; + QSize minimumSize() const; + void setGeometry(const QRect &rect); + QSize sizeHint() const; + QLayoutItem* takeAt(int index); private: - int doLayout(const QRect &rect, bool testOnly) const; - int smartSpacing(QStyle::PixelMetric pm) const; + int doLayout(const QRect &rect, bool testOnly) const; + int smartSpacing(QStyle::PixelMetric pm) const; - QList itemList; - int m_hSpace; - int m_vSpace; + QVector itemList; + int m_hSpace; + int m_vSpace; }; #endif // FLOWLAYOUT_H diff --git a/ui/drivers/qt/ui_qt_load_core_window.cpp b/ui/drivers/qt/ui_qt_load_core_window.cpp index 65da0381fc..00f29f38de 100644 --- a/ui/drivers/qt/ui_qt_load_core_window.cpp +++ b/ui/drivers/qt/ui_qt_load_core_window.cpp @@ -266,8 +266,11 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters) if (rowsToHide.size() != m_table->rowCount()) { - foreach (const int &row, rowsToHide) + int i = 0; + + for (i = 0; i < rowsToHide.count() && rowsToHide.count() > 0; i++) { + const int &row = rowsToHide.at(i); m_table->setRowHidden(row, true); } } diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index b263402e9b..00da8a0ac6 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -200,7 +200,7 @@ void CoreInfoDialog::showCoreInfo() int row = 0; int rowCount = m_formLayout->rowCount(); int i = 0; - QList > infoList = m_mainwindow->getCoreInfo(); + QVector > infoList = m_mainwindow->getCoreInfo(); if (rowCount > 0) { @@ -526,6 +526,7 @@ MainWindow::MainWindow(QWidget *parent) : ,m_gridLayoutWidget(new QWidget()) ,m_zoomSlider(NULL) ,m_lastZoomSliderValue(0) + ,m_pendingItemUpdates() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -707,7 +708,7 @@ MainWindow::MainWindow(QWidget *parent) : qApp->processEvents(); QTimer::singleShot(0, this, SLOT(onBrowserStartClicked())); - for (i = 0; i < m_listWidget->count(); i++) + for (i = 0; i < m_listWidget->count() && m_listWidget->count() > 0; i++) { /* select the first non-hidden row */ if (!m_listWidget->isRowHidden(i)) @@ -737,22 +738,27 @@ MainWindow::~MainWindow() removeGridItems(); } +inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) +{ + QMutexLocker lock(&item->mutex); + int newSize = 0; + + if (zoomValue < 50) + newSize = expScale(lerp(0, 49, 25, 49, zoomValue) / 50.0, 102, 256); + else + newSize = expScale(zoomValue / 100.0, 256, 1024); + + item->widget->setFixedSize(QSize(newSize, newSize)); +} + void MainWindow::onZoomValueChanged(int value) { - if (m_gridItems.count() == 0) - return; + int i = 0; - foreach(GridItem *item, m_gridItems) + for (i = 0; i < m_gridItems.count() && m_gridItems.count() > 0; i++) { - QMutexLocker lock(&item->mutex); - int newSize = 0; - - if (value < 50) - newSize = expScale(lerp(0, 49, 25, 49, value) / 50.0, 102, 256); - else - newSize = expScale(value / 100.0, 256, 1024); - - item->widget->setFixedSize(QSize(newSize, newSize)); + GridItem *item = m_gridItems.at(i); + calcGridItemSize(item, value); } m_lastZoomSliderValue = value; @@ -948,20 +954,17 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&) menu->addAction(hideAction.data()); - if (m_listWidget->count() > 0) + for (j = 0; j < m_listWidget->count() && m_listWidget->count() > 0; j++) { - for (j = 0; j < m_listWidget->count(); j++) - { - QListWidgetItem *item = m_listWidget->item(j); - bool hidden = m_listWidget->isItemHidden(item); + QListWidgetItem *item = m_listWidget->item(j); + bool hidden = m_listWidget->isItemHidden(item); - if (hidden) - { - QAction *action = hiddenPlaylistsMenu->addAction(item->text()); - action->setProperty("row", j); - action->setProperty("core_path", item->data(Qt::UserRole).toString()); - foundHiddenPlaylist = true; - } + if (hidden) + { + QAction *action = hiddenPlaylistsMenu->addAction(item->text()); + action->setProperty("row", j); + action->setProperty("core_path", item->data(Qt::UserRole).toString()); + foundHiddenPlaylist = true; } } @@ -986,17 +989,28 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&) core_info_get_list(&core_info_list); - for (i = 0; i < core_info_list->count; i++) + for (i = 0; i < core_info_list->count && core_info_list->count > 0; i++) { const core_info_t *core = &core_info_list->list[i]; coreList[core->core_name] = core; } - foreach (const QString &key, coreList.keys()) { - const core_info_t *core = coreList.value(key); - QAction *action = associateMenu->addAction(core->core_name); - action->setProperty("core_path", core->path); + QMapIterator coreListIterator(coreList); + + while (coreListIterator.hasNext()) + { + QString key; + const core_info_t *core = NULL; + QAction *action = NULL; + + coreListIterator.next(); + + key = coreListIterator.key(); + core = coreList.value(key); + action = associateMenu->addAction(core->core_name); + action->setProperty("core_path", core->path); + } } menu->addMenu(associateMenu.data()); @@ -1180,6 +1194,7 @@ void MainWindow::reloadPlaylists() QDir playlistDir(settings->paths.directory_playlist); QString currentPlaylistPath; QStringList hiddenPlaylists = m_settings->value("hidden_playlists").toStringList(); + int i = 0; currentItem = m_listWidget->currentItem(); @@ -1230,9 +1245,10 @@ void MainWindow::reloadPlaylists() if (hiddenPlaylists.contains(QFileInfo(settings->paths.path_content_video_history).fileName())) m_listWidget->setRowHidden(m_listWidget->row(videoPlaylistsItem), true); - foreach (QString file, m_playlistFiles) + for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { QListWidgetItem *item = NULL; + const QString &file = m_playlistFiles.at(i); QString fileDisplayName = file; QString fileName = file; bool hasIcon = false; @@ -1270,7 +1286,6 @@ void MainWindow::reloadPlaylists() if (firstItem) { - int i = 0; bool found = false; for (i = 0; i < m_listWidget->count(); i++) @@ -1318,7 +1333,7 @@ void MainWindow::onGotLogMessage(const QString &msg) void MainWindow::onLaunchWithComboBoxIndexChanged(int) { - QList > infoList = getCoreInfo(); + QVector > infoList = getCoreInfo(); QString coreInfoText; QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value(); CoreSelection coreSelection = static_cast(coreMap.value("core_selection").toInt()); @@ -1423,9 +1438,9 @@ void MainWindow::setTheme(Theme theme) } } -QList > MainWindow::getCoreInfo() +QVector > MainWindow::getCoreInfo() { - QList > infoList; + QVector > infoList; QHash currentCore = getSelectedCore(); core_info_list_t *core_info_list = NULL; const core_info_t *core_info = NULL; @@ -1850,7 +1865,7 @@ QHash MainWindow::getSelectedCore() } case CORE_SELECTION_PLAYLIST_DEFAULT: { - QList > cores; + QVector > cores; int i = 0; if (!contentItem || contentHash["db_name"].isEmpty()) @@ -1982,7 +1997,7 @@ void MainWindow::onRunClicked() } case CORE_SELECTION_PLAYLIST_DEFAULT: { - QList > cores = getPlaylistDefaultCores(); + QVector > cores = getPlaylistDefaultCores(); int i = 0; for (i = 0; i < cores.count(); i++) @@ -2047,13 +2062,13 @@ ViewOptionsDialog* MainWindow::viewOptionsDialog() return m_viewOptionsDialog; } -QList > MainWindow::getPlaylistDefaultCores() +QVector > MainWindow::getPlaylistDefaultCores() { settings_t *settings = config_get_ptr(); struct string_list *playlists = string_split(settings->arrays.playlist_names, ";"); struct string_list *cores = string_split(settings->arrays.playlist_cores, ";"); unsigned i = 0; - QList > coreList; + QVector > coreList; if (!playlists || !cores) { @@ -2164,7 +2179,7 @@ void MainWindow::setCoreActions() if (!hash["db_name"].isEmpty()) { - QList > defaultCores = getPlaylistDefaultCores(); + QVector > defaultCores = getPlaylistDefaultCores(); int i = 0; if (defaultCores.count() > 0) @@ -2406,6 +2421,7 @@ void MainWindow::onViewClosedDocksAboutToShow() QMenu *menu = qobject_cast(sender()); QList dockWidgets; bool found = false; + int i = 0; if (!menu) return; @@ -2420,8 +2436,10 @@ void MainWindow::onViewClosedDocksAboutToShow() return; } - foreach (QDockWidget *dock, dockWidgets) + for (i = 0; i < dockWidgets.count() && dockWidgets.count() > 0; i++) { + const QDockWidget *dock = dockWidgets.at(i); + if (!dock->isVisible()) { QAction *action = menu->addAction(dock->property("menu_text").toString(), this, SLOT(onShowHiddenDockWidgetAction())); @@ -2431,9 +2449,7 @@ void MainWindow::onViewClosedDocksAboutToShow() } if (!found) - { menu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE)); - } } void MainWindow::onShowHiddenDockWidgetAction() @@ -2826,6 +2842,7 @@ void MainWindow::removeGridItems() items.remove(); m_gridLayout->removeWidget(item->widget); + m_pendingItemUpdates.removeAll(item); delete item->widget; @@ -2854,13 +2871,39 @@ void MainWindow::onDeferredImageLoaded() if (!item->image.isNull()) { - item->label->setPixmap(QPixmap::fromImage(item->image)); - item->label->update(); + m_pendingItemUpdates.append(item); + QTimer::singleShot(0, this, SLOT(onPendingItemUpdates())); } item->mutex.unlock(); } +void MainWindow::onPendingItemUpdates() +{ + QMutableListIterator list(m_pendingItemUpdates); + + while (list.hasNext()) + { + GridItem *item = list.next(); + + if (!item) + continue; + + onUpdateGridItemPixmapFromImage(item); + + list.remove(); + } +} + +void MainWindow::onUpdateGridItemPixmapFromImage(GridItem *item) +{ + if (!item) + return; + + item->label->setPixmap(QPixmap::fromImage(item->image)); + item->label->update(); +} + void MainWindow::loadImageDeferred(GridItem *item, QString path) { connect(&item->imageWatcher, SIGNAL(finished()), this, SLOT(onDeferredImageLoaded()), Qt::QueuedConnection); @@ -2882,13 +2925,14 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) return item; } -void MainWindow::addPlaylistItemsToGrid(QString pathString) +void MainWindow::addPlaylistItemsToGrid(const QString &pathString) { - QList > items = getPlaylistItems(pathString); + QVector > items = getPlaylistItems(pathString); QScreen *screen = qApp->primaryScreen(); QSize screenSize = screen->size(); settings_t *settings = config_get_ptr(); int i = 0; + int zoomValue = m_zoomSlider->value(); for (i = 0; i < items.count(); i++) { @@ -2938,6 +2982,8 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) item->label = label; + calcGridItemSize(item, zoomValue); + item->widget->layout()->addWidget(label); newLabel = new QLabel(hash.value("label"), item->widget); @@ -2950,6 +2996,8 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString) m_gridItems.append(item); loadImageDeferred(item, imagePath); + + qApp->processEvents(); } } @@ -2969,9 +3017,11 @@ void MainWindow::initContentGridLayout() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); + int i = 0; - foreach (QString playlist, m_playlistFiles) + for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { + const QString &playlist = m_playlistFiles.at(i); addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist)); } } @@ -3018,9 +3068,11 @@ void MainWindow::initContentTableWidget() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); + int i = 0; - foreach (QString playlist, m_playlistFiles) + for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { + const QString &playlist = m_playlistFiles.at(i); addPlaylistItemsToTable(playlistDir.absoluteFilePath(playlist)); } } @@ -3047,10 +3099,10 @@ void MainWindow::initContentTableWidget() onSearchEnterPressed(); } -QList > MainWindow::getPlaylistItems(QString pathString) +QVector > MainWindow::getPlaylistItems(QString pathString) { QByteArray pathArray; - QList > items; + QVector > items; const char *pathData = NULL; playlist_t *playlist = NULL; unsigned playlistSize = 0; @@ -3118,7 +3170,7 @@ QList > MainWindow::getPlaylistItems(QString pathString) void MainWindow::addPlaylistItemsToTable(QString pathString) { - QList > items = getPlaylistItems(pathString); + QVector > items = getPlaylistItems(pathString); int i = 0; int oldRowCount = m_tableWidget->rowCount(); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 91099e6e65..5344e2e842 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -256,10 +256,10 @@ public: QToolButton* runPushButton(); QToolButton* stopPushButton(); QTabWidget* browserAndPlaylistTabWidget(); - QList > getPlaylistDefaultCores(); + QVector > getPlaylistDefaultCores(); ViewOptionsDialog* viewOptionsDialog(); QSettings* settings(); - QList > getCoreInfo(); + QVector > getCoreInfo(); void setTheme(Theme theme = THEME_SYSTEM_DEFAULT); Theme theme(); Theme getThemeFromString(QString themeString); @@ -315,7 +315,7 @@ private slots: void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); void addPlaylistItemsToTable(QString path); - void addPlaylistItemsToGrid(QString path); + void addPlaylistItemsToGrid(const QString &path); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); void onTabWidgetIndexChanged(int index); @@ -328,6 +328,8 @@ private slots: void onDeferredImageLoaded(); void onZoomValueChanged(int value); void onContentGridInited(); + void onUpdateGridItemPixmapFromImage(GridItem *item); + void onPendingItemUpdates(); private: void setCurrentCoreLabel(); @@ -336,7 +338,8 @@ private: bool isContentLessCore(); void removeGridItems(); void loadImageDeferred(GridItem *item, QString path); - QList > getPlaylistItems(QString pathString); + void calcGridItemSize(GridItem *item, int zoomValue); + QVector > getPlaylistItems(QString pathString); LoadCoreWindow *m_loadCoreWindow; QTimer *m_timer; @@ -385,6 +388,7 @@ private: QWidget *m_gridLayoutWidget; QSlider *m_zoomSlider; int m_lastZoomSliderValue; + QList m_pendingItemUpdates; protected: void closeEvent(QCloseEvent *event); From 2a784ae1bc5c73b5836c958a65f0af003f2c81f1 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 6 May 2018 20:50:54 -0400 Subject: [PATCH 34/78] Qt: remove mutex, defer loading of grid items into layout, use guarded pointers for exec() operations, misc cleanup --- Makefile.common | 3 +- ui/drivers/qt/flowlayout.cpp | 16 +++++++-- ui/drivers/qt/flowlayout.h | 8 +++++ ui/drivers/qt/ui_qt_window.cpp | 65 +++++++++++++++++----------------- ui/drivers/ui_qt.h | 1 - 5 files changed, 56 insertions(+), 37 deletions(-) diff --git a/Makefile.common b/Makefile.common index 44d9185717..2152bae548 100644 --- a/Makefile.common +++ b/Makefile.common @@ -336,7 +336,8 @@ OBJ += ui/drivers/ui_qt.o \ ui/drivers/qt/flowlayout.o MOC_HEADERS += ui/drivers/ui_qt.h \ - ui/drivers/qt/ui_qt_load_core_window.h + ui/drivers/qt/ui_qt_load_core_window.h \ + ui/drivers/qt/flowlayout.h DEFINES += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) -DHAVE_MAIN #DEFINES += $(QT5WEBENGINE_CFLAGS) diff --git a/ui/drivers/qt/flowlayout.cpp b/ui/drivers/qt/flowlayout.cpp index 6719c13f5c..8f8ba5333a 100644 --- a/ui/drivers/qt/flowlayout.cpp +++ b/ui/drivers/qt/flowlayout.cpp @@ -60,6 +60,8 @@ FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) { setContentsMargins(margin, margin, margin, margin); + + connect(this, SIGNAL(signalAddWidgetDeferred(QWidget*)), this, SLOT(onAddWidgetDeferred(QWidget*)), Qt::QueuedConnection); } FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) @@ -70,9 +72,9 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) FlowLayout::~FlowLayout() { - QLayoutItem *item; + QLayoutItem *item = NULL; - while ((item = takeAt(0))) + while ((item = takeAt(0)) != NULL) delete item; } @@ -229,3 +231,13 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const else return static_cast(parentObj)->spacing(); } + +void FlowLayout::addWidgetDeferred(QWidget *widget) +{ + emit signalAddWidgetDeferred(widget); +} + +void FlowLayout::onAddWidgetDeferred(QWidget *widget) +{ + addWidget(widget); +} diff --git a/ui/drivers/qt/flowlayout.h b/ui/drivers/qt/flowlayout.h index 282a43df94..84dc349d51 100644 --- a/ui/drivers/qt/flowlayout.h +++ b/ui/drivers/qt/flowlayout.h @@ -65,6 +65,7 @@ class FlowLayout : public QLayout { + Q_OBJECT public: explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); @@ -82,6 +83,13 @@ public: void setGeometry(const QRect &rect); QSize sizeHint() const; QLayoutItem* takeAt(int index); + void addWidgetDeferred(QWidget *widget); + +signals: + void signalAddWidgetDeferred(QWidget *widget); + +private slots: + void onAddWidgetDeferred(QWidget *widget); private: int doLayout(const QRect &rect, bool testOnly) const; diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 00da8a0ac6..6a4d26e759 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -111,6 +111,10 @@ static void scan_finished_handler(void *task_data, void *user_data, const char * menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST; menu_environ.data = NULL; + (void)task_data; + (void)user_data; + (void)err; + menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ); if (!ui_window.qtWindow->settings()->value("scan_finish_confirm", true).toBool()) @@ -128,7 +132,6 @@ GridItem::GridItem() : ,image() ,pixmap() ,imageWatcher() - ,mutex() { } @@ -740,7 +743,6 @@ MainWindow::~MainWindow() inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) { - QMutexLocker lock(&item->mutex); int newSize = 0; if (zoomValue < 50) @@ -850,12 +852,12 @@ void MainWindow::setCustomThemeString(QString qss) bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowModality modality) { - QScopedPointer msgBoxPtr; + QPointer > msgBoxPtr; QMessageBox *msgBox = NULL; QCheckBox *checkBox = NULL; - msgBoxPtr.reset(new QMessageBox(this)); - msgBox = msgBoxPtr.data(); + msgBoxPtr.data()->reset(new QMessageBox(this)); + msgBox = msgBoxPtr.data()->data(); checkBox = new QCheckBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DONT_SHOW_AGAIN), msgBox); msgBox->setWindowModality(modality); @@ -891,6 +893,9 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM msgBox->setText(msg); msgBox->exec(); + if (!msgBoxPtr) + return true; + if (checkBox->isChecked()) return false; @@ -904,7 +909,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&) QScopedPointer associateMenu; QScopedPointer hiddenPlaylistsMenu; QScopedPointer hideAction; - QAction *selectedAction = NULL; + QPointer selectedAction; QPoint cursorPos = QCursor::pos(); QListWidgetItem *selectedItem = m_listWidget->itemAt(m_listWidget->viewport()->mapFromGlobal(cursorPos)); QDir playlistDir(settings->paths.directory_playlist); @@ -1103,7 +1108,7 @@ end: void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&) { #ifdef HAVE_LIBRETRODB - QAction *action = NULL; + QPointer action; QList actions; QScopedPointer scanAction; QDir dir; @@ -1153,6 +1158,8 @@ void MainWindow::onGotStatusMessage(QString msg, unsigned priority, unsigned dur QScreen *screen = qApp->primaryScreen(); QStatusBar *status = statusBar(); + Q_UNUSED(priority) + if (msg.isEmpty()) return; @@ -2831,23 +2838,21 @@ void MainWindow::removeGridItems() { QMutableListIterator items(m_gridItems); + m_pendingItemUpdates.clear(); + while (items.hasNext()) { GridItem *item = items.next(); if (item) { - item->mutex.lock(); + item->imageWatcher.waitForFinished(); items.remove(); m_gridLayout->removeWidget(item->widget); - m_pendingItemUpdates.removeAll(item); delete item->widget; - - item->mutex.unlock(); - delete item; } } @@ -2867,15 +2872,14 @@ void MainWindow::onDeferredImageLoaded() if (!item) return; - item->mutex.lock(); - - if (!item->image.isNull()) + if (m_gridItems.contains(item)) { - m_pendingItemUpdates.append(item); - QTimer::singleShot(0, this, SLOT(onPendingItemUpdates())); + if (!item->image.isNull()) + { + m_pendingItemUpdates.append(item); + QTimer::singleShot(0, this, SLOT(onPendingItemUpdates())); + } } - - item->mutex.unlock(); } void MainWindow::onPendingItemUpdates() @@ -2889,7 +2893,8 @@ void MainWindow::onPendingItemUpdates() if (!item) continue; - onUpdateGridItemPixmapFromImage(item); + if (m_gridItems.contains(item)) + onUpdateGridItemPixmapFromImage(item); list.remove(); } @@ -2900,6 +2905,9 @@ void MainWindow::onUpdateGridItemPixmapFromImage(GridItem *item) if (!item) return; + if (!m_gridItems.contains(item)) + return; + item->label->setPixmap(QPixmap::fromImage(item->image)); item->label->update(); } @@ -2916,12 +2924,11 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) if (!item) return NULL; - item->mutex.lock(); - + /* While we are indeed writing across thread boundaries here, the image is never accessed until after + * its thread finishes, and the item is never deleted without first waiting for the thread to finish. + */ item->image = QImage(path); - item->mutex.unlock(); - return item; } @@ -2992,12 +2999,10 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) item->widget->layout()->addWidget(newLabel); qobject_cast(item->widget->layout())->setStretchFactor(label, 1); - m_gridLayout->addWidget(item->widget); + m_gridLayout->addWidgetDeferred(item->widget); m_gridItems.append(item); loadImageDeferred(item, imagePath); - - qApp->processEvents(); } } @@ -3178,12 +3183,6 @@ void MainWindow::addPlaylistItemsToTable(QString pathString) for (i = 0; i < items.count(); i++) { - const char *path = NULL; - const char *label = NULL; - const char *core_path = NULL; - const char *core_name = NULL; - const char *crc32 = NULL; - const char *db_name = NULL; QTableWidgetItem *labelItem = NULL; const QHash &hash = items.at(i); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 5344e2e842..7952fb3c14 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -75,7 +75,6 @@ struct GridItem QImage image; QPixmap pixmap; QFutureWatcher imageWatcher; - QMutex mutex; }; class ThumbnailWidget : public QWidget From faf52937c5eca732daacbcc95973df2fc04ecf4b Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 7 May 2018 00:07:12 -0400 Subject: [PATCH 35/78] Qt: buildfix --- ui/drivers/qt/ui_qt_window.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 6a4d26e759..5883a98f06 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -852,12 +852,12 @@ void MainWindow::setCustomThemeString(QString qss) bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowModality modality) { - QPointer > msgBoxPtr; + QPointer msgBoxPtr; QMessageBox *msgBox = NULL; QCheckBox *checkBox = NULL; - msgBoxPtr.data()->reset(new QMessageBox(this)); - msgBox = msgBoxPtr.data()->data(); + msgBoxPtr = new QMessageBox(this); + msgBox = msgBoxPtr.data(); checkBox = new QCheckBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DONT_SHOW_AGAIN), msgBox); msgBox->setWindowModality(modality); From 649216c700778622edfa71ae287125d69018760c Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 7 May 2018 02:36:00 -0400 Subject: [PATCH 36/78] Qt: add view menu option to change between icon/list views --- intl/msg_hash_ja.h | 8 +++ intl/msg_hash_us.h | 8 +++ msg_hash.h | 4 ++ ui/drivers/qt/ui_qt_themes.h | 14 ++++- ui/drivers/qt/ui_qt_window.cpp | 109 ++++++++++++++++++++++++++++----- ui/drivers/ui_qt.cpp | 70 +++++++++++++++++---- ui/drivers/ui_qt.h | 14 ++++- 7 files changed, 198 insertions(+), 29 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index ceb35d4a95..ff74abff6e 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3497,6 +3497,14 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST, "ファイルは存在しません。") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, "ロードしたコアを最初に優先する") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM, + "ズーム") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW, + "表示") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS, + "アイコン") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST, + "一覧") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_OVERRIDE_OPTIONS, "Configuration Override options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 29a33bc8e8..5c10866c78 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3646,6 +3646,14 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST, "File does not exist.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, "Suggest loaded core first") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM, + "Zoom") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW, + "View") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS, + "Icons") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST, + "List") MSG_HASH(MENU_ENUM_LABEL_VALUE_QUICK_MENU_OVERRIDE_OPTIONS, "Configuration Override options") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS, diff --git a/msg_hash.h b/msg_hash.h index 833b518760..1120be6a37 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1846,6 +1846,10 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_QT_FILE_IS_EMPTY, MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED, MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST, + MENU_ENUM_LABEL_VALUE_QT_ZOOM, + MENU_ENUM_LABEL_VALUE_QT_VIEW, + MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS, + MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST, MSG_LAST }; diff --git a/ui/drivers/qt/ui_qt_themes.h b/ui/drivers/qt/ui_qt_themes.h index 058a073bc7..46051401fb 100644 --- a/ui/drivers/qt/ui_qt_themes.h +++ b/ui/drivers/qt/ui_qt_themes.h @@ -1,7 +1,15 @@ #include /* %1 is a placeholder for palette(highlight) or the equivalent chosen by the user */ -static const QString qt_theme_default_stylesheet = QStringLiteral(""); +static const QString qt_theme_default_stylesheet = QStringLiteral("" + "QPushButton[flat=\"true\"] {\n" + " min-height:20px;\n" + " min-width:80px;\n" + " padding:1px 3px 1px 3px;\n" + " background-color: transparent;\n" + " border: 1px solid #ddd;\n" + "}\n" +); static const QString qt_theme_dark_stylesheet = QStringLiteral("" "QWidget {\n" @@ -232,6 +240,10 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral("" " border:1px solid %1;\n" " border-radius:4px;\n" "}\n" + "QPushButton[flat=\"true\"] {\n" + " background-color: transparent;\n" + " border: 1px solid #ddd;\n" + "}\n" "QRadioButton::indicator {\n" " width:18px;\n" " height:18px;\n" diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 5883a98f06..6cac031241 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -530,6 +530,7 @@ MainWindow::MainWindow(QWidget *parent) : ,m_zoomSlider(NULL) ,m_lastZoomSliderValue(0) ,m_pendingItemUpdates() + ,m_viewType(VIEW_TYPE_LIST) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -537,9 +538,21 @@ MainWindow::MainWindow(QWidget *parent) : QToolButton *searchResetButton = NULL; QWidget *zoomWidget = new QWidget(); QHBoxLayout *zoomLayout = new QHBoxLayout(); - QLabel *zoomLabel = new QLabel("Zoom:", zoomWidget); + QLabel *zoomLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ZOOM), zoomWidget); + QPushButton *viewTypePushButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW), zoomWidget); + QMenu *viewTypeMenu = new QMenu(viewTypePushButton); + QAction *viewTypeIconsAction = NULL; + QAction *viewTypeListAction = NULL; int i = 0; + viewTypePushButton->setObjectName("viewTypePushButton"); + viewTypePushButton->setFlat(true); + + viewTypeIconsAction = viewTypeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS)); + viewTypeListAction = viewTypeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST)); + + viewTypePushButton->setMenu(viewTypeMenu); + zoomLabel->setObjectName("zoomLabel"); m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); @@ -569,6 +582,7 @@ MainWindow::MainWindow(QWidget *parent) : zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); zoomLayout->addWidget(zoomLabel); zoomLayout->addWidget(m_zoomSlider); + zoomLayout->addWidget(viewTypePushButton); m_gridWidget->layout()->addWidget(zoomWidget); @@ -688,12 +702,13 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_coreInfoPushButton, SIGNAL(clicked()), m_coreInfoDialog, SLOT(showCoreInfo())); connect(m_runPushButton, SIGNAL(clicked()), this, SLOT(onRunClicked())); connect(m_stopPushButton, SIGNAL(clicked()), this, SLOT(onStopClicked())); - connect(m_browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabWidgetIndexChanged(int))); connect(m_dirTree, SIGNAL(itemsSelected(QModelIndexList)), this, SLOT(onTreeViewItemsSelected(QModelIndexList))); connect(m_dirTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onFileBrowserTreeContextMenuRequested(const QPoint&))); connect(m_listWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onPlaylistWidgetContextMenuRequested(const QPoint&))); connect(m_launchWithComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLaunchWithComboBoxIndexChanged(int))); connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onZoomValueChanged(int))); + connect(viewTypeIconsAction, SIGNAL(triggered()), this, SLOT(onIconViewClicked())); + connect(viewTypeListAction, SIGNAL(triggered()), this, SLOT(onListViewClicked())); /* make sure these use an auto connection so it will be queued if called from a different thread (some facilities in RA log messages from other threads) */ connect(this, SIGNAL(gotLogMessage(const QString&)), this, SLOT(onGotLogMessage(const QString&)), Qt::AutoConnection); @@ -711,16 +726,6 @@ MainWindow::MainWindow(QWidget *parent) : qApp->processEvents(); QTimer::singleShot(0, this, SLOT(onBrowserStartClicked())); - for (i = 0; i < m_listWidget->count() && m_listWidget->count() > 0; i++) - { - /* select the first non-hidden row */ - if (!m_listWidget->isRowHidden(i)) - { - m_listWidget->setCurrentRow(i); - break; - } - } - m_searchLineEdit->setFocus(); m_loadCoreWindow->setWindowModality(Qt::ApplicationModal); @@ -741,6 +746,18 @@ MainWindow::~MainWindow() removeGridItems(); } +void MainWindow::onIconViewClicked() +{ + setCurrentViewType(VIEW_TYPE_ICONS); + onCurrentListItemChanged(m_listWidget->currentItem(), NULL); +} + +void MainWindow::onListViewClicked() +{ + setCurrentViewType(VIEW_TYPE_LIST); + onCurrentListItemChanged(m_listWidget->currentItem(), NULL); +} + inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) { int newSize = 0; @@ -2625,16 +2642,58 @@ void MainWindow::resizeThumbnails(bool one, bool two, bool three) } } +void MainWindow::setCurrentViewType(ViewType viewType) +{ + m_viewType = viewType; + + switch (viewType) + { + case VIEW_TYPE_ICONS: + { + m_tableWidget->hide(); + m_gridWidget->show(); + break; + } + case VIEW_TYPE_LIST: + default: + { + m_gridWidget->hide(); + m_tableWidget->show(); + break; + } + } +} + +MainWindow::ViewType MainWindow::getCurrentViewType() +{ + return m_viewType; +} + void MainWindow::onCurrentListItemChanged(QListWidgetItem *current, QListWidgetItem *previous) { + ViewType viewType = getCurrentViewType(); + Q_UNUSED(current) Q_UNUSED(previous) if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)) return; - //initContentTableWidget(); - initContentGridLayout(); + switch (viewType) + { + case VIEW_TYPE_ICONS: + { + initContentGridLayout(); + break; + } + case VIEW_TYPE_LIST: + default: + { + initContentTableWidget(); + break; + } + } + setCoreActions(); } @@ -3041,6 +3100,8 @@ void MainWindow::onContentGridInited() m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); onZoomValueChanged(m_zoomSlider->value()); + + onSearchEnterPressed(); } void MainWindow::initContentTableWidget() @@ -3213,6 +3274,24 @@ QSettings* MainWindow::settings() return m_settings; } +QString MainWindow::getCurrentViewTypeString() +{ + switch (m_viewType) + { + case VIEW_TYPE_ICONS: + { + return QStringLiteral("icons"); + } + case VIEW_TYPE_LIST: + default: + { + return QStringLiteral("list"); + } + } + + return QStringLiteral("list"); +} + void MainWindow::closeEvent(QCloseEvent *event) { if (m_settings->value("save_geometry", false).toBool()) @@ -3222,6 +3301,8 @@ void MainWindow::closeEvent(QCloseEvent *event) if (m_settings->value("save_last_tab", false).toBool()) m_settings->setValue("last_tab", m_browserAndPlaylistTabWidget->currentIndex()); + m_settings->setValue("view_type", getCurrentViewTypeString()); + QMainWindow::closeEvent(event); } diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 842bacd396..5229843ab9 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -237,6 +237,8 @@ static void* ui_companion_qt_init(void) QAction *exitAction = NULL; QComboBox *launchWithComboBox = NULL; QSettings *qsettings = NULL; + QListWidget *listWidget = NULL; + int i = 0; if (!handle) return NULL; @@ -257,6 +259,8 @@ static void* ui_companion_qt_init(void) mainwindow->setWindowTitle("RetroArch"); mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING); + listWidget = mainwindow->playlistListWidget(); + widget = new QWidget(mainwindow); widget->setObjectName("tableWidget"); @@ -264,8 +268,6 @@ static void* ui_companion_qt_init(void) layout->addWidget(mainwindow->contentTableWidget()); layout->addWidget(mainwindow->contentGridWidget()); - mainwindow->contentTableWidget()->hide(); - widget->setLayout(layout); mainwindow->setCentralWidget(widget); @@ -295,6 +297,10 @@ static void* ui_companion_qt_init(void) QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow())); + viewMenu->addSeparator(); + viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked())); + viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked())); + viewMenu->addSeparator(); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog())); playlistWidget = new QWidget(); @@ -464,17 +470,6 @@ static void* ui_companion_qt_init(void) if (qsettings->contains("dock_positions")) mainwindow->restoreState(qsettings->value("dock_positions").toByteArray()); - if (qsettings->contains("save_last_tab")) - { - if (qsettings->contains("last_tab")) - { - int lastTabIndex = qsettings->value("last_tab", 0).toInt(); - - if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) - browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); - } - } - if (qsettings->contains("theme")) { QString themeStr = qsettings->value("theme").toString(); @@ -492,6 +487,55 @@ static void* ui_companion_qt_init(void) else mainwindow->setTheme(); + if (qsettings->contains("view_type")) + { + QString viewType = qsettings->value("view_type", "list").toString(); + + if (viewType == "list") + mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); + else if (viewType == "icons") + mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS); + else + mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); + } + else + mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); + + /* We make sure to hook up the tab widget callback only after the tabs themselves have been added, + * but before changing to a specific one, to avoid the callback firing before the view type is set. + */ + QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int))); + + /* setting the last tab must come after setting the view type */ + if (qsettings->contains("save_last_tab")) + { + if (qsettings->contains("last_tab")) + { + int lastTabIndex = qsettings->value("last_tab", 0).toInt(); + + if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) + { + browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); + mainwindow->onTabWidgetIndexChanged(lastTabIndex); + } + } + } + else + { + browserAndPlaylistTabWidget->setCurrentIndex(0); + mainwindow->onTabWidgetIndexChanged(0); + } + + for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++) + { + /* select the first non-hidden row */ + if (!listWidget->isRowHidden(i)) + { + listWidget->setCurrentRow(i); + break; + } + } + return handle; } diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 7952fb3c14..a035b355b1 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -226,6 +226,12 @@ class MainWindow : public QMainWindow Q_OBJECT public: + enum ViewType + { + VIEW_TYPE_ICONS, + VIEW_TYPE_LIST + }; + enum Theme { THEME_SYSTEM_DEFAULT, @@ -270,6 +276,7 @@ public: void setCustomThemeString(QString qss); const QString& customThemeString() const; GridItem* doDeferredImageLoad(GridItem *item, QString path); + void setCurrentViewType(ViewType viewType); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -303,6 +310,9 @@ public slots: void deferReloadPlaylists(); void onGotReloadPlaylists(); void showWelcomeScreen(); + void onIconViewClicked(); + void onListViewClicked(); + void onTabWidgetIndexChanged(int index); private slots: void onLoadCoreClicked(const QStringList &extensionFilters = QStringList()); @@ -317,7 +327,6 @@ private slots: void addPlaylistItemsToGrid(const QString &path); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); - void onTabWidgetIndexChanged(int index); void onTreeViewItemsSelected(QModelIndexList selectedIndexes); void onSearchResetClicked(); void onLaunchWithComboBoxIndexChanged(int index); @@ -339,6 +348,8 @@ private: void loadImageDeferred(GridItem *item, QString path); void calcGridItemSize(GridItem *item, int zoomValue); QVector > getPlaylistItems(QString pathString); + QString getCurrentViewTypeString(); + ViewType getCurrentViewType(); LoadCoreWindow *m_loadCoreWindow; QTimer *m_timer; @@ -388,6 +399,7 @@ private: QSlider *m_zoomSlider; int m_lastZoomSliderValue; QList m_pendingItemUpdates; + ViewType m_viewType; protected: void closeEvent(QCloseEvent *event); From 03e0510fc46ff1438f5a40829e887399789ae3e1 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 7 May 2018 14:29:54 -0400 Subject: [PATCH 37/78] Qt: use guarded pointer for adding grid items to layout, in case playlist is changed (and hence the items get deleted) before they are all added --- ui/drivers/qt/flowlayout.cpp | 13 +++++++++---- ui/drivers/qt/flowlayout.h | 8 +++++--- ui/drivers/qt/ui_qt_window.cpp | 13 ++++++++----- ui/drivers/ui_qt.h | 13 +++++++++---- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ui/drivers/qt/flowlayout.cpp b/ui/drivers/qt/flowlayout.cpp index 8f8ba5333a..b970e10b10 100644 --- a/ui/drivers/qt/flowlayout.cpp +++ b/ui/drivers/qt/flowlayout.cpp @@ -55,13 +55,14 @@ #include #include "flowlayout.h" +#include "../ui_qt.h" FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) { setContentsMargins(margin, margin, margin, margin); - connect(this, SIGNAL(signalAddWidgetDeferred(QWidget*)), this, SLOT(onAddWidgetDeferred(QWidget*)), Qt::QueuedConnection); + connect(this, SIGNAL(signalAddWidgetDeferred(QPointer)), this, SLOT(onAddWidgetDeferred(QPointer)), Qt::QueuedConnection); } FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) @@ -226,18 +227,22 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const else if (parentObj->isWidgetType()) { const QWidget *pw = static_cast(parentObj); - return pw->style()->pixelMetric(pm, 0, pw); + return pw->style()->pixelMetric(pm, NULL, pw); } else return static_cast(parentObj)->spacing(); } -void FlowLayout::addWidgetDeferred(QWidget *widget) +void FlowLayout::addWidgetDeferred(QPointer widget) { emit signalAddWidgetDeferred(widget); } -void FlowLayout::onAddWidgetDeferred(QWidget *widget) +void FlowLayout::onAddWidgetDeferred(QPointer widget) { + /* widget might have been deleted before we got to it since this uses a queued connection, hence the guarded QPointer */ + if (!widget) + return; + addWidget(widget); } diff --git a/ui/drivers/qt/flowlayout.h b/ui/drivers/qt/flowlayout.h index 84dc349d51..c9d11e7653 100644 --- a/ui/drivers/qt/flowlayout.h +++ b/ui/drivers/qt/flowlayout.h @@ -63,6 +63,8 @@ #include #include +class ThumbnailWidget; + class FlowLayout : public QLayout { Q_OBJECT @@ -83,13 +85,13 @@ public: void setGeometry(const QRect &rect); QSize sizeHint() const; QLayoutItem* takeAt(int index); - void addWidgetDeferred(QWidget *widget); + void addWidgetDeferred(QPointer widget); signals: - void signalAddWidgetDeferred(QWidget *widget); + void signalAddWidgetDeferred(QPointer widget); private slots: - void onAddWidgetDeferred(QWidget *widget); + void onAddWidgetDeferred(QPointer widget); private: int doLayout(const QRect &rect, bool testOnly) const; diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 6cac031241..56ed1c463b 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -126,7 +126,8 @@ static void scan_finished_handler(void *task_data, void *user_data, const char * #endif GridItem::GridItem() : - widget(NULL) + QObject() + ,widget(NULL) ,label(NULL) ,hash() ,image() @@ -545,6 +546,8 @@ MainWindow::MainWindow(QWidget *parent) : QAction *viewTypeListAction = NULL; int i = 0; + qRegisterMetaType >("ThumbnailWidget"); + viewTypePushButton->setObjectName("viewTypePushButton"); viewTypePushButton->setFlat(true); @@ -2895,13 +2898,13 @@ void MainWindow::removeGridItems() { if (m_gridItems.count() > 0) { - QMutableListIterator items(m_gridItems); + QMutableVectorIterator > items(m_gridItems); m_pendingItemUpdates.clear(); while (items.hasNext()) { - GridItem *item = items.next(); + QPointer item = items.next(); if (item) { @@ -3003,8 +3006,8 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) for (i = 0; i < items.count(); i++) { const QHash &hash = items.at(i); - GridItem *item = new GridItem(); - ThumbnailLabel *label = NULL; + QPointer item (new GridItem()); + QPointer label; QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; QSize thumbnailWidgetSizeHint(screenSize.width() / 8, screenSize.height() / 8); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index a035b355b1..42a404faca 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -31,6 +31,7 @@ #include #include #include +#include extern "C" { #include @@ -65,12 +66,14 @@ class ThumbnailWidget; class ThumbnailLabel; class FlowLayout; -struct GridItem +class GridItem : public QObject { + Q_OBJECT +public: GridItem(); - ThumbnailWidget *widget; - ThumbnailLabel *label; + QPointer widget; + QPointer label; QHash hash; QImage image; QPixmap pixmap; @@ -394,7 +397,7 @@ private: FlowLayout *m_gridLayout; QWidget *m_gridWidget; QScrollArea *m_gridScrollArea; - QList m_gridItems; + QVector > m_gridItems; QWidget *m_gridLayoutWidget; QSlider *m_zoomSlider; int m_lastZoomSliderValue; @@ -406,6 +409,8 @@ protected: void keyPressEvent(QKeyEvent *event); }; +Q_DECLARE_METATYPE(QPointer) + RETRO_BEGIN_DECLS typedef struct ui_application_qt From 8c6bc4a6780f0bf89a34387e709a986cbac71d82 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 28 May 2018 18:14:36 -0400 Subject: [PATCH 38/78] Qt: update UI after loading every 25 grid items, keep grid from mixing up content from multiple playlists if the user switches to a new one before one is finished loading --- ui/drivers/qt/ui_qt_window.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 56ed1c463b..f4db64cb15 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -2999,6 +2999,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) QVector > items = getPlaylistItems(pathString); QScreen *screen = qApp->primaryScreen(); QSize screenSize = screen->size(); + QListWidgetItem *currentItem = m_listWidget->currentItem(); settings_t *settings = config_get_ptr(); int i = 0; int zoomValue = m_zoomSlider->value(); @@ -3006,7 +3007,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) for (i = 0; i < items.count(); i++) { const QHash &hash = items.at(i); - QPointer item (new GridItem()); + QPointer item; QPointer label; QString thumbnailFileNameNoExt; QLabel *newLabel = NULL; @@ -3016,6 +3017,14 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) QString imagePath; int lastIndex = -1; + if (m_listWidget->currentItem() != currentItem) + { + /* user changed the current playlist before we finished loading... abort */ + break; + } + + item = new GridItem(); + lastIndex = hash["path"].lastIndexOf('.'); if (lastIndex >= 0) @@ -3065,6 +3074,9 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) m_gridItems.append(item); loadImageDeferred(item, imagePath); + + if (i % 25 == 0) + qApp->processEvents(); } } From 0291c41afa2c80d9a1a8276f937aebb2c19f55cf Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Sat, 14 Jul 2018 11:18:21 -0700 Subject: [PATCH 39/78] fix(Metal): Fix blank screen after full screen toggle; window focus --- gfx/common/metal_common.m | 12 +++++ .../RetroArch_Metal.xcodeproj/project.pbxproj | 20 ++++++- ui/drivers/ui_cocoa.m | 53 ++++++++++++++----- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index efdb0853d2..ad433da056 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -104,6 +104,16 @@ .height = _video.height, .fullscreen = _video.fullscreen, }; + + if (mode.width == 0 || mode.height == 0) + { + // 0 indicates full screen, so we'll use the view's dimensions, which should already be full screen + // If this turns out to be the wrong assumption, we can use NSScreen to query the dimensions + CGSize size = view.frame.size; + mode.width = (unsigned int)size.width; + mode.height = (unsigned int)size.height; + } + [apple_platform setVideoMode:mode]; *input = NULL; @@ -213,6 +223,8 @@ - (void)_updateViewport:(CGSize)size { + RARCH_LOG("[Metal]: _updateViewport size %.0fx%.0f\n", size.width, size.height); + _viewport->full_width = (unsigned int)size.width; _viewport->full_height = (unsigned int)size.height; video_driver_set_size(&_viewport->full_width, &_viewport->full_height); diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index 842da09730..2b2e562f91 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -55,6 +55,14 @@ 0538875720DE11D300769232 /* retro_assert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = retro_assert.h; sourceTree = ""; }; 0538875820DE11D300769232 /* retro_endianness.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = retro_endianness.h; sourceTree = ""; }; 0538875920DE11D300769232 /* libretro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libretro.h; sourceTree = ""; }; + 0548E2B220F976E10094A083 /* driver.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = driver.c; path = ../../driver.c; sourceTree = ""; }; + 0548E2B320F976E10094A083 /* dynamic.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = dynamic.c; path = ../../dynamic.c; sourceTree = ""; }; + 0548E2B420F976E10094A083 /* dynamic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = dynamic.h; path = ../../dynamic.h; sourceTree = ""; }; + 0548E2B520F976E20094A083 /* driver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = driver.h; path = ../../driver.h; sourceTree = ""; }; + 0548E2B620F977060094A083 /* playlist.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = playlist.h; path = ../../playlist.h; sourceTree = ""; }; + 0548E2B720F977060094A083 /* performance_counters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = performance_counters.h; path = ../../performance_counters.h; sourceTree = ""; }; + 0548E2B820F977060094A083 /* performance_counters.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = performance_counters.c; path = ../../performance_counters.c; sourceTree = ""; }; + 0548E2B920F977060094A083 /* playlist.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = playlist.c; path = ../../playlist.c; sourceTree = ""; }; 055312AB20DE130A00C4D7F4 /* gl_capabilities.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = gl_capabilities.c; sourceTree = ""; }; 055312AD20DE130A00C4D7F4 /* scaler_int.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = scaler_int.c; sourceTree = ""; }; 055312AE20DE130A00C4D7F4 /* pixconv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = pixconv.c; sourceTree = ""; }; @@ -1070,8 +1078,6 @@ 05BF821320ED69A500D95B19 /* core */ = { isa = PBXGroup; children = ( - 05B5F91120ED6AAE009C521F /* retroarch.c */, - 05B5F91220ED6AAF009C521F /* retroarch.h */, 05B5F90F20ED6A03009C521F /* command.c */, 05BF821720ED69D100D95B19 /* command.h */, 05BF821420ED69D100D95B19 /* config.def.h */, @@ -1085,6 +1091,16 @@ 05BF821B20ED69D100D95B19 /* core_info.h */, 05B5F90E20ED6A03009C521F /* core_type.h */, 05BF821920ED69D100D95B19 /* core.h */, + 0548E2B220F976E10094A083 /* driver.c */, + 0548E2B520F976E20094A083 /* driver.h */, + 0548E2B320F976E10094A083 /* dynamic.c */, + 0548E2B420F976E10094A083 /* dynamic.h */, + 0548E2B820F977060094A083 /* performance_counters.c */, + 0548E2B720F977060094A083 /* performance_counters.h */, + 0548E2B920F977060094A083 /* playlist.c */, + 0548E2B620F977060094A083 /* playlist.h */, + 05B5F91120ED6AAE009C521F /* retroarch.c */, + 05B5F91220ED6AAF009C521F /* retroarch.h */, ); name = core; sourceTree = ""; diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 6b84e3e857..aced897a60 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -42,6 +42,24 @@ #import #endif +@interface WindowListener : NSResponder +@end + +@implementation WindowListener + +/* Similarly to SDL, we'll respond to key events by doing nothing so we don't beep. + */ +- (void)flagsChanged:(NSEvent *)event +{} + +- (void)keyDown:(NSEvent *)event +{} + +- (void)keyUp:(NSEvent *)event +{} + +@end + id apple_platform; #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) @@ -54,7 +72,7 @@ id apple_platform; apple_view_type_t _vt; NSView* _renderView; id _sleepActivity; - + WindowListener *_listener; } @property (nonatomic, retain) NSWindow IBOutlet* window; @@ -109,7 +127,7 @@ static void app_terminate(void) case NSEventTypeKeyDown: case NSEventTypeKeyUp: { - NSString* ch = (NSString*)event.characters; + NSString* ch = event.characters; uint32_t character = 0; uint32_t mod = 0; @@ -164,13 +182,13 @@ static void app_terminate(void) return; /* Relative */ - apple->mouse_rel_x = event.deltaX; - apple->mouse_rel_y = event.deltaY; + apple->mouse_rel_x = (int16_t)event.deltaX; + apple->mouse_rel_y = (int16_t)event.deltaY; /* Absolute */ pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]; - apple->touches[0].screen_x = pos.x; - apple->touches[0].screen_y = pos.y; + apple->touches[0].screen_x = (int16_t)pos.x; + apple->touches[0].screen_y = (int16_t)pos.y; mouse_pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]; apple->window_pos_x = (int16_t)mouse_pos.x; @@ -245,8 +263,13 @@ static char** waiting_argv; [self.window setCollectionBehavior:NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY]; } #endif + + _listener = [WindowListener new]; + [self.window setAcceptsMouseMovedEvents: YES]; - + [self.window setNextResponder:_listener]; + self.window.delegate = _listener; + [[self.window contentView] setAutoresizesSubviews:YES]; for (i = 0; i < waiting_argc; i++) @@ -262,7 +285,10 @@ static char** waiting_argv; app_terminate(); waiting_argc = 0; - + + [self.window makeMainWindow]; + [self.window makeKeyWindow]; + [self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO]; } @@ -271,7 +297,7 @@ static char** waiting_argv; return; } - RARCH_LOG("[Cocoa] change view type: %d → %d\n", _vt, vt); + RARCH_LOG("[Cocoa]: change view type: %d → %d\n", _vt, vt); _vt = vt; if (_renderView != nil) @@ -279,6 +305,7 @@ static char** waiting_argv; _renderView.wantsLayer = NO; _renderView.layer = nil; [_renderView removeFromSuperview]; + self.window.contentView = nil; _renderView = nil; } @@ -294,7 +321,7 @@ static char** waiting_argv; } #endif break; - + case APPLE_VIEW_TYPE_OPENGL: { _renderView = [CocoaView get]; @@ -308,9 +335,9 @@ static char** waiting_argv; _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; _renderView.frame = self.window.contentView.bounds; - - [self.window.contentView addSubview:_renderView]; - [self.window makeFirstResponder:_renderView]; + + self.window.contentView = _renderView; + [self.window.contentView setNextResponder:_listener]; } - (apple_view_type_t)viewType { From 675b8bb9e20d17f961d379a2b7107c8d4792853b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 05:49:50 +0200 Subject: [PATCH 40/78] Cleanup some code in command_event --- command.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/command.c b/command.c index 7b6b682336..10739f8226 100644 --- a/command.c +++ b/command.c @@ -1835,14 +1835,21 @@ bool command_event(enum event_command cmd, void *data) if (cheevos_hardcore_active) return false; #endif - - return command_event_main_state(cmd); + if (!command_event_main_state(cmd)) + return false; + break; case CMD_EVENT_UNDO_LOAD_STATE: - return command_event_main_state(cmd); + if (!command_event_main_state(cmd)) + return false; + break; case CMD_EVENT_UNDO_SAVE_STATE: - return command_event_main_state(cmd); + if (!command_event_main_state(cmd)) + return false; + break; case CMD_EVENT_RESIZE_WINDOWED_SCALE: - return command_event_resize_windowed_scale(); + if (!command_event_resize_windowed_scale()) + return false; + break; case CMD_EVENT_MENU_TOGGLE: #ifdef HAVE_MENU if (menu_driver_is_alive()) @@ -1883,7 +1890,9 @@ bool command_event(enum event_command cmd, void *data) configuration_set_int(settings, settings->ints.state_slot, new_state_slot); } } - return command_event_main_state(cmd); + if (!command_event_main_state(cmd)) + return false; + break; case CMD_EVENT_SAVE_STATE_DECREMENT: { settings_t *settings = config_get_ptr(); @@ -1933,7 +1942,9 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT: - return retroarch_main_quit(); + if (!retroarch_main_quit()) + return false; + break; case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS cheevos_toggle_hardcore_mode(); @@ -2043,9 +2054,13 @@ TODO: Add a setting for these tweaks */ break; case CMD_EVENT_AUDIO_STOP: midi_driver_set_all_sounds_off(); - return audio_driver_stop(); + if (!audio_driver_stop()) + return false; + break; case CMD_EVENT_AUDIO_START: - return audio_driver_start(rarch_ctl(RARCH_CTL_IS_SHUTDOWN, NULL)); + if (!audio_driver_start(rarch_ctl(RARCH_CTL_IS_SHUTDOWN, NULL))) + return false; + break; case CMD_EVENT_AUDIO_MUTE_TOGGLE: { bool audio_mute_enable = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); @@ -2630,14 +2645,13 @@ TODO: Add a setting for these tweaks */ command_event(CMD_EVENT_REMOTE_DEINIT, NULL); input_driver_init_remote(); break; - case CMD_EVENT_MAPPER_DEINIT: input_driver_deinit_mapper(); break; case CMD_EVENT_MAPPER_INIT: command_event(CMD_EVENT_MAPPER_DEINIT, NULL); input_driver_init_mapper(); - break; + break; case CMD_EVENT_LOG_FILE_DEINIT: retro_main_log_file_deinit(); break; @@ -2646,8 +2660,10 @@ TODO: Add a setting for these tweaks */ const char *path = (const char*)data; if (string_is_empty(path)) return false; - return command_event_disk_control_append_image(path); + if (!command_event_disk_control_append_image(path)) + return false; } + break; case CMD_EVENT_DISK_EJECT_TOGGLE: { rarch_system_info_t *info = runloop_get_system_info(); @@ -2754,10 +2770,8 @@ TODO: Add a setting for these tweaks */ } break; case CMD_EVENT_UI_COMPANION_TOGGLE: - { - ui_companion_driver_toggle(true); - break; - } + ui_companion_driver_toggle(true); + break; case CMD_EVENT_GAME_FOCUS_TOGGLE: { static bool game_focus_state = false; From 311b454a2cd8a0e6c890a3f284e7a16929e04aab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 05:58:01 +0200 Subject: [PATCH 41/78] Change return value to true instead for command_event_save_core_config --- command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/command.c b/command.c index 10739f8226..a33f8e1faf 100644 --- a/command.c +++ b/command.c @@ -1395,7 +1395,6 @@ static bool command_event_save_config( static bool command_event_save_core_config(void) { char msg[128]; - bool ret = false; bool found_path = false; bool overrides_active = false; const char *core_path = NULL; @@ -1502,7 +1501,7 @@ static bool command_event_save_core_config(void) free(config_dir); free(config_name); free(config_path); - return ret; + return true; } /** From d50850762b273b6174dcdba1c789df1eff14198b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 14:17:10 +0200 Subject: [PATCH 42/78] Fix game focus toggling for DInput driver --- input/drivers/dinput.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 35a252702e..4d3b7cace7 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -328,8 +328,10 @@ static bool dinput_is_pressed(struct dinput_input *di, { const struct retro_keybind *bind = &binds[id]; - if (!di->blocked && (bind->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind->key)) - return true; + if ((bind->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind->key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !di->blocked) + return true; + if (binds && binds[id].valid) { if (dinput_mbutton_pressed(di, port, bind->mbutton)) From 98190294db8498fc4c672285322372c52d70442e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 14:18:35 +0200 Subject: [PATCH 43/78] (winraw_input) Fix game focus toggle for winraw_input --- input/drivers/winraw_input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index d56deb4c75..35d40d6ad3 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -403,8 +403,9 @@ static bool winraw_is_pressed(winraw_input_t *wr, { const struct retro_keybind *bind = &binds[id]; - if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) - return true; + if ((bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !wr->kbd_mapp_block) + return true; if (binds && binds[id].valid) { if (winraw_mbutton_pressed(wr, port, bind->mbutton)) From 13431c7cbff811dd94b356914a302e511cf9d9af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 14:20:26 +0200 Subject: [PATCH 44/78] (udev) Fix game focus toggle for udev input driver --- input/drivers/udev_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index b7de9b7253..2c63754ec6 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -900,7 +900,8 @@ static bool udev_is_pressed(udev_input_t *udev, const struct retro_keybind *bind = &binds[id]; if ( (bind->key < RETROK_LAST) && udev_keyboard_pressed(udev, bind->key) ) - return true; + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !udev->blocked) + return true; if (binds && binds[id].valid) { From 9a1ac6d77b5828652bcca91ee31eb5ae2bab1cbb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 14:22:16 +0200 Subject: [PATCH 45/78] (rwebinput) Fix game focus toggle --- input/drivers/rwebinput_input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 3108215bd1..69cdf07f91 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -479,9 +479,9 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, const struct retro_keybind *bind = &binds[id]; int key = bind->key; - if (!rwebinput->blocked && (bind->key < RETROK_LAST) && - rwebinput_key_pressed(rwebinput, key)) - return true; + if ((bind->key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !rwebinput->blocked) + return true; if (bind->valid) { From ea09c29e04dbc3c33570c26005f7ad4ad47315a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 14:34:02 +0200 Subject: [PATCH 46/78] Update implementations for other input drivers - not all input drivers support this yet --- input/drivers/android_input.c | 3 +++ input/drivers/cocoa_input.c | 3 +++ input/drivers/ctr_input.c | 3 +++ input/drivers/dos_input.c | 3 +++ input/drivers/gx_input.c | 3 +++ input/drivers/linuxraw_input.c | 3 +++ input/drivers/ps3_input.c | 3 +++ input/drivers/psp_input.c | 3 +++ input/drivers/qnx_input.c | 6 ++++-- input/drivers/rwebinput_input.c | 2 +- input/drivers/sdl_input.c | 3 +++ input/drivers/switch_input.c | 3 +++ input/drivers/wayland_input.c | 3 +++ input/drivers/x11_input.c | 5 +++-- input/drivers/xdk_xinput_input.c | 3 +++ input/drivers/xenon360_input.c | 3 +++ 16 files changed, 47 insertions(+), 5 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 7efdbdbf9a..5121418acf 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -68,6 +68,9 @@ enum { /* Use this to enable/disable using the touch screen as mouse */ #define ENABLE_TOUCH_SCREEN_MOUSE 1 +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct { float x; diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 2cba64d44f..fa8454a6d7 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -33,6 +33,9 @@ #include "../drivers_keyboard/keyboard_event_apple.h" +/* TODO/FIXME - + * fix game focus toggle */ + /* Forward declarations */ float get_backing_scale_factor(void); diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 90702187d4..86446f3ec4 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -29,6 +29,9 @@ #define MAX_PADS 1 +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct ctr_input { bool blocked; diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index 4c168cd5a2..2485b3b3fe 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -21,6 +21,9 @@ #include "../input_keymaps.h" #include "../drivers_keyboard/keyboard_event_dos.h" +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct dos_input { const input_device_driver_t *joypad; diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 8e4c2d42a8..5fd6801dca 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -31,6 +31,9 @@ #define MAX_PADS 4 #endif +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct gx_input { bool blocked; diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 72928de443..c3c3a1e21c 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -32,6 +32,9 @@ #include "../input_keymaps.h" #include "../input_driver.h" +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct linuxraw_input { bool blocked; diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index f18c9ea327..7d8fee8b83 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -40,6 +40,9 @@ #define MAX_PADS 7 #endif +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct { float x; diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index bc0cd827c0..1247a2c1f4 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -43,6 +43,9 @@ #include "../input_driver.h" +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct psp_input { bool blocked; diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 47b663a3ae..276a1f3ca2 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -736,12 +736,14 @@ static bool qnx_is_pressed(qnx_input_t *qnx, unsigned port, unsigned id) { const struct retro_keybind *bind = &binds[id]; + int key = bind->key; if (id >= RARCH_BIND_LIST_END) return false; - if (!qnx->blocked && qnx_keyboard_pressed(qnx, bind->key)) - return true; + if (qnx_keyboard_pressed(qnx, key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !qnx->blocked) + return true; if (binds && binds[id].valid && input_joypad_pressed(qnx->joypad, joypad_info, port, binds, id)) return true; diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 69cdf07f91..ae4904c53a 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -479,7 +479,7 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, const struct retro_keybind *bind = &binds[id]; int key = bind->key; - if ((bind->key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) + if ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) if ((id == RARCH_GAME_FOCUS_TOGGLE) || !rwebinput->blocked) return true; diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index ead5a79903..3f42839bec 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -31,6 +31,9 @@ #include "../../verbosity.h" #include "../../tasks/tasks_internal.h" +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct sdl_input { bool blocked; diff --git a/input/drivers/switch_input.c b/input/drivers/switch_input.c index a50bcdc80f..d363e22e74 100644 --- a/input/drivers/switch_input.c +++ b/input/drivers/switch_input.c @@ -13,6 +13,9 @@ #define MAX_PADS 10 +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct switch_input { const input_device_driver_t *joypad; diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index 0c23db52f4..0363624320 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -47,6 +47,9 @@ #include "../../verbosity.h" +/* TODO/FIXME - + * fix game focus toggle */ + /* Forward declaration */ void flush_wayland_fd(void *data); diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index d2b1bcd9f5..466c94b2e3 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -131,8 +131,9 @@ static bool x_is_pressed(x11_input_t *x11, { const struct retro_keybind *bind = &binds[id]; - if ( (bind->key < RETROK_LAST) && x_keyboard_pressed(x11, bind->key) ) - return true; + if ((bind->key < RETROK_LAST) && x_keyboard_pressed(x11, bind->key) ) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !x11->blocked) + return true; if (binds && binds[id].valid) { diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index 3d4f1363df..0710c223d0 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -32,6 +32,9 @@ #define MAX_PADS 4 +/* TODO/FIXME - + * fix game focus toggle */ + typedef struct xdk_input { bool blocked; diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index e87d413992..2715055761 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -27,6 +27,9 @@ #define MAX_PADS 4 +/* TODO/FIXME - + * fix game focus toggle */ + static uint64_t state[MAX_PADS]; static void xenon360_input_poll(void *data) From 5159f71cf5aeb5b89e0860fd630bef9bb8f8179b Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 15 Jul 2018 14:43:31 +0200 Subject: [PATCH 47/78] Update CHANGES.md --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5f37180118..c9ed1b06de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - COMMON: Automatically hide "Configuration Override options" in Quick Menu. - COMMON: Small Bugfix to not trigger savestate code when pressing Reset. - COMMON: Added libsixel video driver. +- EMSCRIPTEN: Fix Game Focus Toggle. - HID/OSX: Fix to set hid device registration deterministic (#6497), to address issue #6640 re-adding dynamic device registration. - LOCALIZATION: Update Italian translation. - LOCALIZATION: Update Japanese translation. @@ -20,6 +21,7 @@ - METAL: Initial work-in-progress video driver for Metal. macOS-only right now, and currently requires macOS 10.13. - METAL: Supports XMB/MaterialUI, has a menu display driver. Has a font rendering driver. - METAL/SLANG: Slang shaders should be compatible with Metal video driver. +- QNX: Fix Game Focus Toggle. - PS3: Add audio mixer support for FLAC and MP3. - PSP: Use proper button labels, fix inverted R-Stick Y axis. - REMAPS: Fix the way offsets are calculated for keyboard remapping. @@ -29,6 +31,9 @@ - VULKAN: Try to avoid creating swapchains redundantly. Should fix black screen and having to alt tab out of window again to get display working on Nvidia GPUs (Windows). - VULKAN/OSX: Initial MoltenVK support. Not enabled yet, several MoltenVK bugs should be fixed first before we can have it fully working. - WINDOWS/DINPUT: Add rumble support. +- WINDOWS/DINPUT: Fix Game Focus Toggle. +- WINDOWS/RAWINPUT: Fix Game Focus Toggle. +- X11: Fix Game Focus Toggle. - WII: Change deflicker setting to work in 480p or higher, and always enables vfilter so that the user can easily change brightness. - WIIU: Fix out-of-bounds rendering bug - WIIU: Implement UDP broadcast network logging on Wii U. From eb345019c29e99860c98043fa58a7fd3bbd00107 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2018 20:16:09 +0200 Subject: [PATCH 48/78] Don't implement bind_block/flush_block for drivers that don't implement it --- gfx/drivers_font/caca_font.c | 7 +------ gfx/drivers_font/ctr_font.c | 8 +------- gfx/drivers_font/d3d10_font.c | 7 +------ gfx/drivers_font/d3d11_font.c | 7 +------ gfx/drivers_font/d3d12_font.c | 7 +------ gfx/drivers_font/metal_raster_font.m | 2 +- gfx/drivers_font/sixel_font.c | 15 ++------------- gfx/drivers_font/vga_font.c | 7 +------ gfx/drivers_font/vita2d_font.c | 7 +------ gfx/drivers_font/vulkan_raster_font.c | 15 ++------------- gfx/drivers_font/wiiu_font.c | 8 +------- 11 files changed, 13 insertions(+), 77 deletions(-) diff --git a/gfx/drivers_font/caca_font.c b/gfx/drivers_font/caca_font.c index c337d61eff..f36f60c3e3 100644 --- a/gfx/drivers_font/caca_font.c +++ b/gfx/drivers_font/caca_font.c @@ -129,18 +129,13 @@ static void caca_render_msg(video_frame_info_t *video_info, caca_refresh_display(*font->caca->caca_display); } -static void caca_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - font_renderer_t caca_font = { caca_init_font, caca_render_free_font, caca_render_msg, "caca font", caca_font_get_glyph, /* get_glyph */ - caca_font_bind_block, /* bind_block */ + NULL, /* bind_block */ NULL, /* flush */ caca_get_message_width /* get_message_width */ }; diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index 1bebd0eba5..4eb656f625 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -447,12 +447,6 @@ static const struct font_glyph* ctr_font_get_glyph( return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void ctr_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - - font_renderer_t ctr_font = { ctr_font_init_font, @@ -460,7 +454,7 @@ font_renderer_t ctr_font = ctr_font_render_msg, "ctrfont", ctr_font_get_glyph, - ctr_font_bind_block, + NULL, /* bind_block */ NULL, /* flush_block */ ctr_font_get_message_width, }; diff --git a/gfx/drivers_font/d3d10_font.c b/gfx/drivers_font/d3d10_font.c index 333ff64106..80bb3c357d 100644 --- a/gfx/drivers_font/d3d10_font.c +++ b/gfx/drivers_font/d3d10_font.c @@ -362,18 +362,13 @@ static const struct font_glyph* d3d10_font_get_glyph(void *data, uint32_t code) return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void d3d10_font_bind_block(void* data, void *userdata) -{ - (void)data; -} - font_renderer_t d3d10_font = { d3d10_font_init_font, d3d10_font_free_font, d3d10_font_render_msg, "d3d10font", d3d10_font_get_glyph, - d3d10_font_bind_block, + NULL, /* bind_block */ NULL, /* flush */ d3d10_font_get_message_width, }; diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index 2b9fc2c301..de4f29ade3 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -359,18 +359,13 @@ static const struct font_glyph* d3d11_font_get_glyph(void *data, uint32_t code) return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void d3d11_font_bind_block(void* data, void *userdata) -{ - (void)data; -} - font_renderer_t d3d11_font = { d3d11_font_init_font, d3d11_font_free_font, d3d11_font_render_msg, "d3d11font", d3d11_font_get_glyph, - d3d11_font_bind_block, + NULL, /* bind_block */ NULL, /* flush */ d3d11_font_get_message_width, }; diff --git a/gfx/drivers_font/d3d12_font.c b/gfx/drivers_font/d3d12_font.c index 3276f8d1fb..d7f81262bc 100644 --- a/gfx/drivers_font/d3d12_font.c +++ b/gfx/drivers_font/d3d12_font.c @@ -376,18 +376,13 @@ static const struct font_glyph* d3d12_font_get_glyph( return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void d3d12_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - font_renderer_t d3d12_font = { d3d12_font_init_font, d3d12_font_free_font, d3d12_font_render_msg, "d3d12font", d3d12_font_get_glyph, - d3d12_font_bind_block, + NULL, /* bind_block */ NULL, /* flush */ d3d12_font_get_message_width, }; diff --git a/gfx/drivers_font/metal_raster_font.m b/gfx/drivers_font/metal_raster_font.m index 1fc15fc3aa..287410f150 100644 --- a/gfx/drivers_font/metal_raster_font.m +++ b/gfx/drivers_font/metal_raster_font.m @@ -529,7 +529,7 @@ static const struct font_glyph *metal_raster_font_get_glyph( } static void metal_raster_font_flush_block(unsigned width, unsigned height, - void *data, video_frame_info_t *video_info) + void *data, video_frame_info_t *video_info) { (void)data; } diff --git a/gfx/drivers_font/sixel_font.c b/gfx/drivers_font/sixel_font.c index d7082e37d1..674d9d460a 100644 --- a/gfx/drivers_font/sixel_font.c +++ b/gfx/drivers_font/sixel_font.c @@ -127,24 +127,13 @@ static void sixel_render_msg(video_frame_info_t *video_info, /* FIXME: add text drawing support */ } -static void sixel_font_flush_block(unsigned width, unsigned height, - void* data) -{ - (void)data; -} - -static void sixel_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - font_renderer_t sixel_font = { sixel_init_font, sixel_render_free_font, sixel_render_msg, "sixel font", sixel_font_get_glyph, /* get_glyph */ - sixel_font_bind_block, /* bind_block */ - sixel_font_flush_block, /* flush */ + NULL, /* bind_block */ + NULL, /* flush */ sixel_get_message_width /* get_message_width */ }; diff --git a/gfx/drivers_font/vga_font.c b/gfx/drivers_font/vga_font.c index 794c727bea..c223b3e201 100644 --- a/gfx/drivers_font/vga_font.c +++ b/gfx/drivers_font/vga_font.c @@ -126,18 +126,13 @@ static void vga_render_msg(video_frame_info_t *video_info, } } -static void vga_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - font_renderer_t vga_font = { vga_init_font, vga_render_free_font, vga_render_msg, "vga font", vga_font_get_glyph, /* get_glyph */ - vga_font_bind_block, /* bind_block */ + NULL, /* bind_block */ NULL, /* flush */ vga_get_message_width /* get_message_width */ }; diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c index d3fa780378..72c3d847f1 100644 --- a/gfx/drivers_font/vita2d_font.c +++ b/gfx/drivers_font/vita2d_font.c @@ -347,18 +347,13 @@ static const struct font_glyph *vita2d_font_get_glyph( return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void vita2d_font_bind_block(void *data, void *userdata) -{ - (void)data; -} - font_renderer_t vita2d_vita_font = { vita2d_font_init_font, vita2d_font_free_font, vita2d_font_render_msg, "vita2dfont", vita2d_font_get_glyph, - vita2d_font_bind_block, + NULL, /* bind_block */ NULL, /* flush */ vita2d_font_get_message_width, }; diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index 9d4edb6a7e..5fe9a13abc 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -436,24 +436,13 @@ static const struct font_glyph *vulkan_raster_font_get_glyph( return glyph; } -static void vulkan_raster_font_flush_block(unsigned width, unsigned height, - void *data, video_frame_info_t *video_info) -{ - (void)data; -} - -static void vulkan_raster_font_bind_block(void *data, void *userdata) -{ - (void)data; -} - font_renderer_t vulkan_raster_font = { vulkan_raster_font_init_font, vulkan_raster_font_free_font, vulkan_raster_font_render_msg, "Vulkan raster", vulkan_raster_font_get_glyph, - vulkan_raster_font_bind_block, - vulkan_raster_font_flush_block, + NULL, /* bind_block */ + NULL, /* flush_block */ vulkan_get_message_width }; diff --git a/gfx/drivers_font/wiiu_font.c b/gfx/drivers_font/wiiu_font.c index b959c89664..447360e582 100644 --- a/gfx/drivers_font/wiiu_font.c +++ b/gfx/drivers_font/wiiu_font.c @@ -377,12 +377,6 @@ static const struct font_glyph* wiiu_font_get_glyph( return font->font_driver->get_glyph((void*)font->font_driver, code); } -static void wiiu_font_bind_block(void* data, void* userdata) -{ - (void)data; -} - - font_renderer_t wiiu_font = { wiiu_font_init_font, @@ -390,7 +384,7 @@ font_renderer_t wiiu_font = wiiu_font_render_msg, "wiiufont", wiiu_font_get_glyph, - wiiu_font_bind_block, + NULL, /* bind_block */ NULL, /* flush */ wiiu_font_get_message_width, }; From 62e89974afbb6628344fb084c50712bfab4419de Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 16 Jul 2018 00:15:49 -0400 Subject: [PATCH 49/78] sort config file variables --- libretro-common/file/config_file.c | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 942de7da65..1bb3e1db2c 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -68,6 +68,84 @@ struct config_include_list static config_file_t *config_file_new_internal( const char *path, unsigned depth); +static int config_sort_compare_func(struct config_entry_list *a, + struct config_entry_list *b) +{ + const char *a_key = a ? a->key : NULL; + const char *b_key = b ? b->key : NULL; + + if (!a_key || !b_key) + return 0; + + return strcasecmp(a_key, b_key); +} + +/* https://stackoverflow.com/questions/7685/merge-sort-a-linked-list */ +static struct config_entry_list* merge_sort_linked_list(struct config_entry_list *list, int (*compare)(struct config_entry_list *one,struct config_entry_list *two)) +{ + struct config_entry_list + *right = list, + *temp = list, + *last = list, + *result = 0, + *next = 0, + *tail = 0; + + /* Trivial case. */ + if (!list || !list->next) + return list; + + /* Find halfway through the list (by running two pointers, one at twice the speed of the other). */ + while (temp && temp->next) + { + last = right; + right = right->next; + temp = temp->next->next; + } + + /* Break the list in two. (prev pointers are broken here, but we fix later) */ + last->next = 0; + + /* Recurse on the two smaller lists: */ + list = merge_sort_linked_list(list, compare); + right = merge_sort_linked_list(right, compare); + + /* Merge: */ + while (list || right) + { + /* Take from empty lists, or compare: */ + if (!right) + { + next = list; + list = list->next; + } + else if (!list) + { + next = right; + right = right->next; + } + else if (compare(list, right) < 0) + { + next = list; + list = list->next; + } + else + { + next = right; + right = right->next; + } + + if (!result) + result=next; + else + tail->next=next; + + tail = next; + } + + return result; +} + static char *strip_comment(char *str) { /* Remove everything after comment. @@ -913,6 +991,8 @@ void config_file_dump(config_file_t *conf, FILE *file) list = (struct config_entry_list*)conf->entries; + merge_sort_linked_list(list, config_sort_compare_func); + while (list) { if (!list->readonly && list->key) From 7e609d6a051f652e87e31b72a4c9d72b0b804f94 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 16 Jul 2018 23:01:16 -0400 Subject: [PATCH 50/78] fix some config entries not being saved --- libretro-common/file/config_file.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 1bb3e1db2c..18169f1304 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -136,9 +136,9 @@ static struct config_entry_list* merge_sort_linked_list(struct config_entry_list } if (!result) - result=next; + result = next; else - tail->next=next; + tail->next = next; tail = next; } @@ -989,9 +989,7 @@ void config_file_dump(config_file_t *conf, FILE *file) includes = includes->next; } - list = (struct config_entry_list*)conf->entries; - - merge_sort_linked_list(list, config_sort_compare_func); + list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func); while (list) { From 0addd1aca47ed887929a19ac2eb66a9107b3c699 Mon Sep 17 00:00:00 2001 From: gvbr <41351562+gvbr@users.noreply.github.com> Date: Tue, 17 Jul 2018 20:06:18 -0700 Subject: [PATCH 51/78] Runahead: ensure prefixed second-instance temp directory on linux --- runahead/secondary_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runahead/secondary_core.c b/runahead/secondary_core.c index 74ce5ccc4b..9d0d67de4b 100644 --- a/runahead/secondary_core.c +++ b/runahead/secondary_core.c @@ -80,7 +80,11 @@ char* get_temp_directory_alloc(void) return path; #endif #else - char *path = strcpy_alloc_force(getenv("TMPDIR")); + char *path = "/tmp"; + if (getenv("TMPDIR")) + path = getenv("TMPDIR"); + + path = strcpy_alloc_force(path); return path; #endif } From 9c0ed0f2c4182f3df543a54881e68bb12cf2ed68 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jul 2018 10:06:30 +0200 Subject: [PATCH 52/78] Don't use core profile GLSL shaders for OpenGLES --- .../gl_shaders/pipeline_snow.glsl.vert.h | 16 ++++++++++++++++ ....vert.h => pipeline_snow_core.glsl.vert.h} | 2 +- gfx/drivers_shader/shader_glsl.c | 19 ++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h rename gfx/drivers/gl_shaders/{modern_pipeline_snow.glsl.vert.h => pipeline_snow_core.glsl.vert.h} (87%) diff --git a/gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h new file mode 100644 index 0000000000..0ebbf254dd --- /dev/null +++ b/gfx/drivers/gl_shaders/pipeline_snow.glsl.vert.h @@ -0,0 +1,16 @@ +#include "shaders_common.h" + +/* Need to duplicate these to work around broken stuff on Android. + * Must enforce alpha = 1.0 or 32-bit games can potentially go black. */ +static const char *stock_vertex_xmb_snow = GLSL( + attribute vec2 TexCoord; + attribute vec2 VertexCoord; + attribute vec4 Color; + uniform mat4 MVPMatrix; + varying vec2 tex_coord; + + void main() { + gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0); + tex_coord = TexCoord; + } +); diff --git a/gfx/drivers/gl_shaders/modern_pipeline_snow.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h similarity index 87% rename from gfx/drivers/gl_shaders/modern_pipeline_snow.glsl.vert.h rename to gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h index 7e7719fdad..cae4002833 100644 --- a/gfx/drivers/gl_shaders/modern_pipeline_snow.glsl.vert.h +++ b/gfx/drivers/gl_shaders/pipeline_snow_core.glsl.vert.h @@ -2,7 +2,7 @@ /* Need to duplicate these to work around broken stuff on Android. * Must enforce alpha = 1.0 or 32-bit games can potentially go black. */ -static const char *stock_vertex_xmb_snow_modern = GLSL( +static const char *stock_vertex_xmb_snow_core = GLSL( in vec2 TexCoord; in vec2 VertexCoord; in vec4 Color; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 3a0683422d..8d8dbb4590 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -125,9 +125,10 @@ static const char *glsl_prefixes[] = { #include "../drivers/gl_shaders/core_pipeline_snowflake.glsl.frag.h" #include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" #include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" -#include "../drivers/gl_shaders/modern_pipeline_snow.glsl.vert.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h" #include "../drivers/gl_shaders/pipeline_snow.glsl.frag.h" +#include "../drivers/gl_shaders/pipeline_snow.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_snow_core.glsl.vert.h" #include "../drivers/gl_shaders/pipeline_snow_simple.glsl.frag.h" #include "../drivers/gl_shaders/legacy_pipeline_snow.glsl.vert.h" #include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h" @@ -843,10 +844,10 @@ static void gl_glsl_init_menu_shaders(void *data) &glsl->uniforms[VIDEO_SHADER_MENU_2]); #if defined(HAVE_OPENGLES) - shader_prog_info.vertex = stock_vertex_xmb_snow_modern; + shader_prog_info.vertex = stock_vertex_xmb_snow; shader_prog_info.fragment = stock_fragment_xmb_simple_snow; #else - shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_core : stock_vertex_xmb_snow_legacy; shader_prog_info.fragment = glsl_core ? stock_fragment_xmb_simple_snow_core : stock_fragment_xmb_simple_snow; #endif @@ -860,10 +861,10 @@ static void gl_glsl_init_menu_shaders(void *data) &glsl->uniforms[VIDEO_SHADER_MENU_3]); #if defined(HAVE_OPENGLES) - shader_prog_info.vertex = stock_vertex_xmb_snow_modern; + shader_prog_info.vertex = stock_vertex_xmb_snow; shader_prog_info.fragment = stock_fragment_xmb_snow; #else - shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_core : stock_vertex_xmb_snow_legacy; shader_prog_info.fragment = glsl_core ? stock_fragment_xmb_snow_core : stock_fragment_xmb_snow; #endif @@ -877,10 +878,10 @@ static void gl_glsl_init_menu_shaders(void *data) &glsl->uniforms[VIDEO_SHADER_MENU_4]); #if defined(HAVE_OPENGLES) - shader_prog_info.vertex = stock_vertex_xmb_snow_modern; + shader_prog_info.vertex = stock_vertex_xmb_snow; shader_prog_info.fragment = stock_fragment_xmb_bokeh; #else - shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_core : stock_vertex_xmb_snow_legacy; shader_prog_info.fragment = glsl_core ? stock_fragment_xmb_bokeh_core : stock_fragment_xmb_bokeh; #endif @@ -894,10 +895,10 @@ static void gl_glsl_init_menu_shaders(void *data) &glsl->uniforms[VIDEO_SHADER_MENU_5]); #if defined(HAVE_OPENGLES) - shader_prog_info.vertex = stock_vertex_xmb_snow_modern; + shader_prog_info.vertex = stock_vertex_xmb_snow; shader_prog_info.fragment = stock_fragment_xmb_snowflake; #else - shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_core : stock_vertex_xmb_snow_legacy; shader_prog_info.fragment = glsl_core ? stock_fragment_xmb_snowflake_core : stock_fragment_xmb_snowflake; #endif From 7403cfad993e4fcf8c419465cd2195ac390897f8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Jul 2018 20:54:59 +0200 Subject: [PATCH 53/78] (Stripes) Buildfix --- menu/drivers/stripes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index a66e092e23..0170c57e62 100755 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -681,9 +681,10 @@ static void stripes_messagebox(void *data, const char *message) stripes->box_message = strdup(message); } -static void stripes_render_keyboard(stripes_handle_t *stripes, +static void stripes_render_keyboard( + stripes_handle_t *stripes, video_frame_info_t *video_info, - const char *grid[], unsigned id) + char **grid, unsigned id) { unsigned i; int ptr_width, ptr_height; @@ -900,7 +901,7 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos) goto end; } - menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); + playlist = playlist_get_cached(); if (playlist) { From 454dbc61856995b4e877fc24972e3c507287b7af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Jul 2018 21:14:30 +0200 Subject: [PATCH 54/78] Change this to MENU_STRIPES --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index c681a2ab1e..63e3d29d85 100644 --- a/configuration.c +++ b/configuration.c @@ -530,7 +530,7 @@ static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XUI; #elif defined(HAVE_MATERIALUI) && defined(RARCH_MOBILE) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_MATERIALUI; #elif defined(HAVE_STRIPES) && !defined(_XBOX) -static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB; +static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_STRIPES; #elif defined(HAVE_XMB) && !defined(_XBOX) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB; #elif defined(HAVE_RGUI) From 6ae4350883ace90749a83651944f9e7e802f059f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Jul 2018 21:18:11 +0200 Subject: [PATCH 55/78] (XMB) Add back XMB ribbon - was probably not meant to be removed --- menu/drivers/xmb.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c6dd2103be..f0511dc936 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3968,6 +3968,40 @@ static void xmb_ribbon_set_vertex(float *ribbon_verts, ribbon_verts[idx++] = ((float)row) / (XMB_RIBBON_ROWS-1) * 2.0f - 1.0f; } +static void xmb_init_ribbon(xmb_handle_t * xmb) +{ + video_coords_t coords; + unsigned r, c, col; + unsigned i = 0; + video_coord_array_t *ca = menu_display_get_coords_array(); + unsigned vertices_total = XMB_RIBBON_VERTICES; + float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); + float *ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float)); + + /* Set up vertices */ + for (r = 0; r < XMB_RIBBON_ROWS - 1; r++) + { + for (c = 0; c < XMB_RIBBON_COLS; c++) + { + col = r % 2 ? XMB_RIBBON_COLS - c - 1 : c; + xmb_ribbon_set_vertex(ribbon_verts, i, r, col); + xmb_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col); + i += 4; + } + } + + coords.color = dummy; + coords.vertex = ribbon_verts; + coords.tex_coord = dummy; + coords.lut_tex_coord = dummy; + coords.vertices = vertices_total; + + video_coord_array_append(ca, &coords, coords.vertices); + + free(dummy); + free(ribbon_verts); +} + static void *xmb_init(void **userdata, bool video_is_threaded) { unsigned width, height; @@ -4077,6 +4111,8 @@ static void *xmb_init(void **userdata, bool video_is_threaded) if (xmb->horizontal_list) xmb_init_horizontal_list(xmb); + xmb_init_ribbon(xmb); + return menu; error: From 0a710564e1fedc58db03dfb6b4bf866e2fb63af6 Mon Sep 17 00:00:00 2001 From: Yoshi Sugawara Date: Sun, 22 Jul 2018 11:32:52 -1000 Subject: [PATCH 56/78] issue 6751: read input of overlay for remapped keyboard keys --- input/input_mapper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/input/input_mapper.c b/input/input_mapper.c index b8f7931292..c9c6937a9b 100644 --- a/input/input_mapper.c +++ b/input/input_mapper.c @@ -124,7 +124,10 @@ void input_mapper_poll(input_mapper_t *handle) if (remap_valid) { unsigned current_button_value = BIT256_GET(current_input, j); - +#ifdef HAVE_OVERLAY + if (poll_overlay && i == 0) + current_button_value |= input_overlay_key_pressed(overlay_ptr, j); +#endif if ((current_button_value == 1) && (j != remap_button)) { MAPPER_SET_KEY (handle, From bea736865b8515a726cac31ae4ebdd2c4ccabd18 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Jul 2018 00:10:35 +0200 Subject: [PATCH 57/78] Add some logs --- command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/command.c b/command.c index a33f8e1faf..5775e4f6a2 100644 --- a/command.c +++ b/command.c @@ -1051,8 +1051,11 @@ static void command_event_deinit_core(bool reinit) cheevos_unload(); #endif + RARCH_LOG("Unloading game..\n"); core_unload_game(); + RARCH_LOG("Unloading core..\n"); core_unload(); + RARCH_LOG("Unloading core symbols..\n"); core_uninit_symbols(); if (reinit) From f78337e02e66eb66819be2f1b6faccbe72b78ae4 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 22 Jul 2018 22:05:57 -0400 Subject: [PATCH 58/78] Qt: add progress bar for grid view loading --- intl/msg_hash_ja.h | 2 ++ intl/msg_hash_us.h | 2 ++ msg_hash.h | 1 + ui/drivers/qt/ui_qt_window.cpp | 65 +++++++++++++++++++++++++++++++--- ui/drivers/ui_qt.h | 5 ++- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index cfc87db199..2756c4d4bf 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3630,3 +3630,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "パフォーマンス維持モード") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv対応") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, + "進行状況:") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index bbe66247e9..b96c7ea606 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3788,3 +3788,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, + "Progress:") diff --git a/msg_hash.h b/msg_hash.h index 24a687cd2b..63e952cc07 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1875,6 +1875,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_QT_VIEW, MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS, MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST, + MENU_ENUM_LABEL_VALUE_QT_PROGRESS, MENU_LABEL(MIDI_INPUT), MENU_LABEL(MIDI_OUTPUT), diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 57d0ba1fc3..83bdd6b8e8 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -532,6 +532,8 @@ MainWindow::MainWindow(QWidget *parent) : ,m_lastZoomSliderValue(0) ,m_pendingItemUpdates() ,m_viewType(VIEW_TYPE_LIST) + ,m_gridProgressBar(NULL) + ,m_gridProgressWidget(NULL) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -544,10 +546,16 @@ MainWindow::MainWindow(QWidget *parent) : QMenu *viewTypeMenu = new QMenu(viewTypePushButton); QAction *viewTypeIconsAction = NULL; QAction *viewTypeListAction = NULL; + QHBoxLayout *gridProgressLayout = new QHBoxLayout(); + QLabel *gridProgressLabel = NULL; + QHBoxLayout *gridFooterLayout = NULL; int i = 0; qRegisterMetaType >("ThumbnailWidget"); + m_gridProgressWidget = new QWidget(); + gridProgressLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PROGRESS), m_gridProgressWidget); + viewTypePushButton->setObjectName("viewTypePushButton"); viewTypePushButton->setFlat(true); @@ -556,6 +564,12 @@ MainWindow::MainWindow(QWidget *parent) : viewTypePushButton->setMenu(viewTypeMenu); + gridProgressLabel->setObjectName("gridProgressLabel"); + + m_gridProgressBar = new QProgressBar(m_gridProgressWidget); + + m_gridProgressBar->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred)); + zoomLabel->setObjectName("zoomLabel"); m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); @@ -563,6 +577,7 @@ MainWindow::MainWindow(QWidget *parent) : m_zoomSlider->setMinimum(0); m_zoomSlider->setMaximum(100); m_zoomSlider->setValue(50); + m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred)); m_lastZoomSliderValue = m_zoomSlider->value(); @@ -578,16 +593,28 @@ MainWindow::MainWindow(QWidget *parent) : m_gridWidget->layout()->addWidget(m_gridScrollArea); m_gridWidget->layout()->setAlignment(Qt::AlignCenter); - m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred)); + m_gridProgressWidget->setLayout(gridProgressLayout); + gridProgressLayout->setContentsMargins(0, 0, 0, 0); + gridProgressLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); + gridProgressLayout->addWidget(gridProgressLabel); + gridProgressLayout->addWidget(m_gridProgressBar); + + m_gridWidget->layout()->addWidget(m_gridProgressWidget); zoomWidget->setLayout(zoomLayout); zoomLayout->setContentsMargins(0, 0, 0, 0); - zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); zoomLayout->addWidget(zoomLabel); zoomLayout->addWidget(m_zoomSlider); zoomLayout->addWidget(viewTypePushButton); - m_gridWidget->layout()->addWidget(zoomWidget); + gridFooterLayout = new QHBoxLayout(); + gridFooterLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); + gridFooterLayout->addWidget(m_gridProgressWidget); + gridFooterLayout->addWidget(zoomWidget); + + static_cast(m_gridWidget->layout())->addLayout(gridFooterLayout); + + m_gridProgressWidget->hide(); m_tableWidget->setAlternatingRowColors(true); @@ -2994,7 +3021,7 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) return item; } -void MainWindow::addPlaylistItemsToGrid(const QString &pathString) +void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgress) { QVector > items = getPlaylistItems(pathString); QScreen *screen = qApp->primaryScreen(); @@ -3004,6 +3031,14 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) int i = 0; int zoomValue = m_zoomSlider->value(); + /* setProgress means we are resetting the range of the progress bar as we are only loading a single playlist. If false, just increment by 1 since instead we're loading multiple playlists and we only track the progress of each entire playlist that is loaded, instead of every single entry. */ + if (setProgress) + { + m_gridProgressBar->setMinimum(0); + m_gridProgressBar->setMaximum(items.count() - 1); + m_gridProgressBar->setValue(0); + } + for (i = 0; i < items.count(); i++) { const QHash &hash = items.at(i); @@ -3077,7 +3112,17 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString) if (i % 25 == 0) qApp->processEvents(); + + if (setProgress) + m_gridProgressBar->setValue(i); } + + if (!setProgress) + m_gridProgressBar->setValue(m_gridProgressBar->value() + 1); + + /* If there's only one entry, a min/max/value of all zero would make an indeterminate progress bar that never ends... so just hide it when we are done. */ + if (m_gridProgressBar->value() == m_gridProgressBar->maximum()) + m_gridProgressWidget->hide(); } void MainWindow::initContentGridLayout() @@ -3088,6 +3133,11 @@ void MainWindow::initContentGridLayout() if (!item) return; + m_gridProgressBar->setMinimum(0); + m_gridProgressBar->setMaximum(0); + m_gridProgressBar->setValue(0); + m_gridProgressWidget->show(); + removeGridItems(); path = item->data(Qt::UserRole).toString(); @@ -3098,10 +3148,15 @@ void MainWindow::initContentGridLayout() QDir playlistDir(settings->paths.directory_playlist); int i = 0; + m_gridProgressBar->setMinimum(0); + m_gridProgressBar->setMaximum(m_playlistFiles.count() - 1); + m_gridProgressBar->setValue(0); + for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { const QString &playlist = m_playlistFiles.at(i); - addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist)); + m_gridProgressBar->setValue(i); + addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist), false); } } else diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 42a404faca..20d8f99b76 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -32,6 +32,7 @@ #include #include #include +#include extern "C" { #include @@ -327,7 +328,7 @@ private slots: void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); void addPlaylistItemsToTable(QString path); - void addPlaylistItemsToGrid(const QString &path); + void addPlaylistItemsToGrid(const QString &path, bool setProgress = true); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); void onTreeViewItemsSelected(QModelIndexList selectedIndexes); @@ -403,6 +404,8 @@ private: int m_lastZoomSliderValue; QList m_pendingItemUpdates; ViewType m_viewType; + QProgressBar *m_gridProgressBar; + QWidget *m_gridProgressWidget; protected: void closeEvent(QCloseEvent *event); From 1293447aab9afbd33996aac49fc035c1d7685206 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 23 Jul 2018 09:44:24 -0400 Subject: [PATCH 59/78] Qt: hide progress properly when done showing "all playlists" if user only has a single playlist --- ui/drivers/qt/ui_qt_window.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 83bdd6b8e8..9ea00b13ff 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -3055,6 +3055,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgr if (m_listWidget->currentItem() != currentItem) { /* user changed the current playlist before we finished loading... abort */ + m_gridProgressWidget->hide(); break; } @@ -3117,7 +3118,7 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgr m_gridProgressBar->setValue(i); } - if (!setProgress) + if (!setProgress && m_gridProgressBar->value() < m_gridProgressBar->maximum()) m_gridProgressBar->setValue(m_gridProgressBar->value() + 1); /* If there's only one entry, a min/max/value of all zero would make an indeterminate progress bar that never ends... so just hide it when we are done. */ From bbe1dcd48f352c7bba340e7f734148b4acf71d46 Mon Sep 17 00:00:00 2001 From: kurumushi Date: Mon, 23 Jul 2018 23:11:54 +0900 Subject: [PATCH 60/78] Add imc0: mount for ps vita This allows using the internal storage of the ps vita 2000 model when it's mounted on imc0: instead of ux0: --- frontend/drivers/platform_psp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 2d54b2eb22..61214d8dcc 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -468,6 +468,11 @@ static int frontend_psp_parse_drive_list(void *data, bool load_content) msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), enum_idx, FILE_TYPE_DIRECTORY, 0, 0); + menu_entries_append_enum(list, + "imc0:/", + msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), + enum_idx, + FILE_TYPE_DIRECTORY, 0, 0); #else menu_entries_append_enum(list, "ms0:/", From c8a814ae40225d305b44e28fa81574b83c7f7e21 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 23 Jul 2018 11:17:58 -0400 Subject: [PATCH 61/78] Qt: hook up grid view click/doubleclick events --- ui/drivers/qt/ui_qt_window.cpp | 163 +++++++++++++++++++++++---------- ui/drivers/ui_qt.cpp | 33 +++++-- ui/drivers/ui_qt.h | 15 ++- 3 files changed, 153 insertions(+), 58 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 9ea00b13ff..4b770c723b 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -534,6 +534,8 @@ MainWindow::MainWindow(QWidget *parent) : ,m_viewType(VIEW_TYPE_LIST) ,m_gridProgressBar(NULL) ,m_gridProgressWidget(NULL) + ,m_currentGridHash() + ,m_lastViewType(m_viewType) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -776,6 +778,34 @@ MainWindow::~MainWindow() removeGridItems(); } +void MainWindow::onGridItemClicked() +{ + QHash hash; + ThumbnailWidget *w = static_cast(sender()); + + if (!w) + return; + + hash = w->property("hash").value >(); + + m_currentGridHash = hash; + + currentItemChanged(hash); +} + +void MainWindow::onGridItemDoubleClicked() +{ + QHash hash; + ThumbnailWidget *w = static_cast(sender()); + + if (!w) + return; + + hash = w->property("hash").value >(); + + loadContent(hash); +} + void MainWindow::onIconViewClicked() { setCurrentViewType(VIEW_TYPE_ICONS); @@ -1896,9 +1926,12 @@ QHash MainWindow::getSelectedCore() QHash coreHash; QHash contentHash; QTableWidgetItem *contentItem = m_tableWidget->currentItem(); + ViewType viewType = getCurrentViewType(); - if (contentItem) + if (viewType == VIEW_TYPE_LIST && contentItem) contentHash = contentItem->data(Qt::UserRole).value >(); + else if (viewType == VIEW_TYPE_ICONS) + contentHash = m_currentGridHash; switch(coreSelection) { @@ -1949,12 +1982,19 @@ QHash MainWindow::getSelectedCore() return coreHash; } -void MainWindow::onRunClicked() +/* the hash typically has the following keys: +path - absolute path to the content file +core_path - absolute path to the core, or "DETECT" to ask the user +db_name - the display name of the rdb database this content is from +label - the display name of the content, usually comes from the database +crc32 - an upper-case, 8 byte string representation of the hex CRC32 checksum (e.g. ABCDEF12) followed by "|crc" +core_name - the display name of the core, or "DETECT" if unknown +label_noext - the display name of the content that is guaranteed not to contain a file extension +*/ +void MainWindow::loadContent(const QHash &contentHash) { #ifdef HAVE_MENU content_ctx_info_t content_info; - QHash contentHash; - QTableWidgetItem *item = m_tableWidget->currentItem(); QByteArray corePathArray; QByteArray contentPathArray; QByteArray contentLabelArray; @@ -1964,63 +2004,50 @@ void MainWindow::onRunClicked() QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value(); CoreSelection coreSelection = static_cast(coreMap.value("core_selection").toInt()); - if (!item) - return; - if (m_pendingRun) coreSelection = CORE_SELECTION_CURRENT; - contentHash = item->data(Qt::UserRole).value >(); - if (coreSelection == CORE_SELECTION_ASK) { - QTableWidgetItem *item = m_tableWidget->currentItem(); QStringList extensionFilters; - if (item) + if (contentHash.contains("path")) { - QHash hash; + int lastIndex = contentHash["path"].lastIndexOf('.'); + QString extensionStr; + QByteArray pathArray = contentHash["path"].toUtf8(); + const char *pathData = pathArray.constData(); - hash = item->data(Qt::UserRole).value >(); - - if (hash.contains("path")) + if (lastIndex >= 0) { - int lastIndex = hash["path"].lastIndexOf('.'); - QString extensionStr; - QByteArray pathArray = hash["path"].toUtf8(); - const char *pathData = pathArray.constData(); + extensionStr = contentHash["path"].mid(lastIndex + 1); - if (lastIndex >= 0) + if (!extensionStr.isEmpty()) { - extensionStr = hash["path"].mid(lastIndex + 1); - - if (!extensionStr.isEmpty()) - { - extensionFilters.append(extensionStr.toLower()); - } + extensionFilters.append(extensionStr.toLower()); } + } - if (path_is_compressed_file(pathData)) + if (path_is_compressed_file(pathData)) + { + unsigned i = 0; + struct string_list *list = file_archive_get_file_list(pathData, NULL); + + if (list) { - unsigned i = 0; - struct string_list *list = file_archive_get_file_list(pathData, NULL); - - if (list) + if (list->size > 0) { - if (list->size > 0) + for (i = 0; i < list->size; i++) { - for (i = 0; i < list->size; i++) - { - const char *filePath = list->elems[i].data; - const char *extension = path_get_extension(filePath); + const char *filePath = list->elems[i].data; + const char *extension = path_get_extension(filePath); - if (!extensionFilters.contains(extension, Qt::CaseInsensitive)) - extensionFilters.append(extension); - } + if (!extensionFilters.contains(extension, Qt::CaseInsensitive)) + extensionFilters.append(extension); } - - string_list_free(list); } + + string_list_free(list); } } } @@ -2096,6 +2123,25 @@ void MainWindow::onRunClicked() #endif } +void MainWindow::onRunClicked() +{ +#ifdef HAVE_MENU + QTableWidgetItem *item = m_tableWidget->currentItem(); + ViewType viewType = getCurrentViewType(); + QHash contentHash; + + if (!item) + return; + + if (viewType == VIEW_TYPE_LIST) + contentHash = item->data(Qt::UserRole).value >(); + else if (viewType == VIEW_TYPE_ICONS) + contentHash = m_currentGridHash; + + loadContent(contentHash); +#endif +} + bool MainWindow::isContentLessCore() { rarch_system_info_t *system = runloop_get_system_info(); @@ -2164,6 +2210,7 @@ void MainWindow::setCoreActions() { QTableWidgetItem *currentContentItem = m_tableWidget->currentItem(); QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem(); + ViewType viewType = getCurrentViewType(); QHash hash; m_launchWithComboBox->clear(); @@ -2182,8 +2229,10 @@ void MainWindow::setCoreActions() m_launchWithComboBox->addItem(m_currentCore, QVariant::fromValue(comboBoxMap)); } - if (currentContentItem) + if (viewType == VIEW_TYPE_LIST && currentContentItem) hash = currentContentItem->data(Qt::UserRole).value >(); + else if (viewType == VIEW_TYPE_ICONS) + hash = m_currentGridHash; if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)) { @@ -2341,6 +2390,9 @@ void MainWindow::onTabWidgetIndexChanged(int index) { QModelIndex index = m_dirTree->currentIndex(); + /* force list view for file browser, will set it back to whatever the user had when switching back to playlist tab */ + setCurrentViewType(VIEW_TYPE_LIST); + m_tableWidget->clear(); m_tableWidget->setColumnCount(0); m_tableWidget->setRowCount(0); @@ -2355,6 +2407,9 @@ void MainWindow::onTabWidgetIndexChanged(int index) { QListWidgetItem *item = m_listWidget->currentItem(); + if (m_lastViewType != getCurrentViewType()) + setCurrentViewType(m_lastViewType); + m_tableWidget->clear(); m_tableWidget->setColumnCount(0); m_tableWidget->setRowCount(0); @@ -2544,19 +2599,25 @@ void MainWindow::onSearchEnterPressed() void MainWindow::onCurrentTableItemChanged(QTableWidgetItem *current, QTableWidgetItem *) { - settings_t *settings = config_get_ptr(); QHash hash; - QString label; - QString playlist_name; - QByteArray extension; - QString extensionStr; - int lastIndex = -1; if (!current) return; hash = current->data(Qt::UserRole).value >(); + currentItemChanged(hash); +} + +void MainWindow::currentItemChanged(const QHash &hash) +{ + settings_t *settings = config_get_ptr(); + QString label; + QString playlist_name; + QByteArray extension; + QString extensionStr; + int lastIndex = -1; + label = hash["label_noext"]; label.replace(m_fileSanitizerRegex, "_"); @@ -2674,6 +2735,7 @@ void MainWindow::resizeThumbnails(bool one, bool two, bool three) void MainWindow::setCurrentViewType(ViewType viewType) { + m_lastViewType = m_viewType; m_viewType = viewType; switch (viewType) @@ -3092,6 +3154,11 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgr item->widget->setLayout(new QVBoxLayout()); item->widget->setStyleSheet("background-color: #555555"); + item->widget->setProperty("hash", QVariant::fromValue >(hash)); + + connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked())); + connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked())); + label = new ThumbnailLabel(item->widget); item->label = label; diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 5229843ab9..ba0644b285 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -61,17 +61,31 @@ ThumbnailWidget::ThumbnailWidget(QWidget *parent) : { } +void ThumbnailWidget::mousePressEvent(QMouseEvent *event) +{ + QWidget::mousePressEvent(event); + + emit mousePressed(); +} + +void ThumbnailWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + QWidget::mouseDoubleClickEvent(event); + + emit mouseDoubleClicked(); +} + void ThumbnailWidget::paintEvent(QPaintEvent *event) { - QStyleOption o; - QPainter p; - o.initFrom(this); - p.begin(this); - style()->drawPrimitive( - QStyle::PE_Widget, &o, &p, this); - p.end(); + QStyleOption o; + QPainter p; + o.initFrom(this); + p.begin(this); + style()->drawPrimitive( + QStyle::PE_Widget, &o, &p, this); + p.end(); - QWidget::paintEvent(event); + QWidget::paintEvent(event); } void ThumbnailWidget::resizeEvent(QResizeEvent *event) @@ -497,6 +511,9 @@ static void* ui_companion_qt_init(void) mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS); else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); + + /* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */ + mainwindow->setCurrentViewType(mainwindow->getCurrentViewType()); } else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 20d8f99b76..941a49ba5e 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -88,11 +88,16 @@ public: ThumbnailWidget(QWidget *parent = 0); QSize sizeHint() const; void setSizeHint(QSize size); +signals: + void mouseDoubleClicked(); + void mousePressed(); private: QSize m_sizeHint; protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); }; class ThumbnailLabel : public QWidget @@ -281,6 +286,8 @@ public: const QString& customThemeString() const; GridItem* doDeferredImageLoad(GridItem *item, QString path); void setCurrentViewType(ViewType viewType); + QString getCurrentViewTypeString(); + ViewType getCurrentViewType(); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -300,6 +307,7 @@ public slots: void onShowHiddenDockWidgetAction(); void setCoreActions(); void onRunClicked(); + void loadContent(const QHash &contentHash); void onStartCoreClicked(); void onTableWidgetEnterPressed(); void selectBrowserDir(QString path); @@ -325,6 +333,7 @@ private slots: void onCoreLoaded(); void onCurrentListItemChanged(QListWidgetItem *current, QListWidgetItem *previous); void onCurrentTableItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous); + void currentItemChanged(const QHash &hash); void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); void addPlaylistItemsToTable(QString path); @@ -342,6 +351,8 @@ private slots: void onContentGridInited(); void onUpdateGridItemPixmapFromImage(GridItem *item); void onPendingItemUpdates(); + void onGridItemDoubleClicked(); + void onGridItemClicked(); private: void setCurrentCoreLabel(); @@ -352,8 +363,6 @@ private: void loadImageDeferred(GridItem *item, QString path); void calcGridItemSize(GridItem *item, int zoomValue); QVector > getPlaylistItems(QString pathString); - QString getCurrentViewTypeString(); - ViewType getCurrentViewType(); LoadCoreWindow *m_loadCoreWindow; QTimer *m_timer; @@ -406,6 +415,8 @@ private: ViewType m_viewType; QProgressBar *m_gridProgressBar; QWidget *m_gridProgressWidget; + QHash m_currentGridHash; + ViewType m_lastViewType; protected: void closeEvent(QCloseEvent *event); From a740d73d2184699d651ea3e359d6ce01ff697c02 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Jul 2018 17:42:15 +0200 Subject: [PATCH 62/78] Don't set MENU_STRIPES as default --- configuration.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/configuration.c b/configuration.c index 63e3d29d85..c6142c7bb0 100644 --- a/configuration.c +++ b/configuration.c @@ -529,8 +529,6 @@ static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_NULL; static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XUI; #elif defined(HAVE_MATERIALUI) && defined(RARCH_MOBILE) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_MATERIALUI; -#elif defined(HAVE_STRIPES) && !defined(_XBOX) -static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_STRIPES; #elif defined(HAVE_XMB) && !defined(_XBOX) static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB; #elif defined(HAVE_RGUI) From 6cee45ab9921fb5df3e330a6c231e648621c8a8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Jul 2018 17:42:57 +0200 Subject: [PATCH 63/78] Don't bake in HAVE_STRIPES by default --- qb/config.params.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qb/config.params.sh b/qb/config.params.sh index ecf69bf6bc..709eb2f4a9 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -10,7 +10,7 @@ HAVE_LIBRETRODB=yes # Libretrodb support HAVE_RGUI=yes # RGUI menu HAVE_MATERIALUI=auto # MaterialUI menu HAVE_XMB=auto # XMB menu -HAVE_STRIPES=auto # Stripes menu +HAVE_STRIPES=no # Stripes menu HAVE_ZARCH=no # Zarch menu HAVE_NUKLEAR=no # Nuklear menu HAVE_RUNAHEAD=yes # Runahead support From 3aac9a169363377306a564894a41ea47dd91c724 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 23 Jul 2018 17:45:30 +0200 Subject: [PATCH 64/78] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c9ed1b06de..03be602b94 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ - REMAPS: Fix the way offsets are calculated for keyboard remapping. - RUNAHEAD: Fix full-screen mode change breaking Secondary Core's environment variables. - VITA: Use proper button labels, fix inverted R-Stick Y axis. +- VITA: Add imc0: mount. - VULKAN: Fix two validation errors. - VULKAN: Try to avoid creating swapchains redundantly. Should fix black screen and having to alt tab out of window again to get display working on Nvidia GPUs (Windows). - VULKAN/OSX: Initial MoltenVK support. Not enabled yet, several MoltenVK bugs should be fixed first before we can have it fully working. From ef10b7897dfbb56cd56735287896b08dfedd8365 Mon Sep 17 00:00:00 2001 From: TheOfficialFloW Date: Tue, 24 Jul 2018 10:12:15 +0200 Subject: [PATCH 65/78] Use sceCtrlIsMultiControllerSupported to detect --- input/drivers_joypad/psp_joypad.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 309a8a0f3c..943d4a0721 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -34,7 +34,6 @@ #include #include #define PSP_MAX_PADS 4 -static int psp2_model; static SceCtrlPortInfo old_ctrl_info, curr_ctrl_info; static SceCtrlActuator actuators[PSP_MAX_PADS] = {0}; @@ -64,7 +63,7 @@ extern uint64_t lifecycle_state; static const char *psp_joypad_name(unsigned pad) { #ifdef VITA - if (psp2_model != SCE_KERNEL_MODEL_VITATV) + if (!sceCtrlIsMultiControllerSupported()) return "Vita Controller"; switch (curr_ctrl_info.port[pad + 1]) @@ -89,8 +88,7 @@ static bool psp_joypad_init(void *data) (void)data; #if defined(VITA) - psp2_model = sceKernelGetModelForCDialog(); - if (psp2_model != SCE_KERNEL_MODEL_VITATV) + if (!sceCtrlIsMultiControllerSupported()) { sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START); sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); @@ -192,7 +190,7 @@ static void psp_joypad_poll(void) #endif #ifdef VITA - if (psp2_model != SCE_KERNEL_MODEL_VITATV) + if (!sceCtrlIsMultiControllerSupported()) players_count = 1; else { @@ -237,7 +235,7 @@ static void psp_joypad_poll(void) SceCtrlData state_tmp; unsigned i = player; #if defined(VITA) - unsigned p = (psp2_model == SCE_KERNEL_MODEL_VITATV) ? player + 1 : player; + unsigned p = (sceCtrlIsMultiControllerSupported()) ? player + 1 : player; if (curr_ctrl_info.port[p] == SCE_CTRL_TYPE_UNPAIRED) continue; #elif defined(SN_TARGET_PSP2) @@ -261,7 +259,7 @@ static void psp_joypad_poll(void) continue; #endif #if defined(VITA) - if (psp2_model == SCE_KERNEL_MODEL_VITA + if (!sceCtrlIsMultiControllerSupported() && settings->bools.input_backtouch_enable) { unsigned i; @@ -332,7 +330,7 @@ static bool psp_joypad_rumble(unsigned pad, enum retro_rumble_effect effect, uint16_t strength) { #ifdef VITA - if (psp2_model != SCE_KERNEL_MODEL_VITATV) + if (!sceCtrlIsMultiControllerSupported()) return false; switch (effect) From ccb87f3a96d60b6ea8f895e1a66aae5f50f5f94e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 24 Jul 2018 15:02:42 +0200 Subject: [PATCH 66/78] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 03be602b94..b5659b764b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ - RUNAHEAD: Fix full-screen mode change breaking Secondary Core's environment variables. - VITA: Use proper button labels, fix inverted R-Stick Y axis. - VITA: Add imc0: mount. +- VITA: Use sceCtrlIsMultiControllerSupported to detect. - VULKAN: Fix two validation errors. - VULKAN: Try to avoid creating swapchains redundantly. Should fix black screen and having to alt tab out of window again to get display working on Nvidia GPUs (Windows). - VULKAN/OSX: Initial MoltenVK support. Not enabled yet, several MoltenVK bugs should be fixed first before we can have it fully working. From ab03c1818aa4638c7c0ce62ae6cb4f1c454df6dd Mon Sep 17 00:00:00 2001 From: hizzlekizzle Date: Tue, 24 Jul 2018 11:15:03 -0500 Subject: [PATCH 67/78] update info.plist to v1.7.3 must have been missed in the previous update --- pkg/apple/OSX/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apple/OSX/Info.plist b/pkg/apple/OSX/Info.plist index 18edea946b..aeee252500 100644 --- a/pkg/apple/OSX/Info.plist +++ b/pkg/apple/OSX/Info.plist @@ -30,7 +30,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.7.2 + 1.7.3 CFBundleSignature ???? CFBundleVersion From baa709632d48aff551e22e886bbc49fc45abc612 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 24 Jul 2018 15:09:18 -0400 Subject: [PATCH 68/78] Qt: sort grid entries by name --- ui/drivers/qt/ui_qt_window.cpp | 92 +++++++++++++++++++++++++--------- ui/drivers/ui_qt.h | 6 ++- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 4b770c723b..be64a74f41 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -125,6 +125,11 @@ static void scan_finished_handler(void *task_data, void *user_data, const char * } #endif +inline static bool comp_hash_label_key(const QHash &lhs, const QHash &rhs) +{ + return lhs.value("label") < rhs.value("label"); +} + GridItem::GridItem() : QObject() ,widget(NULL) @@ -3083,9 +3088,32 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) return item; } -void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgress) +void MainWindow::addPlaylistItemsToGrid(const QStringList &paths) +{ + QVector > items; + int i; + + if (paths.isEmpty()) + return; + + for (i = 0; i < paths.size(); i++) + { + int j; + QVector > vec = getPlaylistItems(paths.at(i)); + /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ + for (j = 0; j < vec.size(); j++) + { + items.append(vec.at(j)); + } + } + + std::sort(items.begin(), items.end(), comp_hash_label_key); + + addPlaylistHashToGrid(items); +} + +void MainWindow::addPlaylistHashToGrid(const QVector > &items) { - QVector > items = getPlaylistItems(pathString); QScreen *screen = qApp->primaryScreen(); QSize screenSize = screen->size(); QListWidgetItem *currentItem = m_listWidget->currentItem(); @@ -3093,13 +3121,9 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgr int i = 0; int zoomValue = m_zoomSlider->value(); - /* setProgress means we are resetting the range of the progress bar as we are only loading a single playlist. If false, just increment by 1 since instead we're loading multiple playlists and we only track the progress of each entire playlist that is loaded, instead of every single entry. */ - if (setProgress) - { - m_gridProgressBar->setMinimum(0); - m_gridProgressBar->setMaximum(items.count() - 1); - m_gridProgressBar->setValue(0); - } + m_gridProgressBar->setMinimum(0); + m_gridProgressBar->setMaximum(items.count() - 1); + m_gridProgressBar->setValue(0); for (i = 0; i < items.count(); i++) { @@ -3181,13 +3205,9 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgr if (i % 25 == 0) qApp->processEvents(); - if (setProgress) - m_gridProgressBar->setValue(i); + m_gridProgressBar->setValue(i); } - if (!setProgress && m_gridProgressBar->value() < m_gridProgressBar->maximum()) - m_gridProgressBar->setValue(m_gridProgressBar->value() + 1); - /* If there's only one entry, a min/max/value of all zero would make an indeterminate progress bar that never ends... so just hide it when we are done. */ if (m_gridProgressBar->value() == m_gridProgressBar->maximum()) m_gridProgressWidget->hide(); @@ -3214,21 +3234,19 @@ void MainWindow::initContentGridLayout() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); + QStringList playlists; int i = 0; - m_gridProgressBar->setMinimum(0); - m_gridProgressBar->setMaximum(m_playlistFiles.count() - 1); - m_gridProgressBar->setValue(0); - for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { const QString &playlist = m_playlistFiles.at(i); - m_gridProgressBar->setValue(i); - addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist), false); + playlists.append(playlistDir.absoluteFilePath(playlist)); } + + addPlaylistItemsToGrid(playlists); } else - addPlaylistItemsToGrid(path); + addPlaylistItemsToGrid(QStringList() << path); QTimer::singleShot(0, this, SLOT(onContentGridInited())); } @@ -3272,16 +3290,19 @@ void MainWindow::initContentTableWidget() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); + QStringList playlists; int i = 0; for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { const QString &playlist = m_playlistFiles.at(i); - addPlaylistItemsToTable(playlistDir.absoluteFilePath(playlist)); + playlists.append(playlistDir.absoluteFilePath(playlist)); } + + addPlaylistItemsToTable(playlists); } else - addPlaylistItemsToTable(path); + addPlaylistItemsToTable(QStringList() << path); m_tableWidget->setSortingEnabled(true); @@ -3372,9 +3393,30 @@ QVector > MainWindow::getPlaylistItems(QString pathStrin return items; } -void MainWindow::addPlaylistItemsToTable(QString pathString) +void MainWindow::addPlaylistItemsToTable(const QStringList &paths) +{ + QVector > items; + int i; + + if (paths.isEmpty()) + return; + + for (i = 0; i < paths.size(); i++) + { + int j; + QVector > vec = getPlaylistItems(paths.at(i)); + /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ + for (j = 0; j < vec.size(); j++) + { + items.append(vec.at(j)); + } + } + + addPlaylistHashToTable(items); +} + +void MainWindow::addPlaylistHashToTable(const QVector > &items) { - QVector > items = getPlaylistItems(pathString); int i = 0; int oldRowCount = m_tableWidget->rowCount(); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 941a49ba5e..8380d38e98 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -336,8 +336,10 @@ private slots: void currentItemChanged(const QHash &hash); void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); - void addPlaylistItemsToTable(QString path); - void addPlaylistItemsToGrid(const QString &path, bool setProgress = true); + void addPlaylistItemsToTable(const QStringList &paths); + void addPlaylistHashToTable(const QVector > &items); + void addPlaylistItemsToGrid(const QStringList &paths); + void addPlaylistHashToGrid(const QVector > &items); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); void onTreeViewItemsSelected(QModelIndexList selectedIndexes); From c7052f67dfacbc633067340612a541c99859db96 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 24 Jul 2018 15:10:18 -0400 Subject: [PATCH 69/78] update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index b5659b764b..8566968890 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ - MIDI: Add a Windows driver for MIDI, based on winmm. - MENU/QT/WIMP: QT QSlider styling for Dark Theme. - MENU/QT/WIMP: Remove button ghostly inside highlighting. +- MENU/QT/WIMP: Initial grid view. - METAL: Initial work-in-progress video driver for Metal. macOS-only right now, and currently requires macOS 10.13. - METAL: Supports XMB/MaterialUI, has a menu display driver. Has a font rendering driver. - METAL/SLANG: Slang shaders should be compatible with Metal video driver. From d17c17085cb8bf08e1b8972db3aabf4144bdff70 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 24 Jul 2018 17:07:17 -0400 Subject: [PATCH 70/78] Qt: hook up search box to grid view --- ui/drivers/qt/ui_qt_window.cpp | 149 ++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 41 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index be64a74f41..ccc06c911c 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -1948,7 +1948,7 @@ QHash MainWindow::getSelectedCore() } case CORE_SELECTION_PLAYLIST_SAVED: { - if (!contentItem || contentHash["core_path"].isEmpty()) + if (contentHash.isEmpty() || contentHash["core_path"].isEmpty()) break; coreHash["core_path"] = contentHash["core_path"]; @@ -1960,7 +1960,7 @@ QHash MainWindow::getSelectedCore() QVector > cores; int i = 0; - if (!contentItem || contentHash["db_name"].isEmpty()) + if (contentHash.isEmpty() || contentHash["db_name"].isEmpty()) break; cores = getPlaylistDefaultCores(); @@ -2241,7 +2241,7 @@ void MainWindow::setCoreActions() if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)) { - if (currentContentItem) + if (!hash.isEmpty()) { QString coreName = hash["core_name"]; @@ -2293,7 +2293,6 @@ void MainWindow::setCoreActions() if (defaultCores.count() > 0) { QString currentPlaylistItemDataString; - QHash hash; bool allPlaylists = false; int row = 0; @@ -2303,9 +2302,6 @@ void MainWindow::setCoreActions() allPlaylists = (currentPlaylistItemDataString == ALL_PLAYLISTS_TOKEN); } - if (currentContentItem) - hash = currentContentItem->data(Qt::UserRole).value >(); - for (row = 0; row < m_listWidget->count(); row++) { if (allPlaylists) @@ -2461,23 +2457,14 @@ void MainWindow::onSearchLineEditEdited(const QString &text) { int i = 0; QList items; + QVector > gridItems; QVector textUnicode = text.toUcs4(); QVector textHiraToKata; QVector textKataToHira; + ViewType viewType = getCurrentViewType(); bool foundHira = false; bool foundKata = false; - if (text.isEmpty()) - { - for (i = 0; i < m_tableWidget->rowCount(); i++) - { - m_tableWidget->setRowHidden(i, false); - } - return; - } - - items.append(m_tableWidget->findItems(text, Qt::MatchContains)); - for (i = 0; i < textUnicode.size(); i++) { unsigned code = textUnicode.at(i); @@ -2499,33 +2486,109 @@ void MainWindow::onSearchLineEditEdited(const QString &text) } } - if (foundHira) + switch(viewType) { - items.append(m_tableWidget->findItems(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::MatchContains)); - } - - if (foundKata) - { - items.append(m_tableWidget->findItems(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::MatchContains)); - } - - if (items.isEmpty()) - { - for (i = 0; i < m_tableWidget->rowCount(); i++) + case VIEW_TYPE_LIST: { - m_tableWidget->setRowHidden(i, true); - } + if (text.isEmpty()) + { + for (i = 0; i < m_tableWidget->rowCount(); i++) + { + m_tableWidget->setRowHidden(i, false); + } + return; + } - return; - } - else - { - for (i = 0; i < m_tableWidget->rowCount(); i++) - { - if (items.contains(m_tableWidget->item(i, 0))) - m_tableWidget->setRowHidden(i, false); + items.append(m_tableWidget->findItems(text, Qt::MatchContains)); + + if (foundHira) + { + items.append(m_tableWidget->findItems(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::MatchContains)); + } + + if (foundKata) + { + items.append(m_tableWidget->findItems(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::MatchContains)); + } + + if (items.isEmpty()) + { + for (i = 0; i < m_tableWidget->rowCount(); i++) + { + m_tableWidget->setRowHidden(i, true); + } + + return; + } else - m_tableWidget->setRowHidden(i, true); + { + for (i = 0; i < m_tableWidget->rowCount(); i++) + { + if (items.contains(m_tableWidget->item(i, 0))) + m_tableWidget->setRowHidden(i, false); + else + m_tableWidget->setRowHidden(i, true); + } + } + + break; + } + case VIEW_TYPE_ICONS: + { + int i; + + if (text.isEmpty()) + { + for (i = 0; i < m_gridItems.size(); i++) + { + m_gridItems.at(i)->widget->show(); + } + return; + } + + for (i = 0; i < m_gridItems.count(); i++) + { + const QPointer &item = m_gridItems.at(i); + + if (item->hash.value("label").contains(text, Qt::CaseInsensitive)) + gridItems.append(item); + + if (foundHira) + { + if (item->hash.value("label").contains(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::CaseInsensitive)) + gridItems.append(item); + } + + if (foundKata) + { + if (item->hash.value("label").contains(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive)) + gridItems.append(item); + } + } + + if (gridItems.isEmpty()) + { + for (i = 0; i < m_gridItems.size(); i++) + { + m_gridItems.at(i)->widget->hide(); + } + + return; + } + else + { + for (i = 0; i < m_gridItems.size(); i++) + { + const QPointer &item = m_gridItems.at(i); + + if (gridItems.contains(item)) + item->widget->show(); + else + item->widget->hide(); + } + } + + break; } } } @@ -3228,6 +3291,8 @@ void MainWindow::initContentGridLayout() removeGridItems(); + m_currentGridHash.clear(); + path = item->data(Qt::UserRole).toString(); if (path == ALL_PLAYLISTS_TOKEN) @@ -3270,6 +3335,8 @@ void MainWindow::initContentTableWidget() if (!item) return; + m_currentGridHash.clear(); + horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME); m_tableWidget->clear(); From f0b0be898aa611d83693fdb99775dc639bdf1cd0 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 00:29:48 -0400 Subject: [PATCH 71/78] Qt: draw border around selected grid item --- ui/drivers/qt/ui_qt_themes.h | 6 ++++++ ui/drivers/qt/ui_qt_window.cpp | 37 +++++++++++++++++++++++++++++++--- ui/drivers/ui_qt.cpp | 4 ++-- ui/drivers/ui_qt.h | 7 ++++++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/ui/drivers/qt/ui_qt_themes.h b/ui/drivers/qt/ui_qt_themes.h index 89248ab818..feaff24d75 100644 --- a/ui/drivers/qt/ui_qt_themes.h +++ b/ui/drivers/qt/ui_qt_themes.h @@ -9,6 +9,9 @@ static const QString qt_theme_default_stylesheet = QStringLiteral("" " background-color: transparent;\n" " border: 1px solid #ddd;\n" "}\n" + "ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n" + " background-color:#555555;\n" + "}\n" ); static const QString qt_theme_dark_stylesheet = QStringLiteral("" @@ -386,4 +389,7 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral("" "QSizeGrip {\n" " background-color:solid;\n" "}\n" + "ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n" + " background-color:#555555;\n" + "}\n" ); diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index ccc06c911c..1cd713555d 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -541,6 +541,7 @@ MainWindow::MainWindow(QWidget *parent) : ,m_gridProgressWidget(NULL) ,m_currentGridHash() ,m_lastViewType(m_viewType) + ,m_currentGridWidget(NULL) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -791,8 +792,18 @@ void MainWindow::onGridItemClicked() if (!w) return; - hash = w->property("hash").value >(); + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + m_currentGridWidget->setFrameStyle(QFrame::Plain); + } + hash = w->property("hash").value >(); + w->setObjectName("thumbnailWidgetSelected"); + w->setFrameStyle(QFrame::Box | QFrame::Plain); + w->setLineWidth(2); + + m_currentGridWidget = w; m_currentGridHash = hash; currentItemChanged(hash); @@ -3239,9 +3250,10 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & item->widget->setSizeHint(thumbnailWidgetSizeHint); item->widget->setFixedSize(item->widget->sizeHint()); item->widget->setLayout(new QVBoxLayout()); - item->widget->setStyleSheet("background-color: #555555"); - + item->widget->setObjectName("thumbnailWidget"); item->widget->setProperty("hash", QVariant::fromValue >(hash)); + item->widget->setFrameStyle(QFrame::Plain); + item->widget->setLineWidth(0); connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked())); connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked())); @@ -3255,6 +3267,7 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & item->widget->layout()->addWidget(label); newLabel = new QLabel(hash.value("label"), item->widget); + newLabel->setObjectName("thumbnailQLabel"); newLabel->setAlignment(Qt::AlignCenter); item->widget->layout()->addWidget(newLabel); @@ -3293,6 +3306,15 @@ void MainWindow::initContentGridLayout() m_currentGridHash.clear(); + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + m_currentGridWidget->setFrameStyle(QFrame::Plain); + m_currentGridWidget->setLineWidth(0); + } + + m_currentGridWidget = NULL; + path = item->data(Qt::UserRole).toString(); if (path == ALL_PLAYLISTS_TOKEN) @@ -3337,6 +3359,15 @@ void MainWindow::initContentTableWidget() m_currentGridHash.clear(); + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + m_currentGridWidget->setFrameStyle(QFrame::Plain); + m_currentGridWidget->setLineWidth(0); + } + + m_currentGridWidget = NULL; + horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME); m_tableWidget->clear(); diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index ba0644b285..087a506329 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -56,7 +56,7 @@ typedef struct ui_companion_qt } ui_companion_qt_t; ThumbnailWidget::ThumbnailWidget(QWidget *parent) : - QWidget(parent) + QFrame(parent) ,m_sizeHint(QSize(256, 256)) { } @@ -85,7 +85,7 @@ void ThumbnailWidget::paintEvent(QPaintEvent *event) QStyle::PE_Widget, &o, &p, this); p.end(); - QWidget::paintEvent(event); + QFrame::paintEvent(event); } void ThumbnailWidget::resizeEvent(QResizeEvent *event) diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 8380d38e98..623f7191f9 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -81,11 +82,13 @@ public: QFutureWatcher imageWatcher; }; -class ThumbnailWidget : public QWidget +class ThumbnailWidget : public QFrame { Q_OBJECT public: ThumbnailWidget(QWidget *parent = 0); + ThumbnailWidget(const ThumbnailWidget& other) { assert(false && "DONT EVER USE THIS"); } + QSize sizeHint() const; void setSizeHint(QSize size); signals: @@ -419,12 +422,14 @@ private: QWidget *m_gridProgressWidget; QHash m_currentGridHash; ViewType m_lastViewType; + QPointer m_currentGridWidget; protected: void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); }; +Q_DECLARE_METATYPE(ThumbnailWidget) Q_DECLARE_METATYPE(QPointer) RETRO_BEGIN_DECLS From 5ff77d1833467890567b4c460be02d34a7650e04 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 01:43:57 -0400 Subject: [PATCH 72/78] Qt: better border drawing across styles, add option for max entries in "all playlists" --- intl/msg_hash_ja.h | 10 ++++-- intl/msg_hash_us.h | 10 ++++-- msg_hash.h | 2 ++ ui/drivers/qt/ui_qt_themes.h | 12 +++++-- ui/drivers/qt/ui_qt_window.cpp | 60 ++++++++++++++++++++++++++-------- ui/drivers/ui_qt.cpp | 3 ++ ui/drivers/ui_qt.h | 8 +++-- 7 files changed, 81 insertions(+), 24 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 2756c4d4bf..ab4afce525 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3479,7 +3479,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB, "最後のコンテンツブラウザーのタブを記憶:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME, - "テーマ") + "テーマ:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_SYSTEM_DEFAULT, "<システムデフォルト>") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK, @@ -3543,7 +3543,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDDEN_PLAYLISTS, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDE, "隠す") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR, - "ハイライトカラー") + "ハイライトカラー:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CHOOSE, "選択(&C)...") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR, @@ -3561,7 +3561,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST, "ファイルは存在しません。") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, - "ロードしたコアを最初に優先する") + "ロードしたコアを最初に優先する:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM, "ズーム") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW, @@ -3632,3 +3632,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv対応") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, "進行状況:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, + "「すべてのプレイリスト」の最大個数:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, + "隠しファイルとフォルダを表示:") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index b96c7ea606..1d8aa19983 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3619,7 +3619,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB, "Remember last content browser tab:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME, - "Theme") + "Theme:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_SYSTEM_DEFAULT, "") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK, @@ -3691,7 +3691,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDDEN_PLAYLISTS, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDE, "Hide") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR, - "Highlight Color") + "Highlight color:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CHOOSE, "&Choose...") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR, @@ -3709,7 +3709,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST, "File does not exist.") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, - "Suggest loaded core first") + "Suggest loaded core first:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM, "Zoom") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW, @@ -3790,3 +3790,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, "Progress:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, + "\"All Playlists\" max entries:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, + "Show hidden files and folders:") diff --git a/msg_hash.h b/msg_hash.h index 63e952cc07..60ecfdeef2 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1835,6 +1835,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_TITLE, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, + MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, + MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT, diff --git a/ui/drivers/qt/ui_qt_themes.h b/ui/drivers/qt/ui_qt_themes.h index feaff24d75..0c530e10c2 100644 --- a/ui/drivers/qt/ui_qt_themes.h +++ b/ui/drivers/qt/ui_qt_themes.h @@ -9,9 +9,13 @@ static const QString qt_theme_default_stylesheet = QStringLiteral("" " background-color: transparent;\n" " border: 1px solid #ddd;\n" "}\n" - "ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n" + "ThumbnailWidget#thumbnailWidget, ThumbnailLabel#thumbnailGridLabel, QLabel#thumbnailQLabel {\n" " background-color:#555555;\n" "}\n" + "ThumbnailWidget#thumbnailWidgetSelected {\n" + " background-color:#555555;\n" + " border:3px solid %1;\n" + "}\n" ); static const QString qt_theme_dark_stylesheet = QStringLiteral("" @@ -389,7 +393,11 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral("" "QSizeGrip {\n" " background-color:solid;\n" "}\n" - "ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n" + "ThumbnailWidget#thumbnailWidget, ThumbnailLabel#thumbnailGridLabel, QLabel#thumbnailQLabel {\n" " background-color:#555555;\n" "}\n" + "ThumbnailWidget#thumbnailWidgetSelected {\n" + " background-color:#555555;\n" + " border:3px solid %1;\n" + "}\n" ); diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 1cd713555d..d8c55aaf39 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -280,6 +280,7 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : ,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this)) ,m_customThemePath() ,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this)) + ,m_allPlaylistsMaxCountSpinBox(new QSpinBox(this)) { QFormLayout *form = new QFormLayout(); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -290,6 +291,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK), MainWindow::THEME_DARK); m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_CUSTOM), MainWindow::THEME_CUSTOM); + m_allPlaylistsMaxCountSpinBox->setRange(0, 99999); + form->setFormAlignment(Qt::AlignCenter); form->setLabelAlignment(Qt::AlignCenter); @@ -304,8 +307,9 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY), m_saveGeometryCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS), m_saveDockPositionsCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB), m_saveLastTabCheckBox); - form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox); + form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox); + form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT), m_allPlaylistsMaxCountSpinBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox); form->addRow(m_highlightColorLabel, m_highlightColorPushButton); @@ -381,6 +385,7 @@ void ViewOptionsDialog::loadViewOptions() m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool()); m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool()); m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool()); + m_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 0).toInt()); themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString())); @@ -420,9 +425,12 @@ void ViewOptionsDialog::saveViewOptions() m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked()); m_settings->setValue("highlight_color", m_highlightColor); m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked()); + m_settings->setValue("all_playlists_max_count", m_allPlaylistsMaxCountSpinBox->value()); if (!m_mainwindow->customThemeString().isEmpty()) m_settings->setValue("custom_theme", m_customThemePath); + + m_mainwindow->setAllPlaylistsMaxCount(m_allPlaylistsMaxCountSpinBox->value()); } void ViewOptionsDialog::onAccepted() @@ -455,7 +463,7 @@ CoreInfoWidget::CoreInfoWidget(CoreInfoLabel *label, QWidget *parent) : ,m_label(label) ,m_scrollArea(new QScrollArea(this)) { - m_scrollArea->setFrameShape(QFrame::NoFrame); + //m_scrollArea->setFrameShape(QFrame::NoFrame); m_scrollArea->setWidgetResizable(true); m_scrollArea->setWidget(m_label); } @@ -542,6 +550,7 @@ MainWindow::MainWindow(QWidget *parent) : ,m_currentGridHash() ,m_lastViewType(m_viewType) ,m_currentGridWidget(NULL) + ,m_allPlaylistsMaxCount(0) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -795,12 +804,16 @@ void MainWindow::onGridItemClicked() if (m_currentGridWidget) { m_currentGridWidget->setObjectName("thumbnailWidget"); - m_currentGridWidget->setFrameStyle(QFrame::Plain); + //m_currentGridWidget->setFrameStyle(QFrame::Plain); + m_currentGridWidget->style()->unpolish(m_currentGridWidget); + m_currentGridWidget->style()->polish(m_currentGridWidget); } hash = w->property("hash").value >(); w->setObjectName("thumbnailWidgetSelected"); - w->setFrameStyle(QFrame::Box | QFrame::Plain); + w->style()->unpolish(w); + w->style()->polish(w); + //w->setFrameStyle(QFrame::Box | QFrame::Plain); w->setLineWidth(2); m_currentGridWidget = w; @@ -1517,7 +1530,7 @@ void MainWindow::setTheme(Theme theme) { case THEME_SYSTEM_DEFAULT: { - qApp->setStyleSheet(qt_theme_default_stylesheet); + qApp->setStyleSheet(qt_theme_default_stylesheet.arg(m_settings->value("highlight_color", "palette(highlight)").toString())); break; } @@ -3162,7 +3175,7 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) return item; } -void MainWindow::addPlaylistItemsToGrid(const QStringList &paths) +void MainWindow::addPlaylistItemsToGrid(const QStringList &paths, bool add) { QVector > items; int i; @@ -3177,10 +3190,13 @@ void MainWindow::addPlaylistItemsToGrid(const QStringList &paths) /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ for (j = 0; j < vec.size(); j++) { + if (add && items.size() >= m_allPlaylistsMaxCount) + goto finish; + items.append(vec.at(j)); } } - +finish: std::sort(items.begin(), items.end(), comp_hash_label_key); addPlaylistHashToGrid(items); @@ -3252,13 +3268,14 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & item->widget->setLayout(new QVBoxLayout()); item->widget->setObjectName("thumbnailWidget"); item->widget->setProperty("hash", QVariant::fromValue >(hash)); - item->widget->setFrameStyle(QFrame::Plain); + //item->widget->setFrameStyle(QFrame::Plain); item->widget->setLineWidth(0); connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked())); connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked())); label = new ThumbnailLabel(item->widget); + label->setObjectName("thumbnailGridLabel"); item->label = label; @@ -3309,8 +3326,10 @@ void MainWindow::initContentGridLayout() if (m_currentGridWidget) { m_currentGridWidget->setObjectName("thumbnailWidget"); - m_currentGridWidget->setFrameStyle(QFrame::Plain); + //m_currentGridWidget->setFrameStyle(QFrame::Plain); m_currentGridWidget->setLineWidth(0); + m_currentGridWidget->style()->unpolish(m_currentGridWidget); + m_currentGridWidget->style()->polish(m_currentGridWidget); } m_currentGridWidget = NULL; @@ -3330,7 +3349,7 @@ void MainWindow::initContentGridLayout() playlists.append(playlistDir.absoluteFilePath(playlist)); } - addPlaylistItemsToGrid(playlists); + addPlaylistItemsToGrid(playlists, true); } else addPlaylistItemsToGrid(QStringList() << path); @@ -3362,8 +3381,10 @@ void MainWindow::initContentTableWidget() if (m_currentGridWidget) { m_currentGridWidget->setObjectName("thumbnailWidget"); - m_currentGridWidget->setFrameStyle(QFrame::Plain); + //m_currentGridWidget->setFrameStyle(QFrame::Plain); m_currentGridWidget->setLineWidth(0); + m_currentGridWidget->style()->unpolish(m_currentGridWidget); + m_currentGridWidget->style()->polish(m_currentGridWidget); } m_currentGridWidget = NULL; @@ -3397,7 +3418,7 @@ void MainWindow::initContentTableWidget() playlists.append(playlistDir.absoluteFilePath(playlist)); } - addPlaylistItemsToTable(playlists); + addPlaylistItemsToTable(playlists, true); } else addPlaylistItemsToTable(QStringList() << path); @@ -3491,7 +3512,7 @@ QVector > MainWindow::getPlaylistItems(QString pathStrin return items; } -void MainWindow::addPlaylistItemsToTable(const QStringList &paths) +void MainWindow::addPlaylistItemsToTable(const QStringList &paths, bool add) { QVector > items; int i; @@ -3506,10 +3527,13 @@ void MainWindow::addPlaylistItemsToTable(const QStringList &paths) /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ for (j = 0; j < vec.size(); j++) { + if (add && items.size() >= m_allPlaylistsMaxCount) + goto finish; + items.append(vec.at(j)); } } - +finish: addPlaylistHashToTable(items); } @@ -3584,6 +3608,14 @@ void MainWindow::closeEvent(QCloseEvent *event) QMainWindow::closeEvent(event); } +void MainWindow::setAllPlaylistsMaxCount(int count) +{ + if (count < 1) + count = 0; + + m_allPlaylistsMaxCount = count; +} + static void* ui_window_qt_init(void) { ui_window.qtWindow = new MainWindow(); diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 087a506329..909058cc63 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -476,6 +476,9 @@ static void* ui_companion_qt_init(void) /* this should come last */ mainwindow->resizeThumbnails(true, true, true); + if (qsettings->contains("all_playlists_max_count")) + mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 0).toInt()); + if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 623f7191f9..9d7aa8ce4a 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -58,6 +58,7 @@ class QPixmap; class QPaintEvent; class QSettings; class QCheckBox; +class QSpinBox; class QFormLayout; class QStyle; class QScrollArea; @@ -190,6 +191,7 @@ private: QLabel *m_highlightColorLabel; QString m_customThemePath; QCheckBox *m_suggestLoadedCoreFirstCheckBox; + QSpinBox *m_allPlaylistsMaxCountSpinBox; }; class CoreInfoLabel : public QLabel @@ -291,6 +293,7 @@ public: void setCurrentViewType(ViewType viewType); QString getCurrentViewTypeString(); ViewType getCurrentViewType(); + void setAllPlaylistsMaxCount(int count); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -339,9 +342,9 @@ private slots: void currentItemChanged(const QHash &hash); void onSearchEnterPressed(); void onSearchLineEditEdited(const QString &text); - void addPlaylistItemsToTable(const QStringList &paths); + void addPlaylistItemsToTable(const QStringList &paths, bool all = false); void addPlaylistHashToTable(const QVector > &items); - void addPlaylistItemsToGrid(const QStringList &paths); + void addPlaylistItemsToGrid(const QStringList &paths, bool all = false); void addPlaylistHashToGrid(const QVector > &items); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); @@ -423,6 +426,7 @@ private: QHash m_currentGridHash; ViewType m_lastViewType; QPointer m_currentGridWidget; + int m_allPlaylistsMaxCount; protected: void closeEvent(QCloseEvent *event); From d6b273f60eb75fb0e28f7869656f3e2970595160 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 25 Jul 2018 12:24:07 +0200 Subject: [PATCH 73/78] Add retro_assert.h --- ui/drivers/ui_qt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 9d7aa8ce4a..9e4f568732 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -36,6 +36,7 @@ #include extern "C" { +#include #include #include "../ui_companion_driver.h" } From 065318eb395841b72fbd20276bdf6b12e3327bbb Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 08:44:17 -0400 Subject: [PATCH 74/78] Qt: set default limit for "all playlists" to 5000, use retro_assert instead of assert --- ui/drivers/qt/ui_qt_window.cpp | 2 +- ui/drivers/ui_qt.cpp | 2 +- ui/drivers/ui_qt.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index d8c55aaf39..7c3941076e 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -385,7 +385,7 @@ void ViewOptionsDialog::loadViewOptions() m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool()); m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool()); m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool()); - m_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 0).toInt()); + m_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 5000).toInt()); themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString())); diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 909058cc63..fcdfd23685 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -477,7 +477,7 @@ static void* ui_companion_qt_init(void) mainwindow->resizeThumbnails(true, true, true); if (qsettings->contains("all_playlists_max_count")) - mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 0).toInt()); + mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 5000).toInt()); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 9e4f568732..552dd21473 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -89,7 +89,7 @@ class ThumbnailWidget : public QFrame Q_OBJECT public: ThumbnailWidget(QWidget *parent = 0); - ThumbnailWidget(const ThumbnailWidget& other) { assert(false && "DONT EVER USE THIS"); } + ThumbnailWidget(const ThumbnailWidget& other) { retro_assert(false && "DONT EVER USE THIS"); } QSize sizeHint() const; void setSizeHint(QSize size); From 665628e6c0917d6a48de346e78a94f8269e1a029 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 15:24:26 -0400 Subject: [PATCH 75/78] Qt: add separate settings for max list/grid entries --- intl/msg_hash_ja.h | 6 ++++-- intl/msg_hash_us.h | 6 ++++-- msg_hash.h | 3 ++- ui/drivers/qt/ui_qt_window.cpp | 37 ++++++++++++++++++++++++---------- ui/drivers/ui_qt.cpp | 7 +++++-- ui/drivers/ui_qt.h | 9 ++++++--- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index ab4afce525..4309fcb8b3 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3632,7 +3632,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv対応") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, "進行状況:") -MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, - "「すべてのプレイリスト」の最大個数:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT, + "「すべてのプレイリスト」一覧の最大個数:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT, + "「すべてのプレイリスト」アイコンの最大個数:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, "隠しファイルとフォルダを表示:") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 1d8aa19983..f9a0321199 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3790,7 +3790,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, "Progress:") -MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, - "\"All Playlists\" max entries:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT, + "\"All Playlists\" max list entries:") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT, + "\"All Playlists\" max grid entries:") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, "Show hidden files and folders:") diff --git a/msg_hash.h b/msg_hash.h index 60ecfdeef2..985bff2205 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1836,7 +1836,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, - MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, + MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT, + MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT, MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT, diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 7c3941076e..3832d656be 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -280,7 +280,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : ,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this)) ,m_customThemePath() ,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this)) - ,m_allPlaylistsMaxCountSpinBox(new QSpinBox(this)) + ,m_allPlaylistsListMaxCountSpinBox(new QSpinBox(this)) + ,m_allPlaylistsGridMaxCountSpinBox(new QSpinBox(this)) { QFormLayout *form = new QFormLayout(); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -291,7 +292,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK), MainWindow::THEME_DARK); m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_CUSTOM), MainWindow::THEME_CUSTOM); - m_allPlaylistsMaxCountSpinBox->setRange(0, 99999); + m_allPlaylistsListMaxCountSpinBox->setRange(0, 99999); + m_allPlaylistsGridMaxCountSpinBox->setRange(0, 99999); form->setFormAlignment(Qt::AlignCenter); form->setLabelAlignment(Qt::AlignCenter); @@ -309,7 +311,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB), m_saveLastTabCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox); - form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT), m_allPlaylistsMaxCountSpinBox); + form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT), m_allPlaylistsListMaxCountSpinBox); + form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT), m_allPlaylistsGridMaxCountSpinBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox); form->addRow(m_highlightColorLabel, m_highlightColorPushButton); @@ -385,7 +388,8 @@ void ViewOptionsDialog::loadViewOptions() m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool()); m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool()); m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool()); - m_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 5000).toInt()); + m_allPlaylistsListMaxCountSpinBox->setValue(m_settings->value("all_playlists_list_max_count", 0).toInt()); + m_allPlaylistsGridMaxCountSpinBox->setValue(m_settings->value("all_playlists_grid_max_count", 5000).toInt()); themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString())); @@ -425,12 +429,14 @@ void ViewOptionsDialog::saveViewOptions() m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked()); m_settings->setValue("highlight_color", m_highlightColor); m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked()); - m_settings->setValue("all_playlists_max_count", m_allPlaylistsMaxCountSpinBox->value()); + m_settings->setValue("all_playlists_list_max_count", m_allPlaylistsListMaxCountSpinBox->value()); + m_settings->setValue("all_playlists_grid_max_count", m_allPlaylistsGridMaxCountSpinBox->value()); if (!m_mainwindow->customThemeString().isEmpty()) m_settings->setValue("custom_theme", m_customThemePath); - m_mainwindow->setAllPlaylistsMaxCount(m_allPlaylistsMaxCountSpinBox->value()); + m_mainwindow->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value()); + m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value()); } void ViewOptionsDialog::onAccepted() @@ -550,7 +556,8 @@ MainWindow::MainWindow(QWidget *parent) : ,m_currentGridHash() ,m_lastViewType(m_viewType) ,m_currentGridWidget(NULL) - ,m_allPlaylistsMaxCount(0) + ,m_allPlaylistsListMaxCount(0) + ,m_allPlaylistsGridMaxCount(0) { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); @@ -3190,7 +3197,7 @@ void MainWindow::addPlaylistItemsToGrid(const QStringList &paths, bool add) /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ for (j = 0; j < vec.size(); j++) { - if (add && items.size() >= m_allPlaylistsMaxCount) + if (add && m_allPlaylistsGridMaxCount > 0 && items.size() >= m_allPlaylistsGridMaxCount) goto finish; items.append(vec.at(j)); @@ -3527,7 +3534,7 @@ void MainWindow::addPlaylistItemsToTable(const QStringList &paths, bool add) /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ for (j = 0; j < vec.size(); j++) { - if (add && items.size() >= m_allPlaylistsMaxCount) + if (add && m_allPlaylistsListMaxCount > 0 && items.size() >= m_allPlaylistsListMaxCount) goto finish; items.append(vec.at(j)); @@ -3608,12 +3615,20 @@ void MainWindow::closeEvent(QCloseEvent *event) QMainWindow::closeEvent(event); } -void MainWindow::setAllPlaylistsMaxCount(int count) +void MainWindow::setAllPlaylistsListMaxCount(int count) { if (count < 1) count = 0; - m_allPlaylistsMaxCount = count; + m_allPlaylistsListMaxCount = count; +} + +void MainWindow::setAllPlaylistsGridMaxCount(int count) +{ + if (count < 1) + count = 0; + + m_allPlaylistsGridMaxCount = count; } static void* ui_window_qt_init(void) diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index fcdfd23685..a7e9c7f846 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -476,8 +476,11 @@ static void* ui_companion_qt_init(void) /* this should come last */ mainwindow->resizeThumbnails(true, true, true); - if (qsettings->contains("all_playlists_max_count")) - mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 5000).toInt()); + if (qsettings->contains("all_playlists_list_max_count")) + mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt()); + + if (qsettings->contains("all_playlists_grid_max_count")) + mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt()); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index 552dd21473..bb5d4c66cc 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -192,7 +192,8 @@ private: QLabel *m_highlightColorLabel; QString m_customThemePath; QCheckBox *m_suggestLoadedCoreFirstCheckBox; - QSpinBox *m_allPlaylistsMaxCountSpinBox; + QSpinBox *m_allPlaylistsListMaxCountSpinBox; + QSpinBox *m_allPlaylistsGridMaxCountSpinBox; }; class CoreInfoLabel : public QLabel @@ -294,7 +295,8 @@ public: void setCurrentViewType(ViewType viewType); QString getCurrentViewTypeString(); ViewType getCurrentViewType(); - void setAllPlaylistsMaxCount(int count); + void setAllPlaylistsListMaxCount(int count); + void setAllPlaylistsGridMaxCount(int count); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -427,7 +429,8 @@ private: QHash m_currentGridHash; ViewType m_lastViewType; QPointer m_currentGridWidget; - int m_allPlaylistsMaxCount; + int m_allPlaylistsListMaxCount; + int m_allPlaylistsGridMaxCount; protected: void closeEvent(QCloseEvent *event); From 4b712fa750e14404699d3c9834f906fa6f1843a7 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 19:41:54 -0400 Subject: [PATCH 76/78] Qt: elide grid label text --- ui/drivers/qt/ui_qt_window.cpp | 25 +++++++++++++++++++++---- ui/drivers/ui_qt.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 3832d656be..e38e1c0d56 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -138,9 +138,19 @@ GridItem::GridItem() : ,image() ,pixmap() ,imageWatcher() + ,labelText() { } +/* https://gist.github.com/andrey-str/0f9c7709cbf0c9c49ef9 */ +static void setElidedText(QLabel *label, QWidget *clipWidget, int padding, const QString &text) +{ + QFontMetrics metrix(label->font()); + int width = clipWidget->width() - padding; + QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); + label->setText(clippedText); +} + TreeView::TreeView(QWidget *parent) : QTreeView(parent) { @@ -857,6 +867,7 @@ void MainWindow::onListViewClicked() inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) { int newSize = 0; + QLabel *label = NULL; if (zoomValue < 50) newSize = expScale(lerp(0, 49, 25, 49, zoomValue) / 50.0, 102, 256); @@ -864,6 +875,11 @@ inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) newSize = expScale(zoomValue / 100.0, 256, 1024); item->widget->setFixedSize(QSize(newSize, newSize)); + + label = item->widget->findChild("thumbnailQLabel"); + + if (label) + setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing(), item->labelText); } void MainWindow::onZoomValueChanged(int value) @@ -3285,15 +3301,16 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & label->setObjectName("thumbnailGridLabel"); item->label = label; + item->labelText = hash.value("label"); + + newLabel = new QLabel(item->labelText, item->widget); + newLabel->setObjectName("thumbnailQLabel"); + newLabel->setAlignment(Qt::AlignCenter); calcGridItemSize(item, zoomValue); item->widget->layout()->addWidget(label); - newLabel = new QLabel(hash.value("label"), item->widget); - newLabel->setObjectName("thumbnailQLabel"); - newLabel->setAlignment(Qt::AlignCenter); - item->widget->layout()->addWidget(newLabel); qobject_cast(item->widget->layout())->setStretchFactor(label, 1); diff --git a/ui/drivers/ui_qt.h b/ui/drivers/ui_qt.h index bb5d4c66cc..3912428a2c 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -82,6 +82,7 @@ public: QImage image; QPixmap pixmap; QFutureWatcher imageWatcher; + QString labelText; }; class ThumbnailWidget : public QFrame From 0e86c664cefa2c46fe667494f2110dfa14bced56 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 25 Jul 2018 19:52:08 -0400 Subject: [PATCH 77/78] Qt: add tooltips to show entire grid label text --- ui/drivers/qt/ui_qt_window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index e38e1c0d56..17b122cc79 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -3306,6 +3306,7 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & newLabel = new QLabel(item->labelText, item->widget); newLabel->setObjectName("thumbnailQLabel"); newLabel->setAlignment(Qt::AlignCenter); + newLabel->setToolTip(item->labelText); calcGridItemSize(item, zoomValue); From e9c4192e9b6dbbb8ba20e716642d38b64873765d Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 26 Jul 2018 11:14:01 -0400 Subject: [PATCH 78/78] Qt: fix grid label text getting cut off on Windows, do not change size of grid items when selected --- ui/drivers/qt/ui_qt_window.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 17b122cc79..0b8d94b9ea 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -830,8 +830,6 @@ void MainWindow::onGridItemClicked() w->setObjectName("thumbnailWidgetSelected"); w->style()->unpolish(w); w->style()->polish(w); - //w->setFrameStyle(QFrame::Box | QFrame::Plain); - w->setLineWidth(2); m_currentGridWidget = w; m_currentGridHash = hash; @@ -879,7 +877,7 @@ inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) label = item->widget->findChild("thumbnailQLabel"); if (label) - setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing(), item->labelText); + setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing() + 2, item->labelText); } void MainWindow::onZoomValueChanged(int value) @@ -3291,8 +3289,6 @@ void MainWindow::addPlaylistHashToGrid(const QVector > & item->widget->setLayout(new QVBoxLayout()); item->widget->setObjectName("thumbnailWidget"); item->widget->setProperty("hash", QVariant::fromValue >(hash)); - //item->widget->setFrameStyle(QFrame::Plain); - item->widget->setLineWidth(0); connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked())); connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked())); @@ -3351,8 +3347,6 @@ void MainWindow::initContentGridLayout() if (m_currentGridWidget) { m_currentGridWidget->setObjectName("thumbnailWidget"); - //m_currentGridWidget->setFrameStyle(QFrame::Plain); - m_currentGridWidget->setLineWidth(0); m_currentGridWidget->style()->unpolish(m_currentGridWidget); m_currentGridWidget->style()->polish(m_currentGridWidget); } @@ -3406,8 +3400,6 @@ void MainWindow::initContentTableWidget() if (m_currentGridWidget) { m_currentGridWidget->setObjectName("thumbnailWidget"); - //m_currentGridWidget->setFrameStyle(QFrame::Plain); - m_currentGridWidget->setLineWidth(0); m_currentGridWidget->style()->unpolish(m_currentGridWidget); m_currentGridWidget->style()->polish(m_currentGridWidget); }