1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/ScreenPlayWorkshop/qml/Background.qml

224 lines
4.8 KiB
QML
Raw Normal View History

import QtQuick
2021-07-15 12:07:39 +02:00
import Qt5Compat.GraphicalEffects
2020-08-20 17:21:09 +02:00
Rectangle {
id: root
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
property string backgroundImage: ""
property int imageOffsetTop: 0
property int stackViewDepth: 0
onStackViewDepthChanged: {
if (stackViewDepth > 1) {
root.state = "backgroundBlur"
return true
}
root.state = "backgroundImage"
return false
}
2021-05-16 19:37:55 +02:00
color: "#161C1D"
onImageOffsetTopChanged: {
if ((imageOffsetTop * -1) >= 200) {
root.state = "backgroundColor"
2020-08-20 17:21:09 +02:00
} else {
2021-05-16 19:37:55 +02:00
if (root.state !== "backgroundImage")
root.state = "backgroundImage"
2020-08-20 17:21:09 +02:00
}
}
2020-08-20 17:21:09 +02:00
onBackgroundImageChanged: {
2021-05-16 19:37:55 +02:00
if (backgroundImage === "")
root.state = ""
2021-05-16 19:37:55 +02:00
else
root.state = "backgroundImage"
2020-08-20 17:21:09 +02:00
}
Image {
id: maskSource
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
visible: false
source: "qrc:/ScreenPlayWorkshop/assets/images/mask_workshop.png"
2020-08-20 17:21:09 +02:00
}
Image {
id: bgImage
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
height: bgImage.sourceSize.height
2021-07-15 12:07:39 +02:00
//fillMode: Image.PreserveAspectCrop
2021-05-16 19:37:55 +02:00
opacity: 0
source: root.backgroundImage
2020-08-20 17:21:09 +02:00
anchors {
topMargin: root.imageOffsetTop
top: parent.top
right: parent.right
left: parent.left
}
LinearGradient {
id: gradient
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.fill: parent
z: 4
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
gradient: Gradient {
GradientStop {
2021-05-16 19:37:55 +02:00
position: 0
2020-08-20 17:21:09 +02:00
color: "#00ffffff"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
GradientStop {
position: 0.6
color: "#00ffffff"
}
2021-05-16 19:37:55 +02:00
GradientStop {
position: 1
2020-08-20 17:21:09 +02:00
color: "#161C1D"
}
}
}
}
2021-07-15 12:07:39 +02:00
FastBlur {
id: blur
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.fill: bgImage
source: bgImage
radius: 16
cached: true
opacity: 0
2020-08-20 17:21:09 +02:00
}
Rectangle {
id: bgColor
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
color: "#161C1D"
opacity: 0
anchors.fill: parent
}
states: [
State {
name: ""
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: bgImage
opacity: 0
}
PropertyChanges {
target: bgColor
opacity: 0
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: blur
opacity: 0
}
},
State {
name: "backgroundImage"
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: bgImage
opacity: 1
}
PropertyChanges {
target: bgColor
opacity: 0
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: blur
opacity: 0
radius: 16
2020-08-20 17:21:09 +02:00
}
},
State {
name: "backgroundColor"
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: bgImage
opacity: 1
2020-08-20 17:21:09 +02:00
}
PropertyChanges {
target: bgColor
opacity: 0.8
2020-08-20 17:21:09 +02:00
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: blur
opacity: 1
radius: 16
}
},
State {
name: "backgroundBlur"
PropertyChanges {
target: bgImage
opacity: 1
}
PropertyChanges {
target: bgColor
opacity: 0.85
2020-08-20 17:21:09 +02:00
}
2021-05-16 19:37:55 +02:00
PropertyChanges {
target: blur
opacity: 1
radius: 64
}
2020-08-20 17:21:09 +02:00
}
]
transitions: [
Transition {
from: ""
2020-08-20 17:21:09 +02:00
to: "backgroundImage"
reversible: true
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
targets: [bgImage, bgColor, blur]
duration: 500
2020-08-20 17:21:09 +02:00
easing.type: Easing.InOutQuart
property: "opacity"
}
},
Transition {
from: "backgroundImage"
to: "backgroundColor"
reversible: true
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
targets: [bgImage, bgColor, blur]
duration: 200
2020-08-20 17:21:09 +02:00
easing.type: Easing.InOutQuart
property: "opacity"
}
},
Transition {
from: "backgroundImage"
to: "backgroundBlur"
reversible: true
2021-05-16 19:37:55 +02:00
PropertyAnimation {
targets: [bgImage, bgColor, blur]
duration: 300
easing.type: Easing.InOutQuart
property: "opacity"
}
PropertyAnimation {
target: blur
duration: 300
easing.type: Easing.InOutQuart
property: "radius"
}
2020-08-20 17:21:09 +02:00
}
]
}