9 import QtQuick.Controls 2.4 as QQC2
10 import org.kde.kirigami 2.13 as Kirigami
27 property Item destination
35 property bool restore:
true
53 readonly
property QtObject mask: QtObject {
58 readonly
property real sourceProgress: sourceEffect.progress
64 readonly
property real destinationProgress: destinationEffect.progress
69 readonly
property real sourceHeight: sourceEffect.height
74 readonly
property real sourceWidth: sourceEffect.width
79 readonly
property real destinationWidth: destinationEffect.width
84 readonly
property real destinationHeight: destinationEffect.height
91 property Item item: Rectangle {
95 radius: (width/2) * mask.destinationProgress
96 width: (mask.sourceWidth * mask.sourceProgress) + (mask.destinationWidth * mask.destinationProgress)
97 height: (mask.sourceHeight * mask.sourceProgress) + (mask.destinationHeight * mask.destinationProgress)
104 property alias duration: sourceAni.duration
105 readonly
property QtObject easing: QtObject {
106 property alias amplitude: sourceAni.easing.amplitude
107 property alias bezierCurve: sourceAni.easing.bezierCurve
108 property alias overshoot: sourceAni.easing.overshoot
109 property alias period: sourceAni.easing.period
110 property alias type: sourceAni.easing.type
115 if (source !==
null && destination !==
null && !heroAnimation.running) {
116 heroAnimation.source = source
117 heroAnimation.destination = destination
118 heroAnimation.restart()
122 if (source !==
null && destination !==
null && !heroAnimation.running) {
124 heroAnimation.source = destination
125 heroAnimation.destination = source
126 heroAnimation.restart()
130 SequentialAnimation {
133 property Item source: Item {}
134 property Item destination: Item {}
138 heroAnimation.source.layer.enabled =
true
139 heroAnimation.source.layer.smooth =
true
140 heroAnimation.destination.layer.enabled =
true
141 heroAnimation.destination.layer.smooth =
true
142 sourceEffect.visible =
true
143 destinationEffect.visible =
true
144 sourceEffect.source =
null
145 sourceEffect.source = heroAnimation.source
146 destinationEffect.source =
null
147 destinationEffect.source = heroAnimation.destination
148 heroAnimation.source.opacity = 0
149 heroAnimation.destination.opacity = 0
150 sourceEffect.parent.visible =
true
161 duration: Kirigami.Units.longDuration
162 easing.type: Easing.InOutQuad
165 target: destinationEffect
169 duration: root.duration
170 easing.amplitude: root.easing.amplitude
171 easing.bezierCurve: root.easing.bezierCurve
172 easing.overshoot: root.easing.overshoot
173 easing.period: root.easing.period
174 easing.type: root.easing.type
179 sourceEffect.visible =
false
180 destinationEffect.visible =
false
181 heroAnimation.source.layer.enabled =
false
182 heroAnimation.source.layer.smooth =
false
183 heroAnimation.destination.layer.enabled =
false
184 heroAnimation.destination.layer.smooth =
false
185 heroAnimation.destination.opacity = 1
187 heroAnimation.source.opacity = 1
189 sourceEffect.parent.visible =
false
196 id: __privateShaderSources
197 readonly
property string vertexShader: `
198 uniform highp mat4 qt_Matrix;
199 attribute highp vec4 qt_Vertex;
200 attribute highp vec2 qt_MultiTexCoord0;
201 varying highp vec2 qt_TexCoord0;
202 uniform highp
float startX;
203 uniform highp
float startY;
204 uniform highp
float targetX;
205 uniform highp
float targetY;
206 uniform highp
float scaleWidth;
207 uniform highp
float scaleHeight;
208 uniform highp
float progress;
210 highp mat4 morph = mat4(1.0 + (scaleWidth - 1.0) * progress, 0.0, 0.0, startX*(1.0-progress) + targetX*progress,
211 0.0, 1.0 + (scaleHeight - 1.0) * progress, 0.0, startY*(1.0-progress) + targetY*progress,
216 qt_TexCoord0 = qt_MultiTexCoord0;
217 gl_Position = qt_Matrix * qt_Vertex * morph;
226 parent: heroAnimation.source.QQC2.Overlay.overlay
227 width: heroAnimation.source.width
228 height: heroAnimation.source.height
230 property variant source: heroAnimation.source
231 property real progress: 0
232 property real startX: heroAnimation.source.Kirigami.ScenePosition.x / (applicationWindow().width / 2)
233 property real startY: -heroAnimation.source.Kirigami.ScenePosition.y / (applicationWindow().height / 2)
235 property real targetX: scaleWidth - 1 + (heroAnimation.destination.Kirigami.ScenePosition.x * 2) / applicationWindow().width
236 property real targetY: 1-scaleHeight - (heroAnimation.destination.Kirigami.ScenePosition.y * 2) / applicationWindow().height
237 property real scaleWidth: heroAnimation.destination.width/heroAnimation.source.width
238 property real scaleHeight: heroAnimation.destination.height/heroAnimation.source.height
239 vertexShader: __privateShaderSources.vertexShader
241 varying highp vec2 qt_TexCoord0;
242 uniform sampler2D source;
243 uniform lowp
float qt_Opacity;
244 uniform lowp
float progress;
246 gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity * (1.0 - progress);
252 id: destinationEffect
255 parent: heroAnimation.destination.QQC2.Overlay.overlay
256 width: heroAnimation.destination.width
257 height: heroAnimation.destination.height
259 property variant source: heroAnimation.destination
260 property real progress: sourceEffect.progress
261 property real startX: heroAnimation.destination.Kirigami.ScenePosition.x / (applicationWindow().width / 2)
262 property real startY: -heroAnimation.destination.Kirigami.ScenePosition.y / (applicationWindow().height / 2)
264 property real targetX: scaleWidth - 1 + (heroAnimation.source.Kirigami.ScenePosition.x * 2) / applicationWindow().width
265 property real targetY: 1-scaleHeight - (heroAnimation.source.Kirigami.ScenePosition.y * 2) / applicationWindow().height
266 property real scaleWidth: heroAnimation.source.width/heroAnimation.destination.width
267 property real scaleHeight: heroAnimation.source.height/heroAnimation.destination.height
269 property variant maskSource: root.mask.item
271 vertexShader: __privateShaderSources.vertexShader
273 varying highp vec2 qt_TexCoord0;
274 uniform sampler2D source;
275 uniform sampler2D maskSource;
276 uniform lowp
float qt_Opacity;
277 uniform lowp
float progress;
279 gl_FragColor = texture2D(source, qt_TexCoord0) * texture2D(maskSource, qt_TexCoord0).a * qt_Opacity * (1.0 - progress);