CComponentsPicture: try to rework init behavior inside object

need_init var shoul help to avoid not required inits.
Size of cached image are packed into own vars, should avoid possible
overwriting with current dimensions.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 93777853f0
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-02-05 (Fri, 05 Feb 2016)



------------------
This commit was generated by Migit
This commit is contained in:
2016-02-05 08:58:32 +01:00
parent 710ab7186b
commit 00b19ad88a
2 changed files with 42 additions and 13 deletions

View File

@@ -58,6 +58,9 @@ class CComponentsPicture : public CComponentsItem
///current original image dimensions
int dx, dy;
///cached image dimensions
int dxc, dyc;
///property: name of image (without extensionn) full path to image (with extension), icon names to find in /widget/icons.h, icons will paint never scaled
std::string pic_name, pic_name_old;
@@ -75,6 +78,8 @@ class CComponentsPicture : public CComponentsItem
///sets internal option for keeping aspect, see also setHeight(), setWidth(), default value = false
bool keep_dx_aspect;
bool keep_dy_aspect;
///helper: indicate for reinit
bool need_init;
void init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
@@ -151,9 +156,9 @@ class CComponentsPicture : public CComponentsItem
///set height of object and image, value >0 causes scale of image, parameter keep_aspect = true causes scaling of width with same aspect, , default = false
virtual void setHeight(const int& h, bool keep_aspect = false);
///set width of object and image related to current screen size, see also CComponentsItem::setWidthP(), parameter as uint8_t
virtual void setWidthP(const uint8_t& w_percent){CComponentsItem::setWidthP(w_percent), do_scale = true; initCCItem();}
virtual void setWidthP(const uint8_t& w_percent){CComponentsItem::setWidthP(w_percent), do_scale = true; need_init = hasChanges(); initCCItem();}
///set height of object and image related to current screen size, see also CComponentsItem::setHeightP(), parameter as uint8_t
virtual void setHeightP(const uint8_t& h_percent){CComponentsItem::setHeightP(h_percent), do_scale = true; initCCItem();}
virtual void setHeightP(const uint8_t& h_percent){CComponentsItem::setHeightP(h_percent), do_scale = true; need_init = hasChanges(); initCCItem();}
///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself.
virtual inline bool isPicPainted(){return is_image_painted;};
@@ -249,6 +254,7 @@ class CComponentsChannelLogo : public CComponentsPicture
///set channel id and/or channel name, NOTE: channel name is prefered
void setChannel(const uint64_t& channelId, const std::string& channelName);
uint64_t getChannelID(){return channel_id;}
///set an alternate logo if no logo is available NOTE: value of has_logo will set to true
void setAltLogo(const std::string& picture_name);