diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 99f41624e..d1a109b0a 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -40,26 +40,32 @@ using namespace std; //------------------------------------------------------------------------------------------------------- //sub class CComponentsPicture from CComponentsItem -CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h, - const std::string& image_name, const int alignment, bool has_shadow, +CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h, + const std::string& image_name, const int &alignment, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) { - init(x_pos, y_pos, image_name, alignment, has_shadow, color_frame, color_background, color_shadow); - - width = w; - height = h; - pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO, - - initVarPicture(); + init(x_pos, y_pos, w, h, image_name, alignment, has_shadow, color_frame, color_background, color_shadow); } -void CComponentsPicture::init( int x_pos, int y_pos, const string& image_name, const int alignment, bool has_shadow, +void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, const int &h, const string& image_name, const int &alignment, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) { //CComponents, CComponentsItem cc_item_type = CC_ITEMTYPE_PICTURE; + //CComponents + x = pic_x = x_pos; + y = pic_y = y_pos; + height = h; + width = w; + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_background; + col_shadow = color_shadow; + //CComponentsPicture + pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO, pic_name = image_name; pic_align = alignment; pic_offset = 1; @@ -72,33 +78,24 @@ void CComponentsPicture::init( int x_pos, int y_pos, const string& image_name, c if (pic_name.empty()) pic_width = pic_height = 0; - //CComponents - x = pic_x = x_pos; - y = pic_y = y_pos; - height = 0; - width = 0; - shadow = has_shadow; - shadow_w = SHADOW_OFFSET; - col_frame = color_frame; - col_body = color_background; - col_shadow = color_shadow; + initCCItem(); } void CComponentsPicture::setPicture(const std::string& picture_name) { pic_name = picture_name; - initVarPicture(); + initCCItem(); } void CComponentsPicture::setPictureAlign(const int alignment) { - pic_align = alignment; - initVarPicture(); + pic_align = alignment; + initCCItem(); } -void CComponentsPicture::initVarPicture() +void CComponentsPicture::initCCItem() { pic_width = pic_height = 0; pic_painted = false; @@ -195,7 +192,7 @@ void CComponentsPicture::paintPicture() void CComponentsPicture::paint(bool do_save_bg) { - initVarPicture(); + initCCItem(); paintInit(do_save_bg); paintPicture(); } @@ -207,9 +204,9 @@ void CComponentsPicture::hide(bool no_restore) } -CComponentsChannelLogo::CComponentsChannelLogo( const int x_pos, const int y_pos, const int w, const int h, +CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h, const uint64_t& channelId, const std::string& channelName, - const int alignment, bool has_shadow, + const int &alignment, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) :CComponentsPicture(x_pos, y_pos, w, h, "", alignment, has_shadow, @@ -246,11 +243,11 @@ void CComponentsChannelLogo::initVarPictureChannellLogo() if (!has_logo) pic_name = tmp_logo; -// #ifdef DEBUG_CC +#ifdef DEBUG_CC printf("\t[CComponentsChannelLogo] %s: init image: %s (has_logo=%d, channel_id=%" PRIu64 ")\n", __func__, pic_name.c_str(), has_logo, channel_id); -// #endif +#endif - initVarPicture(); + initCCItem(); } void CComponentsChannelLogo::paint(bool do_save_bg) diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index dd45ec449..0b2710be9 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -43,9 +43,6 @@ Picture is usable like each other CCItems. class CComponentsPicture : public CComponentsItem { protected: - ///initialize all required attributes - void initVarPicture(); - ///some internal modes for icon and image handling enum { @@ -62,25 +59,36 @@ class CComponentsPicture : public CComponentsItem bool pic_paint, pic_paintBg, pic_painted, do_paint; int pic_align, pic_x, pic_y, pic_width, pic_height; int pic_max_w, pic_max_h, pic_paint_mode; - - void init( const int x_pos, const int y_pos, const std::string& image_name, const int alignment, bool has_shadow, - fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow); - + + void init( const int &x_pos, const int &y_pos, const int &w, const int &h, + const std::string& image_name, + const int &alignment, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_background, + fb_pixel_t color_shadow); + + ///initialize all required attributes + void initCCItem(); ///initialize position of picture object dependendly from settings void initPosition(); void paintPicture(); - + public: - CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h, - const std::string& image_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - + CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h, + const std::string& image_name, + const int &alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_background = 0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;}; virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;}; virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;}; virtual void setPicture(const std::string& picture_name); virtual void setPictureAlign(const int alignment); - + virtual inline bool isPicPainted(){return pic_painted;}; virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); virtual void hide(bool no_restore = false); @@ -101,10 +109,14 @@ class CComponentsChannelLogo : public CComponentsPicture, CPictureViewer bool has_logo; public: - CComponentsChannelLogo( const int x_pos, const int y_pos, const int w, const int h, - const uint64_t& channelId =0, const std::string& channelName = "", - const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h, + const uint64_t& channelId =0, + const std::string& channelName = "", + const int &alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_background = 0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); void setChannel(const uint64_t& channelId, const std::string& channelName); void setPicture(const std::string& picture_name);