2 * Copyright (C) 2016 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/>.
18import QtGraphicalEffects 1.0
19import Lomiri.Components 1.3
22 property real fadeDistance: units.gu(8)
24 layer.enabled: contentWidth > width
25 layer.effect: ShaderEffect {
26 property real fadeThreshold: Math.min(1, Math.max(0, 1 - fadeDistance / width))
29 varying highp vec2 qt_TexCoord0;
30 uniform lowp float qt_Opacity;
31 uniform sampler2D source;
32 uniform lowp float fadeThreshold;
35 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
36 lowp float alpha = 1.0;
37 if (qt_TexCoord0.x > fadeThreshold && fadeThreshold < 1.0)
38 alpha = (1.0 - qt_TexCoord0.x) / (1.0 - fadeThreshold);
39 gl_FragColor = sourceColor * alpha * qt_Opacity;