on xenial help sign in
Add touchdown
commit5d9030b818fe149bad35ce87d1d4955157cf884a authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 25 Jul 2014, 14:41 (12 years ago) parent3d1d3f0
8 files changed+81−1
plugins/Dash/CardCreator.js+21−1 tests/plugins/Dash/cardcreator/1.res+8 tests/plugins/Dash/cardcreator/2.res+8 tests/plugins/Dash/cardcreator/3.res+8 tests/plugins/Dash/cardcreator/4.res+8 tests/plugins/Dash/cardcreator/5.res+8 tests/plugins/Dash/cardcreator/6.res+8 tests/qmltests/Dash/tst_Card.qml+12
plugins/Dash/CardCreator.js+21−1
@@ -224,7 +224,7 @@ var kMascotImageCode = 'Image { \n\
224224 }\n';
225225
226226// %1 is used as anchors of titleLabel
227−// %1 is used as color of titleLabel
227+// %2 is used as color of titleLabel
228228// %3 is used as extra condition for visible of titleLabel
229229var kTitleLabelCode = 'Label { \n\
230230 id: titleLabel; \n\
@@ -242,6 +242,16 @@ var kTitleLabelCode = 'Label { \n\
242242 horizontalAlignment: root.headerAlignment; \n\
243243 }\n';
244244
245+// %1 is used as anchors of touchdown effect
246+var kTouchdownCode = 'UbuntuShape { \n\
247+ id: touchdown; \n\
248+ objectName: "touchdown"; \n\
249+ anchors { %1 } \n\
250+ visible: root.pressed; \n\
251+ radius: "medium"; \n\
252+ borderSource: "radius_pressed.sci" \n\
253+ }\n';
254+
245255// %1 is used as anchors of subtitleLabel
246256// %2 is used as color of subtitleLabel
247257var kSubtitleLabelCode = 'Label { \n\
@@ -504,6 +514,16 @@ function cardString(template, components) {
504514 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
505515 }
506516
517+ var touchdownAnchors;
518+ if (hasBackground) {
519+ touchdownAnchors = 'fill: backgroundLoader';
520+ } else if (hasArt && !hasMascot && !hasSummary) {
521+ touchdownAnchors = 'fill: artShapeHolder';
522+ } else {
523+ touchdownAnchors = 'fill: root'
524+ }
525+ code += kTouchdownCode.arg(touchdownAnchors);
526+
507527 if (hasSummary) {
508528 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
509529 } else if (hasHeaderRow) {
tests/plugins/Dash/cardcreator/1.res+8
@@ -82,5 +82,13 @@ leftMargin: units.gu(1);
8282 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
8383 horizontalAlignment: root.headerAlignment;
8484 }
85+UbuntuShape {
86+ id: touchdown;
87+ objectName: "touchdown";
88+ anchors { fill: artShapeHolder }
89+ visible: root.pressed;
90+ radius: "medium";
91+ borderSource: "radius_pressed.sci"
92+}
8593implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
8694}
tests/plugins/Dash/cardcreator/2.res+8
@@ -113,5 +113,13 @@ Label {
113113}
114114]
115115}
116+UbuntuShape {
117+ id: touchdown;
118+ objectName: "touchdown";
119+ anchors { fill: backgroundLoader }
120+ visible: root.pressed;
121+ radius: "medium";
122+ borderSource: "radius_pressed.sci"
123+}
116124implicitHeight: row.y + row.height + units.gu(1);
117125}
tests/plugins/Dash/cardcreator/3.res+8
@@ -100,5 +100,13 @@ Label {
100100 font.weight: Font.Light;
101101 horizontalAlignment: root.headerAlignment;
102102 }
103+UbuntuShape {
104+ id: touchdown;
105+ objectName: "touchdown";
106+ anchors { fill: artShapeHolder }
107+ visible: root.pressed;
108+ radius: "medium";
109+ borderSource: "radius_pressed.sci"
110+}
103111implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
104112}
tests/plugins/Dash/cardcreator/4.res+8
@@ -94,5 +94,13 @@ Label {
9494}
9595]
9696}
97+UbuntuShape {
98+ id: touchdown;
99+ objectName: "touchdown";
100+ anchors { fill: root }
101+ visible: root.pressed;
102+ radius: "medium";
103+ borderSource: "radius_pressed.sci"
104+}
97105implicitHeight: row.y + row.height + units.gu(1);
98106}
tests/plugins/Dash/cardcreator/5.res+8
@@ -141,5 +141,13 @@ Label {
141141 font.weight: Font.Light;
142142 horizontalAlignment: root.headerAlignment;
143143 }
144+UbuntuShape {
145+ id: touchdown;
146+ objectName: "touchdown";
147+ anchors { fill: artShapeHolder }
148+ visible: root.pressed;
149+ radius: "medium";
150+ borderSource: "radius_pressed.sci"
151+}
144152implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
145153}
tests/plugins/Dash/cardcreator/6.res+8
@@ -63,5 +63,13 @@ Item {
6363 }
6464 }
6565readonly property int headerHeight: 0;
66+UbuntuShape {
67+ id: touchdown;
68+ objectName: "touchdown";
69+ anchors { fill: artShapeHolder }
70+ visible: root.pressed;
71+ radius: "medium";
72+ borderSource: "radius_pressed.sci"
73+}
6674implicitHeight: artShapeHolder.height;
6775}
tests/qmltests/Dash/tst_Card.qml+12
@@ -473,5 +473,17 @@ Rectangle {
473473 compare(shape !== null, data.shape);
474474 tryCompare(mascotImage, "visible", !data.shape);
475475 }
476+
477+ function test_touchdown_visibility() {
478+ selector.selectedIndex = 0;
479+
480+ var touchdown = findChild(card, "touchdown");
481+
482+ compare(touchdown.visible, false);
483+ mousePress(card, card.width/2, card.height/2);
484+ compare(touchdown.visible, true);
485+ mouseRelease(card, card.width/2, card.height/2);
486+ compare(touchdown.visible, false);
487+ }
476488 }
477489}