Debian Codegraph @

qml/components/ThinSliderStyle.qml

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
16
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19
20 /*
21 This delegate is styled using the following properties:
22 - backgroundImage: image source for the bar
23 - backgroundImageHeight: specifies the height of the image to be used;
24 if not specified, the images source height will be used
25 - thumbImage: image source for the thumb
26 - thumbWidth, thumbHeight: width and height of the thumb; source measurements
27 will be used if not specified
28 - thumbSpacing: spacing between the thumb and the bar; 0 if not specified
29 */
30
31 Item {
32
33 id: main
34 anchors.fill: parent
35
36 property Item bar: backgroundShape
37 property Item thumb: thumbShape
38
39 property real normalizedValue: SliderUtils.normalizedValue(styledItem)
40 property real thumbSpacing: 0.0
41 property real thumbSpace: backgroundShape.width - (2.0 * thumbSpacing + thumbWidth)
42 property real thumbWidth: units.gu(1.5)
43 property real thumbHeight: units.gu(1.5)
44
45 property string backgroundImage: "../../assets/[email protected]"
46 property string thumbImage: "../../assets/[email protected]"
47
48 implicitHeight: thumbShape.height + 2.0 * thumbSpacing + units.gu(2)
49 implicitWidth: backgroundShape.width
50
51 Image {
52 id: backgroundShape
53 anchors {
54 left: parent.left
55 right: parent.right
56 verticalCenter: parent.verticalCenter
57 }
58 source: backgroundImage
59 height: sourceSize.height
60 asynchronous: true
61 cache: false
62 }
63
64 Image {
65 id: thumbShape
66 objectName: "sliderThumb"
67
68 x: backgroundShape.x + thumbSpacing + normalizedValue * thumbSpace
69 y: backgroundShape.y + thumbSpacing
70 width: thumbWidth
71 height: thumbHeight
72 anchors.verticalCenter: backgroundShape.verticalCenter
73 source: thumbImage
74 asynchronous: true
75 cache: false
76 }
77 }