diff options
Diffstat (limited to 'tests/manual')
65 files changed, 4303 insertions, 97 deletions
diff --git a/tests/manual/nodetypes_ng/AtlasedImages.qml b/tests/manual/nodetypes_ng/AtlasedImages.qml new file mode 100644 index 0000000000..5cb5451dfd --- /dev/null +++ b/tests/manual/nodetypes_ng/AtlasedImages.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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.8 + +// The images here should result in a single draw call that uses an atlas +// texture. The ShaderEffect is then another one (and exercises having an +// effect on an Image backed by an atlased texture). + +Item { + Row { + Image { + source: "qrc:/qt.png" + sourceSize: Qt.size(64, 64) + } + Image { + source: "qrc:/face-smile.png" + } + Image { + source: "qrc:/arrow-down.png" + } + Image { + source: "qrc:/arrow-up.png" + NumberAnimation on rotation { + from: 0; to: 360; duration: 3000 + loops: Animation.Infinite + } + } + Image { + id: minusSign + source: "qrc:/minus-sign.png" + } + // Using a ShaderEffectSource would go through an extra render target + // texture. By specifying the Image directly as the source, no extra + // texture is created. However, when the source Image is atlased, extra + // steps are taken internally to create a non-atlased texture for the + // effect. + ShaderEffect { + id: eff + width: minusSign.width + height: minusSign.height + property variant source: minusSign + property real amplitude: 0.05 + property real frequency: 20 + property real time: 0 + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + vertexShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.vert" : "qrc:/wobble.vert.qsb" + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.frag" : "qrc:/wobble.frag.qsb" + } + Image { + source: "qrc:/plus-sign.png" + } + } +} diff --git a/tests/manual/nodetypes_ng/CompressedImages.qml b/tests/manual/nodetypes_ng/CompressedImages.qml new file mode 100644 index 0000000000..b05baf8ccb --- /dev/null +++ b/tests/manual/nodetypes_ng/CompressedImages.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + border.color: "red" + border.width: 4 + width: im1.sourceSize.width + 8 + height: im1.sourceSize.height + 8 + Image { + id: im1 + source: "qrc:/car_etc2_nomips.ktx" + anchors.centerIn: parent + } + } + + Rectangle { + anchors.centerIn: parent + border.color: "red" + border.width: 4 + width: im2.sourceSize.width + 8 + height: im2.sourceSize.height + 8 + Image { + id: im2 + source: "qrc:/qt_bc1_10mips.ktx" + anchors.centerIn: parent + } + } +} diff --git a/tests/manual/nodetypes_ng/DistanceFieldText.qml b/tests/manual/nodetypes_ng/DistanceFieldText.qml new file mode 100644 index 0000000000..3a6eb4186e --- /dev/null +++ b/tests/manual/nodetypes_ng/DistanceFieldText.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Text { + id: text1 + renderType: Text.QtRendering + anchors.top: parent.top + text: "árvíztűrő tükörfúrógép\nÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP" + } + Text { + renderType: Text.QtRendering + anchors.bottom: parent.bottom + text: "the quick brown fox jumps over the lazy dog\nTHE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" + color: "red" + } + Text { + renderType: Text.QtRendering + anchors.centerIn: parent + text: "rotate rotate rotate" + font.bold: true + font.pointSize: 20 + color: "green" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + + Row { + anchors.top: text1.bottom + anchors.margins: 10 + Text { renderType: Text.QtRendering; font.pointSize: 24; text: "Normal" } + Text { renderType: Text.QtRendering; font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } + Text { renderType: Text.QtRendering; font.pointSize: 24; text: "Outline"; style: Text.Outline; styleColor: "red" } + Text { renderType: Text.QtRendering; font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } + } +} diff --git a/tests/manual/nodetypes_ng/Images.qml b/tests/manual/nodetypes_ng/Images.qml new file mode 100644 index 0000000000..809a6dc74d --- /dev/null +++ b/tests/manual/nodetypes_ng/Images.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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.3 + +Item { + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + + Image { + id: im + source: "qrc:/qt.png" + mipmap: true + + // Changing the mipmap property results in...nothing but a warning, but + // regardless, enable the following to test. +// Timer { +// interval: 5000 +// onTriggered: { +// if (im.mipmap) { +// console.log("disabling mipmap"); +// im.mipmap = false; +// } else { +// console.log("enabling mipmap"); +// im.mipmap = true; +// } +// } +// running: true +// repeat: true +// } + + SequentialAnimation on scale { + loops: Animation.Infinite + NumberAnimation { + from: 1.0 + to: 4.0 + duration: 2000 + } + NumberAnimation { + from: 4.0 + to: 0.1 + duration: 3000 + } + NumberAnimation { + from: 0.1 + to: 1.0 + duration: 1000 + } + } + + Image { + anchors.centerIn: parent + source: "qrc:/face-smile.png" + } + } + + Image { + source: "qrc:/face-smile.png" + anchors.bottom: parent.bottom + anchors.right: parent.right + antialiasing: true // trigger smooth texture material + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + + Item { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + scale: 20 + width: 20 + Image { x: 0; source: "blacknwhite.png"; smooth: false } // solid black + Image { x: 2; source: "blacknwhite.png"; smooth: true } // fade to white on right + Image { x: 4; source: "blacknwhite.png"; smooth: false } // solid black + Image { x: 6; source: "blacknwhite.png"; smooth: true } // fade to white on right + } +} diff --git a/tests/manual/nodetypes_ng/Layers.qml b/tests/manual/nodetypes_ng/Layers.qml new file mode 100644 index 0000000000..defab85f7e --- /dev/null +++ b/tests/manual/nodetypes_ng/Layers.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + color: "lightGray" + anchors.fill: parent + anchors.margins: 10 + + Column { + anchors.fill: parent + spacing: 10 + + Row { + width: parent.width + Rectangle { + color: "red" + width: 300 + height: 100 + layer.enabled: true + Text { text: "this is in a layer, going through an offscreen render target" } + clip: true + Rectangle { + color: "lightGreen" + width: 50 + height: 50 + x: 275 + y: 75 + } + } + Rectangle { + color: "white" + width: 300 + height: 100 + Text { text: "this is not a layer" } + } + Rectangle { + color: "green" + width: 300 + height: 100 + layer.enabled: true + Text { text: "this is another layer" } + Rectangle { + border.width: 4 + border.color: "black" + anchors.centerIn: parent + width: 150 + height: 50 + layer.enabled: true + Text { + anchors.centerIn: parent + text: "layer in a layer" + } + } + Image { + source: "qrc:/face-smile.png" + anchors.bottom: parent.bottom + anchors.right: parent.right + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + } + } + + Row { + width: parent.width + Rectangle { + color: "white" + border.color: "black" + border.width: 4 + width: 300 + height: 100 + layer.enabled: true + layer.smooth: true // sets min/mag filter in the sampler to Linear + layer.textureSize: Qt.size(width * 2, height * 2) + Text { x: 10; y: 10; text: "supersampled layer\n(rendered at 2x, sampled with linear min/mag)" } + Rectangle { + width: 30 + height: 30 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + } + Rectangle { + color: "white" + border.color: "black" + border.width: 4 + width: 300 + height: 100 + layer.enabled: true + layer.samples: 4 // 4x MSAA + Text { x: 10; y: 10; text: "4x MSAA layer\n(rendered into multisample texture/renderbuffer,\nthen resolved into non-msaa texture)" } + Rectangle { + width: 30 + height: 30 + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 10 + color: "red" + NumberAnimation on rotation { from: 360; to: 0; duration: 2000; loops: Animation.Infinite; } + } + } + Rectangle { + color: "white" + border.color: "black" + border.width: 4 + width: 300 + height: 100 + layer.enabled: true + layer.mipmap: true + Text { x: 10; y: 10; text: "Mipmapped layer" } + Rectangle { + width: 30 + height: 30 + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 10 + color: "red" + NumberAnimation on rotation { from: 360; to: 0; duration: 2000; loops: Animation.Infinite; } + } + } + } + } + } +} diff --git a/tests/manual/nodetypes_ng/LotsOfNodes.qml b/tests/manual/nodetypes_ng/LotsOfNodes.qml new file mode 100644 index 0000000000..eee1828b96 --- /dev/null +++ b/tests/manual/nodetypes_ng/LotsOfNodes.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import Stuff 1.0 + +Item { + id: root + + Column { + width: 100 + clip: true + PerPixelRect { width: 100; height: 100; color: "red" } + PerPixelRect { width: 100; height: 100; color: "blue" } + } + + Column { + x: 100 + width: 100 + PerPixelRect { width: 100; height: 100; color: "black" } + PerPixelRect { width: 100; height: 100; color: "#00ff00" } + } +} diff --git a/tests/manual/nodetypes_ng/LotsOfRects.qml b/tests/manual/nodetypes_ng/LotsOfRects.qml new file mode 100644 index 0000000000..f20839d6c3 --- /dev/null +++ b/tests/manual/nodetypes_ng/LotsOfRects.qml @@ -0,0 +1,260 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + anchors.margins: 4 + anchors.fill: parent + + // Background + gradient: Gradient { + GradientStop { position: 0; color: "steelblue" } + GradientStop { position: 1; color: "black" } + } + + // Animated gradient stops. + // NB! Causes a full buffer rebuild on every animated change due to the geometry change! + Row { + spacing: 10 + Repeater { + model: 20 + Rectangle { + width: 20 + height: 20 + gradient: Gradient { + GradientStop { position: 0.0; color: "red" } + GradientStop { NumberAnimation on position { from: 0.01; to: 0.99; duration: 5000; loops: Animation.Infinite } color: "yellow" } + GradientStop { position: 1.0; color: "green" } + } + } + } + } + + // Rounded rects with border (smooth material) + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "blue" + width: 100 + height: 50 + y: 50 + radius: 16 + border.color: "red" + border.width: 4 + + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { + from: 50 + to: 150 + duration: 7000 + } + NumberAnimation { + from: 150 + to: 50 + duration: 3000 + } + } + } + } + } + + // Clip using scissor + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "green" + width: 100 + height: 100 + y: 150 + NumberAnimation on y { + from: 150 + to: 200 + duration: 2000 + loops: Animation.Infinite + } + clip: true + Rectangle { + color: "lightGreen" + width: 50 + height: 50 + x: 75 + y: 75 + } + } + } + } + + // Clip using scissor + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "green" + width: 100 + height: 100 + y: 300 + NumberAnimation on y { + from: 300 + to: 400 + duration: 2000 + loops: Animation.Infinite + } + clip: true + Rectangle { + color: "lightGreen" + width: 50 + height: 50 + x: 75 + y: 75 + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + } + } + } + + // Clip using stencil + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "green" + width: 100 + height: 100 + y: 450 + NumberAnimation on y { + from: 450 + to: 550 + duration: 2000 + loops: Animation.Infinite + } + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + clip: true + Rectangle { + color: "lightGreen" + width: 50 + height: 50 + x: 75 + y: 75 + } + } + } + } + + // The signature red square with another item with animated opacity blended on top + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + + Rectangle { + color: "gray" + width: 50 + height: 50 + anchors.centerIn: parent + + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { + from: 1.0 + to: 0.0 + duration: 4000 + } + NumberAnimation { + from: 0.0 + to: 1.0 + duration: 4000 + easing.type: Easing.InOutQuad + } + } + } + } + + // Animated size and color. + // NB! Causes a full buffer rebuild on every animated change due to the geometry change! + Rectangle { + anchors.right: parent.right + anchors.bottom: parent.bottom + width: 10 + height: 100 + ColorAnimation on color { + from: "blue" + to: "purple" + duration: 5000 + loops: Animation.Infinite + } + NumberAnimation on width { + from: 10 + to: 300 + duration: 5000 + loops: Animation.Infinite + } + } + + // Semi-transparent rect on top. + Rectangle { + anchors.centerIn: parent + opacity: 0.2 + color: "black" + anchors.fill: parent + anchors.margins: 10 + } + } +} diff --git a/tests/manual/nodetypes_ng/MoreWindows.qml b/tests/manual/nodetypes_ng/MoreWindows.qml new file mode 100644 index 0000000000..1144572ebe --- /dev/null +++ b/tests/manual/nodetypes_ng/MoreWindows.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import QtQuick.Window 2.12 + +Item { + Rectangle { + x: 20 + y: 20 + width: 300 + height: 120 + color: "red" + border.color: "black" + border.width: 2 + Text { + text: "Click to toggle window visibility\n(switch to another test to destroy)" + font.bold: true + anchors.centerIn: parent + } + MouseArea { + anchors.fill: parent + onClicked: win.visible = !win.visible + } + } + + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "green" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + + Window { + id: win + width: 640 + height: 480 + + Rectangle { + color: "lightGray" + anchors.fill: parent + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + Text { + text: "Another QQuickWindow" + anchors.top: parent.top + anchors.margins: 20 + ColorAnimation on color { from: "red"; to: "green"; duration: 2000; loops: Animation.Infinite } + } + } + } +} diff --git a/tests/manual/nodetypes_ng/MultiClipRects.qml b/tests/manual/nodetypes_ng/MultiClipRects.qml new file mode 100644 index 0000000000..2d3804af21 --- /dev/null +++ b/tests/manual/nodetypes_ng/MultiClipRects.qml @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + anchors.margins: 4 + anchors.fill: parent + + // Background + gradient: Gradient { + GradientStop { position: 0; color: "steelblue" } + GradientStop { position: 1; color: "black" } + } + + // Clip using scissor, up to 2 levels. This means that the + // lightGreen-yellow-blue batch's clip list will have two clips. + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "green" + width: 150 + height: 150 + y: 200 + clip: true + Rectangle { + color: "lightGreen" + width: 150 + height: 150 + x: 25 + y: 25 + clip: true + + Rectangle { + color: "yellow" + width: 50 + height: 50 + x: 100 + y: 100 + NumberAnimation on rotation { from: 360; to: 0; duration: 5000; loops: Animation.Infinite; } + } + + Rectangle { + color: "blue" + width: 50 + height: 50 + x: -25 + y: 100 + NumberAnimation on rotation { from: 360; to: 0; duration: 5000; loops: Animation.Infinite; } + } + } + } + } + } + + // Clip using stencil, up to 3 levels. This means that the + // lightGreen-yellow-blue batch's clip list will have three clips and + // so two stencil draw calls before drawing the actual content. + Row { + spacing: 10 + Repeater { + model: 5 + Rectangle { + color: "green" + width: 200 + height: 200 + y: 450 + NumberAnimation on rotation { from: 0; to: 360; duration: 5000; loops: Animation.Infinite; } + clip: true + Rectangle { + color: "lightGreen" + width: 150 + height: 150 + x: 50 + y: 50 + rotation: 30 + clip: true + + Rectangle { + color: "yellow" + width: 100 + height: 100 + x: 75 + y: 75 + NumberAnimation on rotation { from: 360; to: 0; duration: 5000; loops: Animation.Infinite; } + clip: true + + Rectangle { + color: "blue" + width: 50 + height: 50 + x: 0 + y: 0 + NumberAnimation on rotation { from: 360; to: 0; duration: 5000; loops: Animation.Infinite; } + } + } + } + } + } + } + } +} diff --git a/tests/manual/nodetypes_ng/Painter.qml b/tests/manual/nodetypes_ng/Painter.qml new file mode 100644 index 0000000000..c5db3496f8 --- /dev/null +++ b/tests/manual/nodetypes_ng/Painter.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 +import Stuff 1.0 + +Item { + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 120 + } + ListElement { + balloonWidth: 120 + } + ListElement { + balloonWidth: 120 + } + ListElement { + balloonWidth: 120 + } + } + + ListView { + anchors.fill: parent + anchors.margins: 10 + id: balloonView + model: balloonModel + spacing: 5 + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + innerAnim: model.index === 1 + NumberAnimation on width { + from: 200 + to: 300 + duration: 5000 + running: model.index === 0 + } + } + } +} diff --git a/tests/manual/nodetypes_ng/Rects.qml b/tests/manual/nodetypes_ng/Rects.qml new file mode 100644 index 0000000000..b370fc7b27 --- /dev/null +++ b/tests/manual/nodetypes_ng/Rects.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + + Rectangle { + color: "gray" + width: 50 + height: 50 + anchors.centerIn: parent + + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { + from: 1.0 + to: 0.0 + duration: 4000 + } + NumberAnimation { + from: 0.0 + to: 1.0 + duration: 4000 + easing.type: Easing.InOutQuad + } + } + } + } + + Rectangle { + color: "green" + width: 100 + height: 200 + x: 0 + y: 0 + + NumberAnimation on x { + from: 0 + to: 300 + duration: 5000 + } + NumberAnimation on y { + from: 0 + to: 50 + duration: 2000 + } + + clip: true // scissor + Rectangle { + color: "lightGreen" + width: 50 + height: 50 + x: 75 + y: 175 + } + } + + Rectangle { + color: "blue" + width: 200 + height: 100 + x: 100 + y: 300 + radius: 16 + border.color: "red" + border.width: 4 + + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { + from: 300 + to: 500 + duration: 7000 + } + NumberAnimation { + from: 500 + to: 300 + duration: 3000 + } + } + } + + Rectangle { + anchors.right: parent.right + width: 100 + height: 100 + gradient: Gradient { + GradientStop { position: 0.0; color: "red" } + GradientStop { position: 0.33; color: "yellow" } + GradientStop { position: 1.0; color: "green" } + } + } +} diff --git a/tests/manual/nodetypes_ng/ShaderEffect.qml b/tests/manual/nodetypes_ng/ShaderEffect.qml new file mode 100644 index 0000000000..cb2caf61a9 --- /dev/null +++ b/tests/manual/nodetypes_ng/ShaderEffect.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +// Use QtQuick 2.8 to get GraphicsInfo and others +import QtQuick 2.8 + +Item { + Rectangle { + color: "gray" + anchors.margins: 10 + anchors.fill: parent + Image { + id: image1 + source: "qrc:/qt.png" + } + ShaderEffectSource { + id: effectSource1 + sourceItem: image1 + hideSource: true + } + ShaderEffect { // wobble + id: eff + width: image1.width + height: image1.height + anchors.centerIn: parent + + property variant source: effectSource1 + property real amplitude: 0.04 * 0.2 + property real frequency: 20 + property real time: 0 + + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + + vertexShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.vert" : "qrc:/wobble.vert.qsb" + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.frag" : "qrc:/wobble.frag.qsb" + } + + Image { + id: image2 + source: "qrc:/face-smile.png" + } + ShaderEffectSource { + id: effectSource2 + sourceItem: image2 + hideSource: true + } + ShaderEffect { // dropshadow + id: eff2 + width: image2.width + height: image2.height + scale: 2 + x: 40 + y: 40 + + property variant source: effectSource2 + + property variant shadow: ShaderEffectSource { + sourceItem: ShaderEffect { + width: eff2.width + height: eff2.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + sourceItem: ShaderEffect { + id: innerEff + width: eff2.width + height: eff2.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: effectSource2 + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/shadow_pass1_legacy_gl.frag" : "qrc:/shadow_pass1.frag.qsb" + } + } + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/shadow_pass1_legacy_gl.frag" : "qrc:/shadow_pass1.frag.qsb" + } + } + property real angle: 0 + property variant offset: Qt.point(5.0 * Math.cos(angle), 5.0 * Math.sin(angle)) + NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } + property variant delta: Qt.size(offset.x / width, offset.y / height) + property real darkness: 0.5 + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/shadow_pass2_legacy_gl.frag" : "qrc:/shadow_pass2.frag.qsb" + } + + Column { + anchors.bottom: parent.bottom + Text { + color: "yellow" + font.pointSize: 24 + text: { + if (GraphicsInfo.api === GraphicsInfo.OpenGL) + "OpenGL"; + else if (GraphicsInfo.api === GraphicsInfo.Software) + "Software"; + else if (GraphicsInfo.api === GraphicsInfo.Direct3D12) + "D3D12"; + else if (GraphicsInfo.api === GraphicsInfo.OpenVG) + "OpenVG"; + else if (GraphicsInfo.api === GraphicsInfo.OpenGLRhi) + "OpenGL via QRhi"; + else if (GraphicsInfo.api === GraphicsInfo.Direct3D11Rhi) + "D3D11 via QRhi"; + else if (GraphicsInfo.api === GraphicsInfo.VulkanRhi) + "Vulkan via QRhi"; + else if (GraphicsInfo.api === GraphicsInfo.MetalRhi) + "Metal via QRhi"; + else if (GraphicsInfo.api === GraphicsInfo.Null) + "Null via QRhi"; + else + "Unknown API"; + } + } + Text { + color: "yellow" + font.pointSize: 24 + text: "Shader effect is " + (GraphicsInfo.shaderType === GraphicsInfo.HLSL + ? "HLSL" : (GraphicsInfo.shaderType === GraphicsInfo.GLSL + ? "GLSL" : (GraphicsInfo.shaderType === GraphicsInfo.RhiShader + ? "QRhiShader" : "UNKNOWN"))) + " based"; + } + Text { + text: GraphicsInfo.shaderType + " " + GraphicsInfo.shaderCompilationType + " " + GraphicsInfo.shaderSourceType + } + Text { + //text: eff.status + " " + eff.log + } + } + } +} diff --git a/tests/manual/nodetypes_ng/ShaderEffectNoAnim.qml b/tests/manual/nodetypes_ng/ShaderEffectNoAnim.qml new file mode 100644 index 0000000000..638775bd2a --- /dev/null +++ b/tests/manual/nodetypes_ng/ShaderEffectNoAnim.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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.8 + +Item { + // make sure we render the scene continuously + Rectangle { color: "red"; width: 10; height: 10; NumberAnimation on rotation { from: 0; to: 360; loops: -1 } } + + Rectangle { + color: "gray" + anchors.margins: 10 + anchors.fill: parent + Image { + id: image1 + source: "qrc:/qt.png" + } + ShaderEffectSource { + id: effectSource1 + sourceItem: image1 + hideSource: true + } + ShaderEffect { // wobble, no animation -> should not cause re-rendering into the texture + id: eff + width: image1.width + height: image1.height + anchors.centerIn: parent + + property variant source: effectSource1 + property real amplitude: 0.04 * 0.2 + property real frequency: 20 + property real time: 0 + + vertexShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.vert" : "qrc:/wobble.vert.qsb" + fragmentShader: GraphicsInfo.shaderType === GraphicsInfo.GLSL ? "qrc:/wobble_legacy_gl.frag" : "qrc:/wobble.frag.qsb" + } + } +} diff --git a/tests/manual/nodetypes_ng/ShaderEffectSource.qml b/tests/manual/nodetypes_ng/ShaderEffectSource.qml new file mode 100644 index 0000000000..dee9477336 --- /dev/null +++ b/tests/manual/nodetypes_ng/ShaderEffectSource.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Rectangle { + width: 200 + height: 100 + gradient: Gradient { + GradientStop { position: 0; color: "white" } + GradientStop { position: 1; color: "black" } + } + Row { + opacity: 0.5 + Item { + id: foo + width: 100; height: 100 + Rectangle { x: 5; y: 5; width: 60; height: 60; color: "red" } + Rectangle { x: 20; y: 20; width: 60; height: 60; color: "orange" } + Rectangle { x: 35; y: 35; width: 60; height: 60; color: "yellow" } + } + ShaderEffectSource { + width: 100; height: 100 + sourceItem: foo + } + ShaderEffectSource { + width: 100; height: 100 + sourceItem: foo + recursive: true + live: true + } + } +} diff --git a/tests/manual/nodetypes_ng/SimpleRect.qml b/tests/manual/nodetypes_ng/SimpleRect.qml new file mode 100644 index 0000000000..d4aa3434ba --- /dev/null +++ b/tests/manual/nodetypes_ng/SimpleRect.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + color: "red" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + + Rectangle { + color: "gray" + width: 50 + height: 50 + anchors.centerIn: parent + } + } +} diff --git a/tests/manual/nodetypes_ng/Text.qml b/tests/manual/nodetypes_ng/Text.qml new file mode 100644 index 0000000000..1741f7e5ab --- /dev/null +++ b/tests/manual/nodetypes_ng/Text.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + Text { + id: text1 + renderType: Text.NativeRendering + anchors.top: parent.top + text: "árvíztűrő tükörfúrógép\nÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP" + } + Text { + renderType: Text.NativeRendering + anchors.bottom: parent.bottom + text: "the quick brown fox jumps over the lazy dog\nTHE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" + color: "red" + } + Text { + renderType: Text.NativeRendering + anchors.centerIn: parent + text: "rotate rotate rotate" + font.bold: true + font.pointSize: 20 + color: "green" + NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; } + } + + Row { + anchors.top: text1.bottom + anchors.margins: 10 + Text { renderType: Text.NativeRendering; font.pointSize: 24; text: "Normal" } + Text { renderType: Text.NativeRendering; font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } + Text { renderType: Text.NativeRendering; font.pointSize: 24; text: "Outline"; style: Text.Outline; styleColor: "red" } + Text { renderType: Text.NativeRendering; font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } + } +} diff --git a/tests/manual/nodetypes_ng/arrow-down.png b/tests/manual/nodetypes_ng/arrow-down.png Binary files differnew file mode 100644 index 0000000000..29d1d4439a --- /dev/null +++ b/tests/manual/nodetypes_ng/arrow-down.png diff --git a/tests/manual/nodetypes_ng/arrow-up.png b/tests/manual/nodetypes_ng/arrow-up.png Binary files differnew file mode 100644 index 0000000000..e437312217 --- /dev/null +++ b/tests/manual/nodetypes_ng/arrow-up.png diff --git a/tests/manual/nodetypes_ng/blacknwhite.png b/tests/manual/nodetypes_ng/blacknwhite.png Binary files differnew file mode 100644 index 0000000000..efbc61e79d --- /dev/null +++ b/tests/manual/nodetypes_ng/blacknwhite.png diff --git a/tests/manual/nodetypes_ng/buildshaders.bat b/tests/manual/nodetypes_ng/buildshaders.bat new file mode 100755 index 0000000000..328b216c07 --- /dev/null +++ b/tests/manual/nodetypes_ng/buildshaders.bat @@ -0,0 +1,4 @@ +qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -o wobble.vert.qsb wobble.vert +qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o wobble.frag.qsb wobble.frag +qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o shadow_pass1.frag.qsb shadow_pass1.frag +qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o shadow_pass2.frag.qsb shadow_pass2.frag diff --git a/tests/manual/nodetypes_ng/car_etc2_nomips.ktx b/tests/manual/nodetypes_ng/car_etc2_nomips.ktx Binary files differnew file mode 100644 index 0000000000..2aefdd306b --- /dev/null +++ b/tests/manual/nodetypes_ng/car_etc2_nomips.ktx diff --git a/tests/manual/nodetypes_ng/face-smile.png b/tests/manual/nodetypes_ng/face-smile.png Binary files differnew file mode 100644 index 0000000000..3d66d72578 --- /dev/null +++ b/tests/manual/nodetypes_ng/face-smile.png diff --git a/tests/manual/nodetypes_ng/main.qml b/tests/manual/nodetypes_ng/main.qml new file mode 100644 index 0000000000..938ae02c8f --- /dev/null +++ b/tests/manual/nodetypes_ng/main.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 + +Item { + focus: true + + Loader { + anchors.fill: parent + id: loader + } + + Keys.onPressed: { + if (event.key === Qt.Key_S) + loader.source = ""; + + if (event.key === Qt.Key_R) + loader.source = "qrc:/SimpleRect.qml"; + if (event.key === Qt.Key_3) + loader.source = "qrc:/Rects.qml"; + if (event.key === Qt.Key_4) + loader.source = "qrc:/LotsOfRects.qml"; + if (event.key === Qt.Key_5) + loader.source = "qrc:/MultiClipRects.qml"; + if (event.key === Qt.Key_I) + loader.source = "qrc:/Images.qml"; + if (event.key === Qt.Key_A) + loader.source = "qrc:/AtlasedImages.qml"; + if (event.key === Qt.Key_P) + loader.source = "qrc:/Painter.qml"; + if (event.key === Qt.Key_C) + loader.source = "qrc:/CompressedImages.qml"; + if (event.key === Qt.Key_T) + loader.source = "qrc:/Text.qml"; + if (event.key === Qt.Key_D) + loader.source = "qrc:/DistanceFieldText.qml"; + if (event.key === Qt.Key_L) + loader.source = "qrc:/Layers.qml"; + if (event.key === Qt.Key_6) + loader.source = "qrc:/ShaderEffectSource.qml"; + if (event.key === Qt.Key_E) + loader.source = "qrc:/ShaderEffect.qml"; + if (event.key === Qt.Key_Z) + loader.source = "qrc:/ShaderEffectNoAnim.qml"; + if (event.key === Qt.Key_G) + helper.testGrabWindow() + if (event.key === Qt.Key_F) + helper.testGrabItem(loader.item) + if (event.key === Qt.Key_W) + loader.source = "qrc:/MoreWindows.qml"; + if (event.key === Qt.Key_N) + loader.source = "qrc:/LotsOfNodes.qml"; + } +} diff --git a/tests/manual/nodetypes_ng/minus-sign.png b/tests/manual/nodetypes_ng/minus-sign.png Binary files differnew file mode 100644 index 0000000000..d6f233d739 --- /dev/null +++ b/tests/manual/nodetypes_ng/minus-sign.png diff --git a/tests/manual/nodetypes_ng/nodetypes_ng.cpp b/tests/manual/nodetypes_ng/nodetypes_ng.cpp new file mode 100644 index 0000000000..8fe0e0dc98 --- /dev/null +++ b/tests/manual/nodetypes_ng/nodetypes_ng.cpp @@ -0,0 +1,325 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QThread> +#include <QQuickView> +#include <QQmlEngine> +#include <QQmlContext> +#include <QQuickPaintedItem> +#include <QPainter> +#include <QTimer> +#include <QQuickItemGrabResult> +#include <QSGRectangleNode> + +class Helper : public QObject +{ + Q_OBJECT + +public: + Helper(QQuickWindow *w) : m_window(w) { } + + Q_INVOKABLE void sleep(int ms) { + QThread::msleep(ms); + } + + Q_INVOKABLE void testGrabWindow() { + QImage img = m_window->grabWindow(); + qDebug() << "Saving image to grab_window_result.png" << img; + img.save("grab_window_result.png"); + } + + Q_INVOKABLE void testGrabItem(QQuickItem *item) { + qDebug() << item; + if (!item) + return; + + QSharedPointer<QQuickItemGrabResult> result = item->grabToImage(); + if (!result) + return; + + auto f = [](const QImage &image) { + qDebug() << "Saving image to grab_item_result.png" << image; + image.save("grab_item_result.png"); + }; + if (result->image().isNull()) { + connect(result.data(), &QQuickItemGrabResult::ready, [f, result] { + f(result->image()); + }); + } else { + f(result->image()); + } + } + + QQuickWindow *m_window; +}; + +class TextBalloon : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + Q_PROPERTY(bool innerAnim READ innerAnimEnabled WRITE setInnerAnimEnabled NOTIFY innerAnimChanged) + +public: + TextBalloon(QQuickItem *parent = nullptr) : QQuickPaintedItem(parent) { + connect(&m_timer, &QTimer::timeout, this, &TextBalloon::onAnim); + m_timer.setInterval(500); + } + void paint(QPainter *painter); + + bool isRightAligned() { return m_rightAligned; } + void setRightAligned(bool rightAligned); + + bool innerAnimEnabled() const { return m_innerAnim; } + void setInnerAnimEnabled(bool b); + +signals: + void rightAlignedChanged(); + void innerAnimChanged(); + +private slots: + void onAnim(); + +private: + bool m_rightAligned = false; + bool m_innerAnim = false; + QTimer m_timer; + QRect m_animRect = QRect(10, 10, 50, 20); + int m_anim = 0; +}; + +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (m_rightAligned) { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } else { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + + if (m_innerAnim) { + painter->fillRect(m_animRect, Qt::lightGray); + const int x = m_animRect.x() + m_anim; + const int y = m_animRect.y() + m_animRect.height() / 2; + painter->setPen(QPen(QBrush(Qt::SolidLine), 4)); + painter->drawLine(x + 4, y, x + 10, y); + m_anim += 10; + if (m_anim > m_animRect.width()) + m_anim = 0; + } +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + if (m_rightAligned == rightAligned) + return; + + m_rightAligned = rightAligned; + emit rightAlignedChanged(); +} + +void TextBalloon::setInnerAnimEnabled(bool b) +{ + if (m_innerAnim == b) + return; + + m_innerAnim = b; + if (!b) + m_timer.stop(); + else + m_timer.start(); + emit innerAnimChanged(); +} + +void TextBalloon::onAnim() +{ + update(m_animRect); +} + +class PerPixelRect : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + +public: + PerPixelRect(); + void setColor(const QColor &c); + QColor color() const { return m_color; } + QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *); + +signals: + void colorChanged(const QColor &c); + +private: + QColor m_color; +}; + +PerPixelRect::PerPixelRect() +{ + setFlag(ItemHasContents); +} + +void PerPixelRect::setColor(const QColor &c) +{ + if (c == m_color) + return; + m_color = c; + emit colorChanged(c); +} + +QSGNode *PerPixelRect::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) +{ + delete node; + node = new QSGNode; + + const int w = width(); + const int h = height(); + QQuickWindow *win = window(); + for (int y = 0; y < h; ++y) { + for (int x = 0; x < w; ++x) { + QSGRectangleNode *rn = win->createRectangleNode(); + rn->setRect(x, y, 1, 1); + rn->setColor(m_color); + node->appendChildNode(rn); + } + } + + return node; +} + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qDebug("Available tests:"); + qDebug(" [R] - Simple rectangle (vertexcolor material)"); + qDebug(" [3] - Rectangles (incl. smoothcolor material, scissor)"); + qDebug(" [4] - A lot of rectangles (incl. stencil and scissor)"); + qDebug(" [5] - Rectangles with multiple clip list entries"); + qDebug(" [I] - Images"); + qDebug(" [A] - Atlased images"); + qDebug(" [P] - QQuickPaintedItem"); + qDebug(" [C] - Compressed textures"); + qDebug(" [T] - Text (native)"); + qDebug(" [D] - Text (distance field)"); + qDebug(" [L] - Layers"); + qDebug(" [6] - ShaderEffectSource without ShaderEffect"); + qDebug(" [E] - ShaderEffect (and GraphicsInfo)"); + qDebug(" [Z] - ShaderEffect without animated properties"); + qDebug(" [G] - Grab current window"); + qDebug(" [F] - Grab item"); + qDebug(" [W] - Multiple windows"); + qDebug(" [N] - Lots of rectangle nodes"); + qDebug("\nPress S to stop the currently running test\n"); + + QQuickView view; + Helper helper(&view); + + const bool usingRhi = qEnvironmentVariableIntValue("QSG_RHI") != 0; + const QString rhiBackend = QString::fromLatin1(qgetenv("QSG_RHI_BACKEND")); + if (usingRhi) + view.setTitle(QLatin1String("RHI: ") + (rhiBackend.isEmpty() ? QLatin1String("default") : rhiBackend)); + else + view.setTitle(QLatin1String("legacy OpenGL")); + + if (app.arguments().contains(QLatin1String("--multisample"))) { + qDebug("Requesting sample count 4"); + QSurfaceFormat fmt = view.format(); + fmt.setSamples(4); + fmt.setDepthBufferSize(24); + fmt.setStencilBufferSize(8); + view.setFormat(fmt); + } + if (app.arguments().contains(QLatin1String("--coreprofile"))) { + qDebug("Requesting core profile (applicable only with OpenGL)"); + QSurfaceFormat fmt = view.format(); + fmt.setVersion(3, 2); + fmt.setProfile(QSurfaceFormat::CoreProfile); + view.setFormat(fmt); + } + if (app.arguments().contains(QLatin1String("--transparent"))) { + qDebug("Requesting alpha channel for the window and using Qt::transparent as background"); + QSurfaceFormat fmt = view.format(); + fmt.setAlphaBufferSize(8); + view.setFormat(fmt); + view.setColor(Qt::transparent); + } + + view.engine()->rootContext()->setContextProperty(QLatin1String("helper"), &helper); + + qmlRegisterType<TextBalloon>("Stuff", 1, 0, "TextBalloon"); + qmlRegisterType<PerPixelRect>("Stuff", 1, 0, "PerPixelRect"); + + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.resize(1024, 768); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} + +#include "nodetypes_ng.moc" diff --git a/tests/manual/nodetypes_ng/nodetypes_ng.pro b/tests/manual/nodetypes_ng/nodetypes_ng.pro new file mode 100644 index 0000000000..68b9211c4f --- /dev/null +++ b/tests/manual/nodetypes_ng/nodetypes_ng.pro @@ -0,0 +1,11 @@ +QT += qml quick + +SOURCES += nodetypes_ng.cpp + +RESOURCES += nodetypes_ng.qrc + +OTHER_FILES += \ + main.qml \ + SimpleRect.qml \ + Rects.qml \ + LotsOfRects.qml diff --git a/tests/manual/nodetypes_ng/nodetypes_ng.qrc b/tests/manual/nodetypes_ng/nodetypes_ng.qrc new file mode 100644 index 0000000000..47ad8d2677 --- /dev/null +++ b/tests/manual/nodetypes_ng/nodetypes_ng.qrc @@ -0,0 +1,38 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>SimpleRect.qml</file> + <file>Rects.qml</file> + <file>LotsOfRects.qml</file> + <file>MultiClipRects.qml</file> + <file>Images.qml</file> + <file>Painter.qml</file> + <file>CompressedImages.qml</file> + <file>Text.qml</file> + <file>DistanceFieldText.qml</file> + <file>Layers.qml</file> + <file>ShaderEffectSource.qml</file> + <file>AtlasedImages.qml</file> + <file>ShaderEffect.qml</file> + <file>ShaderEffectNoAnim.qml</file> + <file>MoreWindows.qml</file> + <file>LotsOfNodes.qml</file> + <file>qt.png</file> + <file>face-smile.png</file> + <file>car_etc2_nomips.ktx</file> + <file>qt_bc1_10mips.ktx</file> + <file>arrow-down.png</file> + <file>arrow-up.png</file> + <file>minus-sign.png</file> + <file>plus-sign.png</file> + <file>blacknwhite.png</file> + <file>wobble.vert.qsb</file> + <file>wobble.frag.qsb</file> + <file>shadow_pass1.frag.qsb</file> + <file>shadow_pass2.frag.qsb</file> + <file>wobble_legacy_gl.vert</file> + <file>wobble_legacy_gl.frag</file> + <file>shadow_pass1_legacy_gl.frag</file> + <file>shadow_pass2_legacy_gl.frag</file> + </qresource> +</RCC> diff --git a/tests/manual/nodetypes_ng/plus-sign.png b/tests/manual/nodetypes_ng/plus-sign.png Binary files differnew file mode 100644 index 0000000000..40df1134f8 --- /dev/null +++ b/tests/manual/nodetypes_ng/plus-sign.png diff --git a/tests/manual/nodetypes_ng/qt.png b/tests/manual/nodetypes_ng/qt.png Binary files differnew file mode 100644 index 0000000000..f30eec0d4d --- /dev/null +++ b/tests/manual/nodetypes_ng/qt.png diff --git a/tests/manual/nodetypes_ng/qt_bc1_10mips.ktx b/tests/manual/nodetypes_ng/qt_bc1_10mips.ktx Binary files differnew file mode 100644 index 0000000000..32c31bf6dc --- /dev/null +++ b/tests/manual/nodetypes_ng/qt_bc1_10mips.ktx diff --git a/tests/manual/nodetypes_ng/shadow_pass1.frag b/tests/manual/nodetypes_ng/shadow_pass1.frag new file mode 100644 index 0000000000..14581eb80e --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass1.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(binding = 1) uniform sampler2D source; + +layout(std140, binding = 0) uniform buf { + // The built-in vertex shader assumes the first 68 bytes are matrix and + // opacity so have them there even though the matrix is not used here. + mat4 qt_Matrix; + float qt_Opacity; + vec2 delta; +} ubuf; + +void main() +{ + fragColor = (0.0538 * texture(source, qt_TexCoord0 - 3.182 * ubuf.delta) + + 0.3229 * texture(source, qt_TexCoord0 - 1.364 * ubuf.delta) + + 0.2466 * texture(source, qt_TexCoord0) + + 0.3229 * texture(source, qt_TexCoord0 + 1.364 * ubuf.delta) + + 0.0538 * texture(source, qt_TexCoord0 + 3.182 * ubuf.delta)) * ubuf.qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb b/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb Binary files differnew file mode 100644 index 0000000000..f3370caee2 --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb diff --git a/tests/manual/nodetypes_ng/shadow_pass1_legacy_gl.frag b/tests/manual/nodetypes_ng/shadow_pass1_legacy_gl.frag new file mode 100644 index 0000000000..65ce0d956c --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass1_legacy_gl.frag @@ -0,0 +1,11 @@ +uniform lowp float qt_Opacity; +uniform sampler2D source; +uniform highp vec2 delta; +varying highp vec2 qt_TexCoord0; +void main() { + gl_FragColor = (0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/shadow_pass2.frag b/tests/manual/nodetypes_ng/shadow_pass2.frag new file mode 100644 index 0000000000..fa11f873bb --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass2.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D shadow; + +layout(std140, binding = 0) uniform buf { + // The built-in vertex shader assumes the first 68 bytes are matrix and + // opacity so have them there even though the matrix is not used here. + mat4 qt_Matrix; + float qt_Opacity; + vec2 delta; + float darkness; +} ubuf; + +void main() +{ + vec4 fg = texture(source, qt_TexCoord0); + vec4 bg = texture(shadow, qt_TexCoord0 + ubuf.delta); + fragColor = (fg + vec4(0., 0., 0., ubuf.darkness * bg.a) * (1. - fg.a)) * ubuf.qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb b/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb Binary files differnew file mode 100644 index 0000000000..cbf9569373 --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb diff --git a/tests/manual/nodetypes_ng/shadow_pass2_legacy_gl.frag b/tests/manual/nodetypes_ng/shadow_pass2_legacy_gl.frag new file mode 100644 index 0000000000..2ea4cc8d89 --- /dev/null +++ b/tests/manual/nodetypes_ng/shadow_pass2_legacy_gl.frag @@ -0,0 +1,12 @@ +uniform lowp float qt_Opacity; +uniform highp vec2 offset; +uniform sampler2D source; +uniform sampler2D shadow; +uniform highp float darkness; +uniform highp vec2 delta; +varying highp vec2 qt_TexCoord0; +void main() { + lowp vec4 fg = texture2D(source, qt_TexCoord0); + lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); + gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/wobble.frag b/tests/manual/nodetypes_ng/wobble.frag new file mode 100644 index 0000000000..a34481c2f2 --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble.frag @@ -0,0 +1,20 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(binding = 1) uniform sampler2D source; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + float amplitude; + float frequency; + float time; +} ubuf; + +void main() +{ + vec2 p = sin(ubuf.time + ubuf.frequency * qt_TexCoord0); + fragColor = texture(source, qt_TexCoord0 + ubuf.amplitude * vec2(p.y, -p.x)) * ubuf.qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/wobble.frag.qsb b/tests/manual/nodetypes_ng/wobble.frag.qsb Binary files differnew file mode 100644 index 0000000000..9d3b80fad8 --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble.frag.qsb diff --git a/tests/manual/nodetypes_ng/wobble.vert b/tests/manual/nodetypes_ng/wobble.vert new file mode 100644 index 0000000000..a49b2d9a9f --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble.vert @@ -0,0 +1,22 @@ +#version 440 + +layout(location = 0) in vec4 qt_Vertex; +layout(location = 1) in vec2 qt_MultiTexCoord0; + +layout(location = 0) out vec2 qt_TexCoord0; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + float amplitude; + float frequency; + float time; +} ubuf; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = ubuf.qt_Matrix * qt_Vertex; +} diff --git a/tests/manual/nodetypes_ng/wobble.vert.qsb b/tests/manual/nodetypes_ng/wobble.vert.qsb Binary files differnew file mode 100644 index 0000000000..0f44e87feb --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble.vert.qsb diff --git a/tests/manual/nodetypes_ng/wobble_legacy_gl.frag b/tests/manual/nodetypes_ng/wobble_legacy_gl.frag new file mode 100644 index 0000000000..2961ca5f50 --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble_legacy_gl.frag @@ -0,0 +1,10 @@ +uniform sampler2D source; +uniform highp float amplitude; +uniform highp float frequency; +uniform highp float time; +uniform lowp float qt_Opacity; +varying highp vec2 qt_TexCoord0; +void main() { + highp vec2 p = sin(time + frequency * qt_TexCoord0); + gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity; +} diff --git a/tests/manual/nodetypes_ng/wobble_legacy_gl.vert b/tests/manual/nodetypes_ng/wobble_legacy_gl.vert new file mode 100644 index 0000000000..b2f33ab402 --- /dev/null +++ b/tests/manual/nodetypes_ng/wobble_legacy_gl.vert @@ -0,0 +1,8 @@ +uniform highp mat4 qt_Matrix; +attribute highp vec4 qt_Vertex; +attribute highp vec2 qt_MultiTexCoord0; +varying highp vec2 qt_TexCoord0; +void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml index ffb5c4e914..636399ba2c 100644 --- a/tests/manual/pointer/content/FakeFlickable.qml +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -26,10 +26,12 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.14 +import Qt.labs.animation 1.0 Item { id: root + objectName: "viewport" default property alias data: __contentItem.data property alias velocity: anim.velocity property alias contentX: __contentItem.x // sign is reversed compared to Flickable.contentX @@ -45,52 +47,81 @@ Item { width: childrenRect.width height: childrenRect.height - property real xlimit: root.width - __contentItem.width - property real ylimit: root.height - __contentItem.height + BoundaryRule on x { + id: xbr + minimum: root.width - __contentItem.width + maximum: 0 + minimumOvershoot: 100 + maximumOvershoot: 100 + overshootFilter: BoundaryRule.Peak + } - function returnToBounds() { - if (x > 0) { - returnXAnim.to = 0 - returnXAnim.start() - } else if (x < xlimit) { - returnXAnim.to = xlimit - returnXAnim.start() - } - if (y > 0) { - returnYAnim.to = 0 - returnYAnim.start() - } else if (y < ylimit) { - returnYAnim.to = ylimit - returnYAnim.start() - } + BoundaryRule on y { + id: ybr + minimum: root.height - __contentItem.height + maximum: 0 + minimumOvershoot: 100 + maximumOvershoot: 100 + overshootFilter: BoundaryRule.Peak } DragHandler { id: dragHandler - onActiveChanged: if (!active) anim.restart(centroid.velocity) + onActiveChanged: + if (active) { + anim.stop() + root.flickStarted() + } else { + var vel = centroid.velocity + if (xbr.returnToBounds()) + vel.x = 0 + if (ybr.returnToBounds()) + vel.y = 0 + if (vel.x !== 0 || vel.y !== 0) + anim.restart(vel) + else + root.flickEnded() + } + } + WheelHandler { + rotationScale: 15 + property: "x" + orientation: Qt.Horizontal + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + onActiveChanged: + // emitting signals in both instances is redundant but hard to avoid + // when the touchpad is flicking along both axes + if (active) { + anim.stop() + root.flickStarted() + } else { + xbr.returnToBounds() + root.flickEnded() + } + } + WheelHandler { + rotationScale: 15 + property: "y" + orientation: Qt.Vertical + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + onActiveChanged: + if (active) { + anim.stop() + root.flickStarted() + } else { + ybr.returnToBounds() + root.flickEnded() + } } MomentumAnimation { id: anim target: __contentItem onStarted: root.flickStarted() onStopped: { - __contentItem.returnToBounds() + xbr.returnToBounds() + ybr.returnToBounds() root.flickEnded() } } - NumberAnimation { - id: returnXAnim - target: __contentItem - property: "x" - duration: 200 - easing.type: Easing.OutQuad - } - NumberAnimation { - id: returnYAnim - target: __contentItem - property: "y" - duration: 200 - easing.type: Easing.OutQuad - } } } diff --git a/tests/manual/pointer/content/LeftDrawer.qml b/tests/manual/pointer/content/LeftDrawer.qml new file mode 100644 index 0000000000..08f2f67b5c --- /dev/null +++ b/tests/manual/pointer/content/LeftDrawer.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.14 +import Qt.labs.animation 1.0 +import QtGraphicalEffects 1.14 + +Item { + id: root + objectName: "LeftHandlerDrawer" + width: 100 + height: 400 + property real stickout: 4 + property real xOpen: rect.radius * -2 + property real xClosed: stickout - width + x: xClosed + y: 10 + + function close() { + openCloseAnimation.to = xClosed + openCloseAnimation.start() + } + function open() { + openCloseAnimation.to = xOpen + openCloseAnimation.start() + } + + DragHandler { + id: dragHandler + yAxis.enabled: false + xAxis.minimum: -1000 + margin: 20 + onActiveChanged: + if (!active) { + if (xbr.returnToBounds()) + return; + if (translation.x > 0) + open() + if (translation.x < 0) + close() + } + } + + BoundaryRule on x { + id: xbr + minimum: xClosed + maximum: xOpen + minimumOvershoot: rect.radius + maximumOvershoot: rect.radius + } + + NumberAnimation on x { + id: openCloseAnimation + duration: 300 + easing { type: Easing.OutBounce; overshoot: 5 } + } + + RectangularGlow { + id: effect + anchors.fill: parent + glowRadius: dragHandler.margin + spread: 0.2 + color: "cyan" + cornerRadius: rect.radius + glowRadius + } + + Rectangle { + id: rect + anchors.fill: parent + anchors.margins: 3 + color: "#333" + border.color: "cyan" + border.width: 2 + radius: 10 + antialiasing: true + } +} diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index c381d97c7c..beb84b176b 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -26,7 +26,8 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.14 +import Qt.labs.animation 1.0 Item { id: root @@ -42,8 +43,16 @@ Item { objectName: label.text + " DragHandler" target: knob xAxis.enabled: false - yAxis.minimum: slot.y - yAxis.maximum: slot.height + slot.y - knob.height + } + + WheelHandler { + id: wheelHandler + objectName: label.text + " WheelHandler" + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + invertible: false // Don't let the system "natural scrolling" setting affect this + rotationScale: -0.5 // But make it go consistently in the same direction as the fingers or wheel, a bit slow + target: knob + property: "y" } Rectangle { @@ -51,8 +60,8 @@ Item { anchors.top: parent.top anchors.bottom: parent.bottom anchors.margins: 10 - anchors.topMargin: 30 - anchors.bottomMargin: 30 + anchors.topMargin: label.height + 6 + anchors.bottomMargin: valueLabel.height + 4 anchors.horizontalCenter: parent.horizontalCenter width: 10 color: "black" @@ -82,10 +91,10 @@ Item { height: root.width / 2 width: implicitWidth / implicitHeight * height property bool programmatic: false - property real multiplier: root.maximumValue / (dragHandler.yAxis.maximum - dragHandler.yAxis.minimum) - onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier + property real multiplier: root.maximumValue / (ybr.maximum - ybr.minimum) + onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - ybr.minimum) * multiplier transformOrigin: Item.Center - function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } + function setValue(value) { knob.y = ybr.maximum - value / knob.multiplier } TapHandler { id: tap objectName: label.text + " TapHandler" @@ -95,9 +104,15 @@ Item { root.tapped } } + BoundaryRule on y { + id: ybr + minimum: slot.y + maximum: slot.height + slot.y - knob.height + } } Text { + id: valueLabel font.pointSize: 16 color: "red" anchors.bottom: parent.bottom diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml index 284e0d1f34..be52e4dbaa 100644 --- a/tests/manual/pointer/fakeFlickable.qml +++ b/tests/manual/pointer/fakeFlickable.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -30,39 +30,34 @@ import QtQuick 2.12 import "content" Rectangle { + id: root color: "#444" width: 480 - height: 480 + height: 640 FakeFlickable { id: ff anchors.fill: parent + anchors.leftMargin: 20 anchors.rightMargin: rightSB.width - Row { - Item { - width: 100 - height: 400 - Slider { - id: slider - label: "font size" - anchors.fill: parent - maximumValue: 36 - value: 14 - } - } - Text { - id: text - color: "beige" - font.family: "mono" - font.pointSize: slider.value - onTextChanged: console.log("text geom " + width + "x" + height + - ", parent " + parent + " geom " + parent.width + "x" + parent.height) - } - } + Text { + id: text + color: "beige" + font.family: "mono" + font.pointSize: slider.value + onTextChanged: console.log("text geom " + width + "x" + height + + ", parent " + parent + " geom " + parent.width + "x" + parent.height) + } - onFlickStarted: console.log("flick started with velocity " + velocity) - onFlickEnded: console.log("flick ended with velocity " + velocity) + onFlickStarted: { + root.border.color = "green" + console.log("flick started with velocity " + velocity) + } + onFlickEnded: { + root.border.color = "transparent" + console.log("flick ended with velocity " + velocity) + } Component.onCompleted: { var request = new XMLHttpRequest() @@ -101,4 +96,17 @@ Rectangle { bottom: parent.bottom } } + + LeftDrawer { + width: 100 + anchors.verticalCenter: parent.verticalCenter + Slider { + id: slider + label: "font\nsize" + anchors.fill: parent + anchors.margins: 10 + maximumValue: 36 + value: 14 + } + } } diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml index c400874d58..0e815ccd9c 100644 --- a/tests/manual/pointer/map.qml +++ b/tests/manual/pointer/map.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -26,7 +26,7 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.14 Item { width: 640 @@ -41,6 +41,20 @@ Item { height: image.height transform: Rotation { id: tilt; origin.x: width / 2; origin.y: height / 2; axis { x: 1; y: 0; z: 0 } } + WheelHandler { + id: wheelHandler + objectName: "vertical mouse wheel for scaling" + property: "scale" + onWheel: console.log("rotation " + event.angleDelta + " scaled " + rotation + " @ " + point.position + " => " + map.scale) + } + + WheelHandler { + id: horizontalWheelHandler + objectName: "horizontal mouse wheel for side-scrolling" + property: "x" + orientation: Qt.Horizontal + } + Image { id: image anchors.centerIn: parent diff --git a/tests/manual/pointer/pinchAndWheel.qml b/tests/manual/pointer/pinchAndWheel.qml new file mode 100644 index 0000000000..0944717bb7 --- /dev/null +++ b/tests/manual/pointer/pinchAndWheel.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.14 +import Qt.labs.animation 1.0 +import "content" + +Rectangle { + id: root + width: 1024; height: 600 + color: "#eee" + + CheckBox { + id: cbTouchpadEnabled + x: 10; y: 6 + label: "Touchpad wheel emulation enabled" + } + + CheckBox { + id: cbHorzWheelEnabled + x: cbTouchpadEnabled.width + 20; y: 6 + label: "Horizontal wheel rotation" + } + + function getTransformationDetails(item, pinchhandler) { + return "\n\npinch.scale:" + pinchhandler.scale.toFixed(2) + + "\npinch.rotation:" + pinchhandler.rotation.toFixed(2) + + "°\npinch.translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + + "\nscale wheel.rotation:" + scaleWheelHandler.rotation.toFixed(2) + + "°\nhorizontal wheel.rotation:" + horizontalRotationWheelHandler.rotation.toFixed(2) + + "°\ncontrol-rotation wheel.rotation:" + controlRotationWheelHandler.rotation.toFixed(2) + + "°\nrect.scale: " + item.scale.toFixed(2) + + "\nrect.rotation: " + item.rotation.toFixed(2) + + "°\nrect.position: " + "(" + item.x.toFixed(2) + "," + item.y.toFixed(2) + ")" + } + + Rectangle { + id: transformable + width: parent.width - 100; height: parent.height - 100; x: 50; y: 50 + color: "#ffe0e0e0" + antialiasing: true + + PinchHandler { + id: parentPinch + objectName: "parent pinch" + minimumScale: 0.5 + maximumScale: 3 + } + + WheelHandler { + id: scaleWheelHandler + objectName: "mouse wheel for scaling" + acceptedDevices: cbTouchpadEnabled.checked ? PointerDevice.Mouse | PointerDevice.TouchPad : PointerDevice.Mouse + acceptedModifiers: Qt.NoModifier + property: "scale" + onActiveChanged: if (!active) sbr.returnToBounds(); + onWheel: console.log(objectName + ": rotation " + event.angleDelta.y + " scaled " + rotation + " @ " + point.position + " => " + parent.scale) + } + + BoundaryRule on scale { + id: sbr + minimum: 0.1 + maximum: 2 + minimumOvershoot: 0.05 + maximumOvershoot: 0.05 + } + + BoundaryRule on rotation { + id: rbr + minimum: -90 + maximum: 360 + minimumOvershoot: 10 + maximumOvershoot: 10 + } + + WheelHandler { + id: horizontalRotationWheelHandler + enabled: cbHorzWheelEnabled.checked + objectName: "horizontal mouse wheel for rotation" + acceptedDevices: cbTouchpadEnabled.checked ? PointerDevice.Mouse | PointerDevice.TouchPad : PointerDevice.Mouse + acceptedModifiers: Qt.NoModifier + property: "rotation" + orientation: Qt.Horizontal + onActiveChanged: if (!active) rbr.returnToBounds() + onWheel: console.log(objectName + ": rotation " + event.angleDelta.y + " scaled " + rotation + " @ " + point.position + " => " + parent.rotation) + } + + WheelHandler { + id: controlRotationWheelHandler + objectName: "control-mouse wheel for rotation" + acceptedDevices: cbTouchpadEnabled.checked ? PointerDevice.Mouse | PointerDevice.TouchPad : PointerDevice.Mouse + acceptedModifiers: Qt.ControlModifier + property: "rotation" + orientation: Qt.Vertical // already the default + // TODO returnToBounds() causes trouble because position isn't being adjusted when this happens + onActiveChanged: if (!active) rbr.returnToBounds() + onWheel: console.log(objectName + ": rotation " + event.angleDelta.y + " scaled " + rotation + " @ " + point.position + " => " + parent.rotation) + } + + HoverHandler { + id: hover + acceptedDevices: PointerDevice.AllDevices + property var scenePoint: transformable.mapToItem(root, point.position.x, point.position.y) + } + + Text { + text: "Pinch with 2 fingers to scale, rotate and translate\nMouse wheel to scale, Ctrl+mouse wheel or horizontal wheel to rotate" + + getTransformationDetails(parent, parentPinch) + } + } + + Rectangle { + width: 1; height: parent.height + color: "blue" + x: hover.scenePoint.x + Text { + x: implicitWidth / -2; style: Text.Outline; styleColor: "white" + y: 30 + color: "blue" + text: "outer " + parent.x.toFixed(2) + " inner " + hover.point.position.x.toFixed(2) + } + } + + Rectangle { + width: parent.width; height: 1 + color: "blue" + y: hover.scenePoint.y + Text { + x: 45 + y: implicitHeight / -2; style: Text.Outline; styleColor: "white" + color: "blue" + text: "outer " + parent.y.toFixed(2) + " inner " + hover.point.position.y.toFixed(2) + } + } +} diff --git a/tests/manual/scalablepath/ShapeTestScale.qml b/tests/manual/scalablepath/ShapeTestScale.qml new file mode 100644 index 0000000000..097ecf3a93 --- /dev/null +++ b/tests/manual/scalablepath/ShapeTestScale.qml @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.14 +import QtQuick.Shapes 1.14 + +Rectangle { + id: i + width: parent.width * 0.5 + height: parent.height * 0.5 + anchors.centerIn: parent + color: "transparent" + border.color: "red" + + Shape { + id: pathLineMove + vendorExtensionsEnabled: false + anchors { + left: parent.left + top: parent.top + bottom: parent.verticalCenter + right: parent.horizontalCenter + } + + visible: true + + ShapePath { + id: c_sp1 + strokeWidth: -1 + fillColor: Qt.rgba(1,0,1,1.0) + scale: Qt.size(pathLineMove.width - 1, pathLineMove.height - 1) + + startX: 0.5; + startY: 1 + + PathLine { + x: 0 + y: 1 + } + PathLine { + x: 0.5 + y: 0 + } + PathLine { + x: 1 + y: 1 + } + PathLine { + x: c_sp1.startX + y: c_sp1.startY + } + + // Inner shape + PathMove { + x: 0.5 + y: 0.25 + } + PathLine { + x: 0.8 + y: 0.8 + } + PathLine { + x: 0.2 + y: 0.8 + } + PathLine { + x: 0.5 + y: 0.25 + } + } + } + Shape { + id: pathCurveArcQuad + vendorExtensionsEnabled: false + anchors { + left: parent.horizontalCenter + top: parent.top + bottom: parent.verticalCenter + right: parent.right + } + + visible: true + + ShapePath { + strokeWidth: 1 + fillColor: "transparent" + strokeColor: "goldenrod" + scale: Qt.size(pathCurveArcQuad.width - 1, pathCurveArcQuad.height - 1) + + startX: 0/400; startY: 100/400 + + PathCurve { x: 75/400; y: 75/400 } + PathCurve { x: 200/400; y: 150/400 } + PathCurve { x: 325/400; y: 25/400 } + PathCurve { x: 400/400; y: 100/400 } + PathMove { x: 0.5; y: 0 } + PathArc { + x: 0; y: 100 / 200 + radiusX: 100 / 200; radiusY: 100 / 200 + useLargeArc: true + } + PathMove { x: 0; y: 0.5 } + PathQuad { x: 1; y: 0.5; controlX: 0.5; controlY: 1 } + } + } + + + Shape { + id: pathCubicAngleArc + vendorExtensionsEnabled: false + anchors { + left: parent.left + top: parent.verticalCenter + bottom: parent.bottom + right: parent.horizontalCenter + } + + visible: true + + ShapePath { + strokeWidth: 1 + fillColor: "transparent" + strokeColor: "deepskyblue" + scale: Qt.size(pathCubicAngleArc.width - 1, pathCubicAngleArc.height - 1) + + startX: 20/200; startY: 0 + + PathCubic { + x: 180/200; y: 0 + control1X: -10/200; control1Y: 90/200 + control2X: 210/200; control2Y: 90/200 + } + + PathAngleArc { + centerX: 0.5; centerY: 0.5 + radiusX: 0.45; radiusY: 0.45 + startAngle: -180 + sweepAngle: 234 + moveToStart: true + } + } + } + Shape { + id: pathSvg + vendorExtensionsEnabled: false + anchors { + left: parent.horizontalCenter + top: parent.verticalCenter + bottom: parent.bottom + right: parent.right + } + + visible: true + + ShapePath { + strokeWidth: 5 + fillColor: "transparent" + strokeColor: "coral" + scale: Qt.size((pathSvg.width - 1), (pathSvg.height - 1)) + startX: .25; startY: .25 + PathSvg { path: "L .75 .25 L .5 .75 z" } + } + + ShapePath { + strokeWidth: 1 + fillColor: "transparent" + strokeColor: "black" + scale: Qt.size((pathSvg.width - 1) / 200, (pathSvg.height - 1) / 200) + startX: 50; startY: 50 + PathSvg { path: "L 150 50 L 100 150 z" } + } + + ShapePath { + strokeColor: "red" + strokeWidth: 4 + fillColor: "transparent" + scale: Qt.size((pathSvg.width - 1) / 500, (pathSvg.height - 1) / 500) + PathSvg { + path: "m 325.03711,0.5 + c -26.61408,6.4494547 -49.95197,2.1018066 -76.21132,1.0771669 + -22.26577,7.6817151 -47.96405,9.3627181 -65.67832,25.8497861 + -15.74718,12.80008 -41.1564,19.605644 -45.74903,40.600391 + -12.46933,17.76181 -25.36105,35.720146 -29.20117,57.999996 + -18.709864,3.10961 -16.347355,30.83801 -22.385143,46.675 + -6.848711,11.2677 11.07278,24.69174 -8.514666,27.97383 + -10.266901,5.61543 -12.859313,28.96588 -13.732346,5.78143 + 0.940083,-11.53398 -13.486195,-38.30626 -16.81701,-34.20231 + 14.608079,7.8234 21.299281,50.52979 11.380052,48.14418 + -3.406456,-15.12428 -26.181106,-38.29457 -31.849471,-35.62945 + 16.851912,6.41472 35.569884,31.75215 28.172486,47.93115 + -7.906485,-15.42757 -37.758959,-35.53783 -44.275447,-31.28685 + 18.975831,1.7428 37.986009,20.68109 42.87115,37.14427 C + 42.279655,225.774 9.879724,213.57795 4.7080253,219.04989 + 20.780803,212.57418 55.055919,239.88547 49.602579,241.25683 + 38.186641,230.40078 6.6930104,222.77983 2.5752529,228.41774 c + 13.6045481,-8.33065 49.4437901,14.89041 43.5525671,14.2358 + -9.759981,-7.96123 -43.5842921,7.36937 -17.554974,-1.20248 + 9.464499,-3.73452 40.555672,12.80659 16.398749,5.14121 + -9.1987,-7.28225 -39.0013156,3.37352 -14.121965,-2.12828 + 13.244874,-0.0206 35.758428,14.62706 10.562447,6.42228 + -10.780465,-8.4873 -47.8282254,11.10651 -21.027329,-0.003 + 11.640859,-4.82877 52.615601,10.74471 24.234828,8.2659 + -10.695834,-7.03902 -42.9384162,8.93905 -34.227854,5.58373 + 9.077539,-8.56443 49.068801,-5.28097 43.06838,0.45546 + -10.900893,-0.7118 -27.449619,17.27258 -10.00187,3.46526 + 15.705191,-9.18198 18.344231,9.31645 1.10807,8.73907 + -9.908444,1.77856 -21.108189,20.66671 -7.974821,4.92019 + 15.750746,-14.10374 34.01348,2.07267 9.796961,8.69337 + -8.17128,5.49929 -12.642664,19.13654 -3.994573,4.19708 + 9.044753,-8.7077 23.850399,-13.64552 21.404959,4.02329 + 12.509737,17.12562 51.158782,11.0442 45.106112,43.34009 + -0.65006,10.05318 -3.79228,13.95389 1.62128,14.30064 + -4.30913,8.82737 -14.652714,37.9591 2.92144,17.46024 + 7.37972,-3.68333 -7.62399,16.24161 -7.98007,23.83761 + -9.336865,18.77418 19.74873,-18.55943 6.62229,5.46195 + 5.46464,-3.7389 36.23886,-19.41901 14.78167,0.58987 + -8.59505,4.55644 29.29441,-2.99423 8.95489,6.47134 -9.22562,5.54437 + -24.09765,26.79976 -11.73274,22.20385 -0.81685,5.4936 + -1.58629,21.47626 2.34158,9.14886 1.61237,14.67029 + -2.38384,25.22225 12.26908,15.1741 -4.40761,8.01039 + -8.23679,36.91214 5.12235,17.92578 1.53454,2.99551 9.37569,3.1726 + 7.15304,14.93579 3.51234,-11.31873 18.4607,-29.83809 + 12.36869,-6.48005 -0.22629,16.26174 5.44303,-7.24791 + 6.56926,10.49819 12.45412,28.9931 3.40908,-41.89883 + 17.52051,-9.19238 3.23093,11.1924 6.53006,29.46941 7.55984,5.1249 + 15.37236,-19.52583 4.09776,20.07416 12.64063,1.48215 + 18.11247,-24.55068 -8.92586,38.39355 6.73828,6.62225 + 4.55353,-6.91007 15.35028,-38.88977 12.55806,-13.78666 + 1.05309,27.02664 11.54743,-24.40259 12.40657,6.86306 + -1.72561,13.28253 11.85393,-24.15909 13.85568,-1.38002 + 3.12455,8.33539 8.76536,26.46432 8.73882,5.09231 3.57025,-10.37352 + -16.025,-37.75672 0.20707,-22.5788 -1.2458,-14.17213 + -2.38918,-16.90145 10.85489,-6.71468 -16.57629,-17.22152 + 0.19706,-26.08949 5.7751,-19.14889 -14.91681,-16.1674 + 19.74174,7.19334 2.31875,-9.86869 -4.32508,-15.23278 + 27.25228,29.12341 20.27514,18.81172 -11.97527,-18.92603 + -17.96305,-45.80333 11.70099,-51.52566 17.19069,-9.57351 + 31.17452,21.93154 38.50541,1.56304 16.26048,-4.6633 + 22.3749,38.26516 24.86349,9.11316 5.94153,-9.9731 30.14313,6.97379 + 36.34294,4.75012 7.07435,18.27732 8.06778,14.78971 11.04264,3.86016 + 2.73754,-15.85945 28.7269,10.06391 28.09146,25.96561 3.00672,2.4754 + 6.55025,-22.10264 11.23552,-14.43872 2.84155,-11.4823 + -3.28976,-27.88574 4.24895,-25.5189 -0.61494,-11.53957 + 22.83611,0.11011 10.64648,-15.28756 -6.5587,-21.38598 + 9.32959,-3.0159 13.5107,-4.69375 -1.38592,-16.74533 + -8.66673,-31.83316 -1.90087,-41.0875 2.39623,-15.14303 + -12.50533,-44.45478 -4.70573,-48.49375 15.08472,3.42779 + -20.39159,-42.17451 -1.69776,-40.85728 24.07272,21.63552 + -3.65989,-30.10299 2.27233,-33.17152 16.90643,17.53071 + -12.7383,-38.42821 6.79531,-21.57013 -4.50946,-21.08135 + -2.53357,-37.43561 -15.5535,-55.59527 -11.0035,-12.40086 + -1.87775,-7.12745 1.34831,-8.11755 C 468.27562,118.9774 + 451.40746,102.656 430.98897,92.119168 439.06192,78.203836 + 455.88012,60.123881 457.38638,40.337815 463.2373,23.183067 + 450.82861,4.7342783 435.04883,22.626367 409.5188,28.206712 + 386.3569,24.131269 365.63904,8.0954152 352.788,2.8857182 + 338.88892,0.40735091 325.03711,0.5 Z m -219.0625,357.04297 + -0.97656,0.88476 z" + } + } + } +} diff --git a/tests/manual/scalablepath/main.cpp b/tests/manual/scalablepath/main.cpp new file mode 100644 index 0000000000..d35c590020 --- /dev/null +++ b/tests/manual/scalablepath/main.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/tests/manual/scalablepath/main.qml b/tests/manual/scalablepath/main.qml new file mode 100644 index 0000000000..e549a753d7 --- /dev/null +++ b/tests/manual/scalablepath/main.qml @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.14 +import QtQuick.Window 2.14 + +Window { + visible: true + width: 512 + height: 512 + color: "black" + + ShapeTestScale { + anchors.centerIn: parent + + } +} diff --git a/tests/manual/scalablepath/qml.qrc b/tests/manual/scalablepath/qml.qrc new file mode 100644 index 0000000000..a7a14beed4 --- /dev/null +++ b/tests/manual/scalablepath/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>ShapeTestScale.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/scalablepath/scalablepath.pro b/tests/manual/scalablepath/scalablepath.pro new file mode 100644 index 0000000000..b95ce1de44 --- /dev/null +++ b/tests/manual/scalablepath/scalablepath.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +QT += quick qml +SOURCES += main.cpp +RESOURCES += qml.qrc +CONFIG += c++11 diff --git a/tests/manual/scenegraph_lancelot/data/shape/shape_multiline.qml b/tests/manual/scenegraph_lancelot/data/shape/shape_multiline.qml new file mode 100644 index 0000000000..8524915bc4 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shape/shape_multiline.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.14 +import QtQuick.Shapes 1.14 + +Item { + id: root + width: 320 + height: 320 + + Shape { + vendorExtensionsEnabled: false + anchors.fill: parent + + ShapePath { + strokeWidth: 1 + strokeColor: "red" + fillColor: Qt.rgba(1,0,0,0.3) + scale: Qt.size(root.width - 1, root.height - 1) + PathMultiline { + paths: [ + [Qt.point(0.5, 0.06698), + Qt.point(1, 0.93301), + Qt.point(0, 0.93301), + Qt.point(0.5, 0.06698)], + + [Qt.point(0.5, 0.12472), + Qt.point(0.95, 0.90414), + Qt.point(0.05, 0.90414), + Qt.point(0.5, 0.12472)], + + [Qt.point(0.47131, 0.32986), + Qt.point(0.36229, 0.64789), + Qt.point(0.51492, 0.58590), + Qt.point(0.47563, 0.76014), + Qt.point(0.44950, 0.73590), + Qt.point(0.46292, 0.83392), + Qt.point(0.52162, 0.75190), + Qt.point(0.48531, 0.76230), + Qt.point(0.57529, 0.53189), + Qt.point(0.41261, 0.59189), + Qt.point(0.53001, 0.32786), + Qt.point(0.47131, 0.32986)] + ] + } + } + } +} diff --git a/tests/manual/tableview/abstracttablemodel/Button.qml b/tests/manual/tableview/abstracttablemodel/Button.qml index 2d4dcde80d..7057e33633 100644 --- a/tests/manual/tableview/abstracttablemodel/Button.qml +++ b/tests/manual/tableview/abstracttablemodel/Button.qml @@ -40,7 +40,7 @@ import QtQuick 2.12 Rectangle { - width: 100 + width: 110 height: 40 border.width: 1 color: "lightgreen" diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml index 52967a1a0d..4b9158f03c 100644 --- a/tests/manual/tableview/abstracttablemodel/main.qml +++ b/tests/manual/tableview/abstracttablemodel/main.qml @@ -37,10 +37,11 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.14 import QtQuick.Window 2.3 import QtQml.Models 2.2 import TestTableModel 0.1 +import QtQuick.Controls 2.5 Window { id: window @@ -54,7 +55,7 @@ Window { TestTableModel { id: tableModel rowCount: 200 - columnCount: 5000 + columnCount: 200 } Rectangle { @@ -62,45 +63,150 @@ Window { anchors.margins: 10 color: "darkgray" - Row { + Column { id: menu x: 2 y: 2 - spacing: 1 - Button { - text: "Add row" - onClicked: tableModel.insertRows(selectedY, 1) + + Row { + spacing: 1 + Button { + text: "Add row" + onClicked: tableModel.insertRows(selectedY, 1) + } + Button { + text: "Remove row" + onClicked: tableModel.removeRows(selectedY, 1) + } + Button { + text: "Add column" + onClicked: tableModel.insertColumns(selectedX, 1) + } + Button { + text: "Remove column" + onClicked: tableModel.removeColumns(selectedX, 1) + } } - Button { - text: "Remove row" - onClicked: tableModel.removeRows(selectedY, 1) + + Row { + spacing: 1 + Button { + text: "fast-flick<br>center table" + onClicked: { + tableView.contentX += tableView.width * 1.2 + } + } + Button { + text: "flick to end<br>center table" + onClicked: { + tableView.contentX = tableView.contentWidth - tableView.width + } + } + Button { + text: "fast-flick<br>headers" + onClicked: { + leftHeader.contentY += 1000 + topHeader.contentX += 1000 + } + } + Button { + text: "set/unset<br>master bindings" + onClicked: { + leftHeader.syncView = leftHeader.syncView ? null : tableView + topHeader.syncView = topHeader.syncView ? null : tableView + } + } + Button { + text: "inc space" + onClicked: { + tableView.columnSpacing += 1 + tableView.rowSpacing += 1 + } + } + } + Text { + text: "Selected: x:" + selectedX + ", y:" + selectedY } - Button { - text: "Add column" - onClicked: tableModel.insertColumns(selectedX, 1) + } + + TableView { + id: topHeader + objectName: "topHeader" + anchors.left: tableView.left + width: tableView.width + anchors.top: menu.bottom + height: 30 + clip: true + ScrollBar.horizontal: ScrollBar {} + + model: TestTableModel { + rowCount: 1 + columnCount: 200 } - Button { - text: "Remove column" - onClicked: tableModel.removeColumns(selectedX, 1) + + delegate: Rectangle { + implicitHeight: topHeader.height + implicitWidth: 20 + color: "lightgray" + Text { text: column } } + + columnSpacing: 1 + rowSpacing: 1 + + syncDirection: Qt.Horizontal } - Text { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 2 - text: "x:" + selectedX + ", y:" + selectedY + + TableView { + id: leftHeader + objectName: "leftHeader" + anchors.left: parent.left + anchors.top: tableView.top + height: tableView.height + width: 30 + clip: true + ScrollBar.vertical: ScrollBar {} + + model: TestTableModel { + rowCount: 200 + columnCount: 1 + } + + delegate: Rectangle { + implicitHeight: 50 + implicitWidth: leftHeader.width + color: "lightgray" + Text { text: row } + } + + columnSpacing: 1 + rowSpacing: 1 + + syncDirection: Qt.Vertical } TableView { id: tableView - anchors.left: parent.left + objectName: "tableview" + anchors.left: leftHeader.right anchors.right: parent.right - anchors.top: menu.bottom + anchors.top: topHeader.bottom anchors.bottom: parent.bottom - anchors.margins: 2 + width: 200 clip: true + columnWidthProvider: function(c) { + if (c > 30) + return 100 + else + return 200; + } + ScrollBar.horizontal: ScrollBar {} + ScrollBar.vertical: ScrollBar {} - model: tableModel + model: TestTableModel { + rowCount: 200 + columnCount: 60 + } delegate: tableViewDelegate columnSpacing: 1 rowSpacing: 1 diff --git a/tests/manual/tableview/tablemodel/form/RowForm.qml b/tests/manual/tableview/tablemodel/form/RowForm.qml new file mode 100644 index 0000000000..bb03e685c0 --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/RowForm.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.11 + +ScrollView { + clip: true + + function inputAsRow() { + return { + checked: checkedCheckBox.checked, + amount: amountSpinBox.value, + fruitType: fruitTypeTextField.text, + fruitName: fruitNameTextField.text, + fruitPrice: parseFloat(fruitPriceTextField.text) + } + } + + default property alias content: gridLayout.children + + GridLayout { + id: gridLayout + columns: 2 + + Label { + text: "checked" + } + CheckBox { + id: checkedCheckBox + } + + Label { + text: "amount" + } + SpinBox { + id: amountSpinBox + value: 1 + } + + Label { + text: "fruitType" + } + TextField { + id: fruitTypeTextField + text: "Pear" + } + + Label { + text: "fruitName" + } + TextField { + id: fruitNameTextField + text: "Williams" + } + + Label { + text: "fruitPrice" + } + TextField { + id: fruitPriceTextField + text: "1.50" + } + } +} diff --git a/tests/manual/tableview/tablemodel/form/form.pro b/tests/manual/tableview/tablemodel/form/form.pro new file mode 100644 index 0000000000..ba6f7a91b1 --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/form.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = form +QT += qml quick +SOURCES += main.cpp +RESOURCES += main.qml RowForm.qml + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/tablemodel/form/main.cpp b/tests/manual/tableview/tablemodel/form/main.cpp new file mode 100644 index 0000000000..2a3b90d392 --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/tableview/tablemodel/form/main.qml b/tests/manual/tableview/tablemodel/form/main.qml new file mode 100644 index 0000000000..6c6874fb4b --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/main.qml @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +ApplicationWindow { + id: window + width: 800 + height: 800 + visible: true + + ColumnLayout { + anchors.fill: parent + + TableView { + id: tableView + boundsBehavior: Flickable.StopAtBounds + + ScrollBar.horizontal: ScrollBar {} + ScrollBar.vertical: ScrollBar {} + + Layout.minimumHeight: window.height / 2 + Layout.fillWidth: true + Layout.fillHeight: true + + model: TableModel { + TableModelColumn { display: "checked" } + TableModelColumn { display: "amount" } + TableModelColumn { display: "fruitType" } + TableModelColumn { display: "fruitName" } + TableModelColumn { display: "fruitPrice" } + + // One row = one type of fruit that can be ordered + rows: [ + { + // Each object (line) is one column, + // and each property in that object represents a role. + checked: false, + amount: 1, + fruitType: "Apple", + fruitName: "Granny Smith", + fruitPrice: 1.50 + }, + { + checked: true, + amount: 4, + fruitType: "Orange", + fruitName: "Navel", + fruitPrice: 2.50 + }, + { + checked: false, + amount: 1, + fruitType: "Banana", + fruitName: "Cavendish", + fruitPrice: 3.50 + } + ] + } + + delegate: DelegateChooser { + DelegateChoice { + column: 0 + delegate: CheckBox { + objectName: "tableViewCheckBoxDelegate" + checked: model.display + onToggled: model.display = display + } + } + DelegateChoice { + column: 1 + delegate: SpinBox { + objectName: "tableViewSpinBoxDelegate" + value: model.display + onValueModified: model.display = value + } + } + DelegateChoice { + delegate: TextField { + objectName: "tableViewTextFieldDelegate" + text: model.display + selectByMouse: true + implicitWidth: 140 + onAccepted: model.display = text + } + } + } + } + + TabBar { + id: operationTabBar + + Layout.fillWidth: true + Layout.preferredHeight: 40 + + TabButton { + text: "Append" + } + TabButton { + text: "Clear" + } + TabButton { + text: "Insert" + } + TabButton { + text: "Move" + } + TabButton { + text: "Remove" + } + TabButton { + text: "Set" + } + } + + StackLayout { + currentIndex: operationTabBar.currentIndex + + ColumnLayout { + RowForm { + id: appendRowForm + + Layout.fillHeight: true + } + + Button { + text: "Append" + + Layout.alignment: Qt.AlignRight + + onClicked: tableView.model.appendRow(appendRowForm.inputAsRow()) + } + } + ColumnLayout { + Button { + text: "Clear" + enabled: tableView.rows > 0 + + onClicked: tableView.model.clear() + } + } + ColumnLayout { + RowForm { + id: insertRowForm + + Layout.fillHeight: true + + Label { + text: "Insert index" + } + SpinBox { + id: insertIndexSpinBox + from: 0 + to: tableView.rows + } + } + + Button { + text: "Insert" + + Layout.alignment: Qt.AlignRight + + onClicked: tableView.model.insertRow(insertIndexSpinBox.value, insertRowForm.inputAsRow()) + } + } + GridLayout { + columns: 2 + + Label { + text: "Move from index" + } + SpinBox { + id: moveFromIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Label { + text: "Move to index" + } + SpinBox { + id: moveToIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Label { + text: "Rows to move" + } + SpinBox { + id: rowsToMoveSpinBox + from: 1 + to: tableView.rows + } + + Button { + text: "Move" + enabled: tableView.rows > 0 + + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + + onClicked: tableView.model.moveRow(moveFromIndexSpinBox.value, moveToIndexSpinBox.value, rowsToMoveSpinBox.value) + } + } + GridLayout { + Label { + text: "Remove index" + } + SpinBox { + id: removeIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Button { + text: "Remove" + enabled: tableView.rows > 0 + + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + + onClicked: tableView.model.removeRow(removeIndexSpinBox.value) + } + } + ColumnLayout { + RowForm { + id: setRowForm + + Layout.fillHeight: true + + Label { + text: "Set index" + } + SpinBox { + id: setIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + } + + Button { + text: "Set" + + onClicked: tableView.model.setRow(setIndexSpinBox.value, setRowForm.inputAsRow()); + } + } + } + } +} diff --git a/tests/manual/tableview/tablemodel/json/JsonData.js b/tests/manual/tableview/tablemodel/json/JsonData.js new file mode 100644 index 0000000000..a37233c539 --- /dev/null +++ b/tests/manual/tableview/tablemodel/json/JsonData.js @@ -0,0 +1,186 @@ +let drivers = [ + { + "driverId":"fisichella", + "code":"FIS", + "url":"http://en.wikipedia.org/wiki/Giancarlo_Fisichella", + "givenName":"Giancarlo", + "familyName":"Fisichella", + "dateOfBirth":"1973-01-14", + "nationality":"Italian" + }, + { + "driverId":"barrichello", + "code":"BAR", + "url":"http://en.wikipedia.org/wiki/Rubens_Barrichello", + "givenName":"Rubens", + "familyName":"Barrichello", + "dateOfBirth":"1972-05-23", + "nationality":"Brazilian" + }, + { + "driverId":"alonso", + "permanentNumber":"14", + "code":"ALO", + "url":"http://en.wikipedia.org/wiki/Fernando_Alonso", + "givenName":"Fernando", + "familyName":"Alonso", + "dateOfBirth":"1981-07-29", + "nationality":"Spanish" + }, + { + "driverId":"coulthard", + "code":"COU", + "url":"http://en.wikipedia.org/wiki/David_Coulthard", + "givenName":"David", + "familyName":"Coulthard", + "dateOfBirth":"1971-03-27", + "nationality":"British" + }, + { + "driverId":"webber", + "code":"WEB", + "url":"http://en.wikipedia.org/wiki/Mark_Webber", + "givenName":"Mark", + "familyName":"Webber", + "dateOfBirth":"1976-08-27", + "nationality":"Australian" + }, + { + "driverId":"montoya", + "code":"MON", + "url":"http://en.wikipedia.org/wiki/Juan_Pablo_Montoya", + "givenName":"Juan", + "familyName":"Pablo Montoya", + "dateOfBirth":"1975-09-20", + "nationality":"Colombian" + }, + { + "driverId":"klien", + "code":"KLI", + "url":"http://en.wikipedia.org/wiki/Christian_Klien", + "givenName":"Christian", + "familyName":"Klien", + "dateOfBirth":"1983-02-07", + "nationality":"Austrian" + }, + { + "driverId":"raikkonen", + "permanentNumber":"7", + "code":"RAI", + "url":"http://en.wikipedia.org/wiki/Kimi_R%C3%A4ikk%C3%B6nen", + "givenName":"Kimi", + "familyName":"Räikkönen", + "dateOfBirth":"1979-10-17", + "nationality":"Finnish" + }, + { + "driverId":"trulli", + "code":"TRU", + "url":"http://en.wikipedia.org/wiki/Jarno_Trulli", + "givenName":"Jarno", + "familyName":"Trulli", + "dateOfBirth":"1974-07-13", + "nationality":"Italian" + }, + { + "driverId":"massa", + "permanentNumber":"19", + "code":"MAS", + "url":"http://en.wikipedia.org/wiki/Felipe_Massa", + "givenName":"Felipe", + "familyName":"Massa", + "dateOfBirth":"1981-04-25", + "nationality":"Brazilian" + }, + { + "driverId":"button", + "permanentNumber":"22", + "code":"BUT", + "url":"http://en.wikipedia.org/wiki/Jenson_Button", + "givenName":"Jenson", + "familyName":"Button", + "dateOfBirth":"1980-01-19", + "nationality":"British" + }, + { + "driverId":"ralf_schumacher", + "code":"SCH", + "url":"http://en.wikipedia.org/wiki/Ralf_Schumacher", + "givenName":"Ralf", + "familyName":"Schumacher", + "dateOfBirth":"1975-06-30", + "nationality":"German" + }, + { + "driverId":"villeneuve", + "code":"VIL", + "url":"http://en.wikipedia.org/wiki/Jacques_Villeneuve", + "givenName":"Jacques", + "familyName":"Villeneuve", + "dateOfBirth":"1971-04-09", + "nationality":"Canadian" + }, + { + "driverId":"sato", + "code":"SAT", + "url":"http://en.wikipedia.org/wiki/Takuma_Sato", + "givenName":"Takuma", + "familyName":"Sato", + "dateOfBirth":"1977-01-28", + "nationality":"Japanese" + }, + { + "driverId":"karthikeyan", + "code":"KAR", + "url":"http://en.wikipedia.org/wiki/Narain_Karthikeyan", + "givenName":"Narain", + "familyName":"Karthikeyan", + "dateOfBirth":"1977-01-14", + "nationality":"Indian" + }, + { + "driverId":"monteiro", + "code":"TMO", + "url":"http://en.wikipedia.org/wiki/Tiago_Monteiro", + "givenName":"Tiago", + "familyName":"Monteiro", + "dateOfBirth":"1976-07-24", + "nationality":"Portuguese" + }, + { + "driverId":"friesacher", + "code":"FRI", + "url":"http://en.wikipedia.org/wiki/Patrick_Friesacher", + "givenName":"Patrick", + "familyName":"Friesacher", + "dateOfBirth":"1980-09-26", + "nationality":"Austrian" + }, + { + "driverId":"michael_schumacher", + "code":"MSC", + "url":"http://en.wikipedia.org/wiki/Michael_Schumacher", + "givenName":"Michael", + "familyName":"Schumacher", + "dateOfBirth":"1969-01-03", + "nationality":"German" + }, + { + "driverId":"heidfeld", + "code":"HEI", + "url":"http://en.wikipedia.org/wiki/Nick_Heidfeld", + "givenName":"Nick", + "familyName":"Heidfeld", + "dateOfBirth":"1977-05-10", + "nationality":"German" + }, + { + "driverId":"albers", + "code":"ALB", + "url":"http://en.wikipedia.org/wiki/Christijan_Albers", + "givenName":"Christijan", + "familyName":"Albers", + "dateOfBirth":"1979-04-16", + "nationality":"Dutch" + } +] diff --git a/tests/manual/tableview/tablemodel/json/json.pro b/tests/manual/tableview/tablemodel/json/json.pro new file mode 100644 index 0000000000..2339e488aa --- /dev/null +++ b/tests/manual/tableview/tablemodel/json/json.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = json +QT += qml quick +SOURCES += main.cpp +RESOURCES += \ + main.qml \ + JsonData.js + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/tablemodel/json/main.cpp b/tests/manual/tableview/tablemodel/json/main.cpp new file mode 100644 index 0000000000..176b532d49 --- /dev/null +++ b/tests/manual/tableview/tablemodel/json/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/tableview/tablemodel/json/main.qml b/tests/manual/tableview/tablemodel/json/main.qml new file mode 100644 index 0000000000..2a835459c0 --- /dev/null +++ b/tests/manual/tableview/tablemodel/json/main.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +import "JsonData.js" as CachedJsonData + +ApplicationWindow { + id: window + width: 800 + height: 300 + visible: true + + function requestJson() { + let doc = new XMLHttpRequest() + doc.onreadystatechange = function() { + if (doc.readyState === XMLHttpRequest.DONE) { + var root = JSON.parse(doc.responseText) + var race = root.MRData.RaceTable.Races[0] + var raceResults = race.Results + var drivers = [] + for (let i = 0; i < raceResults.length; ++i) { + drivers.push(raceResults[i].Driver) + } + tableView.model.rows = drivers + print(JSON.stringify(drivers)) + } + } + + doc.open("GET", "http://ergast.com/api/f1/2005/1/results.json") + doc.send() + } + + Component.onCompleted: requestJson() + // Same as the data we get from ergast. Use it while developing + // to avoid flooding the server with requests. +// Component.onCompleted: tableView.model.rows = CachedJsonData.drivers + + ColumnLayout { + anchors.fill: parent + + TableView { + id: tableView + boundsBehavior: Flickable.StopAtBounds + + ScrollBar.horizontal: ScrollBar { + policy: ScrollBar.AlwaysOn + } + ScrollBar.vertical: ScrollBar { + policy: ScrollBar.AlwaysOn + } + + Layout.minimumHeight: window.height / 2 + Layout.fillWidth: true + Layout.fillHeight: true + + model: TableModel { + TableModelColumn { display: "driverId" } + TableModelColumn { display: "code" } + TableModelColumn { display: "url" } + TableModelColumn { display: "givenName" } + TableModelColumn { display: "familyName" } + TableModelColumn { display: "dateOfBirth" } + TableModelColumn { display: "nationality" } + } + + delegate: TextField { + objectName: "tableViewTextFieldDelegate" + text: model.display + selectByMouse: true + implicitWidth: 140 + onAccepted: model.display = text + } + } + } +} diff --git a/tests/manual/tableview/tablemodel/tablemodel.pro b/tests/manual/tableview/tablemodel/tablemodel.pro new file mode 100644 index 0000000000..4e4eba7653 --- /dev/null +++ b/tests/manual/tableview/tablemodel/tablemodel.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += form |