diff --git a/CHANGES.md b/CHANGES.md index 5f37180118..8566968890 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. @@ -17,18 +18,25 @@ - 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. +- 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. - 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. - 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. diff --git a/Makefile.common b/Makefile.common index 2aca4eb425..b2c83a60b8 100644 --- a/Makefile.common +++ b/Makefile.common @@ -334,14 +334,16 @@ 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 + ui/drivers/qt/ui_qt_load_core_window.h \ + ui/drivers/qt/flowlayout.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 @@ -741,11 +743,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) @@ -777,6 +784,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/command.c b/command.c index 928833b882..62cc725441 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) @@ -1398,7 +1401,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; @@ -1505,7 +1507,7 @@ static bool command_event_save_core_config(void) free(config_dir); free(config_name); free(config_path); - return ret; + return true; } /** @@ -1838,14 +1840,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()) @@ -1886,7 +1895,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(); @@ -1936,7 +1947,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(); @@ -2046,9 +2059,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)); @@ -2633,14 +2650,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; @@ -2649,8 +2665,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(); @@ -2757,10 +2775,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; diff --git a/configuration.c b/configuration.c index 493fb2e7b9..c6142c7bb0 100644 --- a/configuration.c +++ b/configuration.c @@ -284,6 +284,7 @@ enum menu_driver_enum MENU_XUI, MENU_MATERIALUI, MENU_XMB, + MENU_STRIPES, MENU_NUKLEAR, MENU_NULL }; @@ -1026,6 +1027,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 85313af6b4..fa6c3690a8 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/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:/", 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/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_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, }; 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 diff --git a/griffin/griffin.c b/griffin/griffin.c index 77584d9839..1eaeed04c3 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1240,6 +1240,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/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/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)) 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 3108215bd1..ae4904c53a 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 ((key < RETROK_LAST) && rwebinput_key_pressed(rwebinput, key)) + if ((id == RARCH_GAME_FOCUS_TOGGLE) || !rwebinput->blocked) + return true; if (bind->valid) { 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/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) { 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/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)) 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) 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) 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, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index ced77ebd5b..4309fcb8b3 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,15 @@ 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, + "表示") +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, "オーバーライド") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS, @@ -3622,3 +3630,11 @@ 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, + "進行状況:") +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 97dde27334..cc56e89e00 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3739,7 +3739,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, @@ -3811,7 +3811,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, @@ -3829,7 +3829,15 @@ 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, + "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, "Overrides") MSG_HASH(MENU_ENUM_SUBLABEL_QUICK_MENU_OVERRIDE_OPTIONS, @@ -4132,3 +4140,11 @@ MSG_HASH(MSG_CHEAT_COPY_AFTER_SUCCESS, "Cheat copied after this one.") MSG_HASH(MSG_CHEAT_DELETE_SUCCESS, "Cheat deleted.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, + "Progress:") +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/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 15ce4336d1..9c2b76b170 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. @@ -920,7 +998,7 @@ void config_file_dump(config_file_t *conf, FILE *file) includes = includes->next; } - list = (struct config_entry_list*)conf->entries; + list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func); while (list) { diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c new file mode 100755 index 0000000000..0170c57e62 --- /dev/null +++ b/menu/drivers/stripes.c @@ -0,0 +1,4469 @@ +/* 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; + float width; + 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_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_passive_width; + float categories_active_zoom; + float categories_active_alpha; + float categories_active_width; + + 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 +}; + +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); + +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 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_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, + 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; + } + + playlist = playlist_get_cached(); + + 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 ( (!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; + 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); + + if (!node) + continue; + + if (j == stripes->categories_active_idx) + { + 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; + } + 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; + } + + 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); + + entry.target_value = iy; + entry.subject = &node->y; + + menu_animation_push(&entry); + + entry.target_value = ix; + entry.subject = &node->x; + + menu_animation_push(&entry); + + entry.target_value = iw; + entry.subject = &node->width; + + 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->categories_passive_width + * -(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->categories_passive_width * + -(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) +{ + menu_display_ctx_draw_t draw; + struct video_coords coords; + + 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, + }; + + 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_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; + float stack_width = 285; + 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); + + selection = menu_navigation_get_selection(); + + 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); + + /* 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; + + float rgb[3]; + HSLToRGB(0.07*(float)i,0.5,0.5, &rgb[0]) ; + float color[16] = { + 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( + 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, + &color[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++) + { + 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->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; + 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); + } + + stack_width += node->width; + } + + 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, int height) +{ + 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.25; + + stripes->categories_angle = 400 * scale_factor; + + stripes->categories_active_y = height / 2; + 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 * scale_factor; + stripes->categories_after_x = 22 * scale_factor; + + 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 = 1.0; + 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 = 256.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, height); + 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_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); + + 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/drivers/xmb.c b/menu/drivers/xmb.c index a648b39e3a..f0511dc936 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4002,8 +4002,6 @@ static void xmb_init_ribbon(xmb_handle_t * xmb) free(ribbon_verts); } - - static void *xmb_init(void **userdata, bool video_is_threaded) { unsigned width, height; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index e9285912c6..a3033c9c36 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -85,6 +85,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 @@ -743,6 +746,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 b4b28059b1..357f677b19 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -726,6 +726,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, @@ -817,6 +825,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/msg_hash.h b/msg_hash.h index 1497033365..6913b518cc 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1891,6 +1891,9 @@ 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_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, @@ -1927,6 +1930,11 @@ 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, + MENU_ENUM_LABEL_VALUE_QT_PROGRESS, MENU_LABEL(MIDI_INPUT), MENU_LABEL(MIDI_OUTPUT), 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 diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 73e4e0c3bf..901ae4ede8 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -541,7 +541,7 @@ "-DHAVE_MATERIALUI", "-DHAVE_HID", "-DHAVE_XMB", - "-DHAVE_SEGA", + "-DHAVE_STRIPES", "-DHAVE_SHADERPIPELINE", "-DHAVE_MMAP", "-DHAVE_LIBRETRODB", @@ -604,7 +604,7 @@ "-DHAVE_MATERIALUI", "-DHAVE_HID", "-DHAVE_XMB", - "-DHAVE_SEGA", + "-DHAVE_STRIPES", "-DHAVE_SHADERPIPELINE", "-DHAVE_MMAP", "-DHAVE_LIBRETRODB", 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/qb/config.libs.sh b/qb/config.libs.sh index b6d29c9b6e..f4499099ff 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -278,14 +278,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 @@ -510,6 +512,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 @@ -522,6 +525,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 db514977d7..709eb2f4a9 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -10,6 +10,7 @@ HAVE_LIBRETRODB=yes # Libretrodb support HAVE_RGUI=yes # RGUI menu HAVE_MATERIALUI=auto # MaterialUI menu HAVE_XMB=auto # XMB menu +HAVE_STRIPES=no # Stripes menu HAVE_ZARCH=no # Zarch menu HAVE_NUKLEAR=no # Nuklear menu HAVE_RUNAHEAD=yes # Runahead support 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 } diff --git a/ui/drivers/qt/flowlayout.cpp b/ui/drivers/qt/flowlayout.cpp new file mode 100644 index 0000000000..b970e10b10 --- /dev/null +++ b/ui/drivers/qt/flowlayout.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* Original work Copyright (C) 2016 The Qt Company Ltd. + * Modified work Copyright (C) 2018 - Brad Parker + */ + +#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(QPointer)), this, SLOT(onAddWidgetDeferred(QPointer)), Qt::QueuedConnection); +} + +FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) + : m_hSpace(hSpacing), m_vSpace(vSpacing) +{ + setContentsMargins(margin, margin, margin, margin); +} + +FlowLayout::~FlowLayout() +{ + QLayoutItem *item = NULL; + + while ((item = takeAt(0)) != NULL) + 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 NULL; +} + +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; + int i = 0; + + 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 +{ + QRect effectiveRect; + int left = 0, top = 0, right = 0, bottom = 0; + int x = 0; + int y = 0; + int lineHeight = 0; + int i = 0; + + getContentsMargins(&left, &top, &right, &bottom); + effectiveRect = rect.adjusted(+left, +top, -right, -bottom); + x = effectiveRect.x(); + y = effectiveRect.y(); + + if (itemList.isEmpty()) + 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 +{ + const QObject *parentObj = parent(); + + if (!parentObj) + return -1; + else if (parentObj->isWidgetType()) + { + const QWidget *pw = static_cast(parentObj); + return pw->style()->pixelMetric(pm, NULL, pw); + } + else + return static_cast(parentObj)->spacing(); +} + +void FlowLayout::addWidgetDeferred(QPointer widget) +{ + emit signalAddWidgetDeferred(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 new file mode 100644 index 0000000000..c9d11e7653 --- /dev/null +++ b/ui/drivers/qt/flowlayout.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* 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 + +#include +#include +#include + +class ThumbnailWidget; + +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); + ~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 addWidgetDeferred(QPointer widget); + +signals: + void signalAddWidgetDeferred(QPointer widget); + +private slots: + void onAddWidgetDeferred(QPointer widget); + +private: + int doLayout(const QRect &rect, bool testOnly) const; + int smartSpacing(QStyle::PixelMetric pm) const; + + 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_themes.h b/ui/drivers/qt/ui_qt_themes.h index d43867def2..0c530e10c2 100644 --- a/ui/drivers/qt/ui_qt_themes.h +++ b/ui/drivers/qt/ui_qt_themes.h @@ -1,7 +1,22 @@ #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" + "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("" "QWidget {\n" @@ -233,6 +248,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" @@ -374,4 +393,11 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral("" "QSizeGrip {\n" " background-color:solid;\n" "}\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 cf5ee3309f..0b8d94b9ea 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -29,10 +29,12 @@ #include #include #include +#include #include "../ui_qt.h" #include "ui_qt_load_core_window.h" #include "ui_qt_themes.h" +#include "flowlayout.h" extern "C" { #include "../../../version.h" @@ -52,6 +54,7 @@ extern "C" { #include #include #include +#include } #define TIMER_MSEC 1000 /* periodic timer for gathering statistics */ @@ -83,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) { @@ -90,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()) @@ -100,6 +125,32 @@ 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) + ,label(NULL) + ,hash() + ,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) { @@ -168,7 +219,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) { @@ -239,6 +290,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_allPlaylistsListMaxCountSpinBox(new QSpinBox(this)) + ,m_allPlaylistsGridMaxCountSpinBox(new QSpinBox(this)) { QFormLayout *form = new QFormLayout(); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -249,6 +302,9 @@ 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_allPlaylistsListMaxCountSpinBox->setRange(0, 99999); + m_allPlaylistsGridMaxCountSpinBox->setRange(0, 99999); + form->setFormAlignment(Qt::AlignCenter); form->setLabelAlignment(Qt::AlignCenter); @@ -263,8 +319,10 @@ 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_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); @@ -340,6 +398,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_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())); @@ -379,9 +439,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_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->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value()); + m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value()); } void ViewOptionsDialog::onAccepted() @@ -414,7 +479,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); } @@ -487,13 +552,104 @@ MainWindow::MainWindow(QWidget *parent) : ,m_historyPlaylistsItem(NULL) ,m_folderIcon() ,m_customThemeString() + ,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) + ,m_pendingItemUpdates() + ,m_viewType(VIEW_TYPE_LIST) + ,m_gridProgressBar(NULL) + ,m_gridProgressWidget(NULL) + ,m_currentGridHash() + ,m_lastViewType(m_viewType) + ,m_currentGridWidget(NULL) + ,m_allPlaylistsListMaxCount(0) + ,m_allPlaylistsGridMaxCount(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 *zoomWidget = new QWidget(); + QHBoxLayout *zoomLayout = new QHBoxLayout(); + 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; + 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); + + 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); + + 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); + + 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(); + + m_gridWidget->setLayout(new QVBoxLayout()); + + m_gridLayout = new FlowLayout(m_gridLayoutWidget); + + m_gridScrollArea->setAlignment(Qt::AlignCenter); + m_gridScrollArea->setFrameShape(QFrame::NoFrame); + m_gridScrollArea->setWidgetResizable(true); + m_gridScrollArea->setWidget(m_gridLayoutWidget); + + m_gridWidget->layout()->addWidget(m_gridScrollArea); + m_gridWidget->layout()->setAlignment(Qt::AlignCenter); + + 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->addWidget(zoomLabel); + zoomLayout->addWidget(m_zoomSlider); + zoomLayout->addWidget(viewTypePushButton); + + 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); m_logWidget->setObjectName("logWidget"); @@ -610,11 +766,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); @@ -632,16 +790,6 @@ MainWindow::MainWindow(QWidget *parent) : qApp->processEvents(); QTimer::singleShot(0, this, SLOT(onBrowserStartClicked())); - for (i = 0; i < m_listWidget->count(); 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); @@ -658,6 +806,91 @@ MainWindow::~MainWindow() delete m_thumbnailPixmap2; if (m_thumbnailPixmap3) delete m_thumbnailPixmap3; + + removeGridItems(); +} + +void MainWindow::onGridItemClicked() +{ + QHash hash; + ThumbnailWidget *w = static_cast(sender()); + + if (!w) + return; + + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + //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->style()->unpolish(w); + w->style()->polish(w); + + m_currentGridWidget = w; + 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); + 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; + QLabel *label = NULL; + + 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)); + + label = item->widget->findChild("thumbnailQLabel"); + + if (label) + setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing() + 2, item->labelText); +} + +void MainWindow::onZoomValueChanged(int value) +{ + int i = 0; + + for (i = 0; i < m_gridItems.count() && m_gridItems.count() > 0; i++) + { + GridItem *item = m_gridItems.at(i); + calcGridItemSize(item, value); + } + + m_lastZoomSliderValue = value; } void MainWindow::showWelcomeScreen() @@ -746,11 +979,11 @@ 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)); + msgBoxPtr = new QMessageBox(this); msgBox = msgBoxPtr.data(); checkBox = new QCheckBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DONT_SHOW_AGAIN), msgBox); @@ -787,6 +1020,9 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM msgBox->setText(msg); msgBox->exec(); + if (!msgBoxPtr) + return true; + if (checkBox->isChecked()) return false; @@ -800,7 +1036,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); @@ -850,20 +1086,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; } } @@ -888,17 +1121,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()); @@ -991,7 +1235,7 @@ end: void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&) { #ifdef HAVE_LIBRETRODB - QAction *action = NULL; + QPointer action; QList actions; QScopedPointer scanAction; QDir dir; @@ -1041,6 +1285,8 @@ void MainWindow::onGotStatusMessage(QString msg, unsigned priority, unsigned dur QScreen *screen = qApp->primaryScreen(); QStatusBar *status = statusBar(); + Q_UNUSED(priority) + if (msg.isEmpty()) return; @@ -1082,6 +1328,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(); @@ -1132,9 +1379,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; @@ -1172,7 +1420,6 @@ void MainWindow::reloadPlaylists() if (firstItem) { - int i = 0; bool found = false; for (i = 0; i < m_listWidget->count(); i++) @@ -1220,7 +1467,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()); @@ -1304,7 +1551,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; } @@ -1325,9 +1572,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; @@ -1729,9 +1976,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) { @@ -1743,7 +1993,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"]; @@ -1752,10 +2002,10 @@ QHash MainWindow::getSelectedCore() } case CORE_SELECTION_PLAYLIST_DEFAULT: { - QList > cores; + QVector > cores; int i = 0; - if (!contentItem || contentHash["db_name"].isEmpty()) + if (contentHash.isEmpty() || contentHash["db_name"].isEmpty()) break; cores = getPlaylistDefaultCores(); @@ -1782,12 +2032,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; @@ -1797,63 +2054,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); } } } @@ -1884,7 +2128,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++) @@ -1929,6 +2173,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(); @@ -1949,13 +2212,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) { @@ -1997,6 +2260,7 @@ void MainWindow::setCoreActions() { QTableWidgetItem *currentContentItem = m_tableWidget->currentItem(); QListWidgetItem *currentPlaylistItem = m_listWidget->currentItem(); + ViewType viewType = getCurrentViewType(); QHash hash; m_launchWithComboBox->clear(); @@ -2015,12 +2279,14 @@ 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)) { - if (currentContentItem) + if (!hash.isEmpty()) { QString coreName = hash["core_name"]; @@ -2066,13 +2332,12 @@ void MainWindow::setCoreActions() if (!hash["db_name"].isEmpty()) { - QList > defaultCores = getPlaylistDefaultCores(); + QVector > defaultCores = getPlaylistDefaultCores(); int i = 0; if (defaultCores.count() > 0) { QString currentPlaylistItemDataString; - QHash hash; bool allPlaylists = false; int row = 0; @@ -2082,9 +2347,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) @@ -2174,6 +2436,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); @@ -2188,6 +2453,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); @@ -2234,23 +2502,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); @@ -2272,33 +2531,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; } } } @@ -2308,6 +2643,7 @@ void MainWindow::onViewClosedDocksAboutToShow() QMenu *menu = qobject_cast(sender()); QList dockWidgets; bool found = false; + int i = 0; if (!menu) return; @@ -2322,8 +2658,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())); @@ -2333,9 +2671,7 @@ void MainWindow::onViewClosedDocksAboutToShow() } if (!found) - { menu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE)); - } } void MainWindow::onShowHiddenDockWidgetAction() @@ -2376,19 +2712,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, "_"); @@ -2504,15 +2846,59 @@ void MainWindow::resizeThumbnails(bool one, bool two, bool three) } } +void MainWindow::setCurrentViewType(ViewType viewType) +{ + m_lastViewType = m_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(); + switch (viewType) + { + case VIEW_TYPE_ICONS: + { + initContentGridLayout(); + break; + } + case VIEW_TYPE_LIST: + default: + { + initContentTableWidget(); + break; + } + } + setCoreActions(); } @@ -2521,6 +2907,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 +3096,295 @@ void MainWindow::onLoadCoreClicked(const QStringList &extensionFilters) m_loadCoreWindow->initCoreList(extensionFilters); } +void MainWindow::removeGridItems() +{ + if (m_gridItems.count() > 0) + { + QMutableVectorIterator > items(m_gridItems); + + m_pendingItemUpdates.clear(); + + while (items.hasNext()) + { + QPointer item = items.next(); + + if (item) + { + item->imageWatcher.waitForFinished(); + + items.remove(); + + m_gridLayout->removeWidget(item->widget); + + delete item->widget; + delete item; + } + } + } +} + +void MainWindow::onDeferredImageLoaded() +{ + const QFutureWatcher *watcher = static_cast*>(sender()); + GridItem *item = NULL; + + if (!watcher) + return; + + item = watcher->result(); + + if (!item) + return; + + if (m_gridItems.contains(item)) + { + if (!item->image.isNull()) + { + m_pendingItemUpdates.append(item); + QTimer::singleShot(0, this, SLOT(onPendingItemUpdates())); + } + } +} + +void MainWindow::onPendingItemUpdates() +{ + QMutableListIterator list(m_pendingItemUpdates); + + while (list.hasNext()) + { + GridItem *item = list.next(); + + if (!item) + continue; + + if (m_gridItems.contains(item)) + onUpdateGridItemPixmapFromImage(item); + + list.remove(); + } +} + +void MainWindow::onUpdateGridItemPixmapFromImage(GridItem *item) +{ + if (!item) + return; + + if (!m_gridItems.contains(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); + item->imageWatcher.setFuture(QtConcurrent::run(this, &MainWindow::doDeferredImageLoad, item, path)); +} + +GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path) +{ + /* this runs in another thread */ + if (!item) + return NULL; + + /* 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); + + return item; +} + +void MainWindow::addPlaylistItemsToGrid(const QStringList &paths, bool add) +{ + 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++) + { + if (add && m_allPlaylistsGridMaxCount > 0 && items.size() >= m_allPlaylistsGridMaxCount) + goto finish; + + items.append(vec.at(j)); + } + } +finish: + std::sort(items.begin(), items.end(), comp_hash_label_key); + + addPlaylistHashToGrid(items); +} + +void MainWindow::addPlaylistHashToGrid(const QVector > &items) +{ + 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(); + + 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); + QPointer item; + QPointer label; + QString thumbnailFileNameNoExt; + QLabel *newLabel = NULL; + QSize thumbnailWidgetSizeHint(screenSize.width() / 8, screenSize.height() / 8); + QByteArray extension; + QString extensionStr; + QString imagePath; + int lastIndex = -1; + + if (m_listWidget->currentItem() != currentItem) + { + /* user changed the current playlist before we finished loading... abort */ + m_gridProgressWidget->hide(); + break; + } + + item = new GridItem(); + + 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 + { + thumbnailFileNameNoExt = hash["label_noext"]; + thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_"); + imagePath = QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png"; + } + + item->hash = hash; + item->widget = new ThumbnailWidget(); + item->widget->setSizeHint(thumbnailWidgetSizeHint); + item->widget->setFixedSize(item->widget->sizeHint()); + item->widget->setLayout(new QVBoxLayout()); + item->widget->setObjectName("thumbnailWidget"); + 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); + 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); + newLabel->setToolTip(item->labelText); + + calcGridItemSize(item, zoomValue); + + item->widget->layout()->addWidget(label); + + item->widget->layout()->addWidget(newLabel); + qobject_cast(item->widget->layout())->setStretchFactor(label, 1); + + m_gridLayout->addWidgetDeferred(item->widget); + m_gridItems.append(item); + + loadImageDeferred(item, imagePath); + + if (i % 25 == 0) + qApp->processEvents(); + + m_gridProgressBar->setValue(i); + } + + /* 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() +{ + QListWidgetItem *item = m_listWidget->currentItem(); + QString path; + + if (!item) + return; + + m_gridProgressBar->setMinimum(0); + m_gridProgressBar->setMaximum(0); + m_gridProgressBar->setValue(0); + m_gridProgressWidget->show(); + + removeGridItems(); + + m_currentGridHash.clear(); + + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + m_currentGridWidget->style()->unpolish(m_currentGridWidget); + m_currentGridWidget->style()->polish(m_currentGridWidget); + } + + m_currentGridWidget = NULL; + + path = item->data(Qt::UserRole).toString(); + + if (path == ALL_PLAYLISTS_TOKEN) + { + 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); + playlists.append(playlistDir.absoluteFilePath(playlist)); + } + + addPlaylistItemsToGrid(playlists, true); + } + else + addPlaylistItemsToGrid(QStringList() << path); + + QTimer::singleShot(0, this, SLOT(onContentGridInited())); +} + +void MainWindow::onContentGridInited() +{ + m_gridLayoutWidget->resize(m_gridScrollArea->viewport()->size()); + + onZoomValueChanged(m_zoomSlider->value()); + + onSearchEnterPressed(); +} + void MainWindow::initContentTableWidget() { QListWidgetItem *item = m_listWidget->currentItem(); @@ -2710,6 +3395,17 @@ void MainWindow::initContentTableWidget() if (!item) return; + m_currentGridHash.clear(); + + if (m_currentGridWidget) + { + m_currentGridWidget->setObjectName("thumbnailWidget"); + m_currentGridWidget->style()->unpolish(m_currentGridWidget); + m_currentGridWidget->style()->polish(m_currentGridWidget); + } + + m_currentGridWidget = NULL; + horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME); m_tableWidget->clear(); @@ -2730,14 +3426,19 @@ void MainWindow::initContentTableWidget() { settings_t *settings = config_get_ptr(); QDir playlistDir(settings->paths.directory_playlist); + QStringList playlists; + int i = 0; - foreach (QString playlist, m_playlistFiles) + for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++) { - addPlaylistItemsToTable(playlistDir.absoluteFilePath(playlist)); + const QString &playlist = m_playlistFiles.at(i); + playlists.append(playlistDir.absoluteFilePath(playlist)); } + + addPlaylistItemsToTable(playlists, true); } else - addPlaylistItemsToTable(path); + addPlaylistItemsToTable(QStringList() << path); m_tableWidget->setSortingEnabled(true); @@ -2759,14 +3460,14 @@ void MainWindow::initContentTableWidget() onSearchEnterPressed(); } -void MainWindow::addPlaylistItemsToTable(QString pathString) +QVector > MainWindow::getPlaylistItems(QString pathString) { QByteArray pathArray; + QVector > 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 +3475,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 +3483,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 +3520,58 @@ 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(const QStringList &paths, bool add) +{ + 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++) + { + if (add && m_allPlaylistsListMaxCount > 0 && items.size() >= m_allPlaylistsListMaxCount) + goto finish; + + items.append(vec.at(j)); + } + } +finish: + addPlaylistHashToTable(items); +} + +void MainWindow::addPlaylistHashToTable(const QVector > &items) +{ + int i = 0; + int oldRowCount = m_tableWidget->rowCount(); + + m_tableWidget->setRowCount(oldRowCount + items.count()); + + for (i = 0; i < items.count(); i++) + { + 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) @@ -2852,6 +3593,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()) @@ -2861,9 +3620,27 @@ 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); } +void MainWindow::setAllPlaylistsListMaxCount(int count) +{ + if (count < 1) + count = 0; + + m_allPlaylistsListMaxCount = count; +} + +void MainWindow::setAllPlaylistsGridMaxCount(int count) +{ + if (count < 1) + count = 0; + + m_allPlaylistsGridMaxCount = count; +} + static void* ui_window_qt_init(void) { ui_window.qtWindow = new MainWindow(); 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 { diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 6a5272b39b..a7e9c7f846 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -56,21 +56,36 @@ typedef struct ui_companion_qt } ui_companion_qt_t; ThumbnailWidget::ThumbnailWidget(QWidget *parent) : - QWidget(parent) + QFrame(parent) + ,m_sizeHint(QSize(256, 256)) { } +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); + QFrame::paintEvent(event); } void ThumbnailWidget::resizeEvent(QResizeEvent *event) @@ -80,7 +95,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) : @@ -231,6 +251,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; @@ -251,11 +273,14 @@ 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"); layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); + layout->addWidget(mainwindow->contentGridWidget()); widget->setLayout(layout); @@ -286,6 +311,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(); @@ -447,6 +476,12 @@ static void* ui_companion_qt_init(void) /* this should come last */ mainwindow->resizeThumbnails(true, true, true); + 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")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); @@ -455,17 +490,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(); @@ -483,6 +507,58 @@ 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); + + /* 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); + + /* 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 5ebd251212..3912428a2c 100644 --- a/ui/drivers/ui_qt.h +++ b/ui/drivers/ui_qt.h @@ -22,14 +22,21 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include extern "C" { +#include #include #include "../ui_companion_driver.h" } @@ -52,21 +59,51 @@ class QPixmap; class QPaintEvent; class QSettings; class QCheckBox; +class QSpinBox; class QFormLayout; class QStyle; class QScrollArea; +class QSlider; class LoadCoreWindow; class MainWindow; +class ThumbnailWidget; +class ThumbnailLabel; +class FlowLayout; -class ThumbnailWidget : public QWidget +class GridItem : public QObject +{ + Q_OBJECT +public: + GridItem(); + + QPointer widget; + QPointer label; + QHash hash; + QImage image; + QPixmap pixmap; + QFutureWatcher imageWatcher; + QString labelText; +}; + +class ThumbnailWidget : public QFrame { Q_OBJECT public: ThumbnailWidget(QWidget *parent = 0); + ThumbnailWidget(const ThumbnailWidget& other) { retro_assert(false && "DONT EVER USE THIS"); } + 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 @@ -156,6 +193,8 @@ private: QLabel *m_highlightColorLabel; QString m_customThemePath; QCheckBox *m_suggestLoadedCoreFirstCheckBox; + QSpinBox *m_allPlaylistsListMaxCountSpinBox; + QSpinBox *m_allPlaylistsGridMaxCountSpinBox; }; class CoreInfoLabel : public QLabel @@ -204,6 +243,12 @@ class MainWindow : public QMainWindow Q_OBJECT public: + enum ViewType + { + VIEW_TYPE_ICONS, + VIEW_TYPE_LIST + }; + enum Theme { THEME_SYSTEM_DEFAULT, @@ -223,6 +268,8 @@ public: TreeView* dirTreeView(); QListWidget* playlistListWidget(); TableWidget* contentTableWidget(); + FlowLayout* contentGridLayout(); + QWidget* contentGridWidget(); QWidget* searchWidget(); QLineEdit* searchLineEdit(); QComboBox* launchWithComboBox(); @@ -231,10 +278,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); @@ -245,6 +292,12 @@ public: bool setCustomThemeFile(QString filePath); void setCustomThemeString(QString qss); const QString& customThemeString() const; + GridItem* doDeferredImageLoad(GridItem *item, QString path); + void setCurrentViewType(ViewType viewType); + QString getCurrentViewTypeString(); + ViewType getCurrentViewType(); + void setAllPlaylistsListMaxCount(int count); + void setAllPlaylistsGridMaxCount(int count); signals: void thumbnailChanged(const QPixmap &pixmap); @@ -259,10 +312,12 @@ public slots: void onBrowserUpClicked(); void onBrowserStartClicked(); void initContentTableWidget(); + void initContentGridLayout(); void onViewClosedDocksAboutToShow(); void onShowHiddenDockWidgetAction(); void setCoreActions(); void onRunClicked(); + void loadContent(const QHash &contentHash); void onStartCoreClicked(); void onTableWidgetEnterPressed(); void selectBrowserDir(QString path); @@ -277,6 +332,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()); @@ -285,24 +343,38 @@ 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); + void addPlaylistItemsToTable(const QStringList &paths, bool all = false); + void addPlaylistHashToTable(const QVector > &items); + void addPlaylistItemsToGrid(const QStringList &paths, bool all = false); + void addPlaylistHashToGrid(const QVector > &items); void onContentItemDoubleClicked(QTableWidgetItem *item); void onCoreLoadWindowClosed(); - void onTabWidgetIndexChanged(int index); void onTreeViewItemsSelected(QModelIndexList selectedIndexes); void onSearchResetClicked(); void onLaunchWithComboBoxIndexChanged(int index); void onFileBrowserTreeContextMenuRequested(const QPoint &pos); void onPlaylistWidgetContextMenuRequested(const QPoint &pos); void onStopClicked(); + void onDeferredImageLoaded(); + void onZoomValueChanged(int value); + void onContentGridInited(); + void onUpdateGridItemPixmapFromImage(GridItem *item); + void onPendingItemUpdates(); + void onGridItemDoubleClicked(); + void onGridItemClicked(); private: void setCurrentCoreLabel(); void getPlaylistFiles(); bool isCoreLoaded(); bool isContentLessCore(); + void removeGridItems(); + void loadImageDeferred(GridItem *item, QString path); + void calcGridItemSize(GridItem *item, int zoomValue); + QVector > getPlaylistItems(QString pathString); LoadCoreWindow *m_loadCoreWindow; QTimer *m_timer; @@ -344,12 +416,31 @@ private: QListWidgetItem *m_historyPlaylistsItem; QIcon m_folderIcon; QString m_customThemeString; + FlowLayout *m_gridLayout; + QWidget *m_gridWidget; + QScrollArea *m_gridScrollArea; + QVector > m_gridItems; + QWidget *m_gridLayoutWidget; + QSlider *m_zoomSlider; + int m_lastZoomSliderValue; + QList m_pendingItemUpdates; + ViewType m_viewType; + QProgressBar *m_gridProgressBar; + QWidget *m_gridProgressWidget; + QHash m_currentGridHash; + ViewType m_lastViewType; + QPointer m_currentGridWidget; + int m_allPlaylistsListMaxCount; + int m_allPlaylistsGridMaxCount; protected: void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); }; +Q_DECLARE_METATYPE(ThumbnailWidget) +Q_DECLARE_METATYPE(QPointer) + RETRO_BEGIN_DECLS typedef struct ui_application_qt