Warning, /plasma/libplasma/examples/applets/testshaders/contents/ui/Shadows.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2013 Digia Plc and /or its subsidiary(-ies) <http://www.qt-project.org/legal> 0003 0004 This file is part of the examples of the Qt Toolkit. 0005 0006 SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 0009 import QtQuick 0010 //import QtQuick.Particles 0011 0012 import org.kde.plasma.components as PlasmaComponents 0013 import org.kde.ksvg as KSvg 0014 import org.kde.kirigami as Kirigami 0015 0016 ShaderExample { 0017 0018 pageName: "Shadows" 0019 pageDescription: "" 0020 Grid { 0021 id: cfgrid 0022 columns: 2 0023 0024 anchors.top: parent.top 0025 anchors.right: parent.right 0026 width: parent.width * 0.6 0027 height: 96 0028 spacing: 6 0029 columnSpacing: 12 0030 PlasmaComponents.Label { 0031 text: "Distance:"; 0032 width: parent.width * 0.5; 0033 horizontalAlignment: Text.AlignRight 0034 elide: Text.ElideRight 0035 } 0036 PlasmaComponents.Slider { 0037 width: parent.width * 0.4 0038 id: distanceSlider 0039 stepSize: 1 0040 minimumValue: 0 0041 maximumValue: 25 0042 value: 8 0043 } 0044 0045 PlasmaComponents.Label { 0046 text: "Opacity:"; 0047 horizontalAlignment: Text.AlignRight 0048 elide: Text.ElideRight 0049 width: parent.width * 0.5; 0050 } 0051 PlasmaComponents.Slider { 0052 width: parent.width * 0.4 0053 id: opacitySlider 0054 // stepSize: 250 0055 minimumValue: 0 0056 maximumValue: 1.0 0057 stepSize: 0.05 0058 value: 0.4 0059 } 0060 } 0061 0062 Item { 0063 anchors.fill: parent 0064 clip: true 0065 anchors.margins: -_s 0066 0067 Item { 0068 id: theItem 0069 anchors.fill: parent 0070 anchors.topMargin: _s * 2 0071 0072 Column { 0073 anchors.fill: parent 0074 anchors.margins: _s 0075 anchors.topMargin: _s * 2 0076 spacing: _s 0077 0078 Kirigami.Heading { 0079 text: "Effects on Components" 0080 0081 } 0082 PlasmaComponents.Label { 0083 text:"In Plasma 2, the user interface is based on an OpenGL scenegraph, composition of the UI happens on the graphics card. In the past weeks, we've been working on getting a Plasma 2 shell up and running, and on porting the QML imports of the Plasma Components." 0084 } 0085 0086 Kirigami.Heading { 0087 font.pointSize: 48 0088 anchors.horizontalCenter: parent.horizontalCenter 0089 anchors.topMargin: _s * 3 0090 text: "This is shadowy text." 0091 } 0092 Row { 0093 height: 48 0094 width: parent.width 0095 spacing: _s 0096 0097 Kirigami.Icon { 0098 source: "configure" 0099 width: parent.height 0100 height: width 0101 } 0102 Kirigami.Icon { 0103 source: "dialog-ok" 0104 width: parent.height 0105 height: width 0106 } 0107 0108 KSvg.SvgItem { 0109 id: buttonItem 0110 svg: KSvg.Svg { 0111 id: configIconsSvg 0112 imagePath: "widgets/configuration-icons" 0113 } 0114 elementId: "maximize" 0115 width: parent.height 0116 height: width 0117 } 0118 0119 Kirigami.Icon { 0120 source: "akonadi" 0121 width: parent.height 0122 height: width 0123 } 0124 Kirigami.Icon { 0125 source: "clock" 0126 width: parent.height 0127 height: width 0128 } 0129 } 0130 } 0131 } 0132 ShaderEffectSource { 0133 id: theSource 0134 sourceItem: theItem 0135 hideSource: true 0136 } 0137 0138 ShaderEffect { 0139 anchors.fill: theItem 0140 property ShaderEffectSource source: theSource 0141 property ShaderEffectSource shadow: ShaderEffectSource { 0142 sourceItem: ShaderEffect { 0143 width: theItem.width 0144 height: theItem.height 0145 property size delta: Qt.size(0.0, 1.0 / height) 0146 property ShaderEffectSource source: ShaderEffectSource { 0147 sourceItem: ShaderEffect { 0148 width: theItem.width 0149 height: theItem.height 0150 property size delta: Qt.size(1.0 / width, 0.0) 0151 property ShaderEffectSource source: theSource 0152 fragmentShader: " 0153 uniform lowp float qt_Opacity; 0154 uniform sampler2D source; 0155 uniform highp vec2 delta; 0156 varying highp vec2 qt_TexCoord0; 0157 void main() { 0158 gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) 0159 + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) 0160 + 0.2466 * texture2D(source, qt_TexCoord0) 0161 + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) 0162 + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; 0163 }" 0164 } 0165 } 0166 fragmentShader: " 0167 uniform lowp float qt_Opacity; 0168 uniform sampler2D source; 0169 uniform highp vec2 delta; 0170 varying highp vec2 qt_TexCoord0; 0171 void main() { 0172 gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) 0173 + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) 0174 + 0.2466 * texture2D(source, qt_TexCoord0) 0175 + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) 0176 + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; 0177 }" 0178 } 0179 } 0180 property real angle: 0 0181 property point offset: Qt.point(distanceSlider.value * Math.cos(angle), distanceSlider.value * Math.sin(angle)) 0182 NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } 0183 property size delta: Qt.size(offset.x / width, offset.y / height) 0184 property real darkness: opacitySlider.value // Changeme 0185 fragmentShader: " 0186 uniform lowp float qt_Opacity; 0187 uniform highp vec2 offset; 0188 uniform sampler2D source; 0189 uniform sampler2D shadow; 0190 uniform highp float darkness; 0191 uniform highp vec2 delta; 0192 varying highp vec2 qt_TexCoord0; 0193 void main() { 0194 lowp vec4 fg = texture2D(source, qt_TexCoord0); 0195 lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); 0196 gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; 0197 }" 0198 // Slider { 0199 // id: shadowSlider 0200 // anchors.left: parent.left 0201 // anchors.right: parent.right 0202 // anchors.bottom: parent.bottom 0203 // height: 40 0204 // } 0205 } 0206 0207 } 0208 }