From 5d0d0f4af2ada74d0ec7fdd5d9d6d8f7b1032dc7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 5 Jan 2012 09:58:47 +1000 Subject: Document new Path elements. Change-Id: Ic1e2aa7da63a7d9e12357a609fc52b3913f14f28 Reviewed-by: Bea Lam --- doc/src/declarative/elements.qdoc | 3 + doc/src/declarative/whatsnew.qdoc | 2 + doc/src/images/declarative-arcdirection.png | Bin 0 -> 8422 bytes doc/src/images/declarative-arcradius.png | Bin 0 -> 4535 bytes doc/src/images/declarative-largearc.png | Bin 0 -> 8340 bytes doc/src/images/declarative-patharc.png | Bin 0 -> 4827 bytes doc/src/images/declarative-pathcurve.png | Bin 0 -> 6092 bytes doc/src/images/declarative-pathsvg.png | Bin 0 -> 4233 bytes doc/src/snippets/declarative/path/arcdirection.qml | 51 ++++ doc/src/snippets/declarative/path/arcradius.qml | 63 +++++ doc/src/snippets/declarative/path/basicarc.qml | 52 ++++ doc/src/snippets/declarative/path/basiccurve.qml | 63 +++++ doc/src/snippets/declarative/path/largearc.qml | 51 ++++ src/quick/util/qdeclarativepath.cpp | 269 ++++++++++++++++++++- tests/auto/qtquick2/examples/tst_examples.cpp | 1 + 15 files changed, 549 insertions(+), 6 deletions(-) create mode 100644 doc/src/images/declarative-arcdirection.png create mode 100644 doc/src/images/declarative-arcradius.png create mode 100644 doc/src/images/declarative-largearc.png create mode 100644 doc/src/images/declarative-patharc.png create mode 100644 doc/src/images/declarative-pathcurve.png create mode 100644 doc/src/images/declarative-pathsvg.png create mode 100644 doc/src/snippets/declarative/path/arcdirection.qml create mode 100644 doc/src/snippets/declarative/path/arcradius.qml create mode 100644 doc/src/snippets/declarative/path/basicarc.qml create mode 100644 doc/src/snippets/declarative/path/basiccurve.qml create mode 100644 doc/src/snippets/declarative/path/largearc.qml diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 5cacd86ccd..483f221492 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -158,6 +158,9 @@ Elements that animate properties based on data types \o \l {PathLine} - Defines a line in \l {Path} \o \l {PathQuad} - Defines a quadratic Bezier curve in a \l {Path} \o \l {PathCubic} - Defines a cubic Bezier curve in a \l {Path} +\o \l {PathArc} - Defines an arc in a \l {Path} +\o \l {PathCurve} - Defines a point on a Catmull-Rom curve in a \l {Path} +\o \l {PathSvg} - Defines a sub-path specified as a SVG path data string in a \l {Path} \o \l {PathAttribute} - Allows the setting of attributes along a \l {Path} \o \l {PathPercent} - Modifies the item distribution along a \l {Path} \endlist diff --git a/doc/src/declarative/whatsnew.qdoc b/doc/src/declarative/whatsnew.qdoc index ef23d15f62..554ca6ec75 100644 --- a/doc/src/declarative/whatsnew.qdoc +++ b/doc/src/declarative/whatsnew.qdoc @@ -143,6 +143,8 @@ A new property type ("var") has been introduced which obsoletes "variant" proper Properties of this type are equivalent to regular JavaScript variables. See the documentation on \l{QML Basic Types} for more information about "var" properties. +New elements have been added for contructing paths: PathArc, PathCurve, PathSvg. + \section2 QtQuick 1 is now a separate library and module Writing C++ applications using QtQuick 1 specific API, i.e. QDeclarativeView or QDeclarativeItem diff --git a/doc/src/images/declarative-arcdirection.png b/doc/src/images/declarative-arcdirection.png new file mode 100644 index 0000000000..28f4dc2e51 Binary files /dev/null and b/doc/src/images/declarative-arcdirection.png differ diff --git a/doc/src/images/declarative-arcradius.png b/doc/src/images/declarative-arcradius.png new file mode 100644 index 0000000000..9b25a9f3f8 Binary files /dev/null and b/doc/src/images/declarative-arcradius.png differ diff --git a/doc/src/images/declarative-largearc.png b/doc/src/images/declarative-largearc.png new file mode 100644 index 0000000000..9bb94b362e Binary files /dev/null and b/doc/src/images/declarative-largearc.png differ diff --git a/doc/src/images/declarative-patharc.png b/doc/src/images/declarative-patharc.png new file mode 100644 index 0000000000..81c9b803e5 Binary files /dev/null and b/doc/src/images/declarative-patharc.png differ diff --git a/doc/src/images/declarative-pathcurve.png b/doc/src/images/declarative-pathcurve.png new file mode 100644 index 0000000000..c585cff0f0 Binary files /dev/null and b/doc/src/images/declarative-pathcurve.png differ diff --git a/doc/src/images/declarative-pathsvg.png b/doc/src/images/declarative-pathsvg.png new file mode 100644 index 0000000000..949149e722 Binary files /dev/null and b/doc/src/images/declarative-pathsvg.png differ diff --git a/doc/src/snippets/declarative/path/arcdirection.qml b/doc/src/snippets/declarative/path/arcdirection.qml new file mode 100644 index 0000000000..a3e4156e75 --- /dev/null +++ b/doc/src/snippets/declarative/path/arcdirection.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 50; startY: 50 + + PathArc { + x: 150; y: 50 + radiusX: 75; radiusY: 50 + } +} +//![0] diff --git a/doc/src/snippets/declarative/path/arcradius.qml b/doc/src/snippets/declarative/path/arcradius.qml new file mode 100644 index 0000000000..d48636659e --- /dev/null +++ b/doc/src/snippets/declarative/path/arcradius.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 0; startY: 100 + + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 15 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 25 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 50 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 50; radiusY: 100 + } +} +//![0] diff --git a/doc/src/snippets/declarative/path/basicarc.qml b/doc/src/snippets/declarative/path/basicarc.qml new file mode 100644 index 0000000000..0002d26e8a --- /dev/null +++ b/doc/src/snippets/declarative/path/basicarc.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 100; startY: 0 + + PathArc { + x: 0; y: 100 + radiusX: 100; radiusY: 100 + useLargeArc: true + } +} +//![0] diff --git a/doc/src/snippets/declarative/path/basiccurve.qml b/doc/src/snippets/declarative/path/basiccurve.qml new file mode 100644 index 0000000000..c2dd85f89e --- /dev/null +++ b/doc/src/snippets/declarative/path/basiccurve.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Canvas { + width: 400; height: 200 + + Path { + id: myPath + startX: 0; startY: 100 + + PathCurve { x: 75; y: 75 } + PathCurve { x: 200; y: 150 } + PathCurve { x: 325; y: 25 } + PathCurve { x: 400; y: 100 } + } + + onPaint: { + context.strokeStyle = Qt.rgba(.4,.6,.8); + context.path = myPath; + context.stroke(); + } +} +//![0] diff --git a/doc/src/snippets/declarative/path/largearc.qml b/doc/src/snippets/declarative/path/largearc.qml new file mode 100644 index 0000000000..81b05f9cca --- /dev/null +++ b/doc/src/snippets/declarative/path/largearc.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 0; startY: 100 + PathArc { + x: 100; y: 200 + radiusX: 100; radiusY: 100 + direction: PathArc.Clockwise + } +} +//![0] diff --git a/src/quick/util/qdeclarativepath.cpp b/src/quick/util/qdeclarativepath.cpp index 2ba7c372e2..a4f45919ee 100644 --- a/src/quick/util/qdeclarativepath.cpp +++ b/src/quick/util/qdeclarativepath.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE This type is the base for all path types. It cannot be instantiated. - \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic + \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg */ /*! @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE \brief A Path object defines a path for use by \l PathView. A Path is composed of one or more path segments - PathLine, PathQuad, - PathCubic. + PathCubic, PathArc, PathCurve, PathSvg. The spacing of the items along the Path can be adjusted via a PathPercent object. @@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE PathAttribute allows named attributes with values to be defined along the path. - \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic + \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg */ QDeclarativePath::QDeclarativePath(QObject *parent) : QObject(*(new QDeclarativePathPrivate), parent) @@ -174,6 +174,9 @@ bool QDeclarativePath::hasEnd() const \i \l PathLine - a straight line to a given position. \i \l PathQuad - a quadratic Bezier curve to a given position with a control point. \i \l PathCubic - a cubic Bezier curve to a given position with two control points. + \i \l PathArc - an arc to a given position with a radius. + \i \l PathSvg - a path specified as an SVG path data string. + \i \l PathCurve - a point on a Catmull-Rom curve. \i \l PathAttribute - an attribute at a given position in the path. \i \l PathPercent - a way to spread out items along various segments of the path. \endlist @@ -889,7 +892,7 @@ void QDeclarativePathAttribute::setValue(qreal value) } \endqml - \sa Path, PathQuad, PathCubic + \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg */ /*! @@ -897,6 +900,23 @@ void QDeclarativePathAttribute::setValue(qreal value) \qmlproperty real QtQuick2::PathLine::y Defines the end point of the line. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick2::PathLine::relativeX + \qmlproperty real QtQuick2::PathLine::relativeY + + Defines the end point of the line relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y */ inline QPointF positionForCurve(const QDeclarativePathData &data, const QPointF &prevPoint) @@ -933,7 +953,7 @@ void QDeclarativePathLine::addToPath(QPainterPath &path, const QDeclarativePathD \endqml \endtable - \sa Path, PathCubic, PathLine + \sa Path, PathCubic, PathLine, PathArc, PathCurve, PathSvg */ /*! @@ -941,6 +961,23 @@ void QDeclarativePathLine::addToPath(QPainterPath &path, const QDeclarativePathD \qmlproperty real QtQuick2::PathQuad::y Defines the end point of the curve. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick2::PathQuad::relativeX + \qmlproperty real QtQuick2::PathQuad::relativeY + + Defines the end point of the curve relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y */ /*! @@ -985,6 +1022,21 @@ void QDeclarativePathQuad::setControlY(qreal y) } } +/*! + \qmlproperty real QtQuick2::PathCubic::relativeControlX + \qmlproperty real QtQuick2::PathCubic::relativeControlY + + Defines the position of the control point relative to the curve's start. + + If both a relative and absolute control position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative control x + and an absolute control y. + + \sa controlX, controlY +*/ + qreal QDeclarativePathQuad::relativeControlX() const { return _relativeControlX; @@ -1056,7 +1108,7 @@ void QDeclarativePathQuad::addToPath(QPainterPath &path, const QDeclarativePathD \endqml \endtable - \sa Path, PathQuad, PathLine + \sa Path, PathQuad, PathLine, PathArc, PathCurve, PathSvg */ /*! @@ -1064,6 +1116,23 @@ void QDeclarativePathQuad::addToPath(QPainterPath &path, const QDeclarativePathD \qmlproperty real QtQuick2::PathCubic::y Defines the end point of the curve. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick2::PathCubic::relativeX + \qmlproperty real QtQuick2::PathCubic::relativeY + + Defines the end point of the curve relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y */ /*! @@ -1134,6 +1203,23 @@ void QDeclarativePathCubic::setControl2Y(qreal y) } } +/*! + \qmlproperty real QtQuick2::PathCubic::relativeControl1X + \qmlproperty real QtQuick2::PathCubic::relativeControl1Y + \qmlproperty real QtQuick2::PathCubic::relativeControl2X + \qmlproperty real QtQuick2::PathCubic::relativeControl2Y + + Defines the positions of the control points relative to the curve's start. + + If both a relative and absolute control position are specified for a control point's axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative control1 x + and an absolute control1 y. + + \sa control1X, control1Y, control2X, control2Y +*/ + qreal QDeclarativePathCubic::relativeControl1X() const { return _relativeControl1X; @@ -1222,6 +1308,49 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path, const QDeclarativePath /****************************************************************************/ +/*! + \qmlclass PathCurve QDeclarativePathCurve + \inqmlmodule QtQuick 2 + \ingroup qml-view-elements + \brief The PathCurve defines a point on a Catmull-Rom curve. + + PathCurve provides an easy way to specify a curve passing directly through a set of points. + Typically multiple PathCurves are used in a series, as the following example demonstrates: + + \snippet doc/src/snippets/declarative/path/basiccurve.qml 0 + + This example produces the following path (with the starting point and PathCurve points + highlighted in red): + + \image declarative-pathcurve.png + + \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathSvg +*/ + +/*! + \qmlproperty real QtQuick2::PathCurve::x + \qmlproperty real QtQuick2::PathCurve::y + + Defines the end point of the curve. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick2::PathCurve::relativeX + \qmlproperty real QtQuick2::PathCurve::relativeY + + Defines the end point of the curve relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y +*/ + inline QPointF previousPathPosition(const QPainterPath &path) { int count = path.elementCount(); @@ -1294,6 +1423,67 @@ void QDeclarativePathCatmullRomCurve::addToPath(QPainterPath &path, const QDecla /****************************************************************************/ +/*! + \qmlclass PathArc QDeclarativePathArc + \inqmlmodule QtQuick 2 + \ingroup qml-view-elements + \brief The PathArc defines an arc with the given radius. + + PathArc provides a simple way of specifying an arc that ends at a given position + and uses the specified radius. It is modeled after the SVG elliptical arc command. + + The following QML produces the path shown below: + \table + \row + \o \image declarative-patharc.png + \o \snippet doc/src/snippets/declarative/path/basicarc.qml 0 + \endtable + + Note that a single PathArc cannot be used to specify a circle. Instead, you can + use two PathArc elements, each specifying half of the circle. + + \sa Path, PathLine, PathQuad, PathCubic, PathCurve, PathSvg +*/ + +/*! + \qmlproperty real QtQuick2::PathArc::x + \qmlproperty real QtQuick2::PathArc::y + + Defines the end point of the arc. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick2::PathArc::relativeX + \qmlproperty real QtQuick2::PathArc::relativeY + + Defines the end point of the arc relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y +*/ + +/*! + \qmlproperty real QtQuick2::PathArc::radiusX + \qmlproperty real QtQuick2::PathArc::radiusY + + Defines the radius of the arc. + + The following QML demonstrates how different radius values can be used to change + the shape of the arc: + \table + \row + \o \image declarative-arcradius.png + \o \snippet doc/src/snippets/declarative/path/arcradius.qml 0 + \endtable +*/ + qreal QDeclarativePathArc::radiusX() const { return _radiusX; @@ -1322,6 +1512,25 @@ void QDeclarativePathArc::setRadiusY(qreal radius) emit radiusYChanged(); } +/*! + \qmlproperty bool QtQuick2::PathArc::useLargeArc + Whether to use a large arc as defined by the arc points. + + Given fixed start and end positions, radius, and direction, + there are two possible arcs that can fit the data. useLargeArc + is used to distinguish between these. For example, the following + QML can produce either of the two illustrated arcs below by + changing the value of useLargeArc. + + \table + \row + \o \image declarative-largearc.png + \o \snippet doc/src/snippets/declarative/path/largearc.qml 0 + \endtable + + The default value is false. +*/ + bool QDeclarativePathArc::useLargeArc() const { return _useLargeArc; @@ -1336,6 +1545,23 @@ void QDeclarativePathArc::setUseLargeArc(bool largeArc) emit useLargeArcChanged(); } +/*! + \qmlproperty enum QtQuick2::PathArc::direction + + Defines the direction of the arc. Possible values are + PathArc.Clockwise (default) and PathArc.Counterclockwise. + + The following QML can produce either of the two illustrated arcs below + by changing the value of direction. + \table + \row + \o \image declarative-arcdirection.png + \o \snippet doc/src/snippets/declarative/path/arcdirection.qml 0 + \endtable + + \sa useLargeArc +*/ + QDeclarativePathArc::ArcDirection QDeclarativePathArc::direction() const { return _direction; @@ -1367,6 +1593,37 @@ void QDeclarativePathArc::addToPath(QPainterPath &path, const QDeclarativePathDa /****************************************************************************/ +/*! + \qmlclass PathSvg QDeclarativePathSvg + \inqmlmodule QtQuick 2 + \ingroup qml-view-elements + \brief The PathSvg defines a path using an SVG path data string. + + The following QML produces the path shown below: + \table + \row + \o \image declarative-pathsvg.png + \o + \qml + Path { + startX: 50; startY: 50 + PathSvg { path: "L 150 50 L 100 150 z" } + } + \endqml + \endtable + + \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathCurve +*/ + +/*! + \qmlproperty string QtQuick2::PathSvg::path + + The SVG path data string specifying the path. + + See \l {http://www.w3.org/TR/SVG/paths.html#PathData}{W3C SVG Path Data} + for more details on this format. +*/ + QString QDeclarativePathSvg::path() const { return _path; diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp index 3d9a8ad14a..fb3bb76497 100644 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ b/tests/auto/qtquick2/examples/tst_examples.cpp @@ -90,6 +90,7 @@ tst_examples::tst_examples() // Add directories you want excluded here excludedDirs << "examples/declarative/text/fonts"; // QTBUG-21415 + excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem // Not run in QQuickView excludedDirs << "examples/declarative/qtquick1"; -- cgit v1.2.3