mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
CComponentsButton: ensure matching icons inside button
Some icons can be too large for defined button height, so it's required to scale icons. Scaling happens inside cc_btn_icon_obj during its init.
This commit is contained in:
@@ -135,7 +135,19 @@ void CComponentsButton::initIcon()
|
|||||||
|
|
||||||
//initialize icon object
|
//initialize icon object
|
||||||
if (cc_btn_icon_obj == NULL){
|
if (cc_btn_icon_obj == NULL){
|
||||||
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, CC_CENTERED, 0, 0, cc_btn_icon, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, this);
|
int w_icon = 0;
|
||||||
|
int h_icon = 0;
|
||||||
|
frameBuffer->getIconSize(cc_btn_icon.c_str(), &w_icon, &h_icon);
|
||||||
|
|
||||||
|
int h_max = height-2*fr_thickness;
|
||||||
|
if (h_icon > h_max){
|
||||||
|
int ratio = h_icon/h_max;
|
||||||
|
cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon;
|
||||||
|
cc_btn_icon += ".png";
|
||||||
|
w_icon = w_icon*ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, CC_CENTERED, w_icon, h_max, cc_btn_icon, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, this);
|
||||||
cc_btn_icon_obj->doPaintBg(false);
|
cc_btn_icon_obj->doPaintBg(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user