コード例 #1
0
ファイル: generic_layout.cpp プロジェクト: mstorsjo/vlc
void GenericLayout::refreshRect( int x, int y, int width, int height )
{
    // Do nothing if the layout is hidden
    if( !m_visible )
        return;

    // update the transparency global mask
    m_pImage->clear( x, y, width, height );

    // Draw all the controls of the layout
    std::list<LayeredControl>::const_iterator iter;
    for( iter = m_controlList.begin(); iter != m_controlList.end(); ++iter )
    {
        CtrlGeneric *pCtrl = (*iter).m_pControl;
        if( pCtrl->isVisible() )
        {
            pCtrl->draw( *m_pImage, x, y, width, height );
        }
    }

    // Refresh the associated window
    TopWindow *pWindow = getWindow();
    if( pWindow )
    {
        // first apply new shape to the window
        pWindow->updateShape();
        pWindow->invalidateRect( x, y, width, height );
    }
}
コード例 #2
0
ファイル: top_window.cpp プロジェクト: forthyen/SDesk
CtrlGeneric *TopWindow::findHitControl( int xPos, int yPos )
{
    if( m_pActiveLayout == NULL )
    {
        return NULL;
    }

    // Get the controls in the active layout
    const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
    list<LayeredControl>::const_reverse_iterator iter;

    // New control hit by the mouse
    CtrlGeneric *pNewHitControl = NULL;

    // Loop on the control list to find the uppest hit control
    for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); iter++ )
    {
        // Get the position of the control in the layout
        const Position *pos = (*iter).m_pControl->getPosition();
        if( pos != NULL )
        {
            // Compute the coordinates of the mouse relative to the control
            int xRel = xPos - pos->getLeft();
            int yRel = yPos - pos->getTop();

            CtrlGeneric *pCtrl = (*iter).m_pControl;
            // Control hit ?
            if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
            {
                pNewHitControl = (*iter).m_pControl;
                break;
            }
        }
        else
        {
            msg_Dbg( getIntf(), "Control at NULL position" );
        }
    }

    // If the hit control has just been entered, send it an enter event
    if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
    {
        // Don't send the event if another control captured the mouse
        if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
        {
            EvtEnter evt( getIntf() );
            pNewHitControl->handleEvent( evt );

            if( !m_pCapturingControl )
            {
                // Show the tooltip
                m_rWindowManager.hideTooltip();
                UString tipText = pNewHitControl->getTooltipText();
                if( tipText.length() > 0 )
                {
                    // Set the tooltip text variable
                    VarManager *pVarManager = VarManager::instance( getIntf() );
                    pVarManager->getTooltipText().set( tipText );
                    m_rWindowManager.showTooltip();
                }
            }
        }
    }

    return pNewHitControl;
}
コード例 #3
0
void GenericLayout::refreshRect( int x, int y, int width, int height )
{
    // Do nothing if the layout is hidden
    if( !m_visible )
        return;

    // Draw all the controls of the layout
    list<LayeredControl>::const_iterator iter;
    list<LayeredControl>::const_iterator iterVideo = m_controlList.end();
    for( iter = m_controlList.begin(); iter != m_controlList.end(); iter++ )
    {
        CtrlGeneric *pCtrl = (*iter).m_pControl;
        const Position *pPos = pCtrl->getPosition();
        if( pPos && pCtrl->isVisible() )
        {
            pCtrl->draw( *m_pImage, pPos->getLeft(), pPos->getTop() );
        }
    }

    // Refresh the associated window
    TopWindow *pWindow = getWindow();
    if( pWindow )
    {
        // Check boundaries
        if( x < 0 )
            x = 0;
        if( y < 0)
            y = 0;
        if( x + width > m_width )
            width = m_width - x;
        if( y + height > m_height )
            height = m_height - y;

        // Refresh the window... but do not paint on a visible video control!
        if( !m_pVideoControl || !m_pVideoControl->isVisible() )
        {
            // No video control, we can safely repaint the rectangle
            pWindow->refresh( x, y, width, height );
        }
        else
        {
            // Bad luck, there is a video control somewhere (not necessarily
            // in the repainting zone, btw).
            // We will divide the repainting into 4 regions (top, left, bottom
            // and right). The overlapping parts (i.e. the corners) of these
            // regions will be painted twice, because otherwise the algorithm
            // becomes a real mess :)

            // Use short variable names for convenience
            int xx = m_pVideoControl->getPosition()->getLeft();
            int yy = m_pVideoControl->getPosition()->getTop();
            int ww = m_pVideoControl->getPosition()->getWidth();
            int hh = m_pVideoControl->getPosition()->getHeight();

            // Top part:
            if( y < yy )
                pWindow->refresh( x, y, width, yy - y );
            // Left part:
            if( x < xx )
                pWindow->refresh( x, y, xx - x, height );
            // Bottom part
            if( y + height > yy + hh )
                pWindow->refresh( x, yy + hh, width, y + height - (yy + hh) );
            // Right part
            if( x + width > xx + ww )
                pWindow->refresh( xx + ww, y, x + width - (xx + ww), height );
        }
    }
}