on xenial help sign in
Dash: Implement OverlayColor support in Cards

Approved by: Michael Terry

commitc316d84a0552d2bee3fb9447b6fcea9087e99b83 authorAlbert Astals <albert.astals@canonical.com> dateWed 6 Aug 2014, 19:37 (12 years ago) parentc3d22637ae9379
2 files changed+6−3
plugins/Dash/CardCreator.js+3−2 tests/qmltests/Dash/CardHelpers.js+3−1
plugins/Dash/CardCreator.js+3−2
@@ -114,7 +114,7 @@ var kOverlayLoaderCode = 'Loader { \n\
114114 sourceComponent: ShaderEffect { \n\
115115 id: overlay; \n\
116116 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
117− opacity: 0.6; \n\
117+ property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
118118 property var source: ShaderEffectSource { \n\
119119 id: shaderSource; \n\
120120 sourceItem: artShapeLoader.item; \n\
@@ -135,9 +135,10 @@ var kOverlayLoaderCode = 'Loader { \n\
135135 varying highp vec2 coord; \n\
136136 uniform sampler2D source; \n\
137137 uniform lowp float qt_Opacity; \n\
138+ uniform highp vec4 overlayColor; \n\
138139 void main() { \n\
139140 lowp vec4 tex = texture2D(source, coord); \n\
140− gl_FragColor = vec4(0, 0, 0, tex.a) * qt_Opacity; \n\
141+ gl_FragColor = vec4(overlayColor.r, overlayColor.g, overlayColor.b, 1) * qt_Opacity * overlayColor.a * tex.a; \n\
141142 }"; \n\
142143 } \n\
143144 }\n';
tests/qmltests/Dash/CardHelpers.js+3−1
@@ -16,7 +16,7 @@
1616
1717.pragma library
1818
19−var components = ["title", "art", "subtitle", "mascot", "emblem", "old-price", "price", "alt-price", "rating", "alt-rating", "summary", "attributes"]
19+var components = ["title", "art", "subtitle", "mascot", "emblem", "old-price", "price", "alt-price", "rating", "alt-rating", "summary", "attributes", "overlayColor"]
2020
2121var defaultLayout = ' \
2222{ \
@@ -35,6 +35,7 @@ var defaultLayout = ' \
3535 "fill-mode": "crop" \
3636 }, \
3737 "subtitle": null, \
38+ "overlayColor": null, \
3839 "mascot": null, \
3940 "emblem": null, \
4041 "old-price": null, \
@@ -60,6 +61,7 @@ var fullMapping = ' \
6061 "art": "art", \
6162 "subtitle": "subtitle", \
6263 "mascot": "mascot", \
64+ "overlayColor": "overlayColor", \
6365 "summary": "summary", \
6466 "attributes": "attributes" \
6567}'