add support for svg header icons

Origin commit data
------------------
Branch: ni/coolstream
Commit: 6645f2dc21
Author: TangoCash <eric@loxat.de>
Date: 2021-11-05 (Fri, 05 Nov 2021)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2021-11-05 11:25:19 +01:00
committed by vanhofen
parent 7dd441474f
commit 71d21a7e21
2 changed files with 60 additions and 1 deletions

View File

@@ -251,7 +251,12 @@ void CComponentsHeader::setIcon(const char* icon_name)
void CComponentsHeader::setIcon(const std::string& icon_name) void CComponentsHeader::setIcon(const std::string& icon_name)
{ {
cch_icon_name = 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() void CComponentsHeader::initIcon()
@@ -265,6 +270,10 @@ void CComponentsHeader::initIcon()
} }
return; 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 //create instance for cch_icon_obj and add to container at once
if (cch_icon_obj == NULL){ 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() void CComponentsHeader::initLogo()
{ {
// init logo with required height and logo // init logo with required height and logo
@@ -710,6 +764,9 @@ void CComponentsHeader::initCCItems()
//init logo //init logo
initLogo(); initLogo();
//init svg icon
initIconSVG();
} }
void CComponentsHeader::paint(const bool &do_save_bg) void CComponentsHeader::paint(const bool &do_save_bg)

View File

@@ -151,6 +151,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
void initSizeMode(); void initSizeMode();
///sub: init icon object ///sub: init icon object
void initIcon(); void initIcon();
///sub: init svg icon object
void initIconSVG();
///sub: init caption object ///sub: init caption object
void initCaption(); void initCaption();
///sub: init context button object ///sub: init context button object