]> git.sesse.net Git - vlc/commitdiff
Qt: limit the tooltip within the bounds of the widget
authorLudovic Fauvet <etix@l0cal.com>
Thu, 21 Apr 2011 23:19:13 +0000 (01:19 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 22 Apr 2011 22:08:47 +0000 (00:08 +0200)
And avoid showing a negative value. AFAIK time travel is not supported
yet (at least until #35 is closed).

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/util/input_slider.cpp

index d3fb835a5d1d4ec9e351ade9473d7c1db9307616..0788b643c119c74f1a71f5b4708566ed0309463b 100644 (file)
@@ -147,10 +147,13 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event )
     }
 
     /* Tooltip */
-     QPoint p( event->globalX() - mTimeTooltip->width() / 2,
+    int posX = qMax( rect().left(), qMin( rect().right(), event->x() ) );
+
+    QPoint p( event->globalX() - ( event->x() - posX ) - ( mTimeTooltip->width() / 2 ),
                QWidget::mapToGlobal( pos() ).y() - ( mTimeTooltip->height() + 2 ) );
 
-    secstotimestr( psz_length, ( event->x() * inputLength ) / size().width() );
+
+    secstotimestr( psz_length, ( posX * inputLength ) / size().width() );
     mTimeTooltip->setTime( psz_length );
     mTimeTooltip->move( p );
     event->accept();