~mterry/unity8/oobe-revert-geonames

« back to all changes in this revision

Viewing changes to tests/plugins/Dash/cardcreator/11.res.cardcreator

  • Committer: Michael Terry
  • Date: 2016-03-11 17:51:18 UTC
  • mfrom: (1821.227.75 unity8)
  • Revision ID: michael.terry@canonical.com-20160311175118-6za2cj41c21d88ha
Merge silo 64 (soon to be trunk)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
AbstractButton { 
 
2
                id: root; 
 
3
                property var cardData; 
 
4
                property string artShapeStyle: "inset"; 
 
5
                property string backgroundShapeStyle: "inset"; 
 
6
                property real fontScale: 1.0; 
 
7
                property var scopeStyle: null; 
 
8
                property size fixedArtShapeSize: Qt.size(-1, -1); 
 
9
                readonly property string title: cardData && cardData["title"] || ""; 
 
10
                property bool showHeader: true; 
 
11
                implicitWidth: childrenRect.width; 
 
12
                enabled: true; 
 
13
                
 
14
Loader {
 
15
                                id: backgroundLoader; 
 
16
                                objectName: "backgroundLoader"; 
 
17
                                anchors.fill: parent; 
 
18
                                asynchronous: false;
 
19
                                visible: status == Loader.Ready; 
 
20
                                sourceComponent: UbuntuShape { 
 
21
                                    objectName: "background"; 
 
22
                                    radius: "medium"; 
 
23
                                    aspect: { 
 
24
                                        switch (root.backgroundShapeStyle) { 
 
25
                                            case "inset": return UbuntuShape.Inset; 
 
26
                                            case "shadow": return UbuntuShape.DropShadow; 
 
27
                                            default: 
 
28
                                            case "flat": return UbuntuShape.Flat; 
 
29
                                        } 
 
30
                                    } 
 
31
                                    backgroundColor: getColor(0) || "white"; 
 
32
                                    secondaryBackgroundColor: getColor(1) || backgroundColor; 
 
33
                                    backgroundMode: UbuntuShape.VerticalGradient; 
 
34
                                    anchors.fill: parent; 
 
35
                                    source: backgroundImage.source ? backgroundImage : null; 
 
36
                                    property real luminance: Style.luminance(backgroundColor); 
 
37
                                    property Image backgroundImage: Image { 
 
38
                                        objectName: "backgroundImage"; 
 
39
                                        source: { 
 
40
                                            if (cardData && typeof cardData["background"] === "string") return cardData["background"]; 
 
41
                                            else return ""; 
 
42
                                        } 
 
43
                                    } 
 
44
                                    function getColor(index) { 
 
45
                                        if (cardData && typeof cardData["background"] === "object" 
 
46
                                            && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { 
 
47
                                            return cardData["background"]["elements"][index]; 
 
48
                                        } else return index === 0 ? "#E9E9E9" : undefined; 
 
49
                                    } 
 
50
                                } 
 
51
                            }
 
52
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
 
53
Item { 
 
54
                            id: artShapeHolder; 
 
55
                            height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; 
 
56
                            width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width; 
 
57
                            anchors { horizontalCenter: parent.horizontalCenter; } 
 
58
                            Loader { 
 
59
                                id: artShapeLoader; 
 
60
                                objectName: "artShapeLoader"; 
 
61
                                readonly property string cardArt: cardData && cardData["art"] || "";
 
62
                                active: cardArt != "";
 
63
                                asynchronous: false;
 
64
                                visible: status == Loader.Ready; 
 
65
                                sourceComponent: Item { 
 
66
                                    id: artShape; 
 
67
                                    objectName: "artShape"; 
 
68
                                    visible: image.status == Image.Ready; 
 
69
                                    readonly property alias image: artImage; 
 
70
                                    ShaderEffectSource { 
 
71
                                        id: artShapeSource; 
 
72
                                        sourceItem: artImage; 
 
73
                                        anchors.centerIn: parent; 
 
74
                                        width: 1; 
 
75
                                        height: 1; 
 
76
                                        hideSource: true;
 
77
                                    } 
 
78
                                    Loader { 
 
79
                                        anchors.fill: parent; 
 
80
                                        visible: true;
 
81
                                        sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; 
 
82
                                        Component { 
 
83
                                            id: artShapeShapeComponent; 
 
84
                                            UbuntuShape { 
 
85
                                                source: artShapeSource; 
 
86
                                                sourceFillMode: UbuntuShape.PreserveAspectCrop; 
 
87
                                                radius: "medium"; 
 
88
                                                aspect: { 
 
89
                                                    switch (root.artShapeStyle) { 
 
90
                                                        case "inset": return UbuntuShape.Inset; 
 
91
                                                        case "shadow": return UbuntuShape.DropShadow; 
 
92
                                                        default: 
 
93
                                                        case "flat": return UbuntuShape.Flat; 
 
94
                                                    } 
 
95
                                                } 
 
96
                                            } 
 
97
                                        } 
 
98
                                        Component { 
 
99
                                            id: artShapeIconComponent; 
 
100
                                            ProportionalShape { source: artShapeSource; aspect: UbuntuShape.DropShadow; } 
 
101
                                        } 
 
102
                                    } 
 
103
                                    readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; 
 
104
                                    readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
 
105
                                    Component.onCompleted: { updateWidthHeightBindings(); } 
 
106
                                    Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); } 
 
107
                                    function updateWidthHeightBindings() { 
 
108
                                        if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) { 
 
109
                                            width = root.fixedArtShapeSize.width; 
 
110
                                            height = root.fixedArtShapeSize.height; 
 
111
                                        } else { 
 
112
                                            width = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.width }); 
 
113
                                            height = Qt.binding(function() { return image.status !== Image.Ready ? 0 : image.height }); 
 
114
                                        } 
 
115
                                    } 
 
116
                                    CroppedImageMinimumSourceSize { 
 
117
                                        id: artImage; 
 
118
                                        objectName: "artImage"; 
 
119
                                        source: artShapeLoader.cardArt;
 
120
                                        asynchronous: false;
 
121
                                        width: root.width; 
 
122
                                        height: width / artShape.aspect; 
 
123
                                    } 
 
124
                                } 
 
125
                            } 
 
126
                        }
 
127
readonly property int headerHeight: row.height;
 
128
Row { 
 
129
                        id: row; 
 
130
                        objectName: "outerRow"; 
 
131
                        property real margins: units.gu(1); 
 
132
                        spacing: margins; 
 
133
                        anchors { top: artShapeHolder.bottom; 
 
134
                                         topMargin: units.gu(1);
 
135
left: parent.left;
 
136
 } 
 
137
                        anchors.right: parent.right; 
 
138
                        anchors.margins: margins; 
 
139
                        anchors.rightMargin: 0; 
 
140
                        data: [ 
 
141
                                CroppedImageMinimumSourceSize { 
 
142
                            id: mascotImage; 
 
143
                            objectName: "mascotImage"; 
 
144
                            anchors { verticalCenter: parent.verticalCenter; } 
 
145
                            source: cardData && cardData["mascot"] || "";
 
146
                            width: units.gu(6); 
 
147
                            height: units.gu(5.625); 
 
148
                            horizontalAlignment: Image.AlignHCenter; 
 
149
                            verticalAlignment: Image.AlignVCenter; 
 
150
                            visible: showHeader; 
 
151
                        }
 
152
,Item { 
 
153
                            id: headerTitleContainer; 
 
154
                            anchors { verticalCenter: parent.verticalCenter;  } 
 
155
                            width: parent.width - x; 
 
156
                            implicitHeight: titleLabel.height + subtitleLabel.height; 
 
157
                            data: [ 
 
158
                                Label { 
 
159
                        id: titleLabel; 
 
160
                        objectName: "titleLabel"; 
 
161
                        anchors { right: parent.right; 
 
162
rightMargin: units.gu(1); 
 
163
left: parent.left; 
 
164
                             top: parent.top; } 
 
165
                        elide: Text.ElideRight; 
 
166
                        fontSize: "small"; 
 
167
                        wrapMode: Text.Wrap; 
 
168
                        maximumLineCount: 2; 
 
169
                        font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 
 
170
                        color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); 
 
171
                        visible: showHeader ; 
 
172
                        width: undefined; 
 
173
                        text: root.title; 
 
174
                        font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal; 
 
175
                        horizontalAlignment: Text.AlignLeft;
 
176
                    }
 
177
,Label { 
 
178
                            id: subtitleLabel; 
 
179
                            objectName: "subtitleLabel"; 
 
180
                            anchors { right: parent.right; 
 
181
                               left: parent.left; 
 
182
rightMargin: units.gu(1); 
 
183
top: titleLabel.bottom;
 
184
 } 
 
185
                            anchors.topMargin: units.dp(2); 
 
186
                            elide: Text.ElideRight; 
 
187
                            maximumLineCount: 1; 
 
188
                            fontSize: "x-small"; 
 
189
                            font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 
 
190
                            color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white"); 
 
191
                            visible: titleLabel.visible && titleLabel.text; 
 
192
                            text: cardData && cardData["subtitle"] || ""; 
 
193
                            font.weight: Font.Light; 
 
194
                        }
 
195
 
 
196
                            ]
 
197
                        }
 
198
 
 
199
                                ] 
 
200
                    }
 
201
UbuntuShape { 
 
202
                        id: touchdown; 
 
203
                        objectName: "touchdown"; 
 
204
                        anchors { fill: backgroundLoader } 
 
205
                        visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; 
 
206
                        radius: "medium"; 
 
207
                        borderSource: "radius_pressed.sci" 
 
208
                    }
 
209
implicitHeight: row.y + row.height + units.gu(1);
 
210
}