X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fguide.cpp;h=299a82b07f8b4f4b7659f855232601fe38ccbd65;hb=5bac38471d4c90a8a520d6ec32b90913b6f0dbcb;hp=58cf9e9a358979811cc953024f3e8652b00fc91a;hpb=169cc8d6d4b64248e4a50e75747432a3bdcf5ffe;p=kdenlive diff --git a/src/guide.cpp b/src/guide.cpp index 58cf9e9a..299a82b0 100644 --- a/src/guide.cpp +++ b/src/guide.cpp @@ -27,18 +27,21 @@ #include #include -Guide::Guide(CustomTrackView *view, GenTime pos, QString label, double fps, double height) : +Guide::Guide(CustomTrackView *view, GenTime pos, QString label, double height) : QGraphicsLineItem(), m_position(pos), m_label(label), - m_fps(fps), m_view(view), m_pen(QPen()) { setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIgnoresTransformations); +#if QT_VERSION >= 0x040600 + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +#endif setToolTip(label); setLine(0, 0, 0, height); - setPos(m_position.frames(m_fps), 0); + if (m_position < GenTime()) m_position = GenTime(); + setPos(m_position.frames(m_view->fps()), 0); m_pen.setWidthF(0); m_pen.setColor(QColor(0, 0, 200, 180)); //m_pen.setCosmetic(true); @@ -68,7 +71,7 @@ CommentedTime Guide::info() const void Guide::updateGuide(const GenTime newPos, const QString &comment) { m_position = newPos; - setPos(m_position.frames(m_fps), 0); + setPos(m_position.frames(m_view->fps()), 0); if (!comment.isEmpty()) { m_label = comment; setToolTip(m_label); @@ -78,6 +81,11 @@ void Guide::updateGuide(const GenTime newPos, const QString &comment) } } +void Guide::updatePos() +{ + setPos(m_position.frames(m_view->fps()), 0); +} + //virtual int Guide::type() const { @@ -106,6 +114,7 @@ QVariant Guide::itemChange(GraphicsItemChange change, const QVariant &value) QPointF newPos = value.toPointF(); newPos.setY(0); newPos.setX(m_view->getSnapPointForPos(newPos.x())); + if (newPos.x() < 0.0) newPos.setX(0.0); return newPos; } return QGraphicsItem::itemChange(change, value); @@ -118,7 +127,7 @@ QRectF Guide::boundingRect() const double width = m_pen.widthF() / scale * 2; QRectF rect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1()); if (KdenliveSettings::showmarkers()) { - rect.setWidth(width + m_width / scale); + rect.setWidth(width + m_width); } return rect; } @@ -128,12 +137,11 @@ QPainterPath Guide::shape() const { QPainterPath path; if (!scene()) return path; - double scale = m_view->matrix().m11(); - double width = m_pen.widthF() / scale * 2; + double width = m_pen.widthF() * 2; path.addRect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1()); if (KdenliveSettings::showmarkers()) { const QFontMetrics metric = m_view->fontMetrics(); - QRectF txtBounding(line().x1() + 1 / scale, line().y1() + 10, m_width / scale, metric.height() / m_view->matrix().m22()); + QRectF txtBounding(line().x1(), line().y1() + 10, m_width, metric.height()); path.addRect(txtBounding); } return path; @@ -144,7 +152,6 @@ void Guide::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi { QGraphicsLineItem::paint(painter, option); if (KdenliveSettings::showmarkers()) { - //QPointF p1 = painter->matrix().map(line()).p1() + QPointF(1, 0); 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 + ' ');