From 97fc294d54e3af37ef88683eb604ea703816d35a Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 27 Oct 2019 16:24:47 +0100 Subject: [PATCH] cc_frm_footer: add members to enable button allignment on top of footer --- src/gui/components/cc_frm_footer.cpp | 5 +++-- src/gui/components/cc_frm_footer.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index f534c43e2..933da7ee0 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -87,6 +87,7 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const ccf_enable_button_shadow = false ; ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0; ccf_button_shadow_force_paint = false; + ccf_button_container_y = -1; //centered as default col_frame = col_frame_old = color_frame; col_body = col_body_old = color_body; col_shadow = col_shadow_old = color_shadow; @@ -176,7 +177,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con int h_container = ccf_btn_font->getHeight() > height+dist ? height-dist : ccf_btn_font->getHeight()+dist; h_container -= cc_parent ? (cc_parent->getFrameThickness()/2 - shadow_w) : 0; // if footer is embedded then consider possible frame around parent object (e.g. window) int x_container = width/2 - w_container/2; //FIXME: only centered position, other items will be overpainted - int y_container = height/2 - h_container/2; + int y_container = ccf_button_container_y < 0 ? height/2 - h_container/2 : ccf_button_container_y; if (cch_icon_obj) x_container = cch_offset+cch_icon_obj->getWidth()+cch_offset; @@ -200,7 +201,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con */ int x_btn = 0; int h_btn = btn_container->getHeight()- 2*fr_thickness - ccf_button_shadow_width; - int y_btn = btn_container->getHeight()/2 - h_btn/2; + int y_btn = ccf_button_container_y < 0 ? btn_container->getHeight()/2 - h_btn/2 : ccf_button_container_y; /* * Init button label objects diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index f99f8c9ac..e19c5d8aa 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -64,6 +64,8 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect bool ccf_button_shadow_force_paint; ///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled bool btn_auto_frame_col; + ///extra button container y pos, overwrites internal default y centered position if value > 0 + int ccf_button_container_y; ///property: set font for label caption, see also setButtonFont() Font* ccf_btn_font; @@ -162,6 +164,8 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);} ///get button label object with defined item id CComponentsButton* getButtonLabel(const uint& item_id); + /// allows to allign buttons on the top of footer, default parameter is true + void ButtonsOnTop(const bool& enable = true) { ccf_button_container_y = enable ? 0 : -1;} };