on xenial help sign in
Merge lp:~unity-team/unity8/themeing-font-and-mascot.
commit6f4607d3ec44fe83e65438753478aed4790d77c8 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 20 Feb 2014, 14:11 (13 years ago) parentaf316a8c6d94b1
2 files changed+39−19
qml/Dash/Card.qml+15−3 qml/Dash/CardHeader.qml+24−16
qml/Dash/Card.qml+15−3
@@ -140,7 +140,6 @@ AbstractButton {
140140 CardHeader {
141141 id: header
142142 objectName: "cardHeader"
143− inOverlay: root.template && root.template["overlay"] === true
144143 anchors {
145144 top: {
146145 if (template) {
@@ -163,6 +162,9 @@ AbstractButton {
163162 subtitle: cardData && cardData["subtitle"] || ""
164163
165164 opacity: showHeader ? 1 : 0
165+ inOverlay: root.template && root.template["overlay"] === true
166+ fontColor: inOverlay ? "white" : summary.color
167+ useMascotShape: !background.visible && !inOverlay
166168
167169 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
168170 }
@@ -183,7 +185,17 @@ AbstractButton {
183185 text: cardData && cardData["summary"] || ""
184186 height: text ? implicitHeight : 0
185187 fontSize: "small"
186− // TODO karni (for each Label): Update Ubuntu.Components.Themes.Palette and use theme color instead
187− color: "grey"
188+ color: getFontColor(background.color)
189+
190+ function getLuminance(color) {
191+ return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
192+ }
193+
194+ // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
195+ function getFontColor(backgroundColor) {
196+ if (backgroundColor === undefined) return "grey";
197+ var luminance = getLuminance(backgroundColor);
198+ return luminance < 0.7 ? "white" : "grey"
199+ }
188200 }
189201}
qml/Dash/CardHeader.qml+24−16
@@ -30,7 +30,10 @@ Item {
3030 property real fontScale: 1.0
3131
3232 property alias headerAlignment: titleLabel.horizontalAlignment
33+
3334 property bool inOverlay: false
35+ property bool useMascotShape: true
36+ property color fontColor: "grey"
3437
3538 visible: mascotImage.status === Image.Ready || title || price
3639 height: row.height > 0 ? row.height + row.margins * 2 : 0
@@ -41,13 +44,13 @@ Item {
4144
4245 property real margins: units.gu(1)
4346
47+ spacing: mascotShape.visible || mascotImage.visible || inOverlay ? margins : 0
4448 anchors {
4549 top: parent.top; left: parent.left; right: parent.right
4650 margins: margins
4751 leftMargin: spacing
4852 rightMargin: spacing
4953 }
50− spacing: mascotShape.visible || inOverlay ? margins : 0
5154
5255 UbuntuShape {
5356 id: mascotShape
@@ -56,20 +59,23 @@ Item {
5659 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
5760 width: units.gu(6)
5861 height: units.gu(5.625)
59− visible: image.status === Image.Ready
60− // FIXME the * 4 is a workaround to obtain crispness
61− // Find out the proper fix
62+ visible: useMascotShape && image && image.status === Image.Ready
6263 readonly property int maxSize: Math.max(width, height) * 4
6364
64− image: Image {
65− id: mascotImage
66− cache: true
65+ image: useMascotShape ? mascotImage : null
66+ }
6767
68− sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
69− fillMode: Image.PreserveAspectCrop
70− horizontalAlignment: Image.AlignHCenter
71− verticalAlignment: Image.AlignVCenter
72− }
68+ Image {
69+ id: mascotImage
70+
71+ width: source ? mascotShape.width : 0
72+ height: mascotShape.height
73+ visible: !useMascotShape && status === Image.Ready
74+
75+ sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
76+ fillMode: Image.PreserveAspectCrop
77+ horizontalAlignment: Image.AlignHCenter
78+ verticalAlignment: Image.AlignVCenter
7379 }
7480
7581 Column {
@@ -86,8 +92,7 @@ Item {
8692 wrapMode: Text.Wrap
8793 maximumLineCount: 2
8894 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
89− // TODO karni (for each Label): Update Ubuntu.Components.Themes.Palette and use theme color instead
90− color: inOverlay ? "white" : "grey" // Theme.palette.normal.backgroundText
95+ color: fontColor
9196 }
9297
9398 Label {
@@ -98,7 +103,7 @@ Item {
98103 font.weight: Font.Light
99104 visible: titleLabel.text && text
100105 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
101− color: inOverlay ? "white" : "grey" // Theme.palette.normal.backgroundText
106+ color: fontColor
102107 }
103108
104109 Row {
@@ -119,7 +124,7 @@ Item {
119124 width: parent.labelWidth
120125 elide: Text.ElideRight
121126 font.weight: Font.DemiBold
122− color: "grey" // Theme.palette.normal.backgroundText
127+ color: "#ff990000"
123128 visible: text
124129 }
125130
@@ -129,6 +134,8 @@ Item {
129134 width: parent.labelWidth
130135 elide: Text.ElideRight
131136 horizontalAlignment: parent.labels === 3 ? Text.AlignHCenter : Text.AlignRight
137+ font.strikeout: true
138+ color: "black"
132139 visible: text
133140 }
134141
@@ -137,6 +144,7 @@ Item {
137144 width: parent.labelWidth
138145 elide: Text.ElideRight
139146 horizontalAlignment: Text.AlignRight
147+ color: fontColor
140148 visible: text
141149 }
142150 }