From 234f96a92b8f7de0b06d9711ce7f47dfb1d8dda6 Mon Sep 17 00:00:00 2001 From: Kevin Wright Date: Thu, 24 Nov 2011 18:00:38 +0100 Subject: Split behavior and wigglytext examples --- doc/src/declarative/examples.qdoc | 1 + doc/src/examples/qml-examples.qdoc | 9 ++ .../behavior-example/qml/behaviours/wigglytext.qml | 108 --------------------- .../animation/behaviors/wigglytext/main.cpp | 54 +++++++++++ .../wigglytext/qml/wigglytext/wigglytext.qml | 108 +++++++++++++++++++++ .../animation/behaviors/wigglytext/wigglytext.png | Bin 0 -> 3400 bytes .../animation/behaviors/wigglytext/wigglytext.pro | 41 ++++++++ .../behaviors/wigglytext/wigglytext.qmlproject | 16 +++ .../animation/behaviors/wigglytext/wigglytext.svg | 93 ++++++++++++++++++ 9 files changed, 322 insertions(+), 108 deletions(-) delete mode 100644 examples/declarative/animation/behaviors/behavior-example/qml/behaviours/wigglytext.qml create mode 100644 examples/declarative/animation/behaviors/wigglytext/main.cpp create mode 100644 examples/declarative/animation/behaviors/wigglytext/qml/wigglytext/wigglytext.qml create mode 100644 examples/declarative/animation/behaviors/wigglytext/wigglytext.png create mode 100644 examples/declarative/animation/behaviors/wigglytext/wigglytext.pro create mode 100644 examples/declarative/animation/behaviors/wigglytext/wigglytext.qmlproject create mode 100644 examples/declarative/animation/behaviors/wigglytext/wigglytext.svg diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index e0ace56..8685809 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -121,6 +121,7 @@ The examples can be found in Qt's \c examples/declarative directory. \o \l{declarative/animation/easing}{Easing} \o \l{declarative/animation/basics/property-animation}{Property Animation} \o \l{declarative/animation/states}{States} +\o \l{declarative/animation/wigglytext/wigglytext}{Wiggly Text} \endlist \section2 Image Elements diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index f83a8fa..f8c59f3 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -66,6 +66,15 @@ */ /*! + \title Animation: Wiggly Text Example + \example declarative/animation/behaviors/wigglytext + \depends helper/qmlapplicationviewer + + \brief This example shows how to animate text. + +*/ + +/*! \title Animation: Easing Example \example declarative/animation/easing \depends helper/qmlapplicationviewer diff --git a/examples/declarative/animation/behaviors/behavior-example/qml/behaviours/wigglytext.qml b/examples/declarative/animation/behaviors/behavior-example/qml/behaviours/wigglytext.qml deleted file mode 100644 index 6cd93ab..0000000 --- a/examples/declarative/animation/behaviors/behavior-example/qml/behaviours/wigglytext.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 1.0 - -Rectangle { - id: container - - property string text: "Drag this text..." - property bool animated: true - - width: 640; height: 480; color: "#474747"; focus: true - - Keys.onPressed: { - if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) - container.remove() - else if (event.text != "") { - container.append(event.text) - } - } - - function append(text) { - container.animated = false - var lastLetter = container.children[container.children.length - 1] - var newLetter = letterComponent.createObject(container) - newLetter.text = text - newLetter.follow = lastLetter - container.animated = true - } - - function remove() { - if (container.children.length) - container.children[container.children.length - 1].destroy() - } - - function doLayout() { - var follow = null - for (var i = 0; i < container.text.length; ++i) { - var newLetter = letterComponent.createObject(container) - newLetter.text = container.text[i] - newLetter.follow = follow - follow = newLetter - } - } - - Component { - id: letterComponent - Text { - id: letter - property variant follow - - x: follow ? follow.x + follow.width : container.width / 3 - y: follow ? follow.y : container.height / 2 - - font.pixelSize: 40; font.bold: true - color: "#999999"; styleColor: "#222222"; style: Text.Raised - - MouseArea { - anchors.fill: parent - drag.target: letter; drag.axis: Drag.XandYAxis - onPressed: letter.color = "#dddddd" - onReleased: letter.color = "#999999" - } - - Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - } - } - - Component.onCompleted: doLayout() -} diff --git a/examples/declarative/animation/behaviors/wigglytext/main.cpp b/examples/declarative/animation/behaviors/wigglytext/main.cpp new file mode 100644 index 0000000..3407156 --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module 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$ +** +****************************************************************************/ + +#include +#include "qmlapplicationviewer.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/behaviours/behavior-example.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/animation/behaviors/wigglytext/qml/wigglytext/wigglytext.qml b/examples/declarative/animation/behaviors/wigglytext/qml/wigglytext/wigglytext.qml new file mode 100644 index 0000000..6cd93ab --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext/qml/wigglytext/wigglytext.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 1.0 + +Rectangle { + id: container + + property string text: "Drag this text..." + property bool animated: true + + width: 640; height: 480; color: "#474747"; focus: true + + Keys.onPressed: { + if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) + container.remove() + else if (event.text != "") { + container.append(event.text) + } + } + + function append(text) { + container.animated = false + var lastLetter = container.children[container.children.length - 1] + var newLetter = letterComponent.createObject(container) + newLetter.text = text + newLetter.follow = lastLetter + container.animated = true + } + + function remove() { + if (container.children.length) + container.children[container.children.length - 1].destroy() + } + + function doLayout() { + var follow = null + for (var i = 0; i < container.text.length; ++i) { + var newLetter = letterComponent.createObject(container) + newLetter.text = container.text[i] + newLetter.follow = follow + follow = newLetter + } + } + + Component { + id: letterComponent + Text { + id: letter + property variant follow + + x: follow ? follow.x + follow.width : container.width / 3 + y: follow ? follow.y : container.height / 2 + + font.pixelSize: 40; font.bold: true + color: "#999999"; styleColor: "#222222"; style: Text.Raised + + MouseArea { + anchors.fill: parent + drag.target: letter; drag.axis: Drag.XandYAxis + onPressed: letter.color = "#dddddd" + onReleased: letter.color = "#999999" + } + + Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + } + } + + Component.onCompleted: doLayout() +} diff --git a/examples/declarative/animation/behaviors/wigglytext/wigglytext.png b/examples/declarative/animation/behaviors/wigglytext/wigglytext.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/animation/behaviors/wigglytext/wigglytext.png differ diff --git a/examples/declarative/animation/behaviors/wigglytext/wigglytext.pro b/examples/declarative/animation/behaviors/wigglytext/wigglytext.pro new file mode 100644 index 0000000..3ad345f --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext/wigglytext.pro @@ -0,0 +1,41 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/wigglytext +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +# Avoid auto screen rotation +#DEFINES += ORIENTATIONLOCK + +# Needs to be defined for Symbian +#DEFINES += NETWORKACCESS + +symbian:TARGET.UID3 = 0xEB6022A4 + +# Smart Installer package's UID +# This UID is from the protected range +# and therefore the package will fail to install if self-signed +# By default qmake uses the unprotected range value if unprotected UID is defined for the application +# and 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Define QMLJSDEBUGGER to allow debugging of QML in debug builds +# (This might significantly increase build time) +# DEFINES += QMLJSDEBUGGER + +# If your application uses the Qt Mobility libraries, uncomment +# the following lines and add the respective components to the +# MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +desktopInstallPrefix=$$[QT_INSTALL_EXAMPLES]/declarative/animation/wigglytext/wigglytext +exists(qmlapplicationviewer/qmlapplicationviewer.pri):include(qmlapplicationviewer/qmlapplicationviewer.pri) +else:include(../../../../helper/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/animation/behaviors/wigglytext/wigglytext.qmlproject b/examples/declarative/animation/behaviors/wigglytext/wigglytext.qmlproject new file mode 100644 index 0000000..d38084f --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext/wigglytext.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "qml/wigglytext" + } + JavaScriptFiles { + directory: "qml/wigglytext" + } + ImageFiles { + directory: "qml/wigglytext" + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/behaviors/wigglytext/wigglytext.svg b/examples/declarative/animation/behaviors/wigglytext/wigglytext.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/animation/behaviors/wigglytext/wigglytext.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + -- cgit v0.12