From 603b797d745c4129f5d2a151c9146358e36eb668 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 31 Mar 2010 11:16:22 +1000 Subject: Declarative examples cleanup. --- .../declarative/animations/property-animation.qml | 4 +- examples/declarative/behaviors/SideRect.qml | 16 +++++ .../declarative/behaviors/behavior-example.qml | 79 ++++++++++++++++++++++ examples/declarative/behaviours/SideRect.qml | 17 ----- .../declarative/behaviours/behavior-example.qml | 72 -------------------- 5 files changed, 97 insertions(+), 91 deletions(-) create mode 100644 examples/declarative/behaviors/SideRect.qml create mode 100644 examples/declarative/behaviors/behavior-example.qml delete mode 100644 examples/declarative/behaviours/SideRect.qml delete mode 100644 examples/declarative/behaviours/behavior-example.qml diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml index 401feb5..fd5eb3c 100644 --- a/examples/declarative/animations/property-animation.qml +++ b/examples/declarative/animations/property-animation.qml @@ -40,7 +40,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter source: "images/face-smile.png"; y: minHeight - // Animate the y property. Setting repeat to true makes the + // Animate the y property. Setting loops to Animation.Infinite makes the // animation repeat indefinitely, otherwise it would only run once. SequentialAnimation on y { loops: Animation.Infinite @@ -50,7 +50,7 @@ Item { from: smiley.minHeight; to: smiley.maxHeight easing.type: "OutExpo"; duration: 300 } - + // Then move back to minHeight in 1 second, using the OutBounce easing function NumberAnimation { from: smiley.maxHeight; to: smiley.minHeight diff --git a/examples/declarative/behaviors/SideRect.qml b/examples/declarative/behaviors/SideRect.qml new file mode 100644 index 0000000..7caac45 --- /dev/null +++ b/examples/declarative/behaviors/SideRect.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50; radius: 6 + color: "#646464"; border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { focusRect.x = myRect.x; focusRect.y = myRect.y; focusRect.text = myRect.text } + } +} diff --git a/examples/declarative/behaviors/behavior-example.qml b/examples/declarative/behaviors/behavior-example.qml new file mode 100644 index 0000000..8da1ada --- /dev/null +++ b/examples/declarative/behaviors/behavior-example.qml @@ -0,0 +1,79 @@ +import Qt 4.6 + +Rectangle { + color: "#343434" + width: 600; height: 400 + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200; radius: 30 + color: "transparent"; border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.left + text: "Left" + } + + SideRect { + id: rightRect + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.right + text: "Right" + } + + SideRect { + id: topRect + anchors.verticalCenter: parent.top + anchors.horizontalCenter: parent.horizontalCenter + text: "Top" + } + + SideRect { + id: bottomRect + anchors.verticalCenter: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + color: "firebrick" + x: 62.5; y: 75; width: 75; height: 50 + radius: 6; border.width: 4; border.color: "white" + + // Setting an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: "OutElastic"; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Setting an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: "OutElastic"; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white"; font.pixelSize: 16; font.bold: true + + // Setting a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + PropertyAction { } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/declarative/behaviours/SideRect.qml b/examples/declarative/behaviours/SideRect.qml deleted file mode 100644 index 63b7db2..0000000 --- a/examples/declarative/behaviours/SideRect.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: myRect - - property string text - - color: "black" - width: 75; height: 50 - radius: 5 - border.width: 10; border.color: "white"; - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { focusRect.x = myRect.x; focusRect.y = myRect.y; focusRect.text = myRect.text } - } -} diff --git a/examples/declarative/behaviours/behavior-example.qml b/examples/declarative/behaviours/behavior-example.qml deleted file mode 100644 index c84bf62..0000000 --- a/examples/declarative/behaviours/behavior-example.qml +++ /dev/null @@ -1,72 +0,0 @@ -import Qt 4.6 - -Rectangle { - color: "black" - width: 400; height: 400 - - Rectangle { - color: "transparent" - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - border.width: 10; border.color: "white"; - - SideRect { - id: leftRect - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.left - text: "Left" - } - - SideRect { - id: rightRect - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.right - text: "Right" - } - - SideRect { - id: topRect - anchors.verticalCenter: parent.top - anchors.horizontalCenter: parent.horizontalCenter - text: "Top" - } - - SideRect { - id: bottomRect - anchors.verticalCenter: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - color: "red" - width: 75; height: 50 - radius: 5 - border.width: 10; border.color: "white"; - x: 100-37; y: 100-25 - Behavior on x { NumberAnimation { duration: 300 } } - Behavior on y { NumberAnimation { duration: 300 } } - Text { - id: focusText - text: focusRect.text; - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - PropertyAction {} - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - anchors.centerIn: parent; - color: "white"; - font.pixelSize: 16 - font.bold: true - } - } - } -} -- cgit v0.12