From dc90a7fcc1cda9b266eb1a5c3ef208b6469c910f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 16 Jun 2013 00:20:47 +0200 Subject: [PATCH] CComponentsButton: fix alignment of button items Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b18741efc785f98691f2a4d4337ce1af9792f437 Author: Thilo Graf Date: 2013-06-16 (Sun, 16 Jun 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_button.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index d9c8ea970..b302caee5 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -85,26 +85,28 @@ void CComponentsButton::initIcon() cc_btn_icon_obj = NULL; return; } - + + //initialize icon object if (cc_btn_icon_obj == NULL){ cc_btn_icon_obj = new CComponentsPicture(0, 0, 0, 0, cc_btn_icon); - addCCItem(cc_btn_icon_obj); } //get first icon dimensions - int icon_w = 0, icon_h = 0; - frameBuffer->getIconSize(cc_btn_icon.c_str(), &icon_w, &icon_h); - + int icon_w = cc_btn_icon_obj->getWidth(); + int icon_h = cc_btn_icon_obj->getHeight(); + //position of icon default centered - int icon_x = width/2-icon_w/2; + int icon_x = width/2-icon_w/2; + int icon_y = height/2-icon_h/2; //set properties to picture object if (cc_btn_icon_obj){ - cc_btn_icon_obj->setDimensionsAll(icon_x, 0, icon_w, height); + cc_btn_icon_obj->setPos(icon_x, icon_y); cc_btn_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); cc_btn_icon_obj->doPaintBg(false); } + } void CComponentsButton::initCaption() @@ -114,10 +116,10 @@ void CComponentsButton::initCaption() addCCItem(cc_btn_capt_obj); } - - int cap_x = (width/2)-(cc_btn_text_w/2); //text position is default centered - int cap_h = height; - int cap_y = 0 ; + + //text position is default centere + int cap_x = (width/2)-(cc_btn_text_w/2); + int cap_y = (height/2)-(cc_btn_text_h/2); //if we have a icon, then we must calculate centered position for booth items together if (cc_btn_icon_obj){ @@ -129,7 +131,7 @@ void CComponentsButton::initCaption() //set properties to label object if (cc_btn_capt_obj){ - cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, cap_h); + cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, height); cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE); cc_btn_capt_obj->setText(cc_btn_capt, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font); cc_btn_capt_obj->forceTextPaint(); //here required;