From a4c9bde033df86354bfdae1de0554550cf867035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 16 May 2012 18:45:34 +0200 Subject: Fixed qml-compositor and made it properly installable without a qrc. Change-Id: I40936865453392dc90b03f67220f70480c0eae56 Reviewed-by: Laszlo Agocs --- examples/qml-compositor/ContrastEffect.qml | 97 +++++++++++++ examples/qml-compositor/WindowChrome.qml | 56 ++++++++ examples/qml-compositor/WindowContainer.qml | 105 ++++++++++++++ examples/qml-compositor/compositor.js | 155 +++++++++++++++++++++ examples/qml-compositor/main.cpp | 2 +- examples/qml-compositor/main.qml | 101 ++++++++++++++ examples/qml-compositor/qml-compositor.pro | 7 +- examples/qml-compositor/qml-compositor.qrc | 11 -- .../qml/QmlCompositor/ContrastEffect.qml | 97 ------------- .../qml/QmlCompositor/WindowChrome.qml | 56 -------- .../qml/QmlCompositor/WindowContainer.qml | 105 -------------- .../qml-compositor/qml/QmlCompositor/compositor.js | 155 --------------------- examples/qml-compositor/qml/QmlCompositor/main.qml | 101 -------------- 13 files changed, 519 insertions(+), 529 deletions(-) create mode 100644 examples/qml-compositor/ContrastEffect.qml create mode 100644 examples/qml-compositor/WindowChrome.qml create mode 100644 examples/qml-compositor/WindowContainer.qml create mode 100644 examples/qml-compositor/compositor.js create mode 100644 examples/qml-compositor/main.qml delete mode 100644 examples/qml-compositor/qml-compositor.qrc delete mode 100644 examples/qml-compositor/qml/QmlCompositor/ContrastEffect.qml delete mode 100644 examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml delete mode 100644 examples/qml-compositor/qml/QmlCompositor/WindowContainer.qml delete mode 100644 examples/qml-compositor/qml/QmlCompositor/compositor.js delete mode 100644 examples/qml-compositor/qml/QmlCompositor/main.qml (limited to 'examples/qml-compositor') diff --git a/examples/qml-compositor/ContrastEffect.qml b/examples/qml-compositor/ContrastEffect.qml new file mode 100644 index 000000000..0a9ad67b8 --- /dev/null +++ b/examples/qml-compositor/ContrastEffect.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ShaderEffect { + property variant source: null; + property color color: "#ffffff" + property real blend; + + onSourceChanged: { + if (source != null) { + source.setPaintEnabled(false); + vertexShader = source.yInverted ? vShaderInvertedY : vShader; + } + } + + Connections { + target: source; + onYInvertedChanged: { + print("onY " + source.yInverted); + vertexShader = source.yInverted ? vShaderInvertedY : vShader; + } + } + + property string vShader: " + 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; + } + " + property string vShaderInvertedY: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = vec2(0, 1) + qt_MultiTexCoord0 * vec2(1, -1); + gl_Position = qt_Matrix * qt_Vertex; + } + " + + fragmentShader: " + uniform sampler2D source; + uniform float qt_Opacity; + uniform vec4 color; + uniform float blend; + varying highp vec2 qt_TexCoord0; + void main() { + vec4 sourceColor = texture2D(source, qt_TexCoord0); + vec3 delta = sourceColor.rgb - vec3(0.5); + vec3 lowerContrast = vec3(0.5) + 0.4 * delta; + gl_FragColor = qt_Opacity * mix(sourceColor, color * sourceColor.a * dot(lowerContrast, vec3(11, 16, 5) * (1. / 32.)), blend); + } + " +} diff --git a/examples/qml-compositor/WindowChrome.qml b/examples/qml-compositor/WindowChrome.qml new file mode 100644 index 000000000..6fb2ebe4d --- /dev/null +++ b/examples/qml-compositor/WindowChrome.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: chrome + anchors.fill: parent + + property variant window: parent; + + MouseArea { + anchors.fill: parent + enabled: !window.focus + onClicked: { + window.takeFocus(); + } + } +} diff --git a/examples/qml-compositor/WindowContainer.qml b/examples/qml-compositor/WindowContainer.qml new file mode 100644 index 000000000..ae70e3b87 --- /dev/null +++ b/examples/qml-compositor/WindowContainer.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + x: -400; + y: 0; + opacity: 0 + + property variant child: null; + property variant chrome: null; + property bool animationsEnabled: false; + property int index; + + Behavior on x { + enabled: container.animationsEnabled; + NumberAnimation { easing.type: Easing.InCubic; duration: 200; } + } + + Behavior on y { + enabled: container.animationsEnabled; + NumberAnimation { easing.type: Easing.InQuad; duration: 200; } + } + + Behavior on scale { + enabled: container.animationsEnabled; + NumberAnimation { easing.type: Easing.InQuad; duration: 200; } + } + + Behavior on opacity { + enabled: true; + NumberAnimation { easing.type: Easing.Linear; duration: 250; } + } + + ContrastEffect { + id: effect + source: child + anchors.fill: child + blend: { if (child && child.focus) 0.0; else 0.6 } + opacity: 0.8 + z: 1 + + Behavior on blend { + enabled: true; + NumberAnimation { easing.type: Easing.Linear; duration: 200; } + } + } + + transform: [ + Rotation { origin.x: container.width / 2; origin.y: container.height / 2; angle: (child && child.surface ? child.surface.windowRotation : 0) }, + Scale { id: scaleTransform; origin.x: container.width / 2; origin.y: container.height / 2; xScale: 1; yScale: 1 } + ] + + SequentialAnimation { + id: destroyAnimation + NumberAnimation { target: scaleTransform; property: "yScale"; easing.type: Easing.Linear; to: 0.01; duration: 200; } + NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.Linear; to: 0.01; duration: 150; } + NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; } + ScriptAction { script: container.parent.removeWindow(child); } + } + + function runDestroyAnimation() { + destroyAnimation.start(); + } +} diff --git a/examples/qml-compositor/compositor.js b/examples/qml-compositor/compositor.js new file mode 100644 index 000000000..ba0f74e4e --- /dev/null +++ b/examples/qml-compositor/compositor.js @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var windowList = null; +var indexes = null; + +function relayout() { + if (windowList.length == 0) + return; + + var dim = Math.ceil(Math.sqrt(windowList.length)); + + var cols = dim; + var rows = Math.ceil(windowList.length / cols); + + var w = root.width / dim; + var h = root.height / rows; + + var i; + var ix = 0; + var iy = 0; + var lastDim = 1; + + indexes = new Array(dim * dim); + + for (i = 0; i < windowList.length; ++i) { + if (i > 0) { + var currentDim = Math.ceil(Math.sqrt(i + 1)); + if (currentDim == lastDim) { + if (iy < currentDim - 1) { + ++iy; + if (iy == currentDim - 1) + ix = 0; + } else { + ++ix; + } + } else { + iy = 0; + ix = currentDim - 1; + } + lastDim = currentDim; + } + + indexes[iy * dim + ix] = i; + windowList[i].index = iy * dim + ix; + + var cx = (ix + 0.5) * w; + var cy = (iy + 0.5) * h; + + windowList[i].scale = 0.98 * Math.min(w / windowList[i].width, h / windowList[i].height); + + windowList[i].x = (cx - windowList[i].width / 2); + windowList[i].y = (cy - windowList[i].height / 2); + } +} + +function addWindow(window) +{ + if (windowList == null) + windowList = new Array(0); + + windowList.push(window); + relayout(); +} + +function removeWindow(window) +{ + var i; + for (i = 0; i < windowList.length; ++i) { + if (windowList[i] == window) + break; + } + + var index = windowList[i].index; + var dim = Math.ceil(Math.sqrt(windowList.length)); + var maxY = Math.floor((windowList.length-1) / dim); + + var shrinking = Math.ceil(Math.sqrt(windowList.length - 1)) != dim; + + while (true) { + var ix = index % dim; + var iy = Math.floor(index / dim); + + if (shrinking) { + if (iy > 0) + --iy; + else if (++ix == dim) + break; + } else { + if (iy < maxY) { + if (ix > 0) + --ix; + else + ++iy; + } else { + ++ix; + } + } + + var next = iy * dim + ix; + + var currentIndex = indexes[index]; + var nextIndex = indexes[next]; + + if (nextIndex == null) + break; + + var temp = windowList[currentIndex]; + windowList[currentIndex] = windowList[nextIndex]; + windowList[currentIndex].index = currentIndex; + windowList[nextIndex] = temp; + + index = next; + } + + windowList.splice(indexes[index], 1); + relayout(); +} diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index 93175a487..9571c802e 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -60,7 +60,7 @@ public: : WaylandCompositor(this) { enableSubSurfaceExtension(); - setSource(QUrl(QLatin1String("qrc:qml/QmlCompositor/main.qml"))); + setSource(QUrl("main.qml")); setResizeMode(QQuickView::SizeRootObjectToView); winId(); diff --git a/examples/qml-compositor/main.qml b/examples/qml-compositor/main.qml new file mode 100644 index 000000000..bd859f04d --- /dev/null +++ b/examples/qml-compositor/main.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "compositor.js" as CompositorLogic + +Item { + id: root + + width: 1024 + height: 768 + + Image { + id: background + anchors.fill: parent + fillMode: Image.Tile + source: "background.jpg" + smooth: true + } + + function windowAdded(window) { + var windowContainerComponent = Qt.createComponent("WindowContainer.qml"); + var windowContainer = windowContainerComponent.createObject(root); + + window.parent = windowContainer; + + windowContainer.width = window.width; + windowContainer.height = window.height; + windowContainer.child = window; + + var windowChromeComponent = Qt.createComponent("WindowChrome.qml"); + var windowChrome = windowChromeComponent.createObject(window); + + CompositorLogic.addWindow(windowContainer); + + windowContainer.opacity = 1 + windowContainer.animationsEnabled = true; + windowContainer.chrome = windowChrome; + } + + function windowResized(window) { + var windowContainer = window.parent; + windowContainer.width = window.width; + windowContainer.height = window.height; + + CompositorLogic.relayout(); + } + + function windowDestroyed(window) { + var windowContainer = window.parent; + windowContainer.runDestroyAnimation(); + } + + function removeWindow(window) { + var windowContainer = window.parent; + CompositorLogic.removeWindow(windowContainer); + windowContainer.chrome.destroy(); + windowContainer.destroy(); + compositor.destroyWindow(window); + } + + onHeightChanged: CompositorLogic.relayout(); + onWidthChanged: CompositorLogic.relayout(); +} diff --git a/examples/qml-compositor/qml-compositor.pro b/examples/qml-compositor/qml-compositor.pro index 002cce1ea..866f54c81 100644 --- a/examples/qml-compositor/qml-compositor.pro +++ b/examples/qml-compositor/qml-compositor.pro @@ -5,7 +5,7 @@ CONFIG += use_pkgconfig LIBS += -L ../../lib -QT += quick qml v8 +QT += quick qml v8 QT += quick-private QT += compositor @@ -16,9 +16,10 @@ QT += compositor #include (../../src/compositor/compositor.pri) SOURCES += main.cpp -RESOURCES = qml-compositor.qrc + +OTHER_FILES = ContrastEffect.qml main.qml WindowChrome.qml WindowContainer.qml background.jpg compositor.js target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qml-compositor -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qml-compositor.pro +sources.files = $$OTHER_FILES $$SOURCES $$HEADERS $$RESOURCES $$FORMS qml-compositor.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qml-compositor INSTALLS += target sources diff --git a/examples/qml-compositor/qml-compositor.qrc b/examples/qml-compositor/qml-compositor.qrc deleted file mode 100644 index 0a3898fb2..000000000 --- a/examples/qml-compositor/qml-compositor.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - background.jpg - qml/QmlCompositor/main.qml - qml/QmlCompositor/compositor.js - qml/QmlCompositor/ContrastEffect.qml - qml/QmlCompositor/WindowChrome.qml - qml/QmlCompositor/WindowContainer.qml - - - diff --git a/examples/qml-compositor/qml/QmlCompositor/ContrastEffect.qml b/examples/qml-compositor/qml/QmlCompositor/ContrastEffect.qml deleted file mode 100644 index 332c9682d..000000000 --- a/examples/qml-compositor/qml/QmlCompositor/ContrastEffect.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ShaderEffect { - property variant source: null; - property color color: "#ffffff" - property real blend; - - onSourceChanged: { - if (source != null) { - source.setPaintEnabled(false); - vertexShader = source.isYInverted ? vShaderInvertedY : vShader; - } - } - - Connections { - target: source; - onYInvertedChanged: { - print("onY " + source.isYInverted); - vertexShader = source.isYInverted ? vShaderInvertedY : vShader; - } - } - - property string vShader: " - 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; - } - " - property string vShaderInvertedY: " - uniform highp mat4 qt_Matrix; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - varying highp vec2 qt_TexCoord0; - void main() { - qt_TexCoord0 = vec2(0, 1) + qt_MultiTexCoord0 * vec2(1, -1); - gl_Position = qt_Matrix * qt_Vertex; - } - " - - fragmentShader: " - uniform sampler2D source; - uniform float qt_Opacity; - uniform vec4 color; - uniform float blend; - varying highp vec2 qt_TexCoord0; - void main() { - vec4 sourceColor = texture2D(source, qt_TexCoord0); - vec3 delta = sourceColor.rgb - vec3(0.5); - vec3 lowerContrast = vec3(0.5) + 0.4 * delta; - gl_FragColor = qt_Opacity * mix(sourceColor, color * sourceColor.a * dot(lowerContrast, vec3(11, 16, 5) * (1. / 32.)), blend); - } - " -} diff --git a/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml b/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml deleted file mode 100644 index 6fb2ebe4d..000000000 --- a/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: chrome - anchors.fill: parent - - property variant window: parent; - - MouseArea { - anchors.fill: parent - enabled: !window.focus - onClicked: { - window.takeFocus(); - } - } -} diff --git a/examples/qml-compositor/qml/QmlCompositor/WindowContainer.qml b/examples/qml-compositor/qml/QmlCompositor/WindowContainer.qml deleted file mode 100644 index ae70e3b87..000000000 --- a/examples/qml-compositor/qml/QmlCompositor/WindowContainer.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - x: -400; - y: 0; - opacity: 0 - - property variant child: null; - property variant chrome: null; - property bool animationsEnabled: false; - property int index; - - Behavior on x { - enabled: container.animationsEnabled; - NumberAnimation { easing.type: Easing.InCubic; duration: 200; } - } - - Behavior on y { - enabled: container.animationsEnabled; - NumberAnimation { easing.type: Easing.InQuad; duration: 200; } - } - - Behavior on scale { - enabled: container.animationsEnabled; - NumberAnimation { easing.type: Easing.InQuad; duration: 200; } - } - - Behavior on opacity { - enabled: true; - NumberAnimation { easing.type: Easing.Linear; duration: 250; } - } - - ContrastEffect { - id: effect - source: child - anchors.fill: child - blend: { if (child && child.focus) 0.0; else 0.6 } - opacity: 0.8 - z: 1 - - Behavior on blend { - enabled: true; - NumberAnimation { easing.type: Easing.Linear; duration: 200; } - } - } - - transform: [ - Rotation { origin.x: container.width / 2; origin.y: container.height / 2; angle: (child && child.surface ? child.surface.windowRotation : 0) }, - Scale { id: scaleTransform; origin.x: container.width / 2; origin.y: container.height / 2; xScale: 1; yScale: 1 } - ] - - SequentialAnimation { - id: destroyAnimation - NumberAnimation { target: scaleTransform; property: "yScale"; easing.type: Easing.Linear; to: 0.01; duration: 200; } - NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.Linear; to: 0.01; duration: 150; } - NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; } - ScriptAction { script: container.parent.removeWindow(child); } - } - - function runDestroyAnimation() { - destroyAnimation.start(); - } -} diff --git a/examples/qml-compositor/qml/QmlCompositor/compositor.js b/examples/qml-compositor/qml/QmlCompositor/compositor.js deleted file mode 100644 index ba0f74e4e..000000000 --- a/examples/qml-compositor/qml/QmlCompositor/compositor.js +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -var windowList = null; -var indexes = null; - -function relayout() { - if (windowList.length == 0) - return; - - var dim = Math.ceil(Math.sqrt(windowList.length)); - - var cols = dim; - var rows = Math.ceil(windowList.length / cols); - - var w = root.width / dim; - var h = root.height / rows; - - var i; - var ix = 0; - var iy = 0; - var lastDim = 1; - - indexes = new Array(dim * dim); - - for (i = 0; i < windowList.length; ++i) { - if (i > 0) { - var currentDim = Math.ceil(Math.sqrt(i + 1)); - if (currentDim == lastDim) { - if (iy < currentDim - 1) { - ++iy; - if (iy == currentDim - 1) - ix = 0; - } else { - ++ix; - } - } else { - iy = 0; - ix = currentDim - 1; - } - lastDim = currentDim; - } - - indexes[iy * dim + ix] = i; - windowList[i].index = iy * dim + ix; - - var cx = (ix + 0.5) * w; - var cy = (iy + 0.5) * h; - - windowList[i].scale = 0.98 * Math.min(w / windowList[i].width, h / windowList[i].height); - - windowList[i].x = (cx - windowList[i].width / 2); - windowList[i].y = (cy - windowList[i].height / 2); - } -} - -function addWindow(window) -{ - if (windowList == null) - windowList = new Array(0); - - windowList.push(window); - relayout(); -} - -function removeWindow(window) -{ - var i; - for (i = 0; i < windowList.length; ++i) { - if (windowList[i] == window) - break; - } - - var index = windowList[i].index; - var dim = Math.ceil(Math.sqrt(windowList.length)); - var maxY = Math.floor((windowList.length-1) / dim); - - var shrinking = Math.ceil(Math.sqrt(windowList.length - 1)) != dim; - - while (true) { - var ix = index % dim; - var iy = Math.floor(index / dim); - - if (shrinking) { - if (iy > 0) - --iy; - else if (++ix == dim) - break; - } else { - if (iy < maxY) { - if (ix > 0) - --ix; - else - ++iy; - } else { - ++ix; - } - } - - var next = iy * dim + ix; - - var currentIndex = indexes[index]; - var nextIndex = indexes[next]; - - if (nextIndex == null) - break; - - var temp = windowList[currentIndex]; - windowList[currentIndex] = windowList[nextIndex]; - windowList[currentIndex].index = currentIndex; - windowList[nextIndex] = temp; - - index = next; - } - - windowList.splice(indexes[index], 1); - relayout(); -} diff --git a/examples/qml-compositor/qml/QmlCompositor/main.qml b/examples/qml-compositor/qml/QmlCompositor/main.qml deleted file mode 100644 index 65f610971..000000000 --- a/examples/qml-compositor/qml/QmlCompositor/main.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "compositor.js" as CompositorLogic - -Item { - id: root - - width: 1024 - height: 768 - - Image { - id: background - anchors.fill: parent - fillMode: Image.Tile - source: "../../background.jpg" - smooth: true - } - - function windowAdded(window) { - var windowContainerComponent = Qt.createComponent("WindowContainer.qml"); - var windowContainer = windowContainerComponent.createObject(root); - - window.parent = windowContainer; - - windowContainer.width = window.width; - windowContainer.height = window.height; - windowContainer.child = window; - - var windowChromeComponent = Qt.createComponent("WindowChrome.qml"); - var windowChrome = windowChromeComponent.createObject(window); - - CompositorLogic.addWindow(windowContainer); - - windowContainer.opacity = 1 - windowContainer.animationsEnabled = true; - windowContainer.chrome = windowChrome; - } - - function windowResized(window) { - var windowContainer = window.parent; - windowContainer.width = window.width; - windowContainer.height = window.height; - - CompositorLogic.relayout(); - } - - function windowDestroyed(window) { - var windowContainer = window.parent; - windowContainer.runDestroyAnimation(); - } - - function removeWindow(window) { - var windowContainer = window.parent; - CompositorLogic.removeWindow(windowContainer); - windowContainer.chrome.destroy(); - windowContainer.destroy(); - compositor.destroyWindow(window); - } - - onHeightChanged: CompositorLogic.relayout(); - onWidthChanged: CompositorLogic.relayout(); -} -- cgit v1.2.3