From a5a2ac6037ffc7261f0061f7ce55f6f983cfed96 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 28 May 2017 13:12:08 +0200 Subject: [PATCH 1/2] CComponentsButton: use defined offset for append offset --- src/gui/components/cc_frm_button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index c7215b4fc..ff68a47db 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -112,7 +112,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const cc_item_enabled = enabled; cc_item_selected = selected; fr_thickness = 0; //TODO: parts of the GUI still don't use framed buttons - append_x_offset = 6; + append_x_offset = OFFSET_INTER; append_y_offset = 0; corner_rad = RADIUS_SMALL; From 294278aad38bf5bed8fef7e87dbb981edb553e4b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 28 May 2017 13:30:58 +0200 Subject: [PATCH 2/2] CComponentsButton: fix offset between icon and text items We have only two items, therfore it makes sense to set offset to 0 if we have only one item. Otherwise a single item will not be centered. --- src/gui/components/cc_frm_button.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index ff68a47db..c0c0039b0 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -187,6 +187,7 @@ void CComponentsButton::initCaption() } //set basic properties + int x_offset = (!cc_btn_text_obj || !cc_btn_icon_obj) ? 0 : append_x_offset; int w_frame = fr_thickness; int reduce = 2*w_frame; if (cc_btn_text_obj){ @@ -198,7 +199,7 @@ void CComponentsButton::initCaption() if (cc_btn_font == NULL) cc_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT]; - int w_cap = min(width - append_x_offset - x_cap - reduce, cc_btn_font->getRenderWidth(cc_btn_text)); + int w_cap = min(width - x_offset - x_cap - reduce, cc_btn_font->getRenderWidth(cc_btn_text)); int h_cap = min(height - reduce, cc_btn_font->getHeight()); /*NOTE: paint of centered text in y direction without y_offset @@ -235,10 +236,10 @@ void CComponentsButton::initCaption() } //handle common position of icon and text inside container required for alignment - int w_required = w_frame + append_x_offset; - w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0; + int w_required = w_frame + x_offset; + w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + x_offset : 0; w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_text) : 0; - w_required += append_x_offset + w_frame; + w_required += x_offset + w_frame; //dynamic width if (w_required > width){ @@ -247,10 +248,10 @@ void CComponentsButton::initCaption() } //do center - int x_icon = width/2 - w_required/2 /*+ fr_thickness + append_x_offset*/; + int x_icon = width/2 - w_required/2 /*+ fr_thickness + x_offset*/; int w_icon = 0; if (cc_btn_icon_obj){ - x_icon += w_frame + append_x_offset; + x_icon += w_frame + x_offset; cc_btn_icon_obj->setXPos(x_icon); w_icon = cc_btn_icon_obj->getWidth(); /*in case of dynamic changed height of caption or button opbject itself, @@ -260,7 +261,7 @@ void CComponentsButton::initCaption() cc_btn_icon_obj->setYPos(y_icon); } if (cc_btn_text_obj){ - cc_btn_text_obj->setXPos(x_icon + w_icon + append_x_offset); + cc_btn_text_obj->setXPos(x_icon + w_icon + x_offset); cc_btn_text_obj->setWidth(width - cc_btn_text_obj->getXPos()); } }