Debian Codegraph @

src/imports/Components/Themes/Ambiance/1.2/DatePickerStyle.qml

raw
1 /*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components 1.2
19 import Lomiri.Components.ListItems 1.0
20
21 Item {
22 id: control
23 // style properties
24 /*!
25 Specifies the background color
26 */
27 property color backgroundColor: "#0A000000"
28 /*!
29 Background color for highlight.
30 */
31 property color highlightBackgroundColor: "#ffffffff"
32 /*!
33 Highlight color.
34 */
35 property color highlightColor: LomiriColors.orange
36 /*!
37 Scale of the highlight item
38 */
39 property real highlightScaleFactor: 1.2
40 /*!
41 Thickness of the highlight component
42 */
43 property real highlightThickness: units.gu(5)
44
45 /*!
46 The content holder exposed to the Picker so tumbler list can be reparented to it.
47 */
48 property alias tumblerHolder: content
49
50 /*!
51 The property holds the separator to be shown between date and time units
52 */
53 property string unitSeparator: ""
54
55 property Item view: Item {}
56 property ListModel pickerModels: ListModel{}
57
58 anchors.fill: parent
59
60 // frame
61 LomiriShape {
62 anchors.fill: parent
63 radius: "medium"
64 image: shapeSource
65 }
66
67 ShaderEffectSource {
68 id: shapeSource
69 sourceItem: background
70 hideSource: true
71 // FIXME: visible: false prevents rendering so make it a nearly
72 // transparent 1x1 pixel instead
73 opacity: 0.01
74 width: 1
75 height: 1
76 }
77
78 Rectangle {
79 id: background
80 anchors.fill: parent
81
82 MouseArea {
83 anchors.fill: parent
84 }
85 // background
86 color: backgroundColor
87
88 Item {
89 id: content
90 anchors.fill: parent
91 }
92
93 // highlight
94 Rectangle {
95 id: highlightItem
96 y: (content.height - control.highlightThickness) / 2
97 anchors {
98 left: content.left
99 right: content.right
100 }
101 height: control.highlightThickness
102 color: highlightBackgroundColor
103 }
104 ThinDivider {
105 anchors {
106 left: content.left
107 right: content.right
108 bottom: highlightItem.top
109 }
110 }
111 ThinDivider {
112 anchors {
113 left: content.left
114 right: content.right
115 top: highlightItem.bottom
116 }
117 }
118
119 ShaderEffectSource {
120 id: effectSource
121 visible: false
122 sourceItem: view
123
124 property real sourceRectMultiplier: 2.0
125 // XXX: This works because the parent of magnifier is the same as sourceItem
126 // in this case. Otherwise coordinate transformations will be needed.
127 sourceRect: Qt.rect(highlightItem.x, highlightItem.y, highlightItem.width, highlightItem.height)
128 textureSize: Qt.size(highlightItem.width*sourceRectMultiplier, highlightItem.height*sourceRectMultiplier)
129 }
130
131 Row {
132 id: magnifierRow
133 anchors {
134 top: highlightItem.top
135 bottom: highlightItem.bottom
136 horizontalCenter: highlightItem.horizontalCenter
137 }
138
139 Repeater {
140 model: pickerModels
141 HighlightMagnifier {
142 anchors {
143 top: magnifierRow.top
144 bottom: magnifierRow.bottom
145 }
146 width: pickerModel.pickerWidth
147 scaleFactor: control.highlightScaleFactor
148 outputColor: control.highlightColor
149 source: effectSource
150 texCoordRange: Qt.rect((x - source.sourceRect.x) / source.sourceRect.width, 0.0,
151 width / source.sourceRect.width, 1.0);
152
153 Label {
154 text: (index < (pickerModels.count - 1)) ? unitSeparator : ""
155 anchors {
156 right: parent.right
157 verticalCenter: parent.verticalCenter
158 }
159 }
160 }
161 }
162 }
163 }
164 }