Exemplo n.º 1
0
void PlayerContainer::mousePressEvent(QMouseEvent* event)
{
    event->accept();

    tempCardPosition = getCurrArea();
    tempCardObject = cards[tempCardPosition];

    emit onPositionChange();

    if(event->button() == Qt::RightButton) {
        // vraca true ako je grupa ubacena
        if( group->addCard(tempCardObject) ) {
            tempCardObject->move(position.x() + tempCardPosition*cardDistance,
                             position.y() - 20); // npr 20 nebitno je
            emit onAddingCardtoGroup(false);
        }
        else {
            // remove card vraca true ako je grupa ispraznjena
            if( group->removeCard(tempCardObject) )
                emit onEmptyGroup(true);
            tempCardObject->move(position.x() + tempCardPosition*cardDistance,
                             position.y()); // npr 20 nebitno je
        }
    }
}
Exemplo n.º 2
0
void CtrlGeneric::setLayout( GenericLayout *pLayout,
                             const Position &rPosition )
{
    m_pLayout = pLayout;
    delete m_pPosition;
    m_pPosition = new Position( rPosition );
    onPositionChange();
}
Exemplo n.º 3
0
void PlayerContainer::mouseReleaseEvent(QMouseEvent* event)
{
    if(event->button() == Qt::RightButton) {
        return;
    }

    int areaOfCurrCard = getCurrArea();

    if( tempCardPosition == -1)
        return;

    if( tempCardObject->isLeftClick() ) {


        /*
        cards[tempCardPosition] = tempCardObject;
        cards[tempCardPosition]->
            move(position.x() + areaOfCurrCard * cardDistance,
                 position.y());
                 */

        if(areaOfCurrCard == tempCardPosition) {
            cards[areaOfCurrCard] = tempCardObject;
            cards[areaOfCurrCard]->move(position.x() + areaOfCurrCard * cardDistance,
                                        position.y());
        }
        else if( areaOfCurrCard < tempCardPosition) {
            for(int i = tempCardPosition ; i > areaOfCurrCard ; i--) {
                cards[i] = cards[i-1];
                cards[i]->move(position.x() + i * cardDistance,
                               position.y());
            }
            cards[areaOfCurrCard] = tempCardObject;
            cards[areaOfCurrCard]->move(position.x() + areaOfCurrCard * cardDistance,
                                        position.y());
        }
        else {
            for(int i = tempCardPosition ; i < areaOfCurrCard; i++) {
                cards[i] = cards[i+1];
                cards[i]->move(position.x() + i * cardDistance,
                           position.y());
            }
            cards[areaOfCurrCard] = tempCardObject;
            cards[areaOfCurrCard]->move(position.x() + areaOfCurrCard * cardDistance,
                                        position.y());
        }

        cards[tempCardPosition]->e->setOpacity(1);
        cards[tempCardPosition]->setGraphicsEffect(cards[tempCardPosition]->e);

        tempCardPosition = -1;
        emit onPositionChange();

        //    refreshDepth();
        for(Card* c : cards)
            c->raise();
    }
}
Exemplo n.º 4
0
void CtrlGeneric::setLayout( GenericLayout *pLayout,
                             const Position &rPosition )
{
    assert( !m_pLayout && pLayout);

    m_pLayout = pLayout;
    m_pPosition = new Position( rPosition );
    onPositionChange();
}
Exemplo n.º 5
0
void CtrlText::displayText( const UString &rText )
{
    // Create the images ('normal' and 'double') from the text
    // 'Normal' image
    delete m_pImg;
    m_pImg = m_rFont.drawString( rText, m_color );
    if( !m_pImg )
    {
        return;
    }
    // 'Double' image
    const UString doubleStringWithSep = rText + SEPARATOR_STRING + rText;
    delete m_pImgDouble;
    m_pImgDouble = m_rFont.drawString( doubleStringWithSep, m_color );

    // Update the current image used, as if the control size had changed
    onPositionChange();

    if( m_alignment == kRight && getPosition() &&
        getPosition()->getWidth() < m_pImg->getWidth() )
    {
        m_xPos = getPosition()->getWidth() - m_pImg->getWidth();
    }
    else if( m_alignment == kCenter && getPosition() &&
             getPosition()->getWidth() < m_pImg->getWidth() )
    {
        m_xPos = (getPosition()->getWidth() - m_pImg->getWidth()) / 2;
    }
    else
    {
        m_xPos = 0;
    }

    if( getPosition() )
    {
        // If the control was in the moving state, check if the scrolling is
        // still necessary
        const string &rState = m_fsm.getState();
        if( rState == "moving" || rState == "outMoving" )
        {
            if( m_pImg && m_pImg->getWidth() >= getPosition()->getWidth() )
            {
                m_pCurrImg = m_pImgDouble;
                m_pTimer->start( MOVING_TEXT_DELAY, false );
            }
            else
            {
                m_pTimer->stop();
            }
        }
        notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
    }
}
Exemplo n.º 6
0
void CtrlSliderCursor::notifyLayout( int width, int height, int xOffSet, int yOffSet )
{
    if( width > 0 && height > 0 )
    {
        CtrlGeneric::notifyLayout( width, height, xOffSet, yOffSet );
    }
    else
    {
        onPositionChange();

        const Position *pPos = getPosition();
        CtrlGeneric::notifyLayout( m_currentCursorRect.width,
                                   m_currentCursorRect.height,
                                   m_currentCursorRect.x - pPos->getLeft(),
                                   m_currentCursorRect.y - pPos->getTop() );
    }
}
void CtrlText::onResize()
{
    onPositionChange();
}
void CtrlTree::onResize()
{
    onPositionChange();
}
Exemplo n.º 9
0
void CtrlSliderCursor::onResize()
{
    onPositionChange();
}