CComponentsItem: move/rename doCenter()to base class CComponentsItem

So it's possible to use this method for all cc-items.
setCenterPos() comes now with parameter 'along_mode' (CC_ALONG_X, CC_ALONG_Y).
So it's possible to center in x or y direction. As default are
both directions predefined.
This commit is contained in:
2014-02-27 19:43:30 +01:00
parent 38dffb8456
commit 8a897103ac
6 changed files with 22 additions and 12 deletions

View File

@@ -182,3 +182,11 @@ void CComponentsItem::setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_p
setXPosP(xpos_percent);
setYPosP(ypos_percent);
}
void CComponentsItem::setCenterPos(int along_mode)
{
if (along_mode & CC_ALONG_X)
x = cc_parent ? cc_parent->getWidth() - width/2 : getScreenStartX(width);
if (along_mode & CC_ALONG_Y)
y = cc_parent ? cc_parent->getHeight() - height/2 : getScreenStartY(height);
}