From 844a58db7234e1bb2ea6bfbd086f6e1702be022c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 19 Oct 2016 10:06:35 +0200 Subject: [PATCH] color: add getItemColors function to simplify color handling Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/56126c6a61144bdbc33e891f518830171b61fa45 Author: vanhofen Date: 2016-10-19 (Wed, 19 Oct 2016) Origin message was: ------------------ - color: add getItemColors function to simplify color handling --- src/gui/color.cpp | 28 ++++++++++++++++++++++++++++ src/gui/color.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/gui/color.cpp b/src/gui/color.cpp index 4b632f3d3..07f0bda01 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -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; +} diff --git a/src/gui/color.h b/src/gui/color.h index e707c4318..61305ca4e 100644 --- a/src/gui/color.h +++ b/src/gui/color.h @@ -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