diff --git a/src/driver/colorgradient.h b/src/driver/colorgradient.h index 5f6473776..51d7de79e 100644 --- a/src/driver/colorgradient.h +++ b/src/driver/colorgradient.h @@ -33,7 +33,7 @@ class CColorGradient inline uint8_t limitChar(int c); public: - + ///gradient mode enum { gradientDark2Light, gradientLight2Dark, @@ -41,6 +41,7 @@ class CColorGradient gradientLight2Dark2Light }; + ///intensity enum { light, normal diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index 5fdacb8b7..2449f72a2 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -148,7 +148,7 @@ class CFrameBuffer bool calcCorners(int *ofs, int *ofl, int *ofr, const int& dy, const int& line, const int& radius, const int& type); public: - + ///gradient direction enum { gradientHorizontal, gradientVertical diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index 37548d4ba..a75413c8a 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -64,7 +64,7 @@ CComponents::CComponents() : COSDFader(g_settings.theme.menu_Content_alpha) frameBuffer = CFrameBuffer::getInstance(); v_fbdata.clear(); saved_screen.pixbuf = NULL; - cc_gradientBuf = NULL; + cc_body_gradientBuf = NULL; col_body_gradient = false; } @@ -73,6 +73,8 @@ CComponents::~CComponents() hide(); clearSavedScreen(); clearFbData(); + if (cc_body_gradientBuf) + free(cc_body_gradientBuf); } void CComponents::clearSavedScreen() diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 5bfe1c46d..d884198ec 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -34,6 +34,7 @@ #include #include #include +#include /// Basic component class. /*! Basic attributes and member functions for component sub classes @@ -81,9 +82,15 @@ class CComponents : public CComponentsSignals, public COSDFader ///property: contains data for gradiant handling gradientData_t cc_gradientData; ///gradiant pixel buffer - fb_pixel_t *cc_gradientBuf; + fb_pixel_t *cc_body_gradientBuf; ///property: true component can paint gradient, see also enableColBodyGradient() bool col_body_gradient; + ///property: background gradient mode + int cc_body_gradient_mode; + ///property: background gradient intensity + int cc_body_gradient_intensity; + ///property: background gradient direction + int cc_body_gradient_direction; ///property: true=component has shadow bool shadow; @@ -188,6 +195,11 @@ class CComponents : public CComponentsSignals, public COSDFader inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;}; ///set color gradient on/off virtual void enableColBodyGradient(bool do_paint_gradient); + ///set color gradient properties, possible parameter values for mode and intensity to find in CColorGradient, in driver/framebuffer.h> + virtual void setColBodyGradient(const int& mode, const int& direction, const int& intensity = CColorGradient::normal) + { cc_body_gradient_mode = mode; + cc_body_gradient_direction = direction; + cc_body_gradient_intensity=intensity;}; ///get frame color inline virtual fb_pixel_t getColorFrame(){return col_frame;}; diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 7530a5e00..039e72a9d 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -99,6 +99,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const col_shadow = color_shadow; col_body = COL_MENUHEAD_PLUS_0; col_body_gradient = g_settings.gradiant; + cc_body_gradient_direction = CFrameBuffer::gradientVertical; cch_text = caption; cch_icon_name = icon_name; @@ -126,8 +127,6 @@ CComponentsHeader::~CComponentsHeader() { dprintf(DEBUG_DEBUG, "[~CComponentsHeader] [%s - %d] delete...\n", __func__, __LINE__); v_cch_btn.clear(); - if (cc_gradientBuf) - free(cc_gradientBuf); } void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode) diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 8fbf2c5d3..4f594984c 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -52,6 +52,9 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent) cc_page_number = 0; cc_has_focus = true; cc_gradientData.gradientBuf = NULL; + cc_body_gradient_mode = CColorGradient::gradientLight2Dark; + cc_body_gradient_intensity = CColorGradient::light; + cc_body_gradient_direction = CFrameBuffer::gradientVertical; initParent(parent); } @@ -237,11 +240,12 @@ void CComponentsItem::setFocus(bool focus) void CComponentsItem::initBodyGradient() { - if (cc_gradientBuf == NULL) { + if (cc_body_gradientBuf == NULL) { CColorGradient ccGradient; - cc_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, height, CColorGradient::gradientLight2Dark, CColorGradient::light); + int gsize = cc_body_gradient_direction == CFrameBuffer::gradientVertical ? height : width; + cc_body_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity); } - cc_gradientData.gradientBuf = cc_gradientBuf; - cc_gradientData.direction = CFrameBuffer::gradientVertical; + cc_gradientData.gradientBuf = cc_body_gradientBuf; + cc_gradientData.direction = cc_body_gradient_direction; cc_gradientData.mode = CFrameBuffer::pbrg_noOption; }