mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 08:21:07 +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.
Origin commit data
------------------
Commit: 9d014d2039
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-05-03 (Sat, 03 May 2014)
This commit is contained in:
@@ -135,7 +135,19 @@ void CComponentsButton::initIcon()
|
||||
|
||||
//initialize icon object
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user