diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-05-13 14:49:40 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-05-13 14:49:40 +0200 |
commit | b49ccd8365842b0ca57bdb48cab39194afdab6ce (patch) | |
tree | 1653b2dfcf896afb73b4b8f9027058b365db0557 | |
parent | b54f8679745b87cfbacf0ac66becfbfeb730e3cc (diff) |
Simple custom transition
-rw-r--r-- | examples/customtransition/DissolvingPresentation.qml | 110 | ||||
-rw-r--r-- | examples/customtransition/OpacityTransitionPresentation.qml | 63 | ||||
-rw-r--r-- | examples/customtransition/SlideDeck.qml (renamed from examples/customtransition/Slides.qml) | 0 | ||||
-rw-r--r-- | examples/customtransition/distortion.png | bin | 39828 -> 0 bytes |
4 files changed, 63 insertions, 110 deletions
diff --git a/examples/customtransition/DissolvingPresentation.qml b/examples/customtransition/DissolvingPresentation.qml deleted file mode 100644 index 98039ab..0000000 --- a/examples/customtransition/DissolvingPresentation.qml +++ /dev/null @@ -1,110 +0,0 @@ -import QtQuick 2.0 -import Prezo 1.0 - -Presentation { - - id: deck - - width: 600 - height: 400 - - property color textColor: "white" - - property bool inTransition: false; - - property variant fromSlide; - property variant toSlide; - - property int transitionTime: 500; - - Rectangle { - anchors.fill: parent - gradient: Gradient { - GradientStop { position: 0; color: "steelblue" } - GradientStop { position: 1; color: "black" } - } - } - - Image { - id: maskImage - source: "distortion.png" - visible: false - smooth: true - } - - ShaderEffectItem { - id: effect - - anchors.fill: parent - - property variant source: ShaderEffectSource { sourceItem: fromSlide; smooth: true } - property variant mask: maskImage - - property variant maskFactor; - - property real ratio: 0 - property real seed: 15 - - fragmentShader: " - varying highp vec2 qt_TexCoord0; - uniform mediump sampler2D source; - uniform mediump sampler2D mask; - uniform lowp float qt_Opacity; - uniform lowp float ratio; - uniform lowp vec3 maskFactor; - void main() { - lowp vec3 distVec = texture2D(mask, qt_TexCoord0).xyz; - lowp float p = dot(maskFactor, distVec); - mediump vec2 sampleOffset = distVec.xy; - gl_FragColor = texture2D(source, qt_TexCoord0 + ratio * sampleOffset * 0.2) * (1. - ratio * p * 4.) * (1. - ratio); - } - " - - onVisibleChanged: { - effect.seed = Math.random() * Math.PI * 2; - var x = Math.random(); - var y = Math.random(); - var z = Math.random(); - var l = Math.sqrt(x * x + y * y + z * z); - maskFactor = Qt.vector3d(x / l, y / l, z / l); - } - - visible: inTransition - } - - SequentialAnimation { - id: transition - ScriptAction { script: { - deck.inTransition = true - fromSlide.opacity = 0 - toSlide.visible = true - } - } - - ParallelAnimation { - NumberAnimation { target: effect; property: "ratio"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InSine } - NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InSine } - } - - ScriptAction { script: { - deck.inTransition = false - fromSlide.visible = false - fromSlide.opacity = 0 - toSlide.opacity = 1 - } - } - } - - function switchSlides(from, to) - { - if (deck.inTransition) - return false - - deck.fromSlide = from - deck.toSlide = to - - transition.running = true; - - return true - } -} diff --git a/examples/customtransition/OpacityTransitionPresentation.qml b/examples/customtransition/OpacityTransitionPresentation.qml new file mode 100644 index 0000000..40032d4 --- /dev/null +++ b/examples/customtransition/OpacityTransitionPresentation.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 +import Prezo 1.0 + +Presentation { + + id: deck + + width: 600 + height: 400 + + property color textColor: "white" + + property bool inTransition: false; + + property variant fromSlide; + property variant toSlide; + + property int transitionTime: 500; + + Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0; color: "lightsteelblue" } + GradientStop { position: 1; color: "black" } + } + } + + SequentialAnimation { + id: transition + ScriptAction { script: { + deck.inTransition = true + fromSlide.opacity = 0 + toSlide.visible = true + } + } + + ParallelAnimation { + NumberAnimation { target: fromSlide; property: "opacity"; from: 1; to: 0; duration: deck.transitionTime; easing.type: Easing.OutQuart } + NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InQuart } + } + + ScriptAction { script: { + deck.inTransition = false + fromSlide.visible = false + fromSlide.opacity = 0 + toSlide.opacity = 1 + } + } + } + + function switchSlides(from, to) + { + if (deck.inTransition) + return false + + deck.fromSlide = from + deck.toSlide = to + + transition.running = true; + + return true + } +} diff --git a/examples/customtransition/Slides.qml b/examples/customtransition/SlideDeck.qml index 848dc29..848dc29 100644 --- a/examples/customtransition/Slides.qml +++ b/examples/customtransition/SlideDeck.qml diff --git a/examples/customtransition/distortion.png b/examples/customtransition/distortion.png Binary files differdeleted file mode 100644 index 02a1b69..0000000 --- a/examples/customtransition/distortion.png +++ /dev/null |