implement progressbar into cc_frm_header

This commit is contained in:
TangoCash
2022-04-30 16:31:45 +02:00
committed by Thilo Graf
parent cd076c5f14
commit a0590147c0
2 changed files with 103 additions and 2 deletions

View File

@@ -152,6 +152,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
cch_btn_obj = NULL; cch_btn_obj = NULL;
cch_cl_obj = NULL; cch_cl_obj = NULL;
cch_logo_obj = NULL; cch_logo_obj = NULL;
cch_pb_obj = NULL;
cch_logo.Id = 0; cch_logo.Id = 0;
cch_logo.Name = ""; cch_logo.Name = "";
cch_logo.dy_max = -1; cch_logo.dy_max = -1;
@@ -171,6 +172,11 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
cch_cl_sec_format = cch_cl_format; cch_cl_sec_format = cch_cl_format;
cch_cl_enable_run = false; cch_cl_enable_run = false;
cch_pb_x = cch_offset;
cch_pb_w = 100;
cch_pb_percent = 0;
cch_pb_enable = false;
addContextButton(buttons); addContextButton(buttons);
initCCItems(); initCCItems();
initParent(parent); initParent(parent);
@@ -317,14 +323,16 @@ void CComponentsHeader::initLogo()
*/ */
if (next_item) if (next_item)
{ {
if (next_item->getItemType() == CC_ITEMTYPE_FRM_ICONFORM) if (next_item->getItemType() == CC_ITEMTYPE_FRM_CLOCK)
{ {
/* /*
* Either clock is present or buttons are enabled, * Either clock is present or buttons are enabled,
* different order of objects are required, not optimal * different order of objects are required, not optimal
* but works at the moment. * but works at the moment.
*/ */
if (cch_cl_obj) if (cch_pb_obj)
next_item = cch_pb_obj;
else if (cch_cl_obj)
next_item = cch_cl_obj; next_item = cch_cl_obj;
else else
next_item = cch_btn_obj; next_item = cch_btn_obj;
@@ -393,6 +401,71 @@ void CComponentsHeader::initLogo()
} }
} }
void CComponentsHeader::initProgressBar()
{
//exit here if progressbar was disabled
if (!cch_pb_enable){
if (cch_pb_obj){
removeCCItem(cch_pb_obj);
cch_pb_obj = NULL;
}
return;
}
//create instance for header progressbar object and add to container
if (cch_pb_obj == NULL){
dprintf(DEBUG_DEBUG, "[CComponentsHeader]\n [%s - %d] init progressbar...\n", __func__, __LINE__);
cch_pb_obj = new CProgressBar(cch_pb_x, cch_items_y, cch_pb_w, height/2, col_frame, col_body_std, col_shadow, COL_PROGRESSBAR_ACTIVE_PLUS_0, COL_PROGRESSBAR_PASSIVE_PLUS_0, 40, 100, 70, this);
cch_pb_obj->setType(CProgressBar::PB_REDRIGHT);
}
CComponentsItem *next_item;
if (cch_cl_obj)
next_item = cch_cl_obj;
else
next_item = cch_btn_obj;
cch_pb_x = next_item ? next_item->getXPos() - cch_pb_obj->getWidth() - cch_offset : width - cch_pb_obj->getWidth() - cch_offset;
cch_pb_obj->setXPos(cch_pb_x);
cch_pb_w = cch_pb_obj->getWidth();
}
void CComponentsHeader::enableProgessBar(int percent)
{
cch_pb_enable = true;
cch_pb_percent = percent;
initCCItems();
if (cch_pb_obj){
cch_pb_obj->setValues(percent, 100);
}
}
void CComponentsHeader::setProgessBar(int percent)
{
cch_pb_percent = percent;
if (cch_pb_obj){
cch_pb_obj->setValues(percent, 100);
}
}
void CComponentsHeader::disableProgessBar()
{
cch_pb_enable = false;
if (!cch_pb_enable){
if (cch_pb_obj){
removeCCItem(cch_pb_obj);
cch_pb_obj = NULL;
}
}
initCCItems();
}
void CComponentsHeader::addContextButton(const std::string& icon_name) void CComponentsHeader::addContextButton(const std::string& icon_name)
{ {
v_cch_btn.push_back(icon_name); v_cch_btn.push_back(icon_name);
@@ -692,6 +765,9 @@ void CComponentsHeader::initCCItems()
//init text //init text
initCaption(); initCaption();
//init progressbar
initProgressBar();
//init logo //init logo
initLogo(); initLogo();
} }

View File

@@ -99,6 +99,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
CComponentsFrmClock * cch_cl_obj; CComponentsFrmClock * cch_cl_obj;
///object: logo object ///object: logo object
CComponentsChannelLogo * cch_logo_obj; CComponentsChannelLogo * cch_logo_obj;
///object: progressbar object
CProgressBar * cch_pb_obj;
///attributes for logos ///attributes for logos
cch_logo_t cch_logo; cch_logo_t cch_logo;
@@ -124,6 +126,14 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
int cch_clock_w; int cch_clock_w;
///property: internal x-position for caption object ///property: internal x-position for caption object
int cch_text_x; int cch_text_x;
///property: internal x-position for progressbar object
int cch_pb_x;
///property: internal width for progressbar object
int cch_pb_w;
///property: internal progressbar percent for progressbar object
int cch_pb_percent;
///property: enable/disable progressbar object
bool cch_pb_enable;
///property: internal offset of context button icons within context button object ///property: internal offset of context button icons within context button object
int cch_buttons_space; int cch_buttons_space;
///property: internal offset for header items ///property: internal offset for header items
@@ -159,6 +169,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
void initClock(); void initClock();
///sub: init logo object ///sub: init logo object
void initLogo(); void initLogo();
///sub: init progressbar object
void initProgressBar();
///int repaint slot ///int repaint slot
void initRepaintSlot(); void initRepaintSlot();
@@ -362,6 +374,19 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
* @return CComponentsChannelLogo* * @return CComponentsChannelLogo*
*/ */
CComponentsChannelLogo* getChannelLogoObject(){return cch_logo_obj;} CComponentsChannelLogo* getChannelLogoObject(){return cch_logo_obj;}
/**Methode to get progessbar object for direct access to its properties and methodes
* @return CProgressBar*
*/
CProgressBar* getProgressBarObject(){return cch_pb_obj;}
///enable display of progressbar, parameter int percent
void enableProgessBar(int percent);
///set value of progressbar, parameter int percent
void setProgessBar(int percent);
///get value of progressbar, return int percent
int getProgessBar(){return cch_pb_percent;}
///disable progressbar, without parameter
void disableProgessBar();
}; };
#endif #endif