Debian Codegraph @

modules/Lomiri/Components/Extras/qml5/TabsBar/TabContourHalf.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
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.
12 *
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/>.
15 *
16 * Authored-by: Florian Boucault <[email protected]>
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20
21 ShaderEffect {
22 id: tabContour
23
24 property Image source: Image {
25 width: tabContour.width
26 height: tabContour.height
27 source: "tab_contour.png"
28 fillMode: Image.Pad
29 horizontalAlignment: Image.AlignLeft
30 verticalAlignment: Image.AlignTop
31 visible: false
32 cache: true
33 asynchronous: true
34 }
35
36 property color backgroundColor
37 property color contourColor
38 property color outsideColor
39 property real sourceWidth: source.paintedWidth / tabContour.width
40 property real sourceHeight: source.paintedHeight / tabContour.height
41
42 fragmentShader: "
43 varying highp vec2 qt_TexCoord0;
44 uniform sampler2D source;
45 uniform highp vec4 backgroundColor;
46 uniform highp vec4 contourColor;
47 uniform highp vec4 outsideColor;
48 uniform lowp float qt_Opacity;
49 uniform lowp float sourceWidth;
50 uniform lowp float sourceHeight;
51 void main() {
52 lowp vec4 sourceColor = texture2D(source, vec2(qt_TexCoord0.x / sourceWidth, qt_TexCoord0.y / sourceHeight));
53 lowp vec4 backgroundMix = backgroundColor * sourceColor.r;
54 lowp vec4 contourMix = contourColor * sourceColor.g;
55 lowp vec4 outsideMix = outsideColor * sourceColor.b;
56 gl_FragColor = (contourMix + backgroundMix * (1.0 - contourMix.a) + outsideMix * (1.0 - contourMix.a)) * qt_Opacity;
57 }"
58 }