+// virtual
+QRectF Guide::boundingRect() const
+{
+ double scale = m_view->matrix().m11();
+ double width = m_pen.widthF() / scale * 2;
+ QRectF rect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1());
+ if (KdenliveSettings::showmarkers()) {
+ // +3 to cover the arc at the end of the comment
+ rect.setWidth(width + m_width + 3);
+ }
+ return rect;
+}
+
+// virtual
+QPainterPath Guide::shape() const
+{
+ QPainterPath path;
+ 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() && scene()->views().count()) {
+ const QFontMetrics metric = m_view->fontMetrics();
+ int offset = scene()->views()[0]->verticalScrollBar()->value();
+ QRectF txtBounding(line().x1(), line().y1() + offset, m_width, metric.height());
+ path.addRect(txtBounding);
+ }
+ return path;
+}
+
+// virtual
+void Guide::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*w*/)
+{
+ QGraphicsLineItem::paint(painter, option);
+ if (KdenliveSettings::showmarkers() && scene() && scene()->views().count()) {
+ QPointF p1 = line().p1();
+ const QFontMetrics metric = m_view->fontMetrics();
+ painter->setClipRect(option->rect);
+ // makes sure the text stays visible when scrolling vertical
+ int offset = scene()->views()[0]->verticalScrollBar()->value();
+
+ QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + offset, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, m_label);
+ painter->setBrush(QBrush(m_pen.color()));
+ painter->drawRoundedRect(txtBounding.adjusted(-5, -5, 2, 1), 3, 3);
+ painter->setPen(Qt::white);
+ painter->drawText(txtBounding.adjusted(1, 0, 1, 0), Qt::AlignCenter, m_label);
+ }
+}
+