CMsgBox: add option to enable/disable button background

replaces var name btn_contour for better plausibility
This commit is contained in:
2016-08-18 10:27:33 +02:00
parent fc2eb68edc
commit be740c1552
4 changed files with 26 additions and 16 deletions

View File

@@ -83,7 +83,7 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
corner_rad = RADIUS_LARGE; corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM; corner_type = CORNER_BOTTOM;
btn_contour = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
ccf_btn_font = NULL; ccf_btn_font = NULL;
chain = NULL; chain = NULL;
@@ -141,13 +141,15 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
continue; continue;
} }
CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, (btn_contour ? height-2*fr_thickness : height), txt, icon_name); CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, (ccf_enable_button_bg ? height-2*fr_thickness : height), txt, icon_name);
btn->setButtonFont(ccf_btn_font); btn->setButtonFont(ccf_btn_font);
btn->doPaintBg(btn_contour); btn->doPaintBg(ccf_enable_button_bg);
btn->setButtonDirectKey(content[i].directKey); btn->setButtonDirectKey(content[i].directKey);
btn->setButtonDirectKeyA(content[i].directKeyAlt); btn->setButtonDirectKeyA(content[i].directKeyAlt);
btn->setButtonResult(content[i].btn_result); btn->setButtonResult(content[i].btn_result);
btn->setButtonAlias(content[i].btn_alias); btn->setButtonAlias(content[i].btn_alias);
btn->enableShadow();
//set button frames to icon color, predefined for available color buttons //set button frames to icon color, predefined for available color buttons
if (btn_auto_frame_col){ if (btn_auto_frame_col){
@@ -163,9 +165,6 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
btn->setColorFrame(f_col); btn->setColorFrame(f_col);
} }
if (btn_contour)
btn->setFrameThickness(3, 3);
chain->addCCItem(btn); chain->addCCItem(btn);
//set x position of next button object //set x position of next button object
@@ -296,12 +295,12 @@ void CComponentsFooter::setButtonLabel( const char *button_icon,
setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value, directKeyAlt); setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value, directKeyAlt);
} }
void CComponentsFooter::showButtonContour(bool show) void CComponentsFooter::enableButtonBg(bool enable)
{ {
btn_contour = show; ccf_enable_button_bg = enable;
if (chain) { if (chain) {
for (size_t i= 0; i< chain->size(); i++) for (size_t i= 0; i< chain->size(); i++)
chain->getCCItem(i)->doPaintBg(btn_contour); chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
} }
} }

View File

@@ -70,8 +70,8 @@ class CComponentsFooter : public CComponentsHeader
fb_pixel_t color_body, fb_pixel_t color_body,
fb_pixel_t color_shadow ); fb_pixel_t color_shadow );
///show button frame and background, default false ///show button with background, default false
bool btn_contour; bool ccf_enable_button_bg;
///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled ///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled
bool btn_auto_frame_col; bool btn_auto_frame_col;
@@ -126,8 +126,10 @@ class CComponentsFooter : public CComponentsHeader
const int& alias_value = -1, const int& alias_value = -1,
const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey); const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey);
///causes show/hide countour of button frame and background, parameter bool show, default= true ///enables background of buttons, parameter bool show, default= true
void showButtonContour(bool show = true); void enableButtonBg(bool enable = true);
///disables background of buttons
void disableButtonBg(){enableButtonBg(false);}
///select a definied button, parameter1 as size_t ///select a definied button, parameter1 as size_t
void setSelectedButton(size_t item_id); void setSelectedButton(size_t item_id);

View File

@@ -7,7 +7,7 @@
Günther@tuxbox.berlios.org Günther@tuxbox.berlios.org
Implementation of CComponent Window class. Implementation of CComponent Window class.
Copyright (C) 2014-2015 Thilo Graf 'dbt' Copyright (C) 2014-2016 Thilo Graf 'dbt'
License: GPL License: GPL
@@ -87,6 +87,7 @@ void CMsgBox::init(const int& Height, const int& ShowButtons, const msg_result_t
//enable footer and add its height //enable footer and add its height
showFooter(true); showFooter(true);
btn_enable_bg = false;
ccw_footer->doPaintBg(false); ccw_footer->doPaintBg(false);
int h_current = height; int h_current = height;
h_current += ccw_footer->getHeight(); h_current += ccw_footer->getHeight();
@@ -174,8 +175,8 @@ void CMsgBox::initButtons()
ccw_footer->setButtonLabels(v_buttons, 0, 125); ccw_footer->setButtonLabels(v_buttons, 0, 125);
//show buttons with frame and background //show buttons with background
ccw_footer->showButtonContour(true); ccw_footer->enableButtonBg(btn_enable_bg);
//set position of meassage window and refresh window properties //set position of meassage window and refresh window properties
setCenterPos(); setCenterPos();

View File

@@ -112,6 +112,9 @@ class CMsgBox : public CHintBox
///assigned button captions ///assigned button captions
std::string BTN_TEXT(const int& showed_button); std::string BTN_TEXT(const int& showed_button);
///enables/disable button background
bool btn_enable_bg;
void initButtons(); void initButtons();
public: public:
/* Constructor */ /* Constructor */
@@ -181,6 +184,11 @@ class CMsgBox : public CHintBox
*/ */
void setButtonText(const int& showed_button, const std::string& text); void setButtonText(const int& showed_button, const std::string& text);
///enables background of buttons, parameter bool show, default= true
void enableButtonBg(bool enable = true);
///disables background of buttons
void disableButtonBg(){enableButtonBg(false);}
// bool setText(const std::string* newText); // bool setText(const std::string* newText);
}; };