mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
cc_frm_button: rework initIcon(), more simply implementaion
This commit is contained in:
@@ -144,27 +144,21 @@ void CComponentsButton::initIcon()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//init icon file
|
|
||||||
string::size_type pos = cc_btn_icon.find("/", 0);
|
|
||||||
if (pos == string::npos)
|
|
||||||
cc_btn_icon = frameBuffer->getIconPath(cc_btn_icon);
|
|
||||||
|
|
||||||
//get required icon height and position
|
|
||||||
int h_icon = height-2*fr_thickness - 2*OFFSET_INNER_MIN;
|
|
||||||
int dx_tmp, dy_tmp = 0;
|
|
||||||
frameBuffer->getIconSize(cc_btn_icon.c_str(), &dx_tmp, &dy_tmp);
|
|
||||||
h_icon = min(h_icon, dy_tmp);
|
|
||||||
h_icon -= h_icon % 2;
|
|
||||||
int y_icon = height/2 - h_icon/2;
|
|
||||||
|
|
||||||
//init icon object
|
//init icon object
|
||||||
if (cc_btn_icon_obj == NULL)
|
if (cc_btn_icon_obj == NULL)
|
||||||
{
|
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, 0, cc_btn_icon, this);
|
||||||
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, cc_btn_icon, this);
|
|
||||||
cc_btn_icon_obj->SetTransparent(CFrameBuffer::TM_BLACK);
|
//get required icon height and position
|
||||||
}
|
int dx_tmp, dy_tmp = 0;
|
||||||
|
cc_btn_icon_obj->getRealSize(&dx_tmp, &dy_tmp);
|
||||||
|
|
||||||
|
int h_icon = height-2*fr_thickness - 2*OFFSET_INNER_MIN;
|
||||||
|
h_icon = min(h_icon, dy_tmp);
|
||||||
|
|
||||||
|
int y_icon = height/2 - h_icon/2;
|
||||||
|
|
||||||
cc_btn_icon_obj->setHeight(h_icon);
|
cc_btn_icon_obj->setHeight(h_icon);
|
||||||
cc_btn_icon_obj->setPicture(cc_btn_icon);
|
cc_btn_icon_obj->setYPos(y_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsButton::initCaption()
|
void CComponentsButton::initCaption()
|
||||||
@@ -212,11 +206,10 @@ void CComponentsButton::initCaption()
|
|||||||
/* If the required sum for space of icon, text, frame and offsets is too small then adapt font size.
|
/* If the required sum for space of icon, text, frame and offsets is too small then adapt font size.
|
||||||
*/
|
*/
|
||||||
if (dx_tmp > width){
|
if (dx_tmp > width){
|
||||||
int diff = 0;
|
|
||||||
if (width == 0){
|
if (width == 0){
|
||||||
width = dx_tmp;
|
width = dx_tmp;
|
||||||
}else{
|
}else{
|
||||||
diff = dx_tmp - width;
|
int diff = dx_tmp - width;
|
||||||
width -= diff;
|
width -= diff;
|
||||||
w_cap -= diff;
|
w_cap -= diff;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user