on xenial help sign in
Fixed issue of spacing when the touchdown is on the art only
3c5db84Andrea Cimitan
plugins/Dash/CardCreator.js+22−13
@@ -227,13 +227,14 @@ var kTitleLabelCode = 'Label { \n\
227 horizontalAlignment: root.headerAlignment; \n\
227 horizontalAlignment: root.headerAlignment; \n\
228 }\n';
228 }\n';
229
229
230+// %1 is used as extra anchors of emblemImage
230var kEmblemImageCode = 'Image { \n\
231var kEmblemImageCode = 'Image { \n\
231 id: emblemImage; \n\
232 id: emblemImage; \n\
232 objectName: "emblemImage"; \n\
233 objectName: "emblemImage"; \n\
233 anchors { \n\
234 anchors { \n\
234 bottom: titleLabel.baseline; \n\
235 bottom: titleLabel.baseline; \n\
235 right: parent.right; \n\
236 right: parent.right; \n\
236− rightMargin: units.gu(1); \n\
237+ %1
237 } \n\
238 } \n\
238 source: cardData && cardData["emblem"] || ""; \n\
239 source: cardData && cardData["emblem"] || ""; \n\
239 width: height; \n\
240 width: height; \n\
@@ -394,6 +395,8 @@ function cardString(template, components) {
394 headerLeftAnchor = 'left: parent.left;\n';
395 headerLeftAnchor = 'left: parent.left;\n';
395 }
396 }
396
397
398+ var touchdownOnArtShape = !hasBackground && hasArt && !hasMascot && !hasSummary;
399+
397 if (hasHeaderRow) {
400 if (hasHeaderRow) {
398 code += 'readonly property int headerHeight: row.height;\n'
401 code += 'readonly property int headerHeight: row.height;\n'
399 } else if (hasMascot) {
402 } else if (hasMascot) {
@@ -459,6 +462,13 @@ function cardString(template, components) {
459 var titleContainerAnchors;
462 var titleContainerAnchors;
460 var titleRightAnchor;
463 var titleRightAnchor;
461
464
465+ var extraRightAnchor = '';
466+ var extraLeftAnchor = '';
467+ if (!touchdownOnArtShape) {
468+ extraRightAnchor = 'rightMargin: units.gu(1); \n';
469+ extraLeftAnchor = 'leftMargin: units.gu(1); \n';
470+ }
471+
462 if (hasMascot) {
472 if (hasMascot) {
463 titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
473 titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
464 } else {
474 } else {
@@ -466,15 +476,15 @@ function cardString(template, components) {
466 titleContainerAnchors += headerLeftAnchor;
476 titleContainerAnchors += headerLeftAnchor;
467 titleContainerAnchors += headerVerticalAnchors;
477 titleContainerAnchors += headerVerticalAnchors;
468 if (!headerLeftAnchorHasMargin) {
478 if (!headerLeftAnchorHasMargin) {
469− titleContainerAnchors += 'leftMargin: units.gu(1);\n';
479+ titleContainerAnchors += extraLeftAnchor;
470 }
480 }
471 }
481 }
472 if (hasEmblem) {
482 if (hasEmblem) {
473 titleRightAnchor = 'right: emblemImage.left; \n\
483 titleRightAnchor = 'right: emblemImage.left; \n\
474 rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0; \n';
484 rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0; \n';
475 } else {
485 } else {
476− titleRightAnchor = 'right: parent.right; \n\
486+ titleRightAnchor = 'right: parent.right; \n'
477− rightMargin: units.gu(1); \n';
487+ titleRightAnchor += extraRightAnchor;
478 }
488 }
479
489
480 if (hasTitleContainer) {
490 if (hasTitleContainer) {
@@ -483,8 +493,8 @@ function cardString(template, components) {
483 titleAnchors += 'left: parent.left; \n\
493 titleAnchors += 'left: parent.left; \n\
484 top: parent.top;';
494 top: parent.top;';
485 subtitleAnchors = 'right: parent.right; \n\
495 subtitleAnchors = 'right: parent.right; \n\
486− left: parent.left; \n\
496+ left: parent.left; \n';
487− rightMargin: units.gu(1); \n';
497+ subtitleAnchors += extraRightAnchor;
488 if (hasSubtitle) {
498 if (hasSubtitle) {
489 attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
499 attributesAnchors = subtitleAnchors + 'top: subtitleLabel.bottom;\n';
490 subtitleAnchors += 'top: titleLabel.bottom;\n';
500 subtitleAnchors += 'top: titleLabel.bottom;\n';
@@ -508,12 +518,12 @@ function cardString(template, components) {
508 titleAnchors += headerLeftAnchor;
518 titleAnchors += headerLeftAnchor;
509 titleAnchors += headerVerticalAnchors;
519 titleAnchors += headerVerticalAnchors;
510 if (!headerLeftAnchorHasMargin) {
520 if (!headerLeftAnchorHasMargin) {
511− titleAnchors += 'leftMargin: units.gu(1);\n';
521+ titleAnchors += extraLeftAnchor;
512 }
522 }
513 }
523 }
514 subtitleAnchors = 'left: titleLabel.left; \n\
524 subtitleAnchors = 'left: titleLabel.left; \n\
515− leftMargin: titleLabel.leftMargin; \n\
525+ leftMargin: titleLabel.leftMargin; \n';
516− rightMargin: units.gu(1); \n';
526+ subtitleAnchors += extraRightAnchor;
517 if (hasEmblem) {
527 if (hasEmblem) {
518 // using container
528 // using container
519 subtitleAnchors += 'right: parent.right; \n';
529 subtitleAnchors += 'right: parent.right; \n';
@@ -534,7 +544,6 @@ function cardString(template, components) {
534 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra);
544 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(titleColor).arg(titleLabelVisibleExtra);
535 var subtitleCode;
545 var subtitleCode;
536 var attributesCode;
546 var attributesCode;
537− var emblemCode;
538
547
539 // code for the title container
548 // code for the title container
540 var containerCode = [];
549 var containerCode = [];
@@ -546,11 +555,11 @@ function cardString(template, components) {
546 containerHeight += ' + subtitleLabel.height';
555 containerHeight += ' + subtitleLabel.height';
547 }
556 }
548 if (hasEmblem) {
557 if (hasEmblem) {
549− containerCode.push(kEmblemImageCode);
558+ containerCode.push(kEmblemImageCode.arg(extraRightAnchor));
550 }
559 }
551 if (hasAttributes) {
560 if (hasAttributes) {
552 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
561 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
553− containerCode.push(kAttributesRowCode.arg(attributesAnchors).arg(titleColor));
562+ containerCode.push(attributesCode);
554 containerHeight += ' + attributesRow.height';
563 containerHeight += ' + attributesRow.height';
555 }
564 }
556
565
@@ -607,7 +616,7 @@ function cardString(template, components) {
607 var touchdownAnchors;
616 var touchdownAnchors;
608 if (hasBackground) {
617 if (hasBackground) {
609 touchdownAnchors = 'fill: backgroundLoader';
618 touchdownAnchors = 'fill: backgroundLoader';
610− } else if (hasArt && !hasMascot && !hasSummary) {
619+ } else if (touchdownOnArtShape) {
611 touchdownAnchors = 'fill: artShapeHolder';
620 touchdownAnchors = 'fill: artShapeHolder';
612 } else {
621 } else {
613 touchdownAnchors = 'fill: root'
622 touchdownAnchors = 'fill: root'
tests/plugins/Dash/cardcreator/1.res−2
@@ -61,11 +61,9 @@ Label {
61 id: titleLabel;
61 id: titleLabel;
62 objectName: "titleLabel";
62 objectName: "titleLabel";
63 anchors { right: parent.right;
63 anchors { right: parent.right;
64− rightMargin: units.gu(1);
65 left: parent.left;
64 left: parent.left;
66 top: artShapeHolder.bottom;
65 top: artShapeHolder.bottom;
67 topMargin: units.gu(1);
66 topMargin: units.gu(1);
68− leftMargin: units.gu(1);
69 }
67 }
70 elide: Text.ElideRight;
68 elide: Text.ElideRight;
71 fontSize: "small";
69 fontSize: "small";
tests/plugins/Dash/cardcreator/3.res−3
@@ -61,11 +61,9 @@ Label {
61 id: titleLabel;
61 id: titleLabel;
62 objectName: "titleLabel";
62 objectName: "titleLabel";
63 anchors { right: parent.right;
63 anchors { right: parent.right;
64− rightMargin: units.gu(1);
65 left: parent.left;
64 left: parent.left;
66 top: artShapeHolder.bottom;
65 top: artShapeHolder.bottom;
67 topMargin: units.gu(1);
66 topMargin: units.gu(1);
68− leftMargin: units.gu(1);
69 }
67 }
70 elide: Text.ElideRight;
68 elide: Text.ElideRight;
71 fontSize: "small";
69 fontSize: "small";
@@ -83,7 +81,6 @@ Label {
83 objectName: "subtitleLabel";
81 objectName: "subtitleLabel";
84 anchors { left: titleLabel.left;
82 anchors { left: titleLabel.left;
85 leftMargin: titleLabel.leftMargin;
83 leftMargin: titleLabel.leftMargin;
86− rightMargin: units.gu(1);
87 right: titleLabel.right;
84 right: titleLabel.right;
88 top: titleLabel.bottom;
85 top: titleLabel.bottom;
89 }
86 }
tests/plugins/Dash/cardcreator/5.res−2
@@ -103,7 +103,6 @@ Label {
103 id: titleLabel;
103 id: titleLabel;
104 objectName: "titleLabel";
104 objectName: "titleLabel";
105 anchors { right: parent.right;
105 anchors { right: parent.right;
106− rightMargin: units.gu(1);
107 left: parent.left;
106 left: parent.left;
108 leftMargin: units.gu(1);
107 leftMargin: units.gu(1);
109 top: overlayLoader.top;
108 top: overlayLoader.top;
@@ -125,7 +124,6 @@ Label {
125 objectName: "subtitleLabel";
124 objectName: "subtitleLabel";
126 anchors { left: titleLabel.left;
125 anchors { left: titleLabel.left;
127 leftMargin: titleLabel.leftMargin;
126 leftMargin: titleLabel.leftMargin;
128− rightMargin: units.gu(1);
129 right: titleLabel.right;
127 right: titleLabel.right;
130 top: titleLabel.bottom;
128 top: titleLabel.bottom;
131 }
129 }