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
5pragma ComponentBehavior: Bound
6
7import QtQuick
8import QtQuick.Effects
9
17Item {
18 id: wave
19 Accessible.ignored: true
20
24 property bool open: false
25
29 property real size: 0
30
34 property real initialX
35
39 property real initialY
40
44 property real abstractWidth: parent.width
45
49 property real abstractHeight: parent.height
50
54 property real diameter: 2 * Math.sqrt(Math.pow(Math.max(initialX, abstractWidth - initialX), 2) + Math.pow(Math.max(initialY, abstractHeight - initialY), 2))
55
60 signal finished(bool open)
61
65 function openWave(x, y) {
66 wave.initialX = x || parent.width / 2;
67 wave.initialY = y || parent.height / 2;
68 wave.open = true;
69 }
70
74 function closeWave(x, y) {
75 wave.initialX = x || parent.width / 2;
76 wave.initialY = y || parent.height / 2;
77 wave.open = false;
78 }
79
80 visible: open
81 layer.enabled: true
82 layer.effect: MultiEffect {
83 maskEnabled: true
84 maskSource: ShaderEffectSource {
85 sourceItem: Item {
86 width: wave.width
87 height: wave.height
88 Rectangle {
89 x: wave.initialX - wave.size / 2
90 y: wave.initialY - wave.size / 2
91 width: wave.size
92 height: wave.size
93 radius: wave.size / 2
94 }
95 }
96 }
97 }
98
99 states: State {
100 name: "open"
101 when: wave.open
102
103 PropertyChanges {
104 wave.size: wave.diameter
105 }
106 }
107
108 transitions: Transition {
109 from: ""
110 to: "open"
111 reversible: true
112
113 SequentialAnimation {
114 ScriptAction {
115 script: wave.visible = wave.open
116 }
117 NumberAnimation {
118 property: "size"
119 easing.type: Easing.OutCubic
120 }
121 ScriptAction {
122 script: wave.finished(wave.open)
123 }
124 }
125 }
126}