Warning, /plasma/libplasma/examples/applets/testshaders/contents/ui/EditorPage.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
0003
0004 SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008
0009 import org.kde.plasma.components as PlasmaComponents
0010 import org.kde.kirigami as Kirigami
0011
0012 // ButtonsPage
0013
0014 PlasmaComponents.Page {
0015 id: editorPage
0016
0017 property string shader
0018 property alias shaderText: editor.text
0019 property string pageName: "Editor"
0020 property string icon: "accessories-text-editor"
0021
0022 anchors {
0023 fill: parent
0024 margins: _s
0025 }
0026
0027 Image {
0028 id: imageItem
0029 anchors.fill: parent
0030 //source: "../images/elarun-small.png"
0031 }
0032
0033 ShaderEffectSource {
0034 id: effectSource
0035 sourceItem: imageItem
0036 //hideSource: hideSourceCheckbox.checked
0037 hideSource: true
0038 }
0039
0040 ShaderEffect {
0041 id: mainShader
0042 anchors.fill: editorPage
0043 property ShaderEffectSource source: effectSource
0044 property real f: 0
0045 property real f2: 0
0046 property int intensity: 1
0047 smooth: true
0048 }
0049 PlasmaComponents.ToolButton {
0050 iconSource: "dialog-close"
0051 width: _h
0052 height: width
0053 visible: !(mainShader.fragmentShader == "" && mainShader.vertexShader == "")
0054 anchors { top: parent.top; right: parent.right; }
0055 onClicked: {
0056 mainShader.fragmentShader = "";
0057 mainShader.vertexShader = "";
0058 editorPage.shader = ""
0059 vertexPage.shader = ""
0060 }
0061 }
0062
0063
0064 Kirigami.Heading {
0065 id: heading
0066 level: 1
0067 anchors {
0068 top: parent.top;
0069 left: parent.left
0070 right: parent.right
0071 }
0072 text: pageName
0073 }
0074 PlasmaComponents.ButtonColumn {
0075 anchors {
0076 right: parent.right
0077 top: heading.top
0078 }
0079 PlasmaComponents.RadioButton {
0080 id: fragmentRadio
0081 text: "Fragment / Pixel Shader"
0082 }
0083 PlasmaComponents.RadioButton {
0084 text: "Vertex Shader"
0085 }
0086 }
0087
0088 // PlasmaComponents.TextArea {
0089 // id: editor
0090 // anchors {
0091 // top: heading.bottom;
0092 // topMargin: _s
0093 // left: parent.left
0094 // right: parent.right
0095 // bottom: applyButton.top
0096 // wrapMode: TextEdit.Wrap
0097 // bottomMargin: _s
0098 //
0099 // }
0100 // // text: { "void main(void) {\
0101 // // gl_FragColor = vec4(1.0, 0.0, 0.0, 0.3);\
0102 // // }"
0103 // // }
0104 // text:"
0105 // void main(void) {
0106 // gl_FragColor = vec4(0.2, 0.8, 0.6, 0.3);
0107 // }
0108 // "
0109 //
0110 // // width: parent.width
0111 // // parent.height-height: _h*2
0112 // }
0113
0114 PlasmaComponents.Button {
0115 id: applyButton
0116 text: "Upload Shader"
0117 onClicked: {
0118 shader = editor.text
0119 if (fragmentRadio.checked) {
0120 print("Uploading new fragment shader: \n" + shader);
0121 mainShader.fragmentShader = shader
0122 } else {
0123 print("Uploading new vertex shader: \n" + shader);
0124 mainShader.vertexShader = shader;
0125 }
0126 }
0127
0128 anchors {
0129 right: parent.right
0130 bottom: parent.bottom
0131
0132 }
0133
0134
0135
0136 }
0137 // PlasmaComponents.CheckBox {
0138 // id: hideSourceCheckbox
0139 // text: "Hide Source Item"
0140 // anchors { bottom: parent.bottom; left: parent.left; margins: _s; }
0141 // onCheckedChanged: effectSource.hideSource = checked
0142 // }
0143
0144 }