mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
CComponentsButton: fix alignment of button items
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user