on xenial help sign in
Add touchdown
5d9030bAndrea Cimitan
plugins/Dash/CardCreator.js+21−1
@@ -224,7 +224,7 @@ var kMascotImageCode = 'Image { \n\
224 }\n';
224 }\n';
225
225
226// %1 is used as anchors of titleLabel
226// %1 is used as anchors of titleLabel
227−// %1 is used as color of titleLabel
227+// %2 is used as color of titleLabel
228// %3 is used as extra condition for visible of titleLabel
228// %3 is used as extra condition for visible of titleLabel
229var kTitleLabelCode = 'Label { \n\
229var kTitleLabelCode = 'Label { \n\
230 id: titleLabel; \n\
230 id: titleLabel; \n\
@@ -242,6 +242,16 @@ var kTitleLabelCode = 'Label { \n\
242 horizontalAlignment: root.headerAlignment; \n\
242 horizontalAlignment: root.headerAlignment; \n\
243 }\n';
243 }\n';
244
244
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+
245// %1 is used as anchors of subtitleLabel
255// %1 is used as anchors of subtitleLabel
246// %2 is used as color of subtitleLabel
256// %2 is used as color of subtitleLabel
247var kSubtitleLabelCode = 'Label { \n\
257var kSubtitleLabelCode = 'Label { \n\
@@ -504,6 +514,16 @@ function cardString(template, components) {
504 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
514 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
505 }
515 }
506
516
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+
507 if (hasSummary) {
527 if (hasSummary) {
508 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
528 code += 'implicitHeight: summary.y + summary.height + (summary.text ? units.gu(1) : 0);\n';
509 } else if (hasHeaderRow) {
529 } else if (hasHeaderRow) {
tests/plugins/Dash/cardcreator/1.res+8
@@ -82,5 +82,13 @@ leftMargin: units.gu(1);
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
83 horizontalAlignment: root.headerAlignment;
83 horizontalAlignment: root.headerAlignment;
84 }
84 }
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+}
85implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
93implicitHeight: titleLabel.y + titleLabel.height + units.gu(1);
86}
94}
tests/plugins/Dash/cardcreator/2.res+8
@@ -113,5 +113,13 @@ Label {
113}
113}
114]
114]
115}
115}
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+}
116implicitHeight: row.y + row.height + units.gu(1);
124implicitHeight: row.y + row.height + units.gu(1);
117}
125}
tests/plugins/Dash/cardcreator/3.res+8
@@ -100,5 +100,13 @@ Label {
100 font.weight: Font.Light;
100 font.weight: Font.Light;
101 horizontalAlignment: root.headerAlignment;
101 horizontalAlignment: root.headerAlignment;
102 }
102 }
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+}
103implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
111implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
104}
112}
tests/plugins/Dash/cardcreator/4.res+8
@@ -94,5 +94,13 @@ Label {
94}
94}
95]
95]
96}
96}
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+}
97implicitHeight: row.y + row.height + units.gu(1);
105implicitHeight: row.y + row.height + units.gu(1);
98}
106}
tests/plugins/Dash/cardcreator/5.res+8
@@ -141,5 +141,13 @@ Label {
141 font.weight: Font.Light;
141 font.weight: Font.Light;
142 horizontalAlignment: root.headerAlignment;
142 horizontalAlignment: root.headerAlignment;
143 }
143 }
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+}
144implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
152implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
145}
153}
tests/plugins/Dash/cardcreator/6.res+8
@@ -63,5 +63,13 @@ Item {
63 }
63 }
64 }
64 }
65readonly property int headerHeight: 0;
65readonly 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+}
66implicitHeight: artShapeHolder.height;
74implicitHeight: artShapeHolder.height;
67}
75}
tests/qmltests/Dash/tst_Card.qml+12
@@ -473,5 +473,17 @@ Rectangle {
473 compare(shape !== null, data.shape);
473 compare(shape !== null, data.shape);
474 tryCompare(mascotImage, "visible", !data.shape);
474 tryCompare(mascotImage, "visible", !data.shape);
475 }
475 }
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+ }
476 }
488 }
477}
489}