mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
CCButtonSelect: rename chain to btn_container
more plausible name
This commit is contained in:
@@ -24,26 +24,26 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "cc_button_select.h"
|
#include "cc_button_select.h"
|
||||||
|
|
||||||
CCButtonSelect::CCButtonSelect(CComponentsFrmChain *chain_obj)
|
CCButtonSelect::CCButtonSelect()
|
||||||
{
|
{
|
||||||
chain = chain_obj;
|
btn_container = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsFrmChain* CCButtonSelect::getButtonChainObject()
|
CComponentsFrmChain* CCButtonSelect::getButtonChainObject()
|
||||||
{
|
{
|
||||||
return chain;
|
return btn_container;
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsButton* CCButtonSelect::getSelectedButtonObject()
|
CComponentsButton* CCButtonSelect::getSelectedButtonObject()
|
||||||
{
|
{
|
||||||
CComponentsButton* ret = static_cast<CComponentsButton*>(chain->getSelectedItemObject());
|
CComponentsButton* ret = static_cast<CComponentsButton*>(btn_container->getSelectedItemObject());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCButtonSelect::getSelectedButton()
|
int CCButtonSelect::getSelectedButton()
|
||||||
{
|
{
|
||||||
if (chain)
|
if (btn_container)
|
||||||
return chain->getSelectedItem();
|
return btn_container->getSelectedItem();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,15 +57,15 @@ void CCButtonSelect::setSelectedButton(size_t item_id,
|
|||||||
const int& frame_width,
|
const int& frame_width,
|
||||||
const int& sel_frame_width)
|
const int& sel_frame_width)
|
||||||
{
|
{
|
||||||
if (chain){
|
if (btn_container){
|
||||||
for (size_t i= 0; i< chain->size(); i++){
|
for (size_t i= 0; i< btn_container->size(); i++){
|
||||||
CComponentsButton *btn = static_cast<CComponentsButton*>(chain->getCCItem(i));
|
CComponentsButton *btn = static_cast<CComponentsButton*>(btn_container->getCCItem(i));
|
||||||
btn->setButtonTextColor(text_col);
|
btn->setButtonTextColor(text_col);
|
||||||
}
|
}
|
||||||
fb_pixel_t sel_col = fr_col;
|
fb_pixel_t sel_col = fr_col;
|
||||||
if (chain->size() > 1)
|
if (btn_container->size() > 1)
|
||||||
sel_col = sel_fr_col; //TODO: make it configurable
|
sel_col = sel_fr_col; //TODO: make it configurable
|
||||||
chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
|
btn_container->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
|
||||||
|
|
||||||
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
|
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
|
||||||
}
|
}
|
||||||
|
@@ -33,10 +33,10 @@ Class for inheritation of button select handling inside other CComponentsForm ob
|
|||||||
class CCButtonSelect
|
class CCButtonSelect
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CComponentsFrmChain *chain;
|
CComponentsFrmChain *btn_container;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCButtonSelect(CComponentsFrmChain *chain_obj = NULL);
|
CCButtonSelect();
|
||||||
|
|
||||||
///returns selected button object, return value as pointer to object, NULL means nothing is selected
|
///returns selected button object, return value as pointer to object, NULL means nothing is selected
|
||||||
CComponentsButton* getSelectedButtonObject();
|
CComponentsButton* getSelectedButtonObject();
|
||||||
|
@@ -107,8 +107,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
|||||||
void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||||
{
|
{
|
||||||
/* clean up before init*/
|
/* clean up before init*/
|
||||||
if (chain)
|
if (btn_container)
|
||||||
chain->clear();
|
btn_container->clear();
|
||||||
|
|
||||||
if (label_count == 0)
|
if (label_count == 0)
|
||||||
return;
|
return;
|
||||||
@@ -149,11 +149,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
|||||||
int y_chain = height/2 - h_chain/2;
|
int y_chain = height/2 - h_chain/2;
|
||||||
if (cch_icon_obj)
|
if (cch_icon_obj)
|
||||||
x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset;
|
x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset;
|
||||||
if (chain == NULL){
|
if (btn_container == NULL){
|
||||||
chain = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
|
btn_container = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
|
||||||
chain->setAppendOffset(0, 0);
|
btn_container->setAppendOffset(0, 0);
|
||||||
chain->setCorner(this->corner_rad, this->corner_type);
|
btn_container->setCorner(this->corner_rad, this->corner_type);
|
||||||
chain->doPaintBg(false);
|
btn_container->doPaintBg(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate usable width of button labels inside button object container
|
/* Calculate usable width of button labels inside button object container
|
||||||
@@ -165,11 +165,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
|||||||
* button objects itself.
|
* button objects itself.
|
||||||
*/
|
*/
|
||||||
int w_offset = int((label_count-1)*cch_offset);
|
int w_offset = int((label_count-1)*cch_offset);
|
||||||
int w_btn = chain->getWidth()/label_count - w_offset;
|
int w_btn = btn_container->getWidth()/label_count - w_offset;
|
||||||
if (label_width){
|
if (label_width){
|
||||||
int w_label = label_width;
|
int w_label = label_width;
|
||||||
int w_defined = int(label_width*label_count);
|
int w_defined = int(label_width*label_count);
|
||||||
int w_max = chain->getWidth() - w_offset;
|
int w_max = btn_container->getWidth() - w_offset;
|
||||||
while (w_defined > w_max){
|
while (w_defined > w_max){
|
||||||
w_label--;
|
w_label--;
|
||||||
w_defined = int(w_label*label_count) - w_offset;
|
w_defined = int(w_label*label_count) - w_offset;
|
||||||
@@ -181,7 +181,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
|||||||
* with default width to chain object.
|
* with default width to chain object.
|
||||||
*/
|
*/
|
||||||
vector<CComponentsItem*> v_btns;
|
vector<CComponentsItem*> v_btns;
|
||||||
int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width;
|
int h_btn = /*(ccf_enable_button_bg ? */btn_container->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width;
|
||||||
for (size_t i= 0; i< label_count; i++){
|
for (size_t i= 0; i< label_count; i++){
|
||||||
string txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale);
|
string txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale);
|
||||||
string icon_name = string(content[i].button);
|
string icon_name = string(content[i].button);
|
||||||
@@ -192,7 +192,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y_btn = chain->getHeight()/2 - h_btn/2;
|
int y_btn = btn_container->getHeight()/2 - h_btn/2;
|
||||||
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width);
|
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width);
|
||||||
CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow);
|
CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow);
|
||||||
|
|
||||||
@@ -223,27 +223,27 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
|||||||
btn->setButtonFont(NULL);
|
btn->setButtonFont(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%u] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, chain->getWidth());
|
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%u] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, btn_container->getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add generated button objects to chain object.
|
/* add generated button objects to chain object.
|
||||||
*/
|
*/
|
||||||
if (!v_btns.empty()){
|
if (!v_btns.empty()){
|
||||||
/*add all buttons into button container*/
|
/*add all buttons into button container*/
|
||||||
chain->addCCItem(v_btns);
|
btn_container->addCCItem(v_btns);
|
||||||
|
|
||||||
/* set position of labels, as centered inside button container*/
|
/* set position of labels, as centered inside button container*/
|
||||||
int w_chain_used = 0;
|
int w_chain_used = 0;
|
||||||
for (size_t a= 0; a< chain->size(); a++)
|
for (size_t a= 0; a< btn_container->size(); a++)
|
||||||
w_chain_used += chain->getCCItem(a)->getWidth();
|
w_chain_used += btn_container->getCCItem(a)->getWidth();
|
||||||
w_chain_used += (chain->size()-1)*cch_offset;
|
w_chain_used += (btn_container->size()-1)*cch_offset;
|
||||||
|
|
||||||
int x_btn = chain->getWidth()/2 - w_chain_used/2;
|
int x_btn = btn_container->getWidth()/2 - w_chain_used/2;
|
||||||
chain->getCCItem(0)->setXPos(x_btn);
|
btn_container->getCCItem(0)->setXPos(x_btn);
|
||||||
|
|
||||||
for (size_t c= 1; c< chain->size(); c++){
|
for (size_t c= 1; c< btn_container->size(); c++){
|
||||||
x_btn += chain->getCCItem(c-1)->getWidth()+ cch_offset;
|
x_btn += btn_container->getCCItem(c-1)->getWidth()+ cch_offset;
|
||||||
chain->getCCItem(c)->setXPos(x_btn);
|
btn_container->getCCItem(c)->setXPos(x_btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,9 +316,9 @@ void CComponentsFooter::setButtonLabel( const char *button_icon,
|
|||||||
void CComponentsFooter::enableButtonBg(bool enable)
|
void CComponentsFooter::enableButtonBg(bool enable)
|
||||||
{
|
{
|
||||||
ccf_enable_button_bg = enable;
|
ccf_enable_button_bg = enable;
|
||||||
if (chain) {
|
if (btn_container) {
|
||||||
for (size_t i= 0; i< chain->size(); i++)
|
for (size_t i= 0; i< btn_container->size(); i++)
|
||||||
chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
|
btn_container->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,12 +357,12 @@ void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bo
|
|||||||
ccf_enable_button_shadow = mode;
|
ccf_enable_button_shadow = mode;
|
||||||
ccf_button_shadow_width = shadow_width;
|
ccf_button_shadow_width = shadow_width;
|
||||||
ccf_button_shadow_force_paint = force_paint;
|
ccf_button_shadow_force_paint = force_paint;
|
||||||
if (chain){
|
if (btn_container){
|
||||||
for(size_t i=0; i<chain->size(); i++){
|
for(size_t i=0; i<btn_container->size(); i++){
|
||||||
chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
|
btn_container->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
|
||||||
//int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
|
//int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
|
||||||
int y_btn = chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2;
|
int y_btn = btn_container->getHeight()/2 - btn_container->getCCItem(i)->getHeight()/2;
|
||||||
chain->getCCItem(i)->setYPos(y_btn);
|
btn_container->getCCItem(i)->setYPos(y_btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user