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

@@ -251,7 +251,7 @@ class CComponents : public CComponentsSignals, public COSDFader
///allow/disalows paint of item and its contents, but initialize of other properties are not touched
///this can be understood as a counterpart to isPainted(), but before paint and value of is_painted is modified temporarily till next paint of item //TODO: is this sufficiently?
virtual void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;};
void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;};
///returns visibility mode
virtual bool paintAllowed(){return cc_allow_paint;};
@@ -346,6 +346,10 @@ 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

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)