Commit a706dc31 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Use a matrix to calculate the resize anchors of an item.

This fixes some mouse cursor issues.
parent 0b8dbcd4
...@@ -192,11 +192,7 @@ void GraphicsMovieItem::hoverMoveEvent( QGraphicsSceneHoverEvent* event ) ...@@ -192,11 +192,7 @@ void GraphicsMovieItem::hoverMoveEvent( QGraphicsSceneHoverEvent* event )
if ( tracksView()->tool() == TOOL_DEFAULT ) if ( tracksView()->tool() == TOOL_DEFAULT )
{ {
QPoint mouseMapped = tracksView()->mapFromScene( event->pos() ); if ( resizeZone( event->pos() ) )
QPoint sizeMapped = tracksView()->mapFromScene( boundingRect().width(), boundingRect().height() );
if ( mouseMapped.x() < RESIZE_ZONE ||
mouseMapped.x() > ( sizeMapped.x() - RESIZE_ZONE ) )
setCursor( Qt::SizeHorCursor ); setCursor( Qt::SizeHorCursor );
else else
setCursor( Qt::OpenHandCursor ); setCursor( Qt::OpenHandCursor );
...@@ -208,7 +204,12 @@ void GraphicsMovieItem::mousePressEvent( QGraphicsSceneMouseEvent* event ) ...@@ -208,7 +204,12 @@ void GraphicsMovieItem::mousePressEvent( QGraphicsSceneMouseEvent* event )
if ( !tracksView() ) return; if ( !tracksView() ) return;
if ( tracksView()->tool() == TOOL_DEFAULT ) if ( tracksView()->tool() == TOOL_DEFAULT )
setCursor( Qt::ClosedHandCursor ); {
if ( resizeZone( event->pos() ) )
setCursor( Qt::SizeHorCursor );
else
setCursor( Qt::ClosedHandCursor );
}
else if ( tracksView()->tool() == TOOL_CUT ) else if ( tracksView()->tool() == TOOL_CUT )
emit split( this, qRound64( event->pos().x() ) ); emit split( this, qRound64( event->pos().x() ) );
} }
...@@ -221,3 +222,18 @@ void GraphicsMovieItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* event ) ...@@ -221,3 +222,18 @@ void GraphicsMovieItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
if ( tracksView()->tool() == TOOL_DEFAULT ) if ( tracksView()->tool() == TOOL_DEFAULT )
setCursor( Qt::OpenHandCursor ); setCursor( Qt::OpenHandCursor );
} }
bool GraphicsMovieItem::resizeZone( const QPointF& position )
{
// Get the current transformation of the view and invert it.
QTransform transform = tracksView()->transform().inverted();
// Map the RESIZE_ZONE distance from the view to the item coordinates.
QLine line = transform.map( QLine( 0, 0, RESIZE_ZONE, 0 ) );
if ( position.x() < line.x2() ||
position.x() > ( boundingRect().width() - line.x2() ) )
{
return true;
}
return false;
}
...@@ -60,6 +60,7 @@ protected: ...@@ -60,6 +60,7 @@ protected:
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
private: private:
bool resizeZone( const QPointF& position );
Clip* m_clip; Clip* m_clip;
signals: signals:
......
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