Commit 39838f46 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Timeline: ensure the cursor is always visible when dragging

parent f8c66867
...@@ -52,6 +52,9 @@ TracksView::TracksView( QGraphicsScene* scene, QWidget* parent ) ...@@ -52,6 +52,9 @@ TracksView::TracksView( QGraphicsScene* scene, QWidget* parent )
m_cursorLine = new GraphicsCursorItem( maxHeight, QPen( QColor( 220, 30, 30 ) ) ); m_cursorLine = new GraphicsCursorItem( maxHeight, QPen( QColor( 220, 30, 30 ) ) );
m_scene->addItem( m_cursorLine ); m_scene->addItem( m_cursorLine );
connect( m_cursorLine, SIGNAL( cursorPositionChanged(int) ),
this, SLOT( ensureCursorVisible() ) );
} }
void TracksView::dragEnterEvent( QDragEnterEvent* event ) void TracksView::dragEnterEvent( QDragEnterEvent* event )
...@@ -217,3 +220,9 @@ void TracksView::setScale( double scaleFactor ) ...@@ -217,3 +220,9 @@ void TracksView::setScale( double scaleFactor )
} }
centerOn( m_cursorLine ); centerOn( m_cursorLine );
} }
void TracksView::ensureCursorVisible()
{
if ( horizontalScrollBar()->isVisible() )
m_cursorLine->ensureVisible( QRectF(), 150, 50 );
}
...@@ -60,6 +60,9 @@ protected: ...@@ -60,6 +60,9 @@ protected:
virtual void dropEvent( QDropEvent* event ); virtual void dropEvent( QDropEvent* event );
virtual void dragMoveEvent( QDragMoveEvent* event ); virtual void dragMoveEvent( QDragMoveEvent* event );
private slots:
void ensureCursorVisible();
private: private:
QGraphicsScene* m_scene; QGraphicsScene* m_scene;
int m_tracksHeight; int m_tracksHeight;
......
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