on xenial help sign in
Put the touchdown shape inside a loader

We only create the shape when needed, saving a bit of CPU time when we're just scrolling around the scopes Doesn't seem to make the touchdown appear time on press noticeably slower Approved by: Andrea Cimitan, Josh Arenson, Michael Terry, Unity8 CI Bot

commitf1fb224ab21255dc9d0ec166e47872c8c3954a59 authorAlbert Astals Cid <albert.astals@canonical.com> dateThu 22 Sep 2016, 07:33 (10 years ago) parent7eca926b223835
17 files changed+150−105
plugins/Dash/CardCreator.js+8−6 tests/plugins/Dash/cardcreator/1.res+8−6 tests/plugins/Dash/cardcreator/1.res.cardcreator+8−6 tests/plugins/Dash/cardcreator/11.res+10−8 tests/plugins/Dash/cardcreator/11.res.cardcreator+10−8 tests/plugins/Dash/cardcreator/12.res+8−6 tests/plugins/Dash/cardcreator/12.res.cardcreator+8−6 tests/plugins/Dash/cardcreator/4.res+8−6 tests/plugins/Dash/cardcreator/4.res.cardcreator+8−6 tests/plugins/Dash/cardcreator/6.res+8−6 tests/plugins/Dash/cardcreator/6.res.cardcreator+8−6 tests/plugins/Dash/cardcreator/8.res+8−6 tests/plugins/Dash/cardcreator/8.res.cardcreator+8−6 tests/plugins/Dash/cardcreator/9.res+10−8 tests/plugins/Dash/cardcreator/9.res.cardcreator+10−8 tests/qmltests/Dash/tst_Card.qml+7−2 tests/qmltests/Dash/tst_GenericScopeView.qml+15−5
plugins/Dash/CardCreator.js+8−6
@@ -331,13 +331,15 @@ var kEmblemIconCode = 'Icon { \n\
331331 }\n';
332332
333333// %1 is used as anchors of touchdown effect
334−var kTouchdownCode = 'UbuntuShape { \n\
335− id: touchdown; \n\
336− objectName: "touchdown"; \n\
334+var kTouchdownCode = 'Loader { \n\
335+ active: root.pressed; \n\
337336 anchors { %1 } \n\
338− visible: root.pressed; \n\
339− radius: "medium"; \n\
340− borderSource: "radius_pressed.sci" \n\
337+ sourceComponent: UbuntuShape { \n\
338+ objectName: "touchdown"; \n\
339+ anchors.fill: parent; \n\
340+ radius: "medium"; \n\
341+ borderSource: "radius_pressed.sci" \n\
342+ } \n\
341343 }\n';
342344
343345// %1 is used as anchors of subtitleLabel
tests/plugins/Dash/cardcreator/1.res+8−6
@@ -69,13 +69,15 @@ Label {
6969 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
7070 horizontalAlignment: Text.AlignHCenter;
7171 }
72−UbuntuShape {
73− id: touchdown;
74− objectName: "touchdown";
72+Loader {
73+ active: root.pressed;
7574 anchors { fill: artShapeLoader }
76− visible: root.pressed;
77− radius: "medium";
78− borderSource: "radius_pressed.sci"
75+ sourceComponent: UbuntuShape {
76+ objectName: "touchdown";
77+ anchors.fill: parent;
78+ radius: "medium";
79+ borderSource: "radius_pressed.sci"
80+ }
7981}
8082implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8183}
tests/plugins/Dash/cardcreator/1.res.cardcreator+8−6
@@ -65,13 +65,15 @@ Label {
6565 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
6666 horizontalAlignment: Text.AlignHCenter;
6767 }
68−UbuntuShape {
69− id: touchdown;
70− objectName: "touchdown";
68+Loader {
69+ active: root.pressed;
7170 anchors { fill: artShapeLoader }
72− visible: root.pressed;
73− radius: "medium";
74− borderSource: "radius_pressed.sci"
71+ sourceComponent: UbuntuShape {
72+ objectName: "touchdown";
73+ anchors.fill: parent;
74+ radius: "medium";
75+ borderSource: "radius_pressed.sci"
76+ }
7577}
7678implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
7779}
tests/plugins/Dash/cardcreator/11.res+10−8
@@ -163,13 +163,15 @@ top: titleLabel.bottom;
163163
164164 ]
165165 }
166−UbuntuShape {
167− id: touchdown;
168− objectName: "touchdown";
169− anchors { fill: backgroundLoader }
170− visible: root.pressed;
171− radius: "medium";
172− borderSource: "radius_pressed.sci"
173− }
166+Loader {
167+ active: root.pressed;
168+ anchors { fill: backgroundLoader }
169+ sourceComponent: UbuntuShape {
170+ objectName: "touchdown";
171+ anchors.fill: parent;
172+ radius: "medium";
173+ borderSource: "radius_pressed.sci"
174+ }
175+}
174176implicitHeight: row.y + row.height + units.gu(1);
175177}
tests/plugins/Dash/cardcreator/11.res.cardcreator+10−8
@@ -156,13 +156,15 @@ top: titleLabel.bottom;
156156
157157 ]
158158 }
159−UbuntuShape {
160− id: touchdown;
161− objectName: "touchdown";
162− anchors { fill: backgroundLoader }
163− visible: root.pressed;
164− radius: "medium";
165− borderSource: "radius_pressed.sci"
166− }
159+Loader {
160+ active: root.pressed;
161+ anchors { fill: backgroundLoader }
162+ sourceComponent: UbuntuShape {
163+ objectName: "touchdown";
164+ anchors.fill: parent;
165+ radius: "medium";
166+ borderSource: "radius_pressed.sci"
167+ }
168+}
167169implicitHeight: row.y + row.height + units.gu(1);
168170}
tests/plugins/Dash/cardcreator/12.res+8−6
@@ -95,13 +95,15 @@ CardSocialActions {
9595 model: cardData && cardData["socialActions"];
9696 onClicked: root.action(actionId);
9797}
98−UbuntuShape {
99− id: touchdown;
100− objectName: "touchdown";
98+Loader {
99+ active: root.pressed;
101100 anchors { fill: artShapeLoader }
102− visible: root.pressed;
103− radius: "medium";
104− borderSource: "radius_pressed.sci"
101+ sourceComponent: UbuntuShape {
102+ objectName: "touchdown";
103+ anchors.fill: parent;
104+ radius: "medium";
105+ borderSource: "radius_pressed.sci"
106+ }
105107}
106108implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
107109}
tests/plugins/Dash/cardcreator/12.res.cardcreator+8−6
@@ -91,13 +91,15 @@ CardSocialActions {
9191 model: cardData && cardData["socialActions"];
9292 onClicked: root.action(actionId);
9393}
94−UbuntuShape {
95− id: touchdown;
96− objectName: "touchdown";
94+Loader {
95+ active: root.pressed;
9796 anchors { fill: artShapeLoader }
98− visible: root.pressed;
99− radius: "medium";
100− borderSource: "radius_pressed.sci"
97+ sourceComponent: UbuntuShape {
98+ objectName: "touchdown";
99+ anchors.fill: parent;
100+ radius: "medium";
101+ borderSource: "radius_pressed.sci"
102+ }
101103}
102104implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
103105}
tests/plugins/Dash/cardcreator/4.res+8−6
@@ -98,13 +98,15 @@ Label {
9898}
9999]
100100}
101−UbuntuShape {
102− id: touchdown;
103− objectName: "touchdown";
101+Loader {
102+ active: root.pressed;
104103 anchors { fill: root }
105− visible: root.pressed;
106− radius: "medium";
107− borderSource: "radius_pressed.sci"
104+ sourceComponent: UbuntuShape {
105+ objectName: "touchdown";
106+ anchors.fill: parent;
107+ radius: "medium";
108+ borderSource: "radius_pressed.sci"
109+ }
108110}
109111implicitHeight: row.y + row.height + units.gu(1);
110112}
tests/plugins/Dash/cardcreator/4.res.cardcreator+8−6
@@ -95,13 +95,15 @@ Label {
9595}
9696]
9797}
98−UbuntuShape {
99− id: touchdown;
100− objectName: "touchdown";
98+Loader {
99+ active: root.pressed;
101100 anchors { fill: root }
102− visible: root.pressed;
103− radius: "medium";
104− borderSource: "radius_pressed.sci"
101+ sourceComponent: UbuntuShape {
102+ objectName: "touchdown";
103+ anchors.fill: parent;
104+ radius: "medium";
105+ borderSource: "radius_pressed.sci"
106+ }
105107}
106108implicitHeight: row.y + row.height + units.gu(1);
107109}
tests/plugins/Dash/cardcreator/6.res+8−6
@@ -114,13 +114,15 @@ Item {
114114
115115 ]
116116 }
117−UbuntuShape {
118− id: touchdown;
119− objectName: "touchdown";
117+Loader {
118+ active: root.pressed;
120119 anchors { fill: backgroundLoader }
121− visible: root.pressed;
122− radius: "medium";
123− borderSource: "radius_pressed.sci"
120+ sourceComponent: UbuntuShape {
121+ objectName: "touchdown";
122+ anchors.fill: parent;
123+ radius: "medium";
124+ borderSource: "radius_pressed.sci"
125+ }
124126}
125127implicitHeight: headerTitleContainer.y + headerTitleContainer.height + units.gu(1);
126128}
tests/plugins/Dash/cardcreator/6.res.cardcreator+8−6
@@ -112,13 +112,15 @@ Item {
112112
113113 ]
114114 }
115−UbuntuShape {
116− id: touchdown;
117− objectName: "touchdown";
115+Loader {
116+ active: root.pressed;
118117 anchors { fill: backgroundLoader }
119− visible: root.pressed;
120− radius: "medium";
121− borderSource: "radius_pressed.sci"
118+ sourceComponent: UbuntuShape {
119+ objectName: "touchdown";
120+ anchors.fill: parent;
121+ radius: "medium";
122+ borderSource: "radius_pressed.sci"
123+ }
122124}
123125implicitHeight: headerTitleContainer.y + headerTitleContainer.height + units.gu(1);
124126}
tests/plugins/Dash/cardcreator/8.res+8−6
@@ -96,13 +96,15 @@ left: parent.left;
9696
9797 ]
9898 }
99−UbuntuShape {
100− id: touchdown;
101− objectName: "touchdown";
99+Loader {
100+ active: root.pressed;
102101 anchors { fill: backgroundLoader }
103− visible: root.pressed;
104− radius: "medium";
105− borderSource: "radius_pressed.sci"
102+ sourceComponent: UbuntuShape {
103+ objectName: "touchdown";
104+ anchors.fill: parent;
105+ radius: "medium";
106+ borderSource: "radius_pressed.sci"
107+ }
106108}
107109implicitHeight: row.y + row.height + units.gu(1);
108110}
tests/plugins/Dash/cardcreator/8.res.cardcreator+8−6
@@ -93,13 +93,15 @@ left: parent.left;
9393
9494 ]
9595 }
96−UbuntuShape {
97− id: touchdown;
98− objectName: "touchdown";
96+Loader {
97+ active: root.pressed;
9998 anchors { fill: backgroundLoader }
100− visible: root.pressed;
101− radius: "medium";
102− borderSource: "radius_pressed.sci"
99+ sourceComponent: UbuntuShape {
100+ objectName: "touchdown";
101+ anchors.fill: parent;
102+ radius: "medium";
103+ borderSource: "radius_pressed.sci"
104+ }
103105}
104106implicitHeight: row.y + row.height + units.gu(1);
105107}
tests/plugins/Dash/cardcreator/9.res+10−8
@@ -107,13 +107,15 @@ CardAudioProgress {
107107 onPressAndHold: {
108108 root.pressAndHold();
109109 }
110− }UbuntuShape {
111− id: touchdown;
112− objectName: "touchdown";
113− anchors { fill: root }
114− visible: root.pressed;
115− radius: "medium";
116− borderSource: "radius_pressed.sci"
117− }
110+ }Loader {
111+ active: root.pressed;
112+ anchors { fill: root }
113+ sourceComponent: UbuntuShape {
114+ objectName: "touchdown";
115+ anchors.fill: parent;
116+ radius: "medium";
117+ borderSource: "radius_pressed.sci"
118+ }
119+}
118120implicitHeight: audioButton.height;
119121}
tests/plugins/Dash/cardcreator/9.res.cardcreator+10−8
@@ -105,13 +105,15 @@ CardAudioProgress {
105105 onPressAndHold: {
106106 root.pressAndHold();
107107 }
108− }UbuntuShape {
109− id: touchdown;
110− objectName: "touchdown";
111− anchors { fill: root }
112− visible: root.pressed;
113− radius: "medium";
114− borderSource: "radius_pressed.sci"
115− }
108+ }Loader {
109+ active: root.pressed;
110+ anchors { fill: root }
111+ sourceComponent: UbuntuShape {
112+ objectName: "touchdown";
113+ anchors.fill: parent;
114+ radius: "medium";
115+ borderSource: "radius_pressed.sci"
116+ }
117+}
116118implicitHeight: audioButton.height;
117119}
tests/qmltests/Dash/tst_Card.qml+7−2
@@ -618,12 +618,17 @@ Rectangle {
618618 waitForRendering(card);
619619
620620 var touchdown = findChild(card, "touchdown");
621+ compare(touchdown, null);
621622
622− compare(touchdown.visible, false);
623623 mousePress(card);
624+
625+ touchdown = findChild(card, "touchdown");
624626 compare(touchdown.visible, true);
627+
625628 mouseRelease(card);
626− compare(touchdown.visible, false);
629+
630+ touchdown = findChild(card, "touchdown");
631+ compare(touchdown, null);
627632 }
628633
629634 function test_paddings_data() {
tests/qmltests/Dash/tst_GenericScopeView.qml+15−5
@@ -629,11 +629,15 @@ Item {
629629 var item0 = findChild(cardGrid, "delegate0");
630630 waitForRendering(item0);
631631 compare(item0.enabled, false);
632+
632633 var touchdown = findChild(item0, "touchdown");
634+ compare(touchdown, null);
633635
634− compare(touchdown.visible, false);
635636 mousePress(item0);
636− compare(touchdown.visible, false);
637+
638+ touchdown = findChild(item0, "touchdown");
639+ compare(touchdown, null);
640+
637641 mouseRelease(item0);
638642
639643 cardTool.template["non-interactive"] = false;
@@ -643,13 +647,19 @@ Item {
643647 waitForRendering(category0);
644648 item0 = findChild(cardGrid, "delegate0");
645649 compare(item0.enabled, true);
646− var touchdown = findChild(item0, "touchdown");
647650
648− compare(touchdown.visible, false);
651+ touchdown = findChild(item0, "touchdown");
652+ compare(touchdown, null);
653+
649654 mousePress(item0);
655+
656+ touchdown = findChild(item0, "touchdown");
650657 compare(touchdown.visible, true);
658+
651659 mouseRelease(item0);
652− compare(touchdown.visible, false);
660+
661+ touchdown = findChild(item0, "touchdown");
662+ compare(touchdown, null);
653663 closePreview();
654664 }
655665