Commit 14465521 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Prevent clips to overlap when resizing.

parent 114e1eb5
......@@ -500,15 +500,39 @@ void TracksView::mouseMoveEvent( QMouseEvent* event )
QPointF itemPos = m_actionItem->mapToScene( 0, 0 );
QPointF itemNewSize = mapToScene( event->pos() ) - itemPos;
if ( m_actionResizeType == AbstractGraphicsMediaItem::END )
//FIXME: BEGIN UGLY
GraphicsTrack* track = getTrack( m_actionItem->mediaType(), m_actionItem->trackNumber() );
Q_ASSERT( track );
QPointF collidePos = track->sceneBoundingRect().topRight();
collidePos.setX( itemPos.x() + itemNewSize.x() );
QList<QGraphicsItem*> gi = scene()->items( collidePos );
bool collide = false;
for ( int i = 0; i < gi.count(); ++i )
{
qint64 distance = mapToScene( event->pos() ).x() - m_actionResizeStart;
qint64 newsize = qMax( m_actionResizeBase - distance, (qint64)0 );
m_actionItem->resize( newsize , AbstractGraphicsMediaItem::END );
AbstractGraphicsMediaItem* mi = dynamic_cast<AbstractGraphicsMediaItem*>( gi.at( i ) );
if ( mi && mi != m_actionItem )
{
collide = true;
break;
}
}
else
// END UGLY
if ( !collide )
{
m_actionItem->resize( itemNewSize.x(), AbstractGraphicsMediaItem::BEGINNING );
if ( m_actionResizeType == AbstractGraphicsMediaItem::END )
{
qint64 distance = mapToScene( event->pos() ).x() - m_actionResizeStart;
qint64 newsize = qMax( m_actionResizeBase - distance, (qint64)0 );
m_actionItem->resize( newsize , AbstractGraphicsMediaItem::END );
}
else
{
m_actionItem->resize( itemNewSize.x(), AbstractGraphicsMediaItem::BEGINNING );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment