diff --git a/utils/fgqcanvas/fgcanvaselement.cpp b/utils/fgqcanvas/fgcanvaselement.cpp index 1718c6e3c..9d9827055 100644 --- a/utils/fgqcanvas/fgcanvaselement.cpp +++ b/utils/fgqcanvas/fgcanvaselement.cpp @@ -175,30 +175,34 @@ void FGCanvasElement::paint(FGCanvasPaintContext *context) const QPainter* p = context->painter(); p->save(); + QTransform combined = combinedTransform(); if (_hasClip) { + QTransform t = p->transform(); + // clip is defined in the global coordinate system - if (_clipFrame != ReferenceFrame::GLOBAL) { - qWarning() << Q_FUNC_INFO << "implement support for non-global clips"; + if (_clipFrame == ReferenceFrame::GLOBAL) { + // this rpelaces the transform entirely + p->setTransform(context->globalCoordinateTransform()); + } else if (_clipFrame == ReferenceFrame::LOCAL) { + p->setTransform(combined, true /* combine */); + } else if (_clipFrame == ReferenceFrame::PARENT) { + // incoming transform is already our parent + } else { + qWarning() << "Unhandled clip type:" << static_cast(_clipFrame) << "at" << property()->path(); } + #if defined(DEBUG_PAINTING) - p->save(); - p->setTransform(context->globalCoordinateTransform()); p->setPen(Qt::yellow); p->setBrush(QBrush(Qt::yellow, Qt::DiagCrossPattern)); p->drawRect(_clipRect); - p->restore(); #endif - - QTransform t = p->transform(); - p->setTransform(context->globalCoordinateTransform()); - p->setClipRect(_clipRect); p->setClipping(true); - p->setTransform(t); + p->setClipRect(_clipRect); + p->setTransform(t); // restore the previous transformation } - QTransform combined = combinedTransform(); p->setTransform(combined, true /* combine */); if (!_fillColor.isValid()) { @@ -385,7 +389,7 @@ void FGCanvasElement::markClipDirty() requestPolish(); } -float FGCanvasElement::parseCSSValue(QByteArray value) const +double FGCanvasElement::parseCSSValue(QByteArray value) const { value = value.trimmed(); // deal with %, px suffixes @@ -396,7 +400,7 @@ float FGCanvasElement::parseCSSValue(QByteArray value) const value.truncate(value.length() - 2); } bool ok = false; - float v = value.toFloat(&ok); + qreal v = value.toDouble(&ok); if (!ok) { qWarning() << "failed to parse:" << value; } @@ -406,7 +410,7 @@ float FGCanvasElement::parseCSSValue(QByteArray value) const QColor FGCanvasElement::parseColorValue(QVariant value) const { QString colorString = value.toString(); - if (colorString.isEmpty() || colorString == "none") { + if (colorString.isEmpty() || (colorString == QStringLiteral("none"))) { return QColor(); // return an invalid color } diff --git a/utils/fgqcanvas/fgcanvaselement.h b/utils/fgqcanvas/fgcanvaselement.h index ce9cf5d41..be1b1dea9 100644 --- a/utils/fgqcanvas/fgcanvaselement.h +++ b/utils/fgqcanvas/fgcanvaselement.h @@ -140,7 +140,7 @@ private: mutable ReferenceFrame _clipFrame = ReferenceFrame::GLOBAL; void parseCSSClip(QByteArray value); - float parseCSSValue(QByteArray value) const; + double parseCSSValue(QByteArray value) const; }; using FGCanvasElementVec = std::vector; diff --git a/utils/fgqcanvas/fgcanvaspath.cpp b/utils/fgqcanvas/fgcanvaspath.cpp index a21415bbc..4c5e1ed64 100644 --- a/utils/fgqcanvas/fgcanvaspath.cpp +++ b/utils/fgqcanvas/fgcanvaspath.cpp @@ -218,13 +218,13 @@ signals: void strokeChanged(QPen stroke); protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override { QQuickItem::geometryChanged(newGeometry, oldGeometry); update(); } - QRectF boundingRect() const + QRectF boundingRect() const override { if ((width() == 0.0) || (height() == 0.0)) { return QRectF(0.0, 0.0, implicitWidth(), implicitHeight()); diff --git a/utils/fgqcanvas/fgcanvastext.cpp b/utils/fgqcanvas/fgcanvastext.cpp index 1f60c3e63..181e4ebca 100644 --- a/utils/fgqcanvas/fgcanvastext.cpp +++ b/utils/fgqcanvas/fgcanvastext.cpp @@ -210,7 +210,12 @@ void FGCanvasText::dumpElement() void FGCanvasText::doPaint(FGCanvasPaintContext *context) const { context->painter()->setFont(_font); - context->painter()->setPen(fillColor()); + QColor c = fillColor(); + if (!c.isValid()) { + c = Qt::white; + } + + context->painter()->setPen(c); context->painter()->setBrush(Qt::NoBrush); QRectF rect(0, 0, 1000, 1000); diff --git a/utils/fgqcanvas/fgqcanvasimage.cpp b/utils/fgqcanvas/fgqcanvasimage.cpp index c8102547a..029cd2b6c 100644 --- a/utils/fgqcanvas/fgqcanvasimage.cpp +++ b/utils/fgqcanvas/fgqcanvasimage.cpp @@ -89,13 +89,13 @@ public: } protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override { QQuickItem::geometryChanged(newGeometry, oldGeometry); update(); } - QRectF boundingRect() const + QRectF boundingRect() const override { if (!widthValid() || !heightValid()) { return QRectF(QPointF(), m_size);