on xenial help sign in
Concierge mode generated code optimization

No need to create a shape that will always be non visible Approved by: Andrea Cimitan

commit4a9e68ae8affe8475807be77b80d9eed977d66b7 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 27 May 2016, 13:50 (10 years ago) parentb68371c65b4e9e
11 files changed+16−41
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/12.res−1 tests/plugins/Dash/cardcreator/12.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 }';
@@ -520,18 +516,21 @@ function cardString(template, components, isCardTool, artShapeStyle) {
520516 fallbackURICode = 'decodeURI("%1")'.arg(fallback);
521517 }
522518 var artShapeHolderShapeCode;
523− if (artShapeStyle === "icon") {
524− artShapeHolderShapeCode = kArtProportionalShapeCode.arg(isConciergeMode ? "false" : "true");
525− } else {
526− var artShapeHolderShapeAspect;
527− switch (artShapeStyle) {
528− case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
529− case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
530− default:
531− case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
519+ if (!isConciergeMode) {
520+ if (artShapeStyle === "icon") {
521+ artShapeHolderShapeCode = kArtProportionalShapeCode;
522+ } else {
523+ var artShapeHolderShapeAspect;
524+ switch (artShapeStyle) {
525+ case "inset": artShapeHolderShapeAspect = "UbuntuShape.Inset"; break;
526+ case "shadow": artShapeHolderShapeAspect = "UbuntuShape.DropShadow"; break;
527+ default:
528+ case "flat": artShapeHolderShapeAspect = "UbuntuShape.Flat"; break;
529+ }
530+ artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(artShapeHolderShapeAspect);
532531 }
533− artShapeHolderShapeCode = kArtUbuntuShapeCode.arg(isConciergeMode ? "false" : "true")
534− .arg(artShapeHolderShapeAspect);
532+ } else {
533+ artShapeHolderShapeCode = "";
535534 }
536535 code += kArtShapeHolderCode.arg(artAnchors)
537536 .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/12.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/12.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/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(); }