mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
CComponentsButton: ignonre objects if no inititalized
This makes it possible to use buttons with or without icons or text
This commit is contained in:
@@ -164,7 +164,10 @@ void CComponentsButton::initCaption()
|
||||
}
|
||||
|
||||
//handle common position of icon and text inside container required for alignment
|
||||
int w_required = fr_thickness + append_x_offset + cc_btn_icon_obj->getWidth() + append_x_offset + cc_btn_font->getRenderWidth(cc_btn_capt, true) + append_x_offset + fr_thickness;
|
||||
int w_required = fr_thickness + append_x_offset;
|
||||
w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0;
|
||||
w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_capt, true) : 0;
|
||||
w_required += append_x_offset + fr_thickness;
|
||||
|
||||
//dynamic width
|
||||
if (w_required > width){
|
||||
@@ -173,10 +176,17 @@ void CComponentsButton::initCaption()
|
||||
}
|
||||
|
||||
//do center
|
||||
int x_icon = width/2 - w_required/2 + fr_thickness + append_x_offset;
|
||||
cc_btn_icon_obj->setXPos(x_icon);
|
||||
cc_btn_capt_obj->setXPos(x_icon + cc_btn_icon_obj->getWidth() + append_x_offset);
|
||||
cc_btn_capt_obj->setWidth(width - cc_btn_capt_obj->getXPos());
|
||||
int x_icon = width/2 - w_required/2 /*+ fr_thickness + append_x_offset*/;
|
||||
int w_icon = 0;
|
||||
if (cc_btn_icon_obj){
|
||||
x_icon += fr_thickness + append_x_offset;
|
||||
cc_btn_icon_obj->setXPos(x_icon);
|
||||
w_icon = cc_btn_icon_obj->getWidth();
|
||||
}
|
||||
if (cc_btn_capt_obj){
|
||||
cc_btn_capt_obj->setXPos(x_icon + w_icon + append_x_offset);
|
||||
cc_btn_capt_obj->setWidth(width - cc_btn_capt_obj->getXPos());
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsButton::setCaption(const std::string& text)
|
||||
|
Reference in New Issue
Block a user