Debian Codegraph @

src/imports/Components/Themes/Ambiance/1.2/PickerStyle.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: styledItem.__itemHeight + units.gu(1)
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 \internal
52 View instance listing the model
53 */
54 property Item view: Item{}
55
56 anchors.fill: parent
57 implicitWidth: units.gu(8)
58 implicitHeight: units.gu(20)
59
60 // frame
61 LomiriShape {
62 anchors.fill: parent
63 radius: "medium"
64 color: Theme.palette.normal.overlay
65 image: shapeSource
66 }
67
68 ShaderEffectSource {
69 id: shapeSource
70 sourceItem: background
71 hideSource: true
72 // FIXME: visible: false prevents rendering so make it a nearly
73 // transparent 1x1 pixel instead
74 opacity: 0.01
75 width: 1
76 height: 1
77 }
78
79 Rectangle {
80 id: background
81 anchors.fill: parent
82
83 MouseArea {
84 anchors.fill: parent
85 }
86 // background
87 color: backgroundColor
88
89 Item {
90 id: content
91 anchors.fill: parent
92 }
93
94 // highlight
95 Rectangle {
96 id: highlightItem
97 y: (content.height - control.highlightThickness) / 2
98 anchors {
99 left: content.left
100 right: content.right
101 }
102 height: control.highlightThickness
103 color: highlightBackgroundColor
104 }
105 ThinDivider {
106 anchors {
107 left: content.left
108 right: content.right
109 bottom: highlightItem.top
110 }
111 }
112 ThinDivider {
113 anchors {
114 left: content.left
115 right: content.right
116 top: highlightItem.bottom
117 }
118 }
119
120 ShaderEffectSource {
121 id: effectSource
122 visible: false
123 sourceItem: view
124
125 property real sourceRectMultiplier: 2.0
126 // XXX: This works because the parent of magnifier is the same as sourceItem
127 // in this case. Otherwise coordinate transformations will be needed.
128 sourceRect: Qt.rect(highlightItem.x, highlightItem.y, highlightItem.width, highlightItem.height)
129 textureSize: Qt.size(highlightItem.width*sourceRectMultiplier, highlightItem.height*sourceRectMultiplier)
130 }
131 HighlightMagnifier {
132 anchors.fill: highlightItem
133 scaleFactor: control.highlightScaleFactor
134 outputColor: control.highlightColor
135 source: effectSource
136 }
137 }
138 }