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.3
23 // Whether this slider is short or long
24 property bool shortSwipe
26 // How far the user has slid
29 // Set to true when slider is being used
32 // How far in percentage terms
33 readonly property real percent: d.slideOffset / target.x
37 readonly property color trayColor: "#424141"
38 readonly property real margin: units.gu(0.5)
39 readonly property real arrowSize: root.height - margin * 2
40 readonly property real dotSize: units.dp(1)
41 readonly property real slideOffset: MathUtils.clamp(root.offset - offscreenOffset, -offscreenOffset, target.x)
42 readonly property real offscreenOffset: units.gu(2)
45 implicitWidth: shortSwipe ? units.gu(15) : units.gu(27.5)
46 implicitHeight: units.gu(6.5)
51 anchors.rightMargin: clipBox.width - 1
54 // We want to have a circular border around the target. But we can't just
55 // do a radius on two of a rectangle's corners. So we clip a full circle.
60 anchors.top: parent.top
61 anchors.bottom: parent.bottom
62 anchors.right: parent.right
63 width: parent.height / 2
67 anchors.top: parent.top
68 anchors.bottom: parent.bottom
69 anchors.right: parent.right
70 width: parent.width * 2
81 anchors.right: parent.right
82 anchors.rightMargin: d.margin
83 anchors.verticalCenter: parent.verticalCenter
87 anchors.left: handle.horizontalCenter
88 anchors.right: target.horizontalCenter
89 anchors.verticalCenter: parent.verticalCenter
91 layoutDirection: Qt.RightToLeft
92 spacing: d.dotSize * 2
95 model: parent.width / (parent.spacing + d.dotSize)
97 anchors.verticalCenter: parent ? parent.verticalCenter : undefined
111 color: UbuntuColors.orange
112 darkenBy: root.active ? 0.5 : 0
113 anchors.left: parent.left
114 // We use a Translate transform rather than anchors.leftMargin because
115 // the latter has weird performance problems on the TutorialRight page.
121 anchors.verticalCenter: parent.verticalCenter