mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsPicture: fix icon size/scale handling
This commit is contained in:
@@ -113,22 +113,23 @@ void CComponentsPicture::initCCItem()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle size
|
//check for path or name, set icon or image with full path, has no path, then use as icon and disble scale mode
|
||||||
int w_pic = width;
|
|
||||||
int h_pic = height;
|
|
||||||
|
|
||||||
//check for path or name, set icon or image with full path
|
|
||||||
string::size_type pos = pic_name.find("/", 0);
|
string::size_type pos = pic_name.find("/", 0);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
do_scale = false;
|
do_scale = false;
|
||||||
|
|
||||||
if (!do_scale || (w_pic == 0 || w_pic == 0)){
|
//initial internal size
|
||||||
if (!pic_name.empty())
|
int w_pic = width;
|
||||||
frameBuffer->getIconSize(pic_name.c_str(), &width, &height);
|
int h_pic = height;
|
||||||
}else{
|
|
||||||
g_PicViewer->getSize(pic_name.c_str(), &w_pic, &h_pic);
|
if (!do_scale){
|
||||||
if (width != w_pic || height != h_pic)
|
//use image/icon size as object dimension values
|
||||||
g_PicViewer->rescaleImageDimensions(&w_pic, &h_pic, width, height);
|
frameBuffer->getIconSize(pic_name.c_str(), &width, &height);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//if initialized dimension values = 0, set current object dimension values to real image size otherwise use defined size
|
||||||
|
g_PicViewer->getSize(pic_name.c_str(), (width == 0 ? &width : &w_pic), (height == 0 ? &height : &h_pic));
|
||||||
|
g_PicViewer->rescaleImageDimensions(&w_pic, &h_pic, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,17 +235,18 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p
|
|||||||
|
|
||||||
void CComponentsChannelLogo::init(const uint64_t& channelId, const std::string& channelName, bool allow_scale)
|
void CComponentsChannelLogo::init(const uint64_t& channelId, const std::string& channelName, bool allow_scale)
|
||||||
{
|
{
|
||||||
|
alt_pic_name = "";
|
||||||
setChannel(channelId, channelName);
|
setChannel(channelId, channelName);
|
||||||
do_scale = allow_scale;
|
do_scale = allow_scale;
|
||||||
alt_pic_name = "";
|
|
||||||
}
|
}
|
||||||
void CComponentsChannelLogo::setAltLogo(const std::string& picture_name)
|
void CComponentsChannelLogo::setAltLogo(const std::string& picture_name)
|
||||||
{
|
{
|
||||||
alt_pic_name = picture_name;
|
alt_pic_name = picture_name;
|
||||||
channel_id = 0;
|
channel_id = 0;
|
||||||
channel_name = "";
|
channel_name = "";
|
||||||
has_logo = true;
|
has_logo = !alt_pic_name.empty();
|
||||||
initCCItem();
|
if (has_logo)
|
||||||
|
initCCItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsChannelLogo::setAltLogo(const char* picture_name)
|
void CComponentsChannelLogo::setAltLogo(const char* picture_name)
|
||||||
@@ -263,9 +265,18 @@ void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::st
|
|||||||
|
|
||||||
has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, pic_name, &dummy, &dummy);
|
has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, pic_name, &dummy, &dummy);
|
||||||
|
|
||||||
if (!has_logo)
|
if (!has_logo)//no logo was found, use altrenate icon or logo
|
||||||
pic_name = alt_pic_name;
|
pic_name = alt_pic_name;
|
||||||
|
|
||||||
|
//if logo or alternate image still not available, set has logo to false
|
||||||
|
has_logo = !pic_name.empty();
|
||||||
|
|
||||||
|
//refresh object
|
||||||
initCCItem();
|
initCCItem();
|
||||||
|
|
||||||
|
//set has_logo to false if no dimensions were detected
|
||||||
|
if (width && height)
|
||||||
|
has_logo = true;
|
||||||
|
|
||||||
doPaintBg(false);
|
doPaintBg(false);
|
||||||
}
|
}
|
||||||
|
@@ -86,7 +86,7 @@ class CComponentsPicture : public CComponentsItem
|
|||||||
void SetTransparent(int t){ image_transparent = t; }
|
void SetTransparent(int t){ image_transparent = t; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///constructor for image objects, use this for scaled images, scaling dimensions are defined with parameters w (width) and h (height)
|
///constructor for image objects, use this for scaled images, scaling dimensions are defined with parameters w (width) and h (height), only values >0 causes scale of image
|
||||||
CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
|
CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
|
||||||
const std::string& image_name,
|
const std::string& image_name,
|
||||||
CComponentsForm *parent = NULL,
|
CComponentsForm *parent = NULL,
|
||||||
@@ -118,7 +118,14 @@ class CComponentsPicture : public CComponentsItem
|
|||||||
///return height of component
|
///return height of component
|
||||||
virtual int getHeight();
|
virtual int getHeight();
|
||||||
|
|
||||||
virtual void doScale(bool scale = true){do_scale = scale;}
|
///set width of object and image, value >0 causes scale of image
|
||||||
|
virtual void setWidth(const int& w){CComponentsItem::setWidth(w), do_scale = true; initCCItem();}
|
||||||
|
///set height of object and image, value >0 causes scale of image
|
||||||
|
virtual void setHeight(const int& h){CComponentsItem::setHeight(h), do_scale = true; initCCItem();}
|
||||||
|
///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();}
|
||||||
|
///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();}
|
||||||
|
|
||||||
///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself.
|
///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;};
|
virtual inline bool isPicPainted(){return is_image_painted;};
|
||||||
|
Reference in New Issue
Block a user