From f603d4ec302769ffd89e3659e126f29d07460aa9 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 20 Dec 2018 16:11:17 +0000 Subject: [PATCH] (RGUI) Enable customisation of background and border colours --- config.def.h | 4 + configuration.c | 20 +++++ configuration.h | 4 + intl/msg_hash_lbl.h | 8 ++ intl/msg_hash_us.h | 16 ++++ menu/drivers/rgui.c | 178 +++++++++++++++++++++++++--------------- menu/menu_displaylist.c | 16 ++++ menu/menu_setting.c | 56 +++++++++++++ msg_hash.h | 4 + 9 files changed, 242 insertions(+), 64 deletions(-) diff --git a/config.def.h b/config.def.h index 5239c55fce..b12a717149 100644 --- a/config.def.h +++ b/config.def.h @@ -375,6 +375,10 @@ static bool show_advanced_settings = false; static const uint32_t menu_entry_normal_color = 0xffffffff; static const uint32_t menu_entry_hover_color = 0xff64ff64; static const uint32_t menu_title_color = 0xff64ff64; +static const uint32_t menu_bg_dark_color = 0xc0202020; +static const uint32_t menu_bg_light_color = 0xc0404040; +static const uint32_t menu_border_dark_color = 0xc0204020; +static const uint32_t menu_border_light_color = 0xc0408040; #else static bool default_block_config_read = false; diff --git a/configuration.c b/configuration.c index d2712b5d75..871a7cc7b6 100644 --- a/configuration.c +++ b/configuration.c @@ -1914,6 +1914,10 @@ void config_set_defaults(void) settings->uints.menu_entry_normal_color = menu_entry_normal_color; settings->uints.menu_entry_hover_color = menu_entry_hover_color; settings->uints.menu_title_color = menu_title_color; + settings->uints.menu_bg_dark_color = menu_bg_dark_color; + settings->uints.menu_bg_light_color = menu_bg_light_color; + settings->uints.menu_border_dark_color = menu_border_dark_color; + settings->uints.menu_border_light_color = menu_border_light_color; #endif #ifdef HAVE_CHEEVOS @@ -2831,6 +2835,14 @@ static bool config_load_file(const char *path, bool set_defaults, &settings->uints.menu_entry_hover_color); config_get_hex_base(conf, "menu_title_color", &settings->uints.menu_title_color); + config_get_hex_base(conf, "menu_bg_dark_color", + &settings->uints.menu_bg_dark_color); + config_get_hex_base(conf, "menu_bg_light_color", + &settings->uints.menu_bg_light_color); + config_get_hex_base(conf, "menu_border_dark_color", + &settings->uints.menu_border_dark_color); + config_get_hex_base(conf, "menu_border_light_color", + &settings->uints.menu_border_light_color); #endif /* Float settings */ @@ -4335,6 +4347,14 @@ bool config_save_file(const char *path) settings->uints.menu_entry_hover_color); config_set_hex(conf, "menu_title_color", settings->uints.menu_title_color); + config_set_hex(conf, "menu_bg_dark_color", + settings->uints.menu_bg_dark_color); + config_set_hex(conf, "menu_bg_light_color", + settings->uints.menu_bg_light_color); + config_set_hex(conf, "menu_border_dark_color", + settings->uints.menu_border_dark_color); + config_set_hex(conf, "menu_border_light_color", + settings->uints.menu_border_light_color); #endif diff --git a/configuration.h b/configuration.h index 7f0dc3d4cd..85953e18c2 100644 --- a/configuration.h +++ b/configuration.h @@ -406,6 +406,10 @@ typedef struct settings unsigned menu_entry_normal_color; unsigned menu_entry_hover_color; unsigned menu_title_color; + unsigned menu_bg_dark_color; + unsigned menu_bg_light_color; + unsigned menu_border_dark_color; + unsigned menu_border_light_color; unsigned menu_xmb_layout; unsigned menu_xmb_shader_pipeline; unsigned menu_xmb_scale_factor; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 7d2b670981..775daf9f0b 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1125,6 +1125,14 @@ MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_STYLE, "menu_timedate_style") MSG_HASH(MENU_ENUM_LABEL_TITLE_COLOR, "menu_title_color") +MSG_HASH(MENU_ENUM_LABEL_BG_DARK_COLOR, + "menu_bg_dark_color") +MSG_HASH(MENU_ENUM_LABEL_BG_LIGHT_COLOR, + "menu_bg_light_color") +MSG_HASH(MENU_ENUM_LABEL_BORDER_DARK_COLOR, + "menu_border_dark_color") +MSG_HASH(MENU_ENUM_LABEL_BORDER_LIGHT_COLOR, + "menu_border_light_color") MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_ENABLE, "ui_companion_enable") MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_START_ON_BOOT, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index cc95c33a76..ac461f0fbd 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2976,6 +2976,22 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_TITLE_COLOR, "Menu title color" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BG_DARK_COLOR, + "Menu background dark color" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BG_LIGHT_COLOR, + "Menu background light color" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BORDER_DARK_COLOR, + "Menu border dark color" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_BORDER_LIGHT_COLOR, + "Menu border light color" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_TRUE, "True" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 5fe7ef8490..5c172a6f3c 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -69,18 +69,50 @@ typedef struct static uint16_t *rgui_framebuf_data = NULL; -#if defined(GEKKO)|| defined(PSP) -#define HOVER_COLOR(settings) ((3 << 0) | (10 << 4) | (3 << 8) | (7 << 12)) -#define NORMAL_COLOR(settings) 0x7FFF -#define TITLE_COLOR(settings) HOVER_COLOR(settings) +/* Note: if we knew what colour format each of these + * special cases required, we could do away with all + * this nonsense and handle it inside a single colour + * conversion function... + * In the meantime, we'll use the existing obfuscated + * values for all the non-standard platforms, and leave + * it messy... */ +#if defined(GEKKO) || defined(PSP) + +/* Is this supposed to be 4444 ABGR? + * Have no idea what's going on here, so have to use + * fixed colour values... */ +#define HOVER_COLOR(settings) ((3 << 0) | (10 << 4) | (3 << 8) | (7 << 12)) +#define NORMAL_COLOR(settings) 0x7FFF +#define TITLE_COLOR(settings) HOVER_COLOR(settings) +#define BG_DARK_COLOR(settings) ((6 << 12) | (1 << 8) | (1 << 4) | (1 << 0)) +#define BG_LIGHT_COLOR(settings) ((6 << 12) | (2 << 8) | (2 << 4) | (2 << 0)) +#define BORDER_DARK_COLOR(settings) ((6 << 12) | (1 << 8) | (1 << 5) | (1 << 0)) +#define BORDER_LIGHT_COLOR(settings) ((6 << 12) | (2 << 8) | (2 << 5) | (2 << 0)) + #elif defined(PS2) -#define HOVER_COLOR(settings) 0x03E0 -#define NORMAL_COLOR(settings) 0x7FFF -#define TITLE_COLOR(settings) HOVER_COLOR(settings) -#else + +/* Have no idea what's going on here, so have to use + * fixed colour values... */ +#define HOVER_COLOR(settings) 0x03E0 +#define NORMAL_COLOR(settings) 0x7FFF +#define TITLE_COLOR(settings) HOVER_COLOR(settings) +#define BG_DARK_COLOR(settings) ((0 << 15) | (1 << 12) | (1 << 7) | (1 << 2)) +#define BG_LIGHT_COLOR(settings) ((0 << 15) | (2 << 12) | (2 << 7) | (2 << 2)) +#define BORDER_DARK_COLOR(settings) ((0 << 15) | (1 << 12) | (1 << 8) | (1 << 2)) +#define BORDER_LIGHT_COLOR(settings) ((0 << 15) | (2 << 12) | (2 << 8) | (2 << 2)) + +#elif defined(HAVE_LIBNX) && !defined(HAVE_OPENGL) + #define HOVER_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_entry_hover_color)) #define NORMAL_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_entry_normal_color)) #define TITLE_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_title_color)) +/* Is this supposed to be RGB565? + * Have no idea what's going on here, so have to use + * fixed colour values... */ +#define BG_DARK_COLOR(settings) ((((31 * (54)) / 255) << 11) | (((63 * (54)) / 255) << 5) | ((31 * (54)) / 255)) +#define BG_LIGHT_COLOR(settings) BG_DARK_COLOR(settings) +#define BORDER_DARK_COLOR(settings) ((((31 * (54)) / 255) << 11) | (((63 * (109)) / 255) << 5) | ((31 * (54)) / 255)) +#define BORDER_LIGHT_COLOR(settings) BORDER_DARK_COLOR(settings) static uint16_t argb32_to_rgba4444(uint32_t col) { @@ -90,41 +122,41 @@ static uint16_t argb32_to_rgba4444(uint32_t col) unsigned b = ((col & 0xff) ) >> 4; return (r << 12) | (g << 8) | (b << 4) | a; } -#endif - -static uint16_t rgui_gray_filler(rgui_t *rgui, unsigned x, unsigned y) -{ - unsigned shft = (rgui->bg_thickness ? 1 : 0); - unsigned col = (((x >> shft) + (y >> shft)) & 1) + 1; -#if defined(GEKKO) || defined(PSP) - return (6 << 12) | (col << 8) | (col << 4) | (col << 0); -#elif defined(PS2) - return (0 << 15) | (col << 12) | (col << 7) | (col << 2); -#elif defined(HAVE_LIBNX) && !defined(HAVE_OPENGL) - return (((31 * (54)) / 255) << 11) | - (((63 * (54)) / 255) << 5) | - ((31 * (54)) / 255); #else - return (col << 13) | (col << 9) | (col << 5) | (12 << 0); -#endif + +/* This is the only sane case... */ +#define HOVER_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_entry_hover_color)) +#define NORMAL_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_entry_normal_color)) +#define TITLE_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_title_color)) +#define BG_DARK_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_bg_dark_color)) +#define BG_LIGHT_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_bg_light_color)) +#define BORDER_DARK_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_border_dark_color)) +#define BORDER_LIGHT_COLOR(settings) (argb32_to_rgba4444(settings->uints.menu_border_light_color)) + +static uint16_t argb32_to_rgba4444(uint32_t col) +{ + unsigned a = ((col >> 24) & 0xff) >> 4; + unsigned r = ((col >> 16) & 0xff) >> 4; + unsigned g = ((col >> 8) & 0xff) >> 4; + unsigned b = ((col & 0xff) ) >> 4; + return (r << 12) | (g << 8) | (b << 4) | a; } -static uint16_t rgui_green_filler(rgui_t *rgui, unsigned x, unsigned y) -{ - unsigned shft = (rgui->border_thickness ? 1 : 0); - unsigned col = (((x >> shft) + (y >> shft)) & 1) + 1; -#if defined(GEKKO) || defined(PSP) - return (6 << 12) | (col << 8) | (col << 5) | (col << 0); -#elif defined(PS2) - return (0 << 15) | (col << 12) | (col << 8) | (col << 2); -#elif defined(HAVE_LIBNX) && !defined(HAVE_OPENGL) - return (((31 * (54)) / 255) << 11) | - (((63 * (109)) / 255) << 5) | - ((31 * (54)) / 255); -#else - return (col << 13) | (col << 10) | (col << 5) | (12 << 0); #endif + +static uint16_t rgui_bg_filler(rgui_t *rgui, unsigned x, unsigned y, uint16_t dark_color, uint16_t light_color) +{ + unsigned shift = (rgui->bg_thickness ? 1 : 0); + unsigned select = ((x >> shift) + (y >> shift)) & 1; + return (select == 0) ? dark_color : light_color; +} + +static uint16_t rgui_border_filler(rgui_t *rgui, unsigned x, unsigned y, uint16_t dark_color, uint16_t light_color) +{ + unsigned shift = (rgui->border_thickness ? 1 : 0); + unsigned select = ((x >> shift) + (y >> shift)) & 1; + return (select == 0) ? dark_color : light_color; } static void rgui_fill_rect( @@ -133,13 +165,14 @@ static void rgui_fill_rect( size_t pitch, unsigned x, unsigned y, unsigned width, unsigned height, - uint16_t (*col)(rgui_t *rgui, unsigned x, unsigned y)) + uint16_t dark_color, uint16_t light_color, + uint16_t (*col)(rgui_t *rgui, unsigned x, unsigned y, uint16_t dark_color, uint16_t light_color)) { unsigned i, j; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - data[j * (pitch >> 1) + i] = col(rgui, i, j); + data[j * (pitch >> 1) + i] = col(rgui, i, j, dark_color, light_color); } static void rgui_color_rect( @@ -267,7 +300,8 @@ static void rgui_render_background(rgui_t *rgui) unsigned fb_width, fb_height; uint16_t *src = NULL; uint16_t *dst = NULL; - + uint16_t dark_color, light_color; + menu_display_get_fb_size(&fb_width, &fb_height, &fb_pitch); @@ -288,12 +322,18 @@ static void rgui_render_background(rgui_t *rgui) if (settings->bools.menu_rgui_border_filler_enable) { - rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, 5, fb_width - 10, 5, rgui_green_filler); - rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, fb_height - 10, fb_width - 10, 5, rgui_green_filler); + dark_color = BORDER_DARK_COLOR(settings); + light_color = BORDER_LIGHT_COLOR(settings); + + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, 5, fb_width - 10, 5, + dark_color, light_color, rgui_border_filler); + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, fb_height - 10, fb_width - 10, 5, + dark_color, light_color, rgui_border_filler); - rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, 5, 5, fb_height - 10, rgui_green_filler); + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 5, 5, 5, fb_height - 10, + dark_color, light_color, rgui_border_filler); rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, fb_width - 10, 5, 5, fb_height - 10, - rgui_green_filler); + dark_color, light_color, rgui_border_filler); } } } @@ -314,7 +354,8 @@ static void rgui_set_message(void *data, const char *message) static void rgui_render_messagebox(rgui_t *rgui, const char *message) { int x, y; - uint16_t color; + uint16_t normal_color; + uint16_t dark_color, light_color; size_t i, fb_pitch; unsigned fb_width, fb_height; unsigned width, glyphs_width, height; @@ -364,27 +405,30 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message) if (rgui_framebuf_data) { - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, x + 5, y + 5, width - 10, - height - 10, rgui_gray_filler); + dark_color = BG_DARK_COLOR(settings); + light_color = BG_LIGHT_COLOR(settings); + + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, x + 5, y + 5, width - 10, height - 10, + dark_color, light_color, rgui_bg_filler); if (settings->bools.menu_rgui_border_filler_enable) { - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, x, y, width - 5, 5, rgui_green_filler); - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, x + width - 5, y, 5, - height - 5, rgui_green_filler); - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, x + 5, y + height - 5, - width - 5, 5, rgui_green_filler); - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, x, y + 5, 5, - height - 5, rgui_green_filler); + + dark_color = BORDER_DARK_COLOR(settings); + light_color = BORDER_LIGHT_COLOR(settings); + + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, x, y, width - 5, 5, + dark_color, light_color, rgui_border_filler); + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, x + width - 5, y, 5, height - 5, + dark_color, light_color, rgui_border_filler); + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, x + 5, y + height - 5, width - 5, 5, + dark_color, light_color, rgui_border_filler); + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, x, y + 5, 5, height - 5, + dark_color, light_color, rgui_border_filler); } } - color = NORMAL_COLOR(settings); + normal_color = NORMAL_COLOR(settings); for (i = 0; i < list->size; i++) { @@ -393,7 +437,7 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message) int offset_y = (int)(FONT_HEIGHT_STRIDE * i); if (rgui_framebuf_data) - blit_line(x + 8 + offset_x, y + 8 + offset_y, msg, color); + blit_line(x + 8 + offset_x, y + 8 + offset_y, msg, normal_color); } end: @@ -438,6 +482,7 @@ static void rgui_render(void *data, bool is_idle) menu_animation_ctx_ticker_t ticker; unsigned x, y; uint16_t hover_color, normal_color; + uint16_t dark_color, light_color; size_t i, end, fb_pitch, old_start; unsigned fb_width, fb_height; int bottom; @@ -472,8 +517,13 @@ static void rgui_render(void *data, bool is_idle) if (rgui->bg_modified || rgui->last_width != fb_width || rgui->last_height != fb_height) { if (rgui_framebuf_data) - rgui_fill_rect(rgui, rgui_framebuf_data, - fb_pitch, 0, fb_height, fb_width, 4, rgui_gray_filler); + { + dark_color = BG_DARK_COLOR(settings); + light_color = BG_LIGHT_COLOR(settings); + + rgui_fill_rect(rgui, rgui_framebuf_data, fb_pitch, 0, fb_height, fb_width, 4, + dark_color, light_color, rgui_bg_filler); + } rgui->last_width = fb_width; rgui->last_height = fb_height; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 34c47c910d..6902a0b792 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5967,6 +5967,22 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_TITLE_COLOR, PARSE_ONLY_HEX, false) == 0) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_BG_DARK_COLOR, + PARSE_ONLY_HEX, false) == 0) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_BG_LIGHT_COLOR, + PARSE_ONLY_HEX, false) == 0) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_BORDER_DARK_COLOR, + PARSE_ONLY_HEX, false) == 0) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_BORDER_LIGHT_COLOR, + PARSE_ONLY_HEX, false) == 0) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_DPI_OVERRIDE_ENABLE, PARSE_ONLY_BOOL, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 61aca46d12..174e6f68d0 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -7690,6 +7690,62 @@ static bool setting_append_list( general_read_handler); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + + CONFIG_HEX( + list, list_info, + &settings->uints.menu_bg_dark_color, + MENU_ENUM_LABEL_BG_DARK_COLOR, + MENU_ENUM_LABEL_VALUE_BG_DARK_COLOR, + menu_bg_dark_color, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + + CONFIG_HEX( + list, list_info, + &settings->uints.menu_bg_light_color, + MENU_ENUM_LABEL_BG_LIGHT_COLOR, + MENU_ENUM_LABEL_VALUE_BG_LIGHT_COLOR, + menu_bg_light_color, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + + CONFIG_HEX( + list, list_info, + &settings->uints.menu_border_dark_color, + MENU_ENUM_LABEL_BORDER_DARK_COLOR, + MENU_ENUM_LABEL_VALUE_BORDER_DARK_COLOR, + menu_border_dark_color, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + + CONFIG_HEX( + list, list_info, + &settings->uints.menu_border_light_color, + MENU_ENUM_LABEL_BORDER_LIGHT_COLOR, + MENU_ENUM_LABEL_VALUE_BORDER_LIGHT_COLOR, + menu_border_light_color, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); } if (string_is_equal(settings->arrays.menu_driver, "xmb")) diff --git a/msg_hash.h b/msg_hash.h index c2af72b219..28dfa76e8e 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1318,6 +1318,10 @@ enum msg_hash_enums MENU_LABEL(CHEAT_DELETE_MATCH), MENU_LABEL(SCREEN_RESOLUTION), MENU_LABEL(TITLE_COLOR), + MENU_LABEL(BG_DARK_COLOR), + MENU_LABEL(BG_LIGHT_COLOR), + MENU_LABEL(BORDER_DARK_COLOR), + MENU_LABEL(BORDER_LIGHT_COLOR), MENU_LABEL(SAVESTATE_AUTO_INDEX), MENU_LABEL(SAVESTATE_AUTO_SAVE), MENU_LABEL(SAVESTATE_AUTO_LOAD),