diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index e012ad346..e3d188fef 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -533,7 +533,7 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string& } return false; } - +#if 0 bool CPictureViewer::DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height) { char fname[255]; @@ -558,7 +558,7 @@ bool CPictureViewer::DisplayLogo (uint64_t channel_id, int posx, int posy, int w } return ret; } - +#endif void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int max_width, const int max_height, bool upscale) { float aspect; diff --git a/src/driver/pictureviewer/pictureviewer.h b/src/driver/pictureviewer/pictureviewer.h index 8a126834d..0c6550160 100644 --- a/src/driver/pictureviewer/pictureviewer.h +++ b/src/driver/pictureviewer/pictureviewer.h @@ -64,8 +64,8 @@ class CPictureViewer void SetVisible(int startx, int endx, int starty, int endy); static double m_aspect_ratio_correction; bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); - bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height); - bool GetLogoName(const uint64_t& channel_id, const std::string& ChanName, std::string & name, int *width = NULL, int *height = NULL); +// bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height); + virtual bool GetLogoName(const uint64_t& channel_id, const std::string& ChanName, std::string & name, int *width = NULL, int *height = NULL); fb_pixel_t * getImage (const std::string & name, int width, int height); fb_pixel_t * getIcon (const std::string & name, int *width, int *height); void getSize(const char *name, int* width, int *height); diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 3243247ab..6ccc94de6 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -206,3 +206,58 @@ void CComponentsPicture::hide(bool no_restore) hideCCItem(no_restore); pic_painted = false; } + + +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, + 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, + color_frame, color_background, color_shadow) +{ + channel_id = channelId; + channel_name = channelName; + initVarPictureChannellLogo(); +} + +void CComponentsChannelLogo::setPicture(const std::string& picture_name) +{ + pic_name = picture_name; + channel_id = 0; + channel_name = ""; + initVarPictureChannellLogo(); +} + +void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::string& channelName) +{ + channel_id = channelId; + channel_name = channelName; + initVarPictureChannellLogo(); +} + +void CComponentsChannelLogo::initVarPictureChannellLogo() +{ + string tmp_logo = pic_name; + has_logo = false; + + if (!(channel_id == 0 && channel_name.empty() && pic_name.empty())) + has_logo = GetLogoName(channel_id, channel_name, pic_name, &pic_width, &pic_height); + + if (!has_logo) + pic_name = tmp_logo; + +// #ifdef DEBUG_CC + printf(" [CComponentsChannelLogo] %s: init image: %s (has_logo=%d, channel_id=%lld)\n", __FUNCTION__, pic_name.c_str(), has_logo, channel_id); +// #endif + + initVarPicture(); +} + +void CComponentsChannelLogo::paint(bool do_save_bg) +{ + initVarPictureChannellLogo(); + paintInit(do_save_bg); + paintPicture(); + has_logo = false; //reset +} diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index a70534898..2b74c1709 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -89,4 +89,27 @@ class CComponentsPicture : public CComponentsItem virtual void setMaxHeight(const int h_max){pic_max_h = h_max;}; }; +class CComponentsChannelLogo : public CComponentsPicture, CPictureViewer +{ + protected: + ///initialize all required attributes + void initVarPictureChannellLogo(); + + private: + uint64_t channel_id; + std::string channel_name; + 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); + + void setChannel(const uint64_t& channelId, const std::string& channelName); + void setPicture(const std::string& picture_name); + bool hasLogo(){return has_logo;}; + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + #endif