]> git.sesse.net Git - kdenlive/commitdiff
Fix guide comment not visible when scrolling vertically (make it float):
authorTill Theato <root@ttill.de>
Sun, 12 Dec 2010 12:07:21 +0000 (12:07 +0000)
committerTill Theato <root@ttill.de>
Sun, 12 Dec 2010 12:07:21 +0000 (12:07 +0000)
http://kdenlive.org/mantis/view.php?id=1911

svn path=/trunk/kdenlive/; revision=5164

src/guide.cpp

index 299a82b07f8b4f4b7659f855232601fe38ccbd65..8c27f4dbff52eea8b9132f99a6b8f930ed8421eb 100644 (file)
@@ -26,6 +26,8 @@
 #include <QPen>
 #include <QBrush>
 #include <QStyleOptionGraphicsItem>
+#include <QGraphicsView>
+#include <QScrollBar>
 
 Guide::Guide(CustomTrackView *view, GenTime pos, QString label, double height) :
         QGraphicsLineItem(),
@@ -139,9 +141,10 @@ QPainterPath Guide::shape() const
     if (!scene()) return path;
     double width = m_pen.widthF() * 2;
     path.addRect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1());
-    if (KdenliveSettings::showmarkers()) {
+    if (KdenliveSettings::showmarkers() && scene()->views().count()) {
         const QFontMetrics metric = m_view->fontMetrics();
-        QRectF txtBounding(line().x1(), line().y1() + 10, m_width, metric.height());
+        int offset = scene()->views()[0]->verticalScrollBar()->value();
+        QRectF txtBounding(line().x1(), line().y1() + 10 + offset, m_width, metric.height());
         path.addRect(txtBounding);
     }
     return path;
@@ -151,10 +154,14 @@ QPainterPath Guide::shape() const
 void Guide::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*w*/)
 {
     QGraphicsLineItem::paint(painter, option);
-    if (KdenliveSettings::showmarkers()) {
+    if (KdenliveSettings::showmarkers() && scene() && scene()->views().count()) {
         QPointF p1 = line().p1() + QPointF(1, 0);
         const QFontMetrics metric = m_view->fontMetrics();
-        QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + 10, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, ' ' + m_label + ' ');
+
+        // makes sure the text stays visible when scrolling vertical
+        int offset = scene()->views()[0]->verticalScrollBar()->value();
+
+        QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + 10 + offset, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, ' ' + m_label + ' ');
         QPainterPath path;
         path.addRoundedRect(txtBounding, 3, 3);
         painter->fillPath(path, m_pen.color());