From 884c6181df575c00d56e370fc72bc7e3c996780f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 7 Dec 2020 23:28:52 +0100 Subject: [PATCH] cc_frm_buttons: expand functionality of setButtonTextColor() Color parameters for 'select' and 'disable' colors added. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/88c8147707a7eeb0f369a08b4f6f2b66c616f2d7 Author: Thilo Graf Date: 2020-12-07 (Mon, 07 Dec 2020) --- src/gui/components/cc_frm_button.cpp | 13 +++++++++++-- src/gui/components/cc_frm_button.h | 11 +++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index f464b4800..cb3a5d4ce 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -117,7 +117,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const append_y_offset = 0; corner_rad = RADIUS_SMALL; - cc_btn_text_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_ENABLED : COL_MENUFOOT_TEXT; + cc_btn_text_col = cc_btn_text_std_col = cc_btn_text_sel_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_ENABLED : COL_MENUFOOT_TEXT; cc_btn_text_disable_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_DISABLED : COL_MENUCONTENTINACTIVE_TEXT; cc_btn_icon_obj = NULL; cc_btn_text_obj = NULL; @@ -224,7 +224,16 @@ void CComponentsButton::initCaption() cc_btn_text_obj->getCTextBoxObject()->setTextBorderWidth(0,0); //set color - cc_btn_text_obj->setTextColor(this->cc_item_enabled ? cc_btn_text_col : cc_btn_text_disable_col); + if (isEnabled()) + { + if(isSelected()) + cc_btn_text_col = cc_btn_text_sel_col; + else + cc_btn_text_col = cc_btn_text_std_col; + } + else + cc_btn_text_col = cc_btn_text_disable_col; + cc_btn_text_obj->setTextColor(cc_btn_text_col); //corner of text item cc_btn_text_obj->setCorner(corner_rad-w_frame, corner_type); diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 5d1846a60..2c95e1830 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -78,9 +78,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen int cc_btn_alias; ///property: text color - fb_pixel_t cc_btn_text_col; - ///property: text color for disabled button - fb_pixel_t cc_btn_text_disable_col; + fb_pixel_t cc_btn_text_col, cc_btn_text_disable_col, cc_btn_text_std_col, cc_btn_text_sel_col; ///object: text font Font* cc_btn_font; ///object: dynamic font object handler @@ -135,7 +133,12 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen virtual ~CComponentsButton(){}; ///set text color - void setButtonTextColor(fb_pixel_t caption_color){cc_btn_text_col = caption_color;}; + void setButtonTextColor(const fb_pixel_t &caption_color, const fb_pixel_t &sel_caption_color = COL_BUTTON_TEXT_ENABLED, const fb_pixel_t &dis_caption_color = COL_BUTTON_TEXT_DISABLED) + { + cc_btn_text_std_col = caption_color; + cc_btn_text_sel_col = sel_caption_color; + cc_btn_text_disable_col = dis_caption_color; + }; /**Member to modify background behavior of embeded caption object. * @param[in] mode