From 581405e07625ad8fbfe66d59a244f0c5490a77cd Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 20 Sep 2014 21:34:58 +0200 Subject: [PATCH] CComponentsItem: move initBodyGradient() into base class This provides functinality for all sub classes too --- src/gui/components/cc_base.h | 3 +++ src/gui/components/cc_frm_header.cpp | 15 --------------- src/gui/components/cc_frm_header.h | 2 -- src/gui/components/cc_item.cpp | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index cfbaa7873..5bfe1c46d 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -336,6 +336,9 @@ class CComponentsItem : public CComponents virtual void setHeightP(const uint8_t& h_percent); ///set item width, parameter as uint8_t, as percent value related to current width of parent form or screen virtual void setWidthP(const uint8_t& w_percent); + + ///sub: init body color gradient + virtual void initBodyGradient(); }; #endif diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 4d8c37886..7530a5e00 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -389,17 +389,6 @@ void CComponentsHeader::initCaption() } } -void CComponentsHeader::initGradient() -{ - if (cc_gradientBuf == NULL) { - CColorGradient ccGradient; - cc_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, height, CColorGradient::gradientLight2Dark, CColorGradient::light); - } - cc_gradientData.gradientBuf = cc_gradientBuf; - cc_gradientData.direction = CFrameBuffer::gradientVertical; - cc_gradientData.mode = CFrameBuffer::pbrg_noOption; -} - void CComponentsHeader::initCCItems() { //set size @@ -413,10 +402,6 @@ void CComponentsHeader::initCCItems() //init text initCaption(); - - //init color gradient - if (col_body_gradient) - initGradient(); } void CComponentsHeader::paint(bool do_save_bg) diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 33b66b31e..a55154660 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -93,8 +93,6 @@ class CComponentsHeader : public CComponentsForm void initCaption(); ///sub: init context button object void initButtons(); - ///sub: init color gradient - void initGradient(); public: enum diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 03a6a5132..8fbf2c5d3 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -67,6 +67,10 @@ void CComponentsItem::initParent(CComponentsForm* parent) // If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this! void CComponentsItem::paintInit(bool do_save_bg) { + //init color gradient + if (col_body_gradient) + initBodyGradient(); + clearFbData(); int th = fr_thickness; @@ -230,3 +234,14 @@ void CComponentsItem::setFocus(bool focus) } cc_has_focus = focus; } + +void CComponentsItem::initBodyGradient() +{ + if (cc_gradientBuf == NULL) { + CColorGradient ccGradient; + cc_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, height, CColorGradient::gradientLight2Dark, CColorGradient::light); + } + cc_gradientData.gradientBuf = cc_gradientBuf; + cc_gradientData.direction = CFrameBuffer::gradientVertical; + cc_gradientData.mode = CFrameBuffer::pbrg_noOption; +}