2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-03-07 07:57:56 +03:00
|
|
|
//
|
2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-01-17 06:05:02 +03:00
|
|
|
import QtGraphicalEffects 1.0
|
2022-01-02 08:22:27 +03:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2021-01-12 01:50:26 +03:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: ripple
|
|
|
|
|
|
|
|
property color color: "#22000000"
|
|
|
|
property real maxRadius: Math.max(width, height)
|
2021-03-14 18:24:04 +03:00
|
|
|
readonly property real radiusAnimationRate: 0.05
|
|
|
|
readonly property real radiusTailAnimationRate: 0.5
|
|
|
|
readonly property real opacityAnimationDuration: 300
|
2021-01-12 01:50:26 +03:00
|
|
|
property var rippleTarget: parent
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
PointHandler {
|
|
|
|
id: ph
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
onGrabChanged: {
|
|
|
|
circle.centerX = point.position.x
|
|
|
|
circle.centerY = point.position.y
|
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
target: Rectangle {
|
|
|
|
id: backgroundLayer
|
|
|
|
parent: rippleTarget
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
color: "transparent"
|
|
|
|
clip: true
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
Rectangle {
|
|
|
|
id: circle
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
property real centerX
|
|
|
|
property real centerY
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
x: centerX - radius
|
|
|
|
y: centerY - radius
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
height: radius*2
|
|
|
|
width: radius*2
|
|
|
|
radius: 0
|
|
|
|
color: ripple.color
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
state: ph.active ? "ACTIVE" : "NORMAL"
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "NORMAL"
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "ACTIVE"
|
2021-01-12 01:50:26 +03:00
|
|
|
}
|
2022-01-02 08:22:27 +03:00
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "NORMAL"
|
|
|
|
to: "ACTIVE"
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
SequentialAnimation {
|
|
|
|
//PropertyAction { target: circle; property: "centerX"; value: ph.point.position.x }
|
|
|
|
//PropertyAction { target: circle; property: "centerY"; value: ph.point.position.y }
|
|
|
|
PropertyAction { target: circle; property: "visible"; value: true }
|
|
|
|
PropertyAction { target: circle; property: "opacity"; value: 1 }
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
NumberAnimation {
|
|
|
|
id: radius_animation
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
target: circle
|
|
|
|
properties: "radius"
|
|
|
|
from: 0
|
|
|
|
to: ripple.maxRadius
|
|
|
|
duration: ripple.maxRadius / ripple.radiusAnimationRate
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
easing {
|
|
|
|
type: Easing.OutQuad
|
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "ACTIVE"
|
|
|
|
to: "NORMAL"
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
SequentialAnimation {
|
|
|
|
ParallelAnimation {
|
|
|
|
NumberAnimation {
|
|
|
|
id: radius_tail_animation
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
target: circle
|
|
|
|
properties: "radius"
|
|
|
|
to: ripple.maxRadius
|
|
|
|
duration: ripple.maxRadius / ripple.radiusTailAnimationRate
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
easing {
|
|
|
|
type: Easing.Linear
|
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
NumberAnimation {
|
|
|
|
id: opacity_animation
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 22:13:21 +03:00
|
|
|
target: circle
|
2022-01-02 08:22:27 +03:00
|
|
|
properties: "opacity"
|
|
|
|
to: 0
|
|
|
|
duration: ripple.opacityAnimationDuration
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
easing {
|
|
|
|
type: Easing.InQuad
|
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
|
2022-01-02 08:22:27 +03:00
|
|
|
}
|
|
|
|
PropertyAction { target: circle; property: "visible"; value: false }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-01-12 01:50:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|