mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 00:11:08 +02:00
CComponentsButton: rework position handling for buttons and code comments
Origin commit data
------------------
Commit: 7d82da09ae
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-06-03 (Mon, 03 Jun 2013)
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "cc_frm_button.h"
|
||||
|
||||
#define FRAME_TH 3
|
||||
#define H_SPACE 4
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -91,8 +92,16 @@ void CComponentsButton::initIcon()
|
||||
addCCItem(cc_btn_icon_obj);
|
||||
}
|
||||
|
||||
//get first icon dimensions
|
||||
int icon_w = 0, icon_h = 0;
|
||||
frameBuffer->getIconSize(cc_btn_icon.c_str(), &icon_w, &icon_h);
|
||||
|
||||
//position of icon default centered
|
||||
int icon_x = width/2-icon_w/2;
|
||||
|
||||
//set properties to picture object
|
||||
if (cc_btn_icon_obj){
|
||||
cc_btn_icon_obj->setDimensionsAll(this->getRealXPos(), this->getRealYPos(), height/*-2*fr_thickness*/, height-2*fr_thickness);
|
||||
cc_btn_icon_obj->setDimensionsAll(icon_x, 0, icon_w, height);
|
||||
cc_btn_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
|
||||
cc_btn_icon_obj->doPaintBg(false);
|
||||
}
|
||||
@@ -106,13 +115,19 @@ void CComponentsButton::initCaption()
|
||||
addCCItem(cc_btn_capt_obj);
|
||||
}
|
||||
|
||||
int cap_x = this->getRealXPos()+(width/2)-(cc_btn_text_w/2);
|
||||
int cap_h = height/*-2*fr_thickness*/;
|
||||
int cap_y = this->getRealYPos();
|
||||
int cap_x = (width/2)-(cc_btn_text_w/2); //text position is default centered
|
||||
int cap_h = height;
|
||||
int cap_y = 0 ;
|
||||
|
||||
if (cc_btn_icon_obj)
|
||||
cap_x = this->getRealXPos()+cc_btn_icon_obj->getWidth();
|
||||
|
||||
//if we have a icon, then we must calculate centered position for booth items together
|
||||
if (cc_btn_icon_obj){
|
||||
int face_w = cc_btn_icon_obj->getWidth() + H_SPACE + cc_btn_text_w + 2*fr_thickness;
|
||||
int face_x = width/2 - face_w/2;
|
||||
cc_btn_icon_obj->setXPos(face_x);
|
||||
cap_x = face_x + cc_btn_icon_obj->getWidth() + H_SPACE;
|
||||
}
|
||||
|
||||
//set properties to label object
|
||||
if (cc_btn_capt_obj){
|
||||
cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, cap_h);
|
||||
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE);
|
||||
|
Reference in New Issue
Block a user