Commit 723844e0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved resize undo/redo precision problem

parent a9104000
......@@ -132,7 +132,18 @@ void Commands::MainWorkflow::ResizeClip::redo()
void Commands::MainWorkflow::ResizeClip::undo()
{
m_renderer->resizeClip( m_clip, m_oldBegin, m_oldEnd, m_oldPos, m_trackId, m_trackType, m_undoRedoAction );
//This code is complete crap.
// We need to case, because when we redo a "begin-resize", we need to first resize, then move.
//In the other cases, we need to move, then resize.
if ( m_oldBegin == m_newBegin )
{
m_renderer->resizeClip( m_clip, m_oldBegin, m_oldEnd, m_oldPos, m_trackId, m_trackType, m_undoRedoAction );
}
else
{
m_clip->setBoundaries( m_oldBegin, m_oldEnd );
::MainWorkflow::getInstance()->moveClip( m_clip->getUuid(), m_trackId, m_trackId, m_oldPos, m_trackType, m_undoRedoAction );
}
}
Commands::MainWorkflow::SplitClip::SplitClip( WorkflowRenderer* renderer, Clip* toSplit, uint32_t trackId,
......
......@@ -100,27 +100,31 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
{
Q_ASSERT( clip() );
if ( size > clip()->getParent()->getNbFrames() )
{
qWarning( "AbstractGraphicsMediaItem: Can't expand a clip beyond its original size" );
if ( size > clip()->getParent()->getNbFrames() || size < 0 )
return;
}
if ( size < 0 ) return;
qint64 realBegin = startPos() - clip()->getBegin();
qint64 realEnd = realBegin + clip()->getParent()->getNbFrames();
if ( from == BEGINNING )
{
tracksView()->getRenderer()->resizeClip( clip(), clip()->getBegin(), clip()->getBegin() + size, boundingRect().x(),
if ( clip()->getBegin() + size > realEnd )
return ;
tracksView()->getRenderer()->resizeClip( clip(), clip()->getBegin(), clip()->getBegin() + size, 0, //This parameter is unused in this case
trackNumber(), MainWorkflow::VideoTrack );
}
else
{
qint64 newBegin = qMax( clip()->getEnd() - size, (qint64)0 );
if ( realBegin > newBegin + startPos() )
return ;
qint64 oldLength = clip()->getLength();
if ( ( clip()->getEnd() - size ) < 0 )
{
qWarning( "Warning: resizing a region with a size below 0" );
size += clip()->getEnd() - size;
}
m_resizeExpected = true;
tracksView()->getRenderer()->resizeClip( clip(), qMax( clip()->getEnd() - size, (qint64)0 ), clip()->getEnd(),
startPos() + ( oldLength - size ), trackNumber(), MainWorkflow::VideoTrack );
setStartPos( startPos() + ( oldLength - size ) );
......@@ -131,6 +135,11 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
void AbstractGraphicsMediaItem::adjustLength()
{
if ( m_resizeExpected == true )
{
m_resizeExpected = false;
return ;
}
Q_ASSERT( clip() );
resize( clip()->getLength() );
}
......@@ -121,8 +121,10 @@ private:
/// Pointer used to save the address of a linked item.
AbstractGraphicsMediaItem* m_group;
qint64 m_width;
qint64 m_height;
qint64 m_width;
qint64 m_height;
//FIXME: this is a nasty forest boolean
bool m_resizeExpected;
};
#endif // ABSTRACTGRAPHICSMEDIAITEM_H
......@@ -335,6 +335,7 @@ void WorkflowRenderer::resizeClip( Clip* clip, qint64 newBegin, qint64 newEnd
m_mainWorkflow->moveClip( clip->getUuid(), trackId, trackId, newPos, trackType, undoRedoAction );
}
clip->setBoundaries( newBegin, newEnd );
// }
}
......
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