CComponentsPicture: rework constructors, clean ups

This commit is contained in:
2014-02-03 09:41:40 +01:00
parent 718824015a
commit 34fcdec276
2 changed files with 56 additions and 47 deletions

View File

@@ -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();
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)

View File

@@ -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
{
@@ -63,17 +60,28 @@ class CComponentsPicture : public CComponentsItem
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;};
@@ -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);