on xenial help sign in
Add card overlay.
commitc7fbd0114a786cb2cc7a277137002b2ce76f8fd9 authorMichał Karnicki <michal.karnicki@canonical.com> dateTue 4 Feb 2014, 17:05 (13 years ago) parentc87b241
2 files changed+56−2
qml/Dash/Card.qml+55−2 tests/qmltests/Dash/tst_Card.qml+1
qml/Dash/Card.qml+55−2
@@ -58,12 +58,64 @@ Item {
5858 }
5959 }
6060
61+ ShaderEffect {
62+ id: overlay
63+ anchors {
64+ left: artShape.left
65+ right: artShape.right
66+ bottom: artShape.bottom
67+ }
68+
69+ height: units.gu(8)
70+ opacity: 0.6
71+ visible: template && template["overlay"] && artShape.visible && artShape.image.status === Image.Ready || false
72+
73+ property var source: ShaderEffectSource {
74+ id: shaderSource
75+ sourceItem: artShape
76+ onVisibleChanged: if (visible) scheduleUpdate()
77+ live: false
78+ sourceRect: Qt.rect(0, artShape.height - overlay.height, artShape.width, overlay.height)
79+ }
80+
81+ vertexShader: "
82+ uniform highp mat4 qt_Matrix;
83+ attribute highp vec4 qt_Vertex;
84+ attribute highp vec2 qt_MultiTexCoord0;
85+ varying highp vec2 coord;
86+ void main() {
87+ coord = qt_MultiTexCoord0;
88+ gl_Position = qt_Matrix * qt_Vertex;
89+ }"
90+
91+ fragmentShader: "
92+ varying highp vec2 coord;
93+ uniform sampler2D source;
94+ uniform lowp float qt_Opacity;
95+ void main() {
96+ lowp vec4 tex = texture2D(source, coord);
97+ gl_FragColor = vec4(0, 0, 0, tex.a) * qt_Opacity;
98+ }"
99+
100+ }
101+
61102 CardHeader {
62103 id: header
63104 objectName: "cardHeader"
64105 anchors {
65− top: template && template["card-layout"] === "horizontal" ? artShape.top : artShape.bottom
66− left: template && template["card-layout"] === "horizontal" ? artShape.right : parent.left
106+ top: {
107+ if (template) {
108+ if (template["overlay"]) return overlay.top;
109+ if (template["card-layout"] === "horizontal") return artShape.top;
110+ }
111+ return artShape.bottom;
112+ }
113+ left: {
114+ if (template) {
115+ if (!template["overlay"] && template["card-layout"] === "horizontal") return artShape.right;
116+ }
117+ return parent.left;
118+ }
67119 right: parent.right
68120 }
69121
@@ -73,6 +125,7 @@ Item {
73125 }
74126
75127 Label {
128+ id: summary
76129 objectName: "summaryLabel"
77130 anchors { top: header.visible ? header.bottom : artShape.bottom; left: parent.left; right: parent.right }
78131 wrapMode: Text.Wrap
tests/qmltests/Dash/tst_Card.qml+1
@@ -224,6 +224,7 @@ Rectangle {
224224 }
225225
226226 function test_card_size(data) {
227+ waitForRendering(card);
227228 selector.selectedIndex = data.index;
228229
229230 if (data.hasOwnProperty("size")) {