CComponentsItem: add setXPos/setYPos(), that consider real position

This commit is contained in:
2014-11-30 00:07:21 +01:00
parent 6fc8d1bb9f
commit 8ebb5f98ca
2 changed files with 21 additions and 3 deletions

View File

@@ -194,16 +194,30 @@ bool CComponentsItem::isAdded()
return false;
}
inline void CComponentsItem::setXPos(const int& xpos)
{
x = xpos;
if (cc_parent)
setRealXPos(cc_parent->getRealXPos() + x);
}
inline void CComponentsItem::setYPos(const int& ypos)
{
y = ypos;
if (cc_parent)
setRealYPos(cc_parent->getRealYPos() + y);
}
void CComponentsItem::setXPosP(const uint8_t& xpos_percent)
{
int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth();
x = x_tmp/100;
setXPos(x_tmp/100);
}
void CComponentsItem::setYPosP(const uint8_t& ypos_percent)
{
int y_tmp = cc_parent ? ypos_percent*cc_parent->getHeight() : ypos_percent*frameBuffer->getScreenHeight();
x = y_tmp/100;
setYPos(y_tmp/100);
}
void CComponentsItem::setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent)