on xenial help sign in
Concierge mode generated code optimization

No need to create a shape that will always be non visible

commit15626fed66394c8ad606efcb0d0e1ba575818ed6 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 4 Mar 2016, 15:34 (11 years ago) parent71cdedb
9 files changed+16−39
plugins/Dash/CardCreator.js+16−17 tests/plugins/Dash/cardcreator/1.res−1 tests/plugins/Dash/cardcreator/1.res.cardcreator−1 tests/plugins/Dash/cardcreator/11.res−1 tests/plugins/Dash/cardcreator/11.res.cardcreator−1 tests/plugins/Dash/cardcreator/3.res−1 tests/plugins/Dash/cardcreator/3.res.cardcreator−1 tests/plugins/Dash/cardcreator/5.res−8 tests/plugins/Dash/cardcreator/5.res.cardcreator−8
plugins/Dash/CardCreator.js+16−17
@@ -59,21 +59,17 @@ var kBackgroundLoaderCode = 'Loader {\n\
5959 } \n\
6060 }\n';
6161
62−// %1 is the visible code
63−// %2 is the aspect of the UbuntuShape
62+// %1 is the aspect of the UbuntuShape
6463var kArtUbuntuShapeCode = 'UbuntuShape { \n\
6564 anchors.fill: parent; \n\
66− visible: %1; \n\
6765 source: artImage; \n\
6866 sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
6967 radius: "medium"; \n\
70− aspect: %2; \n\
68+ aspect: %1; \n\
7169 }';
7270
73−// %1 is the visible code
7471var kArtProportionalShapeCode = 'ProportionalShape { \n\
7572 anchors.fill: parent; \n\
76− visible: %1; \n\
7773 source: artImage; \n\
7874 aspect: UbuntuShape.DropShadow; \n\
7975 }';
@@ -505,18 +501,21 @@ function cardString(template, components, isCardTool, artShapeStyle) {
505501 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
506502 }
507503 var artShapeHolderShapeCode;
508− if (artShapeStyle === "icon") {
509− artShapeHolderShapeCode = kArtProportionalShapeCode.arg(isConciergeMode ? "false" : "true");
510− } else {
511− var artShapeHolderShapeAspect;
512− switch (artShapeStyle) {
513− case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
514− case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
515− default:
516− case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
504+ if (!isConciergeMode) {
505+ if (artShapeStyle === "icon") {
506+ artShapeHolderShapeCode = kArtProportionalShapeCode;
507+ } else {
508+ var artShapeHolderShapeAspect;
509+ switch (artShapeStyle) {
510+ case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
511+ case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
512+ default:
513+ case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
514+ }
515+ artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(artShapeHolderShapeAspect);
517516 }
518− artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(isConciergeMode ? "false" : "true")
519− .arg(artShapeHolderShapeAspect);
517+ } else {
518+ artShapeHolderShapeCode = "";
520519 }
521520 code += kArtShapeHolderCode.arg(artAnchors)
522521 .arg(widthCode)
tests/plugins/Dash/cardcreator/1.res−1
@@ -31,7 +31,6 @@ Item {
3131 readonly property alias image: artImage;
3232 UbuntuShape {
3333 anchors.fill: parent;
34− visible: true;
3534 source: artImage;
3635 sourceFillMode: UbuntuShape.PreserveAspectCrop;
3736 radius: "medium";
tests/plugins/Dash/cardcreator/1.res.cardcreator−1
@@ -30,7 +30,6 @@ Item {
3030 readonly property alias image: artImage;
3131 UbuntuShape {
3232 anchors.fill: parent;
33− visible: true;
3433 source: artImage;
3534 sourceFillMode: UbuntuShape.PreserveAspectCrop;
3635 radius: "medium";
tests/plugins/Dash/cardcreator/11.res−1
@@ -69,7 +69,6 @@ Item {
6969 readonly property alias image: artImage;
7070 UbuntuShape {
7171 anchors.fill: parent;
72− visible: true;
7372 source: artImage;
7473 sourceFillMode: UbuntuShape.PreserveAspectCrop;
7574 radius: "medium";
tests/plugins/Dash/cardcreator/11.res.cardcreator−1
@@ -68,7 +68,6 @@ Item {
6868 readonly property alias image: artImage;
6969 UbuntuShape {
7070 anchors.fill: parent;
71− visible: true;
7271 source: artImage;
7372 sourceFillMode: UbuntuShape.PreserveAspectCrop;
7473 radius: "medium";
tests/plugins/Dash/cardcreator/3.res−1
@@ -31,7 +31,6 @@ Item {
3131 readonly property alias image: artImage;
3232 ProportionalShape {
3333 anchors.fill: parent;
34− visible: true;
3534 source: artImage;
3635 aspect: UbuntuShape.DropShadow;
3736 }
tests/plugins/Dash/cardcreator/3.res.cardcreator−1
@@ -30,7 +30,6 @@ Item {
3030 readonly property alias image: artImage;
3131 ProportionalShape {
3232 anchors.fill: parent;
33− visible: true;
3433 source: artImage;
3534 aspect: UbuntuShape.DropShadow;
3635 }
tests/plugins/Dash/cardcreator/5.res−8
@@ -29,14 +29,6 @@ Item {
2929 objectName: "artShape";
3030 visible: image.status == Image.Ready;
3131 readonly property alias image: artImage;
32− UbuntuShape {
33− anchors.fill: parent;
34− visible: false;
35− source: artImage;
36− sourceFillMode: UbuntuShape.PreserveAspectCrop;
37− radius: "medium";
38− aspect: UbuntuShape.DropShadow;
39− }
4032 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
4133 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
4234 Component.onCompleted: { updateWidthHeightBindings(); }
tests/plugins/Dash/cardcreator/5.res.cardcreator−8
@@ -28,14 +28,6 @@ Item {
2828 objectName: "artShape";
2929 visible: image.status == Image.Ready;
3030 readonly property alias image: artImage;
31− UbuntuShape {
32− anchors.fill: parent;
33− visible: false;
34− source: artImage;
35− sourceFillMode: UbuntuShape.PreserveAspectCrop;
36− radius: "medium";
37− aspect: UbuntuShape.DropShadow;
38− }
3931 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
4032 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : 1;
4133 Component.onCompleted: { updateWidthHeightBindings(); }