CComponentsItem: add missing methodes for position setters

Parent items were not considered for position calculation.
This commit is contained in:
2017-04-16 16:53:06 +02:00
parent f499d3d387
commit 069379930a
2 changed files with 19 additions and 0 deletions

View File

@@ -261,6 +261,20 @@ bool CComponentsItem::isAdded()
return false;
}
void CComponentsItem::setXPos(const int& xpos)
{
CCDraw::setXPos(xpos);
if (cc_parent)
cc_xr = cc_parent->getXPos() + x;
}
void CComponentsItem::setYPos(const int& ypos)
{
CCDraw::setYPos(ypos);
if (cc_parent)
cc_yr = cc_parent->getYPos() + y;
}
void CComponentsItem::setXPosP(const uint8_t& xpos_percent)
{
int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth();

View File

@@ -134,6 +134,11 @@ class CComponentsItem : public CComponents
///returns current number of page location of current item, see: cc_page_number
virtual u_int8_t getPageNumber(){return cc_page_number;};
///set screen x-position, parameter as int
virtual void setXPos(const int& xpos);
///set screen y-position, parameter as int
virtual void setYPos(const int& ypos);
///set screen x-position, parameter as uint8_t, percent x value related to current width of parent form or screen
virtual void setXPosP(const uint8_t& xpos_percent);
///set screen y-position, parameter as uint8_t, percent y value related to current height of parent form or screen