mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 15:02:56 +02:00
add support for svg header icons
Signed-off-by: Thilo Graf <dbt@novatux.de> The CComponentsPicture class is currently being refactored. It's almost done, but various adjustments and tests are still missing, to identifying side effects on other objects. It will be strongly simplified and will support svg feature. Perhaps, an implementation of this kind in the header class is not required.
This commit is contained in:
@@ -251,7 +251,12 @@ void CComponentsHeader::setIcon(const char* icon_name)
|
||||
void CComponentsHeader::setIcon(const std::string& icon_name)
|
||||
{
|
||||
cch_icon_name = icon_name;
|
||||
initIcon();
|
||||
std::string fullpath_icon_name = frameBuffer->getIconPath(cch_icon_name);
|
||||
|
||||
if (fullpath_icon_name.find(".svg") == (fullpath_icon_name.length() - 4))
|
||||
initIconSVG();
|
||||
else
|
||||
initIcon();
|
||||
}
|
||||
|
||||
void CComponentsHeader::initIcon()
|
||||
@@ -265,6 +270,10 @@ void CComponentsHeader::initIcon()
|
||||
}
|
||||
return;
|
||||
}
|
||||
std::string fullpath_icon_name = frameBuffer->getIconPath(cch_icon_name);
|
||||
|
||||
if (fullpath_icon_name.find(".svg") == (fullpath_icon_name.length() - 4))
|
||||
return;
|
||||
|
||||
//create instance for cch_icon_obj and add to container at once
|
||||
if (cch_icon_obj == NULL){
|
||||
@@ -301,6 +310,51 @@ void CComponentsHeader::initIcon()
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsHeader::initIconSVG()
|
||||
{
|
||||
//init cch_icon_obj only if an icon available
|
||||
if (cch_icon_name.empty()) {
|
||||
cch_icon_w = 0;
|
||||
if (cch_icon_obj){
|
||||
removeCCItem(cch_icon_obj);
|
||||
cch_icon_obj = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::string fullpath_icon_name = frameBuffer->getIconPath(cch_icon_name, "svg");
|
||||
|
||||
if (!(fullpath_icon_name.find(".svg") == (fullpath_icon_name.length() - 4)))
|
||||
return;
|
||||
|
||||
cch_icon_name = fullpath_icon_name;
|
||||
|
||||
//create instance for cch_icon_obj and add to container at once
|
||||
if (cch_icon_obj == NULL){
|
||||
dprintf(DEBUG_DEBUG, "[CComponentsHeader]\n [%s - %d] init header svg icon: %s\n", __func__, __LINE__, cch_icon_name.c_str());
|
||||
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name, this);
|
||||
}
|
||||
|
||||
//set properties for icon object
|
||||
if (cch_icon_obj){
|
||||
cch_icon_obj->setPicture(cch_icon_name);
|
||||
//get dimensions of header icon
|
||||
dprintf(DEBUG_INFO, "[CComponentsHeader]\n [%s - %d] init svg icon size: height = %d\n", __func__, __LINE__, height);
|
||||
cch_icon_obj->setHeight(height - OFFSET_INNER_SMALL,true);
|
||||
cch_icon_obj->doPaintBg(false);
|
||||
|
||||
//set corner mode of icon item
|
||||
int cc_icon_corner_type = CORNER_LEFT;
|
||||
if (corner_type & CORNER_TOP_LEFT || corner_type & CORNER_TOP)
|
||||
cc_icon_corner_type = CORNER_TOP_LEFT;
|
||||
|
||||
cch_icon_obj->setCorner(corner_rad-fr_thickness, cc_icon_corner_type);
|
||||
|
||||
//global set width of icon object
|
||||
cch_icon_w = cch_icon_obj->getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsHeader::initLogo()
|
||||
{
|
||||
// init logo with required height and logo
|
||||
@@ -710,6 +764,9 @@ void CComponentsHeader::initCCItems()
|
||||
|
||||
//init logo
|
||||
initLogo();
|
||||
|
||||
//init svg icon
|
||||
initIconSVG();
|
||||
}
|
||||
|
||||
void CComponentsHeader::paint(const bool &do_save_bg)
|
||||
|
@@ -151,6 +151,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
||||
void initSizeMode();
|
||||
///sub: init icon object
|
||||
void initIcon();
|
||||
///sub: init svg icon object
|
||||
void initIconSVG();
|
||||
///sub: init caption object
|
||||
void initCaption();
|
||||
///sub: init context button object
|
||||
|
Reference in New Issue
Block a user