aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-09-20 15:15:06 -0500
committerMichael Brasser <michael.brasser@live.com>2017-11-07 16:29:16 +0000
commit7bedd55551fbe95355b0db11f9d576924e829f9d (patch)
treefdef6c4ec81b46161162abacefe350c87a373830 /src/imports
parenta10f154e3b46cc004ab6f7d5319f550c450987d4 (diff)
Add new PathAngleArc type
This type allows working with arcs in different ways (based on angles rather than start/end positions) that can be more intuitive for certain use cases (such as a circular progress indicator). [ChangeLog][QtQuick][Path] Add new PathAngleArc type Change-Id: Icbe5fc0450edd9a4d92f9a8d03438842b72a312d Task-number: QTBUG-62684 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/shapes/qquickshapenvprrenderer.cpp25
-rw-r--r--src/imports/shapes/shapes.pro2
2 files changed, 26 insertions, 1 deletions
diff --git a/src/imports/shapes/qquickshapenvprrenderer.cpp b/src/imports/shapes/qquickshapenvprrenderer.cpp
index c0a918bda5..88f367fe70 100644
--- a/src/imports/shapes/qquickshapenvprrenderer.cpp
+++ b/src/imports/shapes/qquickshapenvprrenderer.cpp
@@ -43,6 +43,7 @@
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <qmath.h>
+#include <private/qpainterpath_p.h>
#include <private/qquickpath_p_p.h>
QT_BEGIN_NAMESPACE
@@ -287,6 +288,30 @@ void QQuickShapeNvprRenderer::convertPath(const QQuickPath *path, ShapePathGuiDa
if (d->path.str.isEmpty())
d->path.str = QString(QStringLiteral("M %1 %2 ")).arg(pos.x()).arg(pos.y()).toUtf8();
d->path.str.append(o->path().toUtf8());
+ } else if (QQuickPathAngleArc *o = qobject_cast<QQuickPathAngleArc *>(e)) {
+ QRectF rect(o->centerX() - o->radiusX(), o->centerY() - o->radiusY(), o->radiusX() * 2, o->radiusY() * 2);
+ QPointF startPoint;
+ QPointF endPoint;
+ qt_find_ellipse_coords(rect, o->startAngle(), -o->sweepAngle(), &startPoint, &endPoint);
+
+ // get to our starting position
+ if (o->moveToStart())
+ d->path.cmd.append(GL_MOVE_TO_NV);
+ else
+ d->path.cmd.append(GL_LINE_TO_NV); // ### should we check if startPoint == pos?
+ d->path.coord.append(startPoint.x());
+ d->path.coord.append(startPoint.y());
+
+ const bool sweepFlag = o->sweepAngle() > 0; // maps to CCW, not a typo
+ d->path.cmd.append(qAbs(o->sweepAngle()) > 180.0
+ ? (sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV)
+ : (sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV));
+ d->path.coord.append(o->radiusX());
+ d->path.coord.append(o->radiusY());
+ d->path.coord.append(0); // xAxisRotation
+ d->path.coord.append(endPoint.x());
+ d->path.coord.append(endPoint.y());
+ pos = endPoint;
} else {
qWarning() << "Shape/NVPR: unsupported Path element" << e;
}
diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro
index 4406474c3f..60cc61e974 100644
--- a/src/imports/shapes/shapes.pro
+++ b/src/imports/shapes/shapes.pro
@@ -3,7 +3,7 @@ TARGET = qmlshapesplugin
TARGETPATH = QtQuick/Shapes
IMPORT_VERSION = 1.0
-QT = core gui qml quick quick-private
+QT = core gui-private qml quick-private
HEADERS += \
qquickshape_p.h \