CComponentsHeader: Try to adopt different logo/title alignments

Not all constellations are tested. Please report.


Origin commit data
------------------
Commit: 5b541571f9
Author: Thilo Graf <dbt@novatux.de>
Date: 2017-05-10 (Wed, 10 May 2017)
This commit is contained in:
2017-05-10 10:42:08 +02:00
parent 8d11ff178f
commit 908e23005d

View File

@@ -302,13 +302,23 @@ void CComponentsHeader::initLogo()
//right end //right end
int x_logo_right = width - cch_logo_obj->getWidth(); int x_logo_right = width - cch_logo_obj->getWidth();
if (cch_btn_obj) if (cch_caption_align != CTextBox::RIGHT){
x_logo_right -= cch_btn_obj->getWidth(); if (cch_btn_obj)
if (cch_cl_obj) x_logo_right -= cch_btn_obj->getWidth();
x_logo_right -= cch_cl_obj->getWidth(); if (cch_cl_obj)
x_logo_right -= cch_cl_obj->getWidth();
}else{
if (cch_icon_obj)
x_logo_right += cch_icon_obj->getWidth();
}
//left end //left end
int x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0; int x_logo_left = cch_offset;
if (cch_caption_align != CTextBox::RIGHT)
x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0;
else
if (cch_icon_obj)
x_logo_left += cch_icon_obj->getWidth();
//calculate available space //calculate available space
int logo_space = x_logo_right + cch_logo_obj->getWidth() - x_logo_left; int logo_space = x_logo_right + cch_logo_obj->getWidth() - x_logo_left;
@@ -319,17 +329,30 @@ void CComponentsHeader::initLogo()
//set final logo position //set final logo position
int x_logo = 0; int x_logo = 0;
if (cch_logo.Align == CC_LOGO_RIGHT) if (cch_logo.Align == CC_LOGO_RIGHT){
x_logo = x_logo_right; if (cch_caption_align == CTextBox::RIGHT)
if (cch_text_obj)
x_logo = cch_text_obj->getXPos() - cch_logo_obj->getWidth();
else
x_logo = x_logo_right;
}
if (cch_logo.Align == CC_LOGO_LEFT) if (cch_logo.Align == CC_LOGO_LEFT)
x_logo = x_logo_left; x_logo = x_logo_left;
if (cch_logo.Align == CC_LOGO_CENTER){ if (cch_logo.Align == CC_LOGO_CENTER){
x_logo = width/2 - cch_logo_obj->getWidth()/2; x_logo = width/2 - cch_logo_obj->getWidth()/2;
//fallback if previous item and logo are overlapping //fallback if adjacent item and logo are overlapping
if (getCCItem(prev_id)){ if (cch_caption_align != CTextBox::RIGHT){
int x_tmp = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2; if (getCCItem(prev_id)){
if (x_logo <= x_logo_left) int x_tmp = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2;
x_logo = x_tmp; if (x_logo <= x_logo_left)
x_logo = x_tmp;
}
}else{
if (cch_text_obj){
if (x_logo + cch_logo_obj->getWidth() >= cch_text_obj->getXPos()){
x_logo = (x_logo_left + cch_text_obj->getXPos())/2 - cch_logo_obj->getWidth()/2;
}
}
} }
} }
@@ -576,13 +599,20 @@ void CComponentsHeader::initCaption()
//set header text properties //set header text properties
if (cch_text_obj){ if (cch_text_obj){
int w_free = cc_text_w;
//recalc caption width //recalc caption width
cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)/*+ OFFSET_INNER_MID*/); cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID);
//set alignment of text item in dependency from text alignment //set alignment of text item in dependency from text alignment
if (cch_caption_align == CTextBox::CENTER) if (cch_caption_align == CTextBox::CENTER)
cch_text_x = width/2 - cc_text_w/2; cch_text_x = width/2 - cc_text_w/2;
if (cch_caption_align == CTextBox::RIGHT){
cch_text_x += w_free;
cch_text_x -= max(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID);
}
//assign general properties //assign general properties
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height); cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->setColorBody(col_body); cch_text_obj->setColorBody(col_body);