2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 1.1
19 import QtGraphicalEffects 1.0
25 height: childrenRect.height
27 signal leftTriggered()
28 signal rightTriggered()
30 property string leftIconName
31 property string rightIconName
32 readonly property double sliderHeight: units.gu(6)
33 readonly property double gap: units.gu(1)
34 readonly property double halfWay: mouseArea.drag.maximumX / 2
38 width: parent.width * 5
43 start: Qt.point(parent.x, parent.y)
44 end: Qt.point(parent.width, parent.y)
46 GradientStop { position: 0.0; color: UbuntuColors.red }
47 GradientStop { position: 0.2; color: UbuntuColors.red }
48 GradientStop { position: 0.4; color: "#dddddd" }
49 GradientStop { position: 0.6; color: "#dddddd" }
50 GradientStop { position: 0.8; color: UbuntuColors.green }
51 GradientStop { position: 1.0; color: UbuntuColors.green }
57 id: effectSourceGradient
60 height: gradient.height
61 sourceRect: Qt.rect(0.4 * gradient.width * (slider.x / halfWay), 0, mask.width, mask.height)
87 property variant mask: effectSourceMask
88 property variant gradient: effectSourceGradient
90 uniform highp mat4 qt_Matrix;
91 attribute highp vec4 qt_Vertex;
92 attribute highp vec2 qt_MultiTexCoord0;
93 varying highp vec2 coord;
95 coord = qt_MultiTexCoord0;
96 gl_Position = qt_Matrix * qt_Vertex;
99 varying highp vec2 coord;
100 uniform sampler2D mask;
101 uniform sampler2D gradient;
103 lowp vec4 texMask = texture2D(mask, coord);
104 lowp vec4 texGradient = texture2D(gradient, coord);
105 gl_FragColor = texGradient.rgba * texMask.a ;
121 color: UbuntuColors.red
124 target: innerLeftShape
125 color: UbuntuColors.red
136 target: innerLeftShape
137 color: UbuntuColors.red
146 opacity: slider.x <= halfWay ? 1.0 : 1.0 - ((slider.x - halfWay) / halfWay)
149 anchors.centerIn: parent
151 width: parent.width - units.gu(.5)
152 height: parent.height - units.gu(.5)
155 anchors.centerIn: parent
165 width: (row.width - (leftShape.width + slider.width + rightShape.width + 4 * row.spacing)) / 2
175 UbuntuNumberAnimation {
176 duration: UbuntuAnimation.FastDuration
177 easing.type: Easing.OutBounce
181 Behavior on opacity {
182 UbuntuNumberAnimation {
183 duration: UbuntuAnimation.FastDuration
189 if (rightShape.state === "selected") {
192 if (leftShape.state === "selected") {
206 anchors.leftMargin: units.gu(.5)
207 anchors.rightMargin: units.gu(.5)
209 anchors.verticalCenter: parent.verticalCenter
215 anchors.verticalCenter: parent.verticalCenter
225 width: leftSpacer.width
237 color: UbuntuColors.green
240 target: innerRightShape
241 color: UbuntuColors.green
252 target: innerRightShape
253 color: UbuntuColors.green
262 opacity: slider.x >= halfWay ? 1.0 : slider.x / halfWay
265 anchors.centerIn: parent
267 width: parent.width - units.gu(.5)
268 height: parent.height - units.gu(.5)
271 anchors.centerIn: parent
282 objectName: "swipeMouseArea"
286 drag.axis: Drag.XAxis
288 drag.maximumX: row.width - slider.width
291 if (slider.x !== drag.minimumX || slider.x !== drag.maximumX) {
294 if (slider.x === drag.minimumX) {
295 slider.x = drag.minimumX
298 leftShape.state = "selected"
300 if (slider.x === drag.maximumX) {
301 slider.x = drag.maximumX
304 rightShape.state = "selected"