Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
Wave.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2018 Michael Spencer <sonrisesoftware@gmail.com>
2// SPDX-FileCopyrightText: 2014 Bogdan Cuza <bogdan.cuza@hotmail.com>
3// SPDX-License-Identifier: MPL-2.0
4
5import QtQuick
6import Qt5Compat.GraphicalEffects
7
15Item {
16 id: wave
17 Accessible.ignored: true
18
22 property bool open: false
23
27 property real size: 0
28
32 property real initialX
33
37 property real initialY
38
42 property real abstractWidth: parent.width
43
47 property real abstractHeight: parent.height
48
52 property real diameter: 2 * Math.sqrt(Math.pow(Math.max(initialX, abstractWidth - initialX), 2) + Math.pow(Math.max(initialY, abstractHeight - initialY), 2))
53
58 signal finished(bool open)
59
63 function openWave(x, y) {
64 wave.initialX = x || parent.width / 2;
65 wave.initialY = y || parent.height / 2;
66 wave.open = true;
67 }
68
72 function closeWave(x, y) {
73 wave.initialX = x || parent.width / 2;
74 wave.initialY = y || parent.height / 2;
75 wave.open = false;
76 }
77
78 visible: open
79 layer.enabled: true
80 layer.effect: OpacityMask {
81 maskSource: Item {
82 width: wave.width
83 height: wave.height
84 Rectangle {
85 x: initialX - size / 2
86 y: initialY - size / 2
87 width: size
88 height: size
89 radius: size / 2
90 }
91 }
92 }
93
94 states: State {
95 name: "open"
96 when: wave.open
97
98 PropertyChanges {
99 target: wave
100 size: wave.diameter
101 }
102 }
103
104 transitions: Transition {
105 from: ""
106 to: "open"
107 reversible: true
108
109 SequentialAnimation {
110 ScriptAction {
111 script: wave.visible = wave.open
112 }
113 NumberAnimation {
114 property: "size"
115 easing.type: Easing.OutCubic
116 }
117 ScriptAction {
118 script: wave.finished(wave.open)
119 }
120 }
121 }
122}