From 8e2a79c496d24981a1afe872f919164099f58c3e Mon Sep 17 00:00:00 2001 From: NightlyFox Date: Wed, 19 Sep 2018 23:31:17 -0500 Subject: [PATCH] added two new theming attributes, borderColor, borderTextcolor, allows users to modify the boxes that surrounds the menu entries --- common/menu.c | 9 ++++----- common/theme.c | 12 +++++++++++- common/theme.h | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/menu.c b/common/menu.c index 76af412..91e44ed 100644 --- a/common/menu.c +++ b/common/menu.c @@ -122,7 +122,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) { int border_start_x, border_end_x; int border_start_y, border_end_y; - color_t border_color = MakeColor(255, 255, 255, 255); + color_t border_color = MakeColor(themeCurrent.borderColor.r, themeCurrent.borderColor.g, themeCurrent.borderColor.b, 255); int shadow_start_y, shadow_y; int shadow_inset; @@ -132,7 +132,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) { int shadow_size = 4; if (is_active) { - highlight_multiplier = fmax(0.0, fabs(fmod(menuTimer, 1.0) - 0.5) / 0.5); + border_color = MakeColor(themeCurrent.highlightColor.r + (255 - themeCurrent.highlightColor.r) * highlight_multiplier, themeCurrent.highlightColor.g + (255 - themeCurrent.highlightColor.g) * highlight_multiplier, themeCurrent.highlightColor.b + (255 - themeCurrent.highlightColor.b) * highlight_multiplier, 255); border_start_x = start_x-6; border_end_x = end_x+6; @@ -201,7 +201,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) { for (y=start_y; yname, 140 - 32, "..."); + DrawTextTruncate(interuiregular14, start_x + 4, start_y + 4 + 18, MakeColor(themeCurrent.borderTextColor.r, themeCurrent.borderTextColor.g, themeCurrent.borderTextColor.b, 255), me->name, 140 - 32, "...");//Add to theme if (is_active) { start_x = 1280 - 790; diff --git a/common/theme.c b/common/theme.c index f95ece9..a747888 100644 --- a/common/theme.c +++ b/common/theme.c @@ -36,6 +36,8 @@ void themeStartup(ThemePreset preset) { .backgroundColor = MakeColor(233, 236, 241, 255), .highlightColor = MakeColor(91, 237, 224, 255), .separatorColor = MakeColor(219, 218, 219, 255), + .borderColor = MakeColor(255,255,255,255), + .borderTextColor = MakeColor(64,64,64,255), .enableWaveBlending = 0, .buttonAText = buttonAText,/*setting the buttonAText = "\uE0E0" directly allocates the literal on the stack */ .buttonBText = buttonBText,/*and sets the buttonAText to point to the address of the literal which is why calloc is used above*/ @@ -52,6 +54,8 @@ void themeStartup(ThemePreset preset) { .backgroundColor = MakeColor(45, 45, 50, 255), .highlightColor = MakeColor(91, 237, 224, 255), .separatorColor = MakeColor(219, 218, 219, 255), + .borderColor = MakeColor(255,255,255,255), + .borderTextColor = MakeColor(64,64,64,255), .enableWaveBlending = 0, .buttonAText = buttonAText, .buttonBText = buttonBText, @@ -72,7 +76,7 @@ void themeStartup(ThemePreset preset) { config_t cfg = {0}; config_init(&cfg); config_setting_t *theme; - color_t text, frontWave, middleWave, backWave, background, highlight, separator; + color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor; int waveBlending; const char *AText, *BText; bool good_cfg = config_read_file(&cfg, tmp_path); @@ -106,6 +110,10 @@ void themeStartup(ThemePreset preset) { highlight = themeDefault->highlightColor; if (!colorFromSetting(config_setting_lookup(theme, "separatorColor"), &separator)) separator = themeDefault->separatorColor; + if (!colorFromSetting(config_setting_lookup(theme, "borderColor"), &borderColor)) + borderColor = themeDefault->borderColor; + if (!colorFromSetting(config_setting_lookup(theme, "borderTextColor"), &borderTextColor)) + borderTextColor = themeDefault->borderTextColor; if (!config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending)) waveBlending = themeDefault->enableWaveBlending; if (!config_setting_lookup_string(theme, "buttonAText", &AText)) @@ -120,6 +128,8 @@ void themeStartup(ThemePreset preset) { .backgroundColor = background, .highlightColor = highlight, .separatorColor = separator, + .borderColor = borderColor, + .borderTextColor = borderTextColor, .enableWaveBlending = waveBlending, .buttonAText = AText, .buttonBText = BText, diff --git a/common/theme.h b/common/theme.h index 187a087..79313b9 100644 --- a/common/theme.h +++ b/common/theme.h @@ -12,7 +12,8 @@ typedef struct color_t backgroundColor; color_t highlightColor; color_t separatorColor; - color_t activeColor; + color_t borderColor; + color_t borderTextColor; bool enableWaveBlending; const char *buttonAText; const char *buttonBText;