示例#1
0
void WindowManager::startResize( GenericLayout &rLayout, Direction_t direction )
{
    m_direction = direction;

    // Rebuild the set of moving windows.
    // From the resized window, we only take into account the anchors which
    // are mobile with the current type of resizing, and that are hanging a
    // window. The hanged windows will come will all their dependencies.

    m_resizeMovingE.clear();
    m_resizeMovingS.clear();
    m_resizeMovingSE.clear();

    WinSet_t::const_iterator itWin;
    AncList_t::const_iterator itAnc1, itAnc2;
    // Get the anchors of the layout
    const AncList_t &ancList1 = rLayout.getAnchorList();

    // Iterate through all the hanged windows
    for( itWin = m_dependencies[rLayout.getWindow()].begin();
         itWin != m_dependencies[rLayout.getWindow()].end(); ++itWin )
    {
        // Now, check for anchoring between the 2 windows
        const AncList_t &ancList2 =
            (*itWin)->getActiveLayout().getAnchorList();
        for( itAnc1 = ancList1.begin(); itAnc1 != ancList1.end(); ++itAnc1 )
        {
            for( itAnc2 = ancList2.begin();
                 itAnc2 != ancList2.end(); ++itAnc2 )
            {
                if( (*itAnc1)->isHanging( **itAnc2 ) )
                {
                    // Add the dependencies of the hanged window to one of the
                    // lists of moving windows
                    Position::Ref_t aRefPos =
                        (*itAnc1)->getPosition().getRefLeftTop();
                    if( aRefPos == Position::kRightTop )
                        buildDependSet( m_resizeMovingE, *itWin );
                    else if( aRefPos == Position::kLeftBottom )
                        buildDependSet( m_resizeMovingS, *itWin );
                    else if( aRefPos == Position::kRightBottom )
                        buildDependSet( m_resizeMovingSE, *itWin );
                    break;
                }
            }
        }
    }

    // The checkAnchors() method will need to have m_movingWindows properly set
    // so let's insert in it the contents of the other sets
    m_movingWindows.clear();
    m_movingWindows.insert( rLayout.getWindow() );
    m_movingWindows.insert( m_resizeMovingE.begin(), m_resizeMovingE.end() );
    m_movingWindows.insert( m_resizeMovingS.begin(), m_resizeMovingS.end() );
    m_movingWindows.insert( m_resizeMovingSE.begin(), m_resizeMovingSE.end() );
}
示例#2
0
void WindowManager::resize( GenericLayout &rLayout,
                            int width, int height ) const
{
    // TODO: handle anchored windows
    // Compute the real resizing offset
    int xOffset = width - rLayout.getWidth();
    int yOffset = height - rLayout.getHeight();

    // Check anchoring; this can change the values of xOffset and yOffset
    checkAnchors( rLayout.getWindow(), xOffset, yOffset );
    if( m_direction == kResizeS )
        xOffset = 0;
    if( m_direction == kResizeE )
        yOffset = 0;

    int newWidth = rLayout.getWidth() + xOffset;
    int newHeight = rLayout.getHeight() + yOffset;

    // Check boundaries
    if( newWidth < rLayout.getMinWidth() )
    {
        newWidth = rLayout.getMinWidth();
    }
    if( newWidth > rLayout.getMaxWidth() )
    {
        newWidth = rLayout.getMaxWidth();
    }
    if( newHeight < rLayout.getMinHeight() )
    {
        newHeight = rLayout.getMinHeight();
    }
    if( newHeight > rLayout.getMaxHeight() )
    {
        newHeight = rLayout.getMaxHeight();
    }

    if( newWidth == rLayout.getWidth() && newHeight == rLayout.getHeight() )
    {
        return;
    }

    // New offset, after the last corrections
    int xNewOffset = newWidth - rLayout.getWidth();
    int yNewOffset = newHeight - rLayout.getHeight();

    // Resize the window
    TopWindow *pWindow = rLayout.getWindow();
    pWindow->resize( newWidth, newHeight );

    // Do the actual resizing
    rLayout.resize( newWidth, newHeight );

    // refresh content
    rLayout.refreshAll();

    // Move all the anchored windows
    WinSet_t::const_iterator it;
    if( m_direction == kResizeE ||
        m_direction == kResizeSE )
    {
        for( it = m_resizeMovingE.begin(); it != m_resizeMovingE.end(); ++it )
        {
            (*it)->move( (*it)->getLeft() + xNewOffset,
                         (*it)->getTop() );
        }
    }
    if( m_direction == kResizeS ||
        m_direction == kResizeSE )
    {
        for( it = m_resizeMovingS.begin(); it != m_resizeMovingS.end(); ++it )
        {
            (*it)->move( (*it)->getLeft(),
                         (*it)->getTop( )+ yNewOffset );
        }
    }
    if( m_direction == kResizeE ||
        m_direction == kResizeS ||
        m_direction == kResizeSE )
    {
        for( it = m_resizeMovingSE.begin(); it != m_resizeMovingSE.end(); ++it )
        {
            (*it)->move( (*it)->getLeft() + xNewOffset,
                         (*it)->getTop() + yNewOffset );
        }
    }
}