From 85e658fab56fca9e8a0eafd0140d09a04de64c4d Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 11 Jul 2013 09:34:04 +0200 Subject: [PATCH] Define real text color for use in RenderString() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/e60067545f4434ee81edf31361a601b6f3113320 Author: Michael Liebmann Date: 2013-07-11 (Thu, 11 Jul 2013) --- src/gui/color.cpp | 22 ++++++++-- src/gui/color.h | 30 ++++++++++++-- src/system/setting_helpers.cpp | 76 ++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 7 deletions(-) diff --git a/src/gui/color.cpp b/src/gui/color.cpp index 322dfb896..4a64c54ac 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -89,7 +89,7 @@ void fadeColor(unsigned char &r, unsigned char &g, unsigned char &b, int fade, b protectColor(r,g,b, protect); } -unsigned char getBrightnessRGB(fb_pixel_t &color) +unsigned char getBrightnessRGB(fb_pixel_t color) { RgbColor rgb; rgb.r = (color & 0x00FF0000) >> 16; @@ -99,7 +99,7 @@ unsigned char getBrightnessRGB(fb_pixel_t &color) return rgb.r > rgb.g ? (rgb.r > rgb.b ? rgb.r : rgb.b) : (rgb.g > rgb.b ? rgb.g : rgb.b); } -fb_pixel_t changeBrightnessRGBRel(fb_pixel_t &color, int br) +fb_pixel_t changeBrightnessRGBRel(fb_pixel_t color, int br) { int br_ = (int)getBrightnessRGB(color); br_ += br; @@ -108,7 +108,23 @@ fb_pixel_t changeBrightnessRGBRel(fb_pixel_t &color, int br) return changeBrightnessRGB(color, (unsigned char)br_); } -fb_pixel_t changeBrightnessRGB(fb_pixel_t &color, unsigned char br) +void changeBrightnessRGBRel2(RgbColor *rgb, int br) +{ + fb_pixel_t color = (((rgb->r << 16) & 0x00FF0000) | + ((rgb->g << 8) & 0x0000FF00) | + ((rgb->b ) & 0x000000FF)); + int br_ = (int)getBrightnessRGB(color); + br_ += br; + if (br_ < 0) br_ = 0; + if (br_ > 255) br_ = 255; + + HsvColor hsv; + Rgb2Hsv(rgb, &hsv); + hsv.v = br; + Hsv2Rgb(&hsv, rgb); +} + +fb_pixel_t changeBrightnessRGB(fb_pixel_t color, unsigned char br) { HsvColor hsv; RgbColor rgb; diff --git a/src/gui/color.h b/src/gui/color.h index bcffc5b6f..8e6a2e75c 100644 --- a/src/gui/color.h +++ b/src/gui/color.h @@ -33,8 +33,10 @@ #ifndef __color__ #define __color__ -#define COL_MAXFREE 254-8*9 - 1 #include + +#define COL_MAXFREE 254-8*12 - 1 +#define COL_NEUTRINO_TEXT 254-8*12 // 24 values #define COL_COLORED_EVENTS_CHANNELLIST 254-8*9 #define COL_COLORED_EVENTS_INFOBAR 254-8*8 #define COL_INFOBAR_SHADOW 254-8*7 @@ -91,6 +93,23 @@ #define COL_MENUCONTENTSELECTED_PLUS_2 (CFrameBuffer::getInstance()->realcolor[(COL_MENUCONTENTSELECTED + 2)]) #define COL_MENUCONTENTINACTIVE_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_MENUCONTENTINACTIVE + 0)]) #define COL_BACKGROUND_PLUS_0 (CFrameBuffer::getInstance()->realcolor[(COL_BACKGROUND + 0)]) + +// text colors +#define COL_COLORED_EVENTS_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 0)]) +#define COL_INFOBAR_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 1)]) +#define COL_INFOBAR_SHADOW_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 2)]) +#define COL_MENUHEAD_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 3)]) +#define COL_MENUCONTENT_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 4)]) +#define COL_MENUCONTENT_TEXT_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 5)]) +#define COL_MENUCONTENT_TEXT_PLUS_2 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 6)]) +#define COL_MENUCONTENT_TEXT_PLUS_3 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 7)]) +#define COL_MENUCONTENTDARK_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 8)]) +#define COL_MENUCONTENTDARK_TEXT_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 9)]) +#define COL_MENUCONTENTDARK_TEXT_PLUS_2 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 10)]) +#define COL_MENUCONTENTSELECTED_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 11)]) +#define COL_MENUCONTENTSELECTED_TEXT_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 12)]) +#define COL_MENUCONTENTSELECTED_TEXT_PLUS_2 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 13)]) +#define COL_MENUCONTENTINACTIVE_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 14)]) #endif @@ -111,9 +130,12 @@ typedef struct { unsigned char v; } HsvColor; -unsigned char getBrightnessRGB(fb_pixel_t &color); -fb_pixel_t changeBrightnessRGBRel(fb_pixel_t &color, int br); -fb_pixel_t changeBrightnessRGB(fb_pixel_t &color, unsigned char br); +unsigned char getBrightnessRGB(fb_pixel_t color); + +fb_pixel_t changeBrightnessRGBRel(fb_pixel_t color, int br); +fb_pixel_t changeBrightnessRGB(fb_pixel_t color, unsigned char br); +void changeBrightnessRGBRel2(RgbColor *rgb, int br); + void Hsv2Rgb(HsvColor *hsv, RgbColor *rgb); void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv); diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 42f9fb6cd..99717e25f 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -178,6 +178,82 @@ void CColorSetupNotifier::setPalette() convertSetupColor2RGB(g_settings.colored_events_red, g_settings.colored_events_green, g_settings.colored_events_blue), 8, convertSetupAlpha2Alpha(g_settings.infobar_alpha) ); + // ##### TEXT COLORS ##### + // COL_COLORED_EVENTS_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 0, + convertSetupColor2RGB(g_settings.colored_events_red, g_settings.colored_events_green, g_settings.colored_events_blue), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_INFOBAR_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 1, + convertSetupColor2RGB(g_settings.infobar_Text_red, g_settings.infobar_Text_green, g_settings.infobar_Text_blue), + convertSetupAlpha2Alpha(g_settings.infobar_alpha)); + + // COL_INFOBAR_SHADOW_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 2, + convertSetupColor2RGB(int(g_settings.infobar_Text_red*0.6), int(g_settings.infobar_Text_green*0.6), int(g_settings.infobar_Text_blue*0.6)), + convertSetupAlpha2Alpha(g_settings.infobar_alpha)); + + // COL_MENUHEAD_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 3, + convertSetupColor2RGB(g_settings.menu_Head_Text_red, g_settings.menu_Head_Text_green, g_settings.menu_Head_Text_blue), + convertSetupAlpha2Alpha(g_settings.menu_Head_alpha)); + + // COL_MENUCONTENT_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 4, + convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENT_TEXT_PLUS_1 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 5, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), -16), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENT_TEXT_PLUS_2 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 6, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), -32), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENT_TEXT_PLUS_3 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 7, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), -48), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENTDARK_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 8, + convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENTDARK_TEXT_PLUS_1 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 9, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), -52), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENTDARK_TEXT_PLUS_2 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 10, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Text_red, g_settings.menu_Content_Text_green, g_settings.menu_Content_Text_blue), -60), + convertSetupAlpha2Alpha(g_settings.menu_Content_alpha)); + + // COL_MENUCONTENTSELECTED_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 11, + convertSetupColor2RGB(g_settings.menu_Content_Selected_Text_red, g_settings.menu_Content_Selected_Text_green, g_settings.menu_Content_Selected_Text_blue), + convertSetupAlpha2Alpha(g_settings.menu_Content_Selected_alpha)); + + // COL_MENUCONTENTSELECTED_TEXT_PLUS_1 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 12, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Selected_Text_red, g_settings.menu_Content_Selected_Text_green, g_settings.menu_Content_Selected_Text_blue), -16), + convertSetupAlpha2Alpha(g_settings.menu_Content_Selected_alpha)); + + // COL_MENUCONTENTSELECTED_TEXT_PLUS_2 + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 13, + changeBrightnessRGBRel(convertSetupColor2RGB(g_settings.menu_Content_Selected_Text_red, g_settings.menu_Content_Selected_Text_green, g_settings.menu_Content_Selected_Text_blue), -32), + convertSetupAlpha2Alpha(g_settings.menu_Content_Selected_alpha)); + + // COL_MENUCONTENTINACTIVE_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 14, + convertSetupColor2RGB(g_settings.menu_Content_inactive_Text_red, g_settings.menu_Content_inactive_Text_green, g_settings.menu_Content_inactive_Text_blue), + convertSetupAlpha2Alpha(g_settings.menu_Content_inactive_alpha)); + frameBuffer->paletteSet(); }