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
commit9552e73433f81eaa5add260453e8958ff491fa9d
authorAlbert Astals Cid <albert.astals@canonical.com>
dateThu 21 Jul 2016, 11:34 (10 years ago)
parent65b1efb
plugins/Dash/CardCreator.js+8−6
@@ -339,13 +339,15 @@ var kEmblemIconCode = 'Icon { \n\
339339 }\n';
340340
341341// %1 is used as anchors of touchdown effect
342−var kTouchdownCode = 'UbuntuShape { \n\
343− id: touchdown; \n\
344− objectName: "touchdown"; \n\
342+var kTouchdownCode = 'Loader { \n\
343+ active: root.pressed; \n\
345344 anchors { %1 } \n\
346− visible: root.pressed; \n\
347− radius: "medium"; \n\
348− borderSource: "radius_pressed.sci" \n\
345+ sourceComponent: UbuntuShape { \n\
346+ objectName: "touchdown"; \n\
347+ anchors.fill: parent; \n\
348+ radius: "medium"; \n\
349+ borderSource: "radius_pressed.sci" \n\
350+ } \n\
349351 }\n';
350352
351353// %1 is used as anchors of subtitleLabel
tests/plugins/Dash/cardcreator/1.res+8−6
@@ -72,13 +72,15 @@ Label {
7272 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
7373 horizontalAlignment: Text.AlignHCenter;
7474 }
75−UbuntuShape {
76− id: touchdown;
77− objectName: "touchdown";
75+Loader {
76+ active: root.pressed;
7877 anchors { fill: artShapeHolder }
79− visible: root.pressed;
80− radius: "medium";
81− borderSource: "radius_pressed.sci"
78+ sourceComponent: UbuntuShape {
79+ objectName: "touchdown";
80+ anchors.fill: parent;
81+ radius: "medium";
82+ borderSource: "radius_pressed.sci"
83+ }
8284}
8385implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8486}
tests/plugins/Dash/cardcreator/1.res.cardcreator+8−6
@@ -70,13 +70,15 @@ Label {
7070 font.weight: cardData && cardData["subtitle"] ? Font.DemiBold : Font.Normal;
7171 horizontalAlignment: Text.AlignHCenter;
7272 }
73−UbuntuShape {
74− id: touchdown;
75− objectName: "touchdown";
73+Loader {
74+ active: root.pressed;
7675 anchors { fill: artShapeHolder }
77− visible: root.pressed;
78− radius: "medium";
79− borderSource: "radius_pressed.sci"
76+ sourceComponent: UbuntuShape {
77+ objectName: "touchdown";
78+ anchors.fill: parent;
79+ radius: "medium";
80+ borderSource: "radius_pressed.sci"
81+ }
8082}
8183implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8284}
tests/plugins/Dash/cardcreator/11.res+10−8
@@ -166,13 +166,15 @@ top: titleLabel.bottom;
166166
167167 ]
168168 }
169−UbuntuShape {
170− id: touchdown;
171− objectName: "touchdown";
172− anchors { fill: backgroundLoader }
173− visible: root.pressed;
174− radius: "medium";
175− borderSource: "radius_pressed.sci"
176− }
169+Loader {
170+ active: root.pressed;
171+ anchors { fill: backgroundLoader }
172+ sourceComponent: UbuntuShape {
173+ objectName: "touchdown";
174+ anchors.fill: parent;
175+ radius: "medium";
176+ borderSource: "radius_pressed.sci"
177+ }
178+}
177179implicitHeight: row.y + row.height + units.gu(1);
178180}
tests/plugins/Dash/cardcreator/11.res.cardcreator+10−8
@@ -161,13 +161,15 @@ top: titleLabel.bottom;
161161
162162 ]
163163 }
164−UbuntuShape {
165− id: touchdown;
166− objectName: "touchdown";
167− anchors { fill: backgroundLoader }
168− visible: root.pressed;
169− radius: "medium";
170− borderSource: "radius_pressed.sci"
171− }
164+Loader {
165+ active: root.pressed;
166+ anchors { fill: backgroundLoader }
167+ sourceComponent: UbuntuShape {
168+ objectName: "touchdown";
169+ anchors.fill: parent;
170+ radius: "medium";
171+ borderSource: "radius_pressed.sci"
172+ }
173+}
172174implicitHeight: row.y + row.height + units.gu(1);
173175}
tests/plugins/Dash/cardcreator/12.res+8−6
@@ -98,13 +98,15 @@ CardSocialActions {
9898 model: cardData && cardData["socialActions"];
9999 onClicked: root.action(actionId);
100100}
101−UbuntuShape {
102− id: touchdown;
103− objectName: "touchdown";
101+Loader {
102+ active: root.pressed;
104103 anchors { fill: artShapeHolder }
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: socialActionsRow.y + socialActionsRow.height + units.gu(1);
110112}
tests/plugins/Dash/cardcreator/12.res.cardcreator+8−6
@@ -96,13 +96,15 @@ CardSocialActions {
9696 model: cardData && cardData["socialActions"];
9797 onClicked: root.action(actionId);
9898}
99−UbuntuShape {
100− id: touchdown;
101− objectName: "touchdown";
99+Loader {
100+ active: root.pressed;
102101 anchors { fill: artShapeHolder }
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: socialActionsRow.y + socialActionsRow.height + units.gu(1);
108110}
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() {