color: add getItemColors function to simplify color handling

Origin commit data
------------------
Commit: 56126c6a61
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-10-19 (Wed, 19 Oct 2016)

Origin message was:
------------------
- color: add getItemColors function to simplify color handling
This commit is contained in:
vanhofen
2016-10-19 10:06:35 +02:00
parent 645b667d3e
commit 844a58db72
2 changed files with 30 additions and 0 deletions

View File

@@ -228,3 +228,31 @@ void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv)
hsv->s = f_S;
hsv->v = f_V;
}
void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected, bool marked, bool switch_background)
{
if (selected && marked)
{
t = COL_MENUCONTENTSELECTED_TEXT_PLUS_2;
b = COL_MENUCONTENTSELECTED_PLUS_2;
return;
}
if (selected)
{
t = COL_MENUCONTENTSELECTED_TEXT;
b = COL_MENUCONTENTSELECTED_PLUS_0;
return;
}
if (marked)
{
t = COL_MENUCONTENT_TEXT_PLUS_2;
b = COL_MENUCONTENT_PLUS_2;
return;
}
// default
t = COL_MENUCONTENT_TEXT;
b = switch_background ? COL_MENUCONTENTDARK_PLUS_0 : COL_MENUCONTENT_PLUS_0;
}

View File

@@ -161,4 +161,6 @@ uint8_t SysColor2Hsv(fb_pixel_t color, HsvColor *hsv);
void Hsv2Rgb(HsvColor *hsv, RgbColor *rgb);
void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv);
void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected = false, bool marked = false, bool switch_background = false);
#endif