From f7faf07ab165d5289d7b824b42b2c99b782c52d3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 4 Oct 2014 00:20:48 +0200 Subject: [PATCH] CComponentsForm: fix item offset with enabled frame frame width was not considered --- src/gui/components/cc_frm.cpp | 25 +++++++++++++++---------- src/gui/components/cc_frm_button.cpp | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index cd916cdc3..a99068860 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -363,6 +363,7 @@ void CComponentsForm::paintCCItems() //using of real x/y values to paint items if this text object is bound in a parent form int this_x = x, auto_x = x, this_y = y, auto_y = y, this_w = width; + int w_parent_frame = 0; if (cc_parent){ this_x = auto_x = cc_xr; this_y = auto_y = cc_yr; @@ -406,14 +407,14 @@ void CComponentsForm::paintCCItems() dprintf(DEBUG_INFO, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page); - //get current dimension of item - int w_item = cc_item->getWidth(); - int h_item = cc_item->getHeight(); - //get current position of item int xpos = cc_item->getXPos(); int ypos = cc_item->getYPos(); + //get current dimension of item + int w_item = cc_item->getWidth() - (xpos <= fr_thickness ? fr_thickness : 0); + int h_item = cc_item->getHeight() - (ypos <= fr_thickness ? fr_thickness : 0); + //check item for corrupt position, skip current item if found problems if (ypos > height || xpos > this_w){ dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined this_w=%d \ndefinied y=%d, defined height=%d \n", @@ -422,37 +423,41 @@ void CComponentsForm::paintCCItems() continue; } + w_parent_frame = xpos <= fr_thickness ? fr_thickness : 0; + //set required x-position to item: //append vertical if (xpos == CC_APPEND){ auto_x += append_x_offset; - cc_item->setRealXPos(auto_x + xpos); + cc_item->setRealXPos(auto_x + xpos + w_parent_frame); auto_x += w_item; } //positionize vertical centered else if (xpos == CC_CENTERED){ auto_x = this_w/2 - w_item/2; - cc_item->setRealXPos(this_x + auto_x); + cc_item->setRealXPos(this_x + auto_x + w_parent_frame); } else{ - cc_item->setRealXPos(this_x + xpos); + cc_item->setRealXPos(this_x + xpos + w_parent_frame); auto_x = (cc_item->getRealXPos() + w_item); } + w_parent_frame = ypos <= fr_thickness ? fr_thickness : 0; + //set required y-position to item //append hor if (ypos == CC_APPEND){ auto_y += append_y_offset; - cc_item->setRealYPos(auto_y + ypos); + cc_item->setRealYPos(auto_y + ypos + w_parent_frame); auto_y += h_item; } //positionize hor centered else if (ypos == CC_CENTERED){ auto_y = height/2 - h_item/2; - cc_item->setRealYPos(this_y + auto_y); + cc_item->setRealYPos(this_y + auto_y + w_parent_frame); } else{ - cc_item->setRealYPos(this_y + ypos); + cc_item->setRealYPos(this_y + ypos + w_parent_frame); auto_y = (cc_item->getRealYPos() + h_item); } diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index cb5d8b322..e68795a24 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -184,7 +184,7 @@ void CComponentsButton::initCaption() x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0; int w_cap = width - fr_thickness - append_x_offset - x_cap - fr_thickness; - int h_cap = height - 2*fr_thickness; + int h_cap = height*80/100/* - 2*fr_thickness*/; /*NOTE: paint of centered text in y direction without y_offset @@ -192,7 +192,7 @@ void CComponentsButton::initCaption() but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered! Therefore we here need other icons or a hack, that considers some different height values. */ - int y_cap = height/2 - h_cap/2 - fr_thickness; + int y_cap = height/2 - h_cap/2 + fr_thickness/2; cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);