on xenial help sign in
Use fixedHeaderHeight only in the non cardtool cards

Approved by: Andrea Cimitan

commit7552279c24a617f4b249b6f146fca85aa2b77729 authorAlbert Astals Cid <albert.astals@canonical.com> dateThu 10 Mar 2016, 22:38 (11 years ago) parent07566cc46bc39e
20 files changed+25−35
plugins/Dash/CardCreator.js+15−8 tests/plugins/Dash/cardcreator/1.res.cardcreator−1 tests/plugins/Dash/cardcreator/10.res+1−1 tests/plugins/Dash/cardcreator/10.res.cardcreator−2 tests/plugins/Dash/cardcreator/11.res+1−1 tests/plugins/Dash/cardcreator/11.res.cardcreator−2 tests/plugins/Dash/cardcreator/2.res+1−1 tests/plugins/Dash/cardcreator/2.res.cardcreator−2 tests/plugins/Dash/cardcreator/3.res.cardcreator−1 tests/plugins/Dash/cardcreator/4.res+1−1 tests/plugins/Dash/cardcreator/4.res.cardcreator−2 tests/plugins/Dash/cardcreator/5.res+1−1 tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2 tests/plugins/Dash/cardcreator/6.res.cardcreator−1 tests/plugins/Dash/cardcreator/7.res+1−1 tests/plugins/Dash/cardcreator/7.res.cardcreator−2 tests/plugins/Dash/cardcreator/8.res+1−1 tests/plugins/Dash/cardcreator/8.res.cardcreator−2 tests/plugins/Dash/cardcreator/9.res+1−1 tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
plugins/Dash/CardCreator.js+15−8
@@ -190,9 +190,10 @@ var kAudioButtonCode = 'AbstractButton { \n\
190190 }';
191191
192192// %1 is whether the loader should be asynchronous or not
193+// %2 is the header height code
193194var kOverlayLoaderCode = 'Loader { \n\
194195 id: overlayLoader; \n\
195− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
196+ readonly property real overlayHeight: %2 + units.gu(2); \n\
196197 anchors.fill: artShapeHolder; \n\
197198 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false; \n\
198199 asynchronous: %1; \n\
@@ -214,17 +215,19 @@ function kHeaderRowCodeGenerator() {
214215 objectName: "outerRow"; \n\
215216 property real margins: units.gu(1); \n\
216217 spacing: margins; \n\
217− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
218+ %2\
218219 anchors { %1 } \n\
219220 anchors.right: parent.right; \n\
220221 anchors.margins: margins; \n\
221222 anchors.rightMargin: 0; \n\
222223 data: [ \n\
223− %2 \n\
224+ %3 \n\
224225 ] \n\
225226 }\n';
226227 var args = Array.prototype.slice.call(arguments);
227− var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(args.join(',\n'));
228+ var isCardTool = args.shift();
229+ var heightCode = isCardTool ? "" : "height: root.fixedHeaderHeight; \n";
230+ var code = kHeaderRowCodeTemplate.arg(args.shift()).arg(heightCode).arg(args.join(',\n'));
228231 return code;
229232}
230233
@@ -415,7 +418,7 @@ function cardString(template, components, isCardTool) {
415418 property string backgroundShapeStyle: "inset"; \n\
416419 property real fontScale: 1.0; \n\
417420 property var scopeStyle: null; \n\
418− property int fixedHeaderHeight: -1; \n\
421+ %2\
419422 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
420423 readonly property string title: cardData && cardData["title"] || ""; \n\
421424 property bool showHeader: true; \n\
@@ -423,6 +426,8 @@ function cardString(template, components, isCardTool) {
423426 enabled: %1; \n\
424427 \n'.arg(templateInteractive);
425428
429+ code = code.arg(isCardTool ? "" : "property int fixedHeaderHeight: -1; \n");
430+
426431 var hasArt = components["art"] && components["art"]["field"] || false;
427432 var hasSummary = components["summary"] || false;
428433 var isConciergeMode = components["art"] && components["art"]["conciergeMode"] || false;
@@ -524,7 +529,8 @@ function cardString(template, components, isCardTool) {
524529 }
525530
526531 if (headerAsOverlay) {
527− code += kOverlayLoaderCode.arg(asynchronous);
532+ var headerHeightCode = isCardTool ? "headerHeight" : "root.fixedHeaderHeight";
533+ code += kOverlayLoaderCode.arg(asynchronous).arg(headerHeightCode);
528534 }
529535
530536 var headerVerticalAnchors;
@@ -785,7 +791,7 @@ function cardString(template, components, isCardTool) {
785791 if (mascotShapeCode != '') {
786792 rowCode.unshift(mascotShapeCode);
787793 }
788− code += kHeaderRowCodeGenerator(headerVerticalAnchors + headerLeftAnchor, rowCode)
794+ code += kHeaderRowCodeGenerator(isCardTool, headerVerticalAnchors + headerLeftAnchor, rowCode)
789795 } else {
790796 code += mascotShapeCode + mascotCode + titleSubtitleCode;
791797 }
@@ -809,7 +815,8 @@ function cardString(template, components, isCardTool) {
809815 } else {
810816 audioButtonAnchorsFill = 'undefined';
811817 audioButtonWidth = 'height';
812− audioButtonHeight = '(root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1)';
818+ audioButtonHeight = isCardTool ? 'headerHeight + 2 * units.gu(1)'
819+ : 'root.fixedHeaderHeight + 2 * units.gu(1)';
813820 }
814821 code += kAudioButtonCode.arg(audioButtonAnchorsFill).arg(audioButtonWidth).arg(audioButtonHeight);
815822 }
tests/plugins/Dash/cardcreator/1.res.cardcreator−1
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
tests/plugins/Dash/cardcreator/10.res+1−1
@@ -57,7 +57,7 @@ Row {
5757 objectName: "outerRow";
5858 property real margins: units.gu(1);
5959 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
60+ height: root.fixedHeaderHeight;
6161 anchors { top: parent.top;
6262 topMargin: units.gu(1);
6363left: parent.left;
tests/plugins/Dash/cardcreator/10.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -57,7 +56,6 @@ Row {
5756 objectName: "outerRow";
5857 property real margins: units.gu(1);
5958 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6159 anchors { top: parent.top;
6260 topMargin: units.gu(1);
6361left: parent.left;
tests/plugins/Dash/cardcreator/11.res+1−1
@@ -132,7 +132,7 @@ Row {
132132 objectName: "outerRow";
133133 property real margins: units.gu(1);
134134 spacing: margins;
135− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
135+ height: root.fixedHeaderHeight;
136136 anchors { top: artShapeHolder.bottom;
137137 topMargin: units.gu(1);
138138left: parent.left;
tests/plugins/Dash/cardcreator/11.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -131,7 +130,6 @@ Row {
131130 objectName: "outerRow";
132131 property real margins: units.gu(1);
133132 spacing: margins;
134− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
135133 anchors { top: artShapeHolder.bottom;
136134 topMargin: units.gu(1);
137135left: parent.left;
tests/plugins/Dash/cardcreator/2.res+1−1
@@ -57,7 +57,7 @@ Row {
5757 objectName: "outerRow";
5858 property real margins: units.gu(1);
5959 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
60+ height: root.fixedHeaderHeight;
6161 anchors { top: parent.top;
6262 topMargin: units.gu(1);
6363 left: parent.left;
tests/plugins/Dash/cardcreator/2.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -57,7 +56,6 @@ Row {
5756 objectName: "outerRow";
5857 property real margins: units.gu(1);
5958 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6159 anchors { top: parent.top;
6260 topMargin: units.gu(1);
6361 left: parent.left;
tests/plugins/Dash/cardcreator/3.res.cardcreator−1
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
tests/plugins/Dash/cardcreator/4.res+1−1
@@ -19,7 +19,7 @@ Row {
1919 objectName: "outerRow";
2020 property real margins: units.gu(1);
2121 spacing: margins;
22− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
22+ height: root.fixedHeaderHeight;
2323 anchors { top: parent.top;
2424 topMargin: units.gu(1);
2525 left: parent.left;
tests/plugins/Dash/cardcreator/4.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -19,7 +18,6 @@ Row {
1918 objectName: "outerRow";
2019 property real margins: units.gu(1);
2120 spacing: margins;
22− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
2321 anchors { top: parent.top;
2422 topMargin: units.gu(1);
2523 left: parent.left;
tests/plugins/Dash/cardcreator/5.res+1−1
@@ -89,7 +89,7 @@ Item {
8989 }
9090Loader {
9191 id: overlayLoader;
92− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
92+ readonly property real overlayHeight: root.fixedHeaderHeight + units.gu(2);
9393 anchors.fill: artShapeHolder;
9494 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
9595 asynchronous: true;
tests/plugins/Dash/cardcreator/5.res.cardcreator+1−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -89,7 +88,7 @@ Item {
8988 }
9089Loader {
9190 id: overlayLoader;
92− readonly property real overlayHeight: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
91+ readonly property real overlayHeight: headerHeight + units.gu(2);
9392 anchors.fill: artShapeHolder;
9493 active: artShapeLoader.active && artShapeLoader.item && artShapeLoader.item.image.status === Image.Ready || false;
9594 asynchronous: false;
tests/plugins/Dash/cardcreator/6.res.cardcreator−1
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
tests/plugins/Dash/cardcreator/7.res+1−1
@@ -57,7 +57,7 @@ Row {
5757 objectName: "outerRow";
5858 property real margins: units.gu(1);
5959 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
60+ height: root.fixedHeaderHeight;
6161 anchors { top: parent.top;
6262 topMargin: units.gu(1);
6363 left: parent.left;
tests/plugins/Dash/cardcreator/7.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -57,7 +56,6 @@ Row {
5756 objectName: "outerRow";
5857 property real margins: units.gu(1);
5958 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6159 anchors { top: parent.top;
6260 topMargin: units.gu(1);
6361 left: parent.left;
tests/plugins/Dash/cardcreator/8.res+1−1
@@ -57,7 +57,7 @@ Row {
5757 objectName: "outerRow";
5858 property real margins: units.gu(1);
5959 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
60+ height: root.fixedHeaderHeight;
6161 anchors { top: parent.top;
6262 topMargin: units.gu(1);
6363left: parent.left;
tests/plugins/Dash/cardcreator/8.res.cardcreator−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -57,7 +56,6 @@ Row {
5756 objectName: "outerRow";
5857 property real margins: units.gu(1);
5958 spacing: margins;
60− height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
6159 anchors { top: parent.top;
6260 topMargin: units.gu(1);
6361left: parent.left;
tests/plugins/Dash/cardcreator/9.res+1−1
@@ -70,7 +70,7 @@ CardAudioProgress {
7070 id: audioButton;
7171 anchors.fill: undefined;
7272 width: height;
73− height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
73+ height: root.fixedHeaderHeight + 2 * units.gu(1);
7474 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
7575 UbuntuShape {
7676 anchors.fill: parent;
tests/plugins/Dash/cardcreator/9.res.cardcreator+1−2
@@ -5,7 +5,6 @@ AbstractButton {
55 property string backgroundShapeStyle: "inset";
66 property real fontScale: 1.0;
77 property var scopeStyle: null;
8− property int fixedHeaderHeight: -1;
98 property size fixedArtShapeSize: Qt.size(-1, -1);
109 readonly property string title: cardData && cardData["title"] || "";
1110 property bool showHeader: true;
@@ -70,7 +69,7 @@ CardAudioProgress {
7069 id: audioButton;
7170 anchors.fill: undefined;
7271 width: height;
73− height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
72+ height: headerHeight + 2 * units.gu(1);
7473 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
7574 UbuntuShape {
7675 anchors.fill: parent;