Esempio n. 1
0
void MythRect::CalculateArea(const MythRect & parentArea)
{
    QRect area  = parentArea.toQRect();
    if ((m_parentArea == area && !m_needsUpdate) || !parentArea.isValid())
        return;

    m_parentArea  = area;

    int w = width();
    int h = height();
    int X = x();
    int Y = y();

    if (m_percentX > 0.0)
        X = (int) (m_percentX * (float)m_parentArea.width()) + m_offsetX;
    if (m_percentY > 0.0)
        Y = (int) (m_percentY * (float)m_parentArea.height()) + m_offsetY;
    if (m_percentWidth > 0.0)
        w = (int) (m_percentWidth * (float)(m_parentArea.width() - X))
                   + m_offsetWidth;
    else if (m_offsetWidth != 0)
        w = m_parentArea.width() - X + m_offsetWidth;
    if (m_percentHeight > 0.0)
        h = (int) (m_percentHeight * (float)(m_parentArea.height() - Y))
                   + m_offsetHeight;
    else if (m_offsetHeight != 0)
        h = m_parentArea.height() - Y + m_offsetHeight;

    QRect::setRect(X,Y,w,h);

    m_needsUpdate = false;
}
Esempio n. 2
0
void MythPoint::CalculatePoint(const MythRect & parentArea)
{
    QRect area  = parentArea.toQRect();
    if ((m_parentArea == area && !m_needsUpdate) || !parentArea.isValid())
        return;

    m_parentArea  = area;

    int X = x();
    int Y = y();

    if (m_percentX > 0.0)
        X = (int) (m_percentX * (float)m_parentArea.width()) + m_offsetX;
    if (m_percentY > 0.0)
        Y = (int) (m_percentY * (float)m_parentArea.height()) + m_offsetY;

    QPoint::setX(X);
    QPoint::setY(Y);

    m_needsUpdate = false;
    valid = true;
}