CComponentsButton: fix button icon position on dynamic changed conditions

In some constellations it is possible, that costum icons with
other dimensions will be not correct positionized. This should
fix this issue.

This reverts partial commit 289f5b30e6.


Origin commit data
------------------
Commit: 7197f51e89
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-03-17 (Thu, 17 Mar 2016)
This commit is contained in:
2016-03-17 09:12:43 +01:00
parent b11faa31f9
commit fc29aa59c7

View File

@@ -142,15 +142,17 @@ void CComponentsButton::initIcon()
}
//initialize icon object
if (cc_btn_icon_obj == NULL){
int y_icon = 0;
string::size_type pos = cc_btn_icon.find("/", 0);
if (pos == string::npos)
cc_btn_icon = frameBuffer->getIconBasePath() + "/" + cc_btn_icon + ".png";
cc_btn_icon_obj = new CComponentsPictureScalable(fr_thickness, y_icon, cc_btn_icon, this);
if (cc_btn_icon_obj == NULL){
cc_btn_icon_obj = new CComponentsPictureScalable(fr_thickness, 0, cc_btn_icon, this);
cc_btn_icon_obj->SetTransparent(CFrameBuffer::TM_BLACK);
cc_btn_icon_obj->doPaintBg(false);
}
int y_icon = cc_btn_icon_obj->getYPos();
int h_icon = cc_btn_icon_obj->getHeight();
//get required icon height
@@ -163,8 +165,6 @@ void CComponentsButton::initIcon()
y_icon = h_max/2 - cc_btn_icon_obj->getHeight()/2;
cc_btn_icon_obj->setYPos(y_icon);
cc_btn_icon_obj->doPaintBg(false);
}
}
void CComponentsButton::initCaption()
@@ -237,6 +237,11 @@ void CComponentsButton::initCaption()
x_icon += fr_thickness + append_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,
*we must ensure centered y position of icon object
*/
int y_icon = height/2 - cc_btn_icon_obj->getHeight()/2;
cc_btn_icon_obj->setYPos(y_icon);
}
if (cc_btn_capt_obj){
cc_btn_capt_obj->setXPos(x_icon + w_icon + append_x_offset);