2
* Copyright (C) 2014 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
\qmlproperty color color
27
property alias color: colorizedImage.keyColorOut
30
\qmlproperty color keyColor
32
property alias keyColor: colorizedImage.keyColorIn
39
/* Necessary so that icons are not loaded before a size is set. */
46
Component.onCompleted: update()
47
onWidthChanged: update()
48
onHeightChanged: update()
51
onNameChanged: image.update()
52
onSourceChanged: image.update()
56
// only set sourceSize.width, sourceSize.height and source when
57
// icon dimensions are valid, see bug #1349769.
58
if (width > 0 && height > 0 && icon.name) {
59
sourceSize.width = width;
60
sourceSize.height = height;
61
if (icon.hasOwnProperty("source")) {
64
source = "image://theme/%1".arg(icon.name);
69
sourceSize.height = 0;
74
visible: !colorizedImage.active
83
// Whether or not a color has been set.
84
property bool active: keyColorOut != Qt.rgba(0.0, 0.0, 0.0, 0.0)
86
property Image source: active && image.status == Image.Ready ? image : null
87
property color keyColorOut: Qt.rgba(0.0, 0.0, 0.0, 0.0)
88
property color keyColorIn: "#808080"
89
property real threshold: 0.1
92
varying highp vec2 qt_TexCoord0;
93
uniform sampler2D source;
94
uniform highp vec4 keyColorOut;
95
uniform highp vec4 keyColorIn;
96
uniform lowp float threshold;
97
uniform lowp float qt_Opacity;
99
lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
100
gl_FragColor = mix(vec4(keyColorOut.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, keyColorIn.rgb))) * qt_Opacity;