CComponents: add setColBodyGradient() to set gradient properties

This provides possibility to set relevant gradiant properties in cc sub classes
This commit is contained in:
2014-09-20 21:35:02 +02:00
committed by [CST] Focus
parent 581405e076
commit f9147d185a
6 changed files with 28 additions and 10 deletions

View File

@@ -33,7 +33,7 @@ class CColorGradient
inline uint8_t limitChar(int c); inline uint8_t limitChar(int c);
public: public:
///gradient mode
enum { enum {
gradientDark2Light, gradientDark2Light,
gradientLight2Dark, gradientLight2Dark,
@@ -41,6 +41,7 @@ class CColorGradient
gradientLight2Dark2Light gradientLight2Dark2Light
}; };
///intensity
enum { enum {
light, light,
normal normal

View File

@@ -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); bool calcCorners(int *ofs, int *ofl, int *ofr, const int& dy, const int& line, const int& radius, const int& type);
public: public:
///gradient direction
enum { enum {
gradientHorizontal, gradientHorizontal,
gradientVertical gradientVertical

View File

@@ -64,7 +64,7 @@ CComponents::CComponents() : COSDFader(g_settings.theme.menu_Content_alpha)
frameBuffer = CFrameBuffer::getInstance(); frameBuffer = CFrameBuffer::getInstance();
v_fbdata.clear(); v_fbdata.clear();
saved_screen.pixbuf = NULL; saved_screen.pixbuf = NULL;
cc_gradientBuf = NULL; cc_body_gradientBuf = NULL;
col_body_gradient = false; col_body_gradient = false;
} }
@@ -73,6 +73,8 @@ CComponents::~CComponents()
hide(); hide();
clearSavedScreen(); clearSavedScreen();
clearFbData(); clearFbData();
if (cc_body_gradientBuf)
free(cc_body_gradientBuf);
} }
void CComponents::clearSavedScreen() void CComponents::clearSavedScreen()

View File

@@ -34,6 +34,7 @@
#include <driver/pictureviewer/pictureviewer.h> #include <driver/pictureviewer/pictureviewer.h>
#include <gui/widget/icons.h> #include <gui/widget/icons.h>
#include <driver/fade.h> #include <driver/fade.h>
#include <driver/colorgradient.h>
/// Basic component class. /// Basic component class.
/*! /*!
Basic attributes and member functions for component sub classes 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 ///property: contains data for gradiant handling
gradientData_t cc_gradientData; gradientData_t cc_gradientData;
///gradiant pixel buffer ///gradiant pixel buffer
fb_pixel_t *cc_gradientBuf; fb_pixel_t *cc_body_gradientBuf;
///property: true component can paint gradient, see also enableColBodyGradient() ///property: true component can paint gradient, see also enableColBodyGradient()
bool col_body_gradient; 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 ///property: true=component has shadow
bool 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;}; 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 ///set color gradient on/off
virtual void enableColBodyGradient(bool do_paint_gradient); 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 ///get frame color
inline virtual fb_pixel_t getColorFrame(){return col_frame;}; inline virtual fb_pixel_t getColorFrame(){return col_frame;};

View File

@@ -99,6 +99,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
col_shadow = color_shadow; col_shadow = color_shadow;
col_body = COL_MENUHEAD_PLUS_0; col_body = COL_MENUHEAD_PLUS_0;
col_body_gradient = g_settings.gradiant; col_body_gradient = g_settings.gradiant;
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
cch_text = caption; cch_text = caption;
cch_icon_name = icon_name; cch_icon_name = icon_name;
@@ -126,8 +127,6 @@ CComponentsHeader::~CComponentsHeader()
{ {
dprintf(DEBUG_DEBUG, "[~CComponentsHeader] [%s - %d] delete...\n", __func__, __LINE__); dprintf(DEBUG_DEBUG, "[~CComponentsHeader] [%s - %d] delete...\n", __func__, __LINE__);
v_cch_btn.clear(); v_cch_btn.clear();
if (cc_gradientBuf)
free(cc_gradientBuf);
} }
void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode) void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode)

View File

@@ -52,6 +52,9 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent)
cc_page_number = 0; cc_page_number = 0;
cc_has_focus = true; cc_has_focus = true;
cc_gradientData.gradientBuf = NULL; cc_gradientData.gradientBuf = NULL;
cc_body_gradient_mode = CColorGradient::gradientLight2Dark;
cc_body_gradient_intensity = CColorGradient::light;
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
initParent(parent); initParent(parent);
} }
@@ -237,11 +240,12 @@ void CComponentsItem::setFocus(bool focus)
void CComponentsItem::initBodyGradient() void CComponentsItem::initBodyGradient()
{ {
if (cc_gradientBuf == NULL) { if (cc_body_gradientBuf == NULL) {
CColorGradient ccGradient; 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.gradientBuf = cc_body_gradientBuf;
cc_gradientData.direction = CFrameBuffer::gradientVertical; cc_gradientData.direction = cc_body_gradient_direction;
cc_gradientData.mode = CFrameBuffer::pbrg_noOption; cc_gradientData.mode = CFrameBuffer::pbrg_noOption;
} }