blob: f12e0520a95dbfc1c71f236f04173a3fa28a0d06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QQEMLib 1.0
Item {
id: mainView
property alias effectManager: effectManager
property alias outputView: outputView
property alias outputEditorView: outputView.outputEditorView
property alias nodeViewItem: nodeViewItem
property alias propertyEditDialog: propertyEditDialog
property alias currentEditorComponent: codeEditorView.currentEditorComponent
property alias mainToolbar: mainToolbar
property color highlightColor: "#2aafd3"
property color backgroundColor1: "#1f1f1f"
property color backgroundColor2: "#2e2f30"
property color foregroundColor1: "#606060"
property color foregroundColor2: "#dadada"
property bool previewAnimationRunning: false
// True = design mode, false = coding mode.
property alias designMode: mainToolbar.designMode
property alias designModeAnimated: mainToolbar.designModeAnimated
property bool switchDesignModeInstantly: false
// Initial sizes, can be adjusted by user
property real designViewWidth: 0.3
property real codeViewWidth: 0.6
property real currentLeftViewWidth: designMode ? designViewWidth : codeViewWidth
property bool showFindBar: false
anchors.fill: parent
function updateShaders(forceUpdate) {
nodeViewItem.selectedNodeQmlCode = codeEditorView.qmlText;
nodeViewItem.selectedNodeFragmentCode = codeEditorView.fragmentText;
nodeViewItem.selectedNodeVertexCode = codeEditorView.vertexText;
effectManager.updateQmlComponent();
effectManager.bakeShaders(forceUpdate);
}
Behavior on currentLeftViewWidth {
enabled: !mainSplitView.resizing && !switchDesignModeInstantly
NumberAnimation {
duration: 400
easing.type: Easing.InOutQuad
}
}
PropertyEditDialog {
id: propertyEditDialog
}
EffectManager {
id: effectManager
nodeView: nodeViewItem
vertexShader: outputEditorView.vertexEditor.text
fragmentShader: outputEditorView.fragmentEditor.text
onVertexShaderChanged: {
outputEditorView.vertexEditor.text = effectManager.vertexShader
}
onFragmentShaderChanged: {
outputEditorView.fragmentEditor.text = effectManager.fragmentShader
}
onQmlComponentStringChanged: {
outputEditorView.qmlEditor.text = effectManager.qmlComponentString
}
Component.onCompleted: {
// Initialize
effectManager.bakeShaders(true);
}
}
CustomSplitView {
id: mainSplitView
anchors.fill: parent
orientation: Qt.Horizontal
Item {
SplitView.preferredWidth: mainView.width * currentLeftViewWidth
SplitView.minimumWidth: mainView.width * 0.2
SplitView.maximumWidth: mainView.width * 0.8
clip: true
onWidthChanged: {
if (mainSplitView.resizing) {
// User is moving the SplitView separator, so store
// the updated width into current mode.
var newWidth = width / mainSplitView.width;
if (designMode)
designViewWidth = newWidth;
else
codeViewWidth = newWidth;
}
}
MainToolbar {
id: mainToolbar
width: parent.width
height: 50
z: 2
}
NodeView {
id: nodeViewItem
anchors.top: mainToolbar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
opacity: designModeAnimated
visible: opacity && initialized
}
Item {
anchors.top: mainToolbar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
opacity: 1.0 - designModeAnimated
visible: opacity
EditorView {
id: codeEditorView
anchors.fill: parent
fragmentText: nodeViewItem.selectedNodeFragmentCode
onFragmentTextChanged: {
shaderUpdateTimer.restart();
}
vertexText: nodeViewItem.selectedNodeVertexCode
onVertexTextChanged: {
shaderUpdateTimer.restart();
}
qmlText: nodeViewItem.selectedNodeQmlCode
onQmlTextChanged: {
shaderUpdateTimer.restart();
}
visible: nodeViewItem.effectNodeSelected || nodeViewItem.mainNodeSelected
Timer {
id: shaderUpdateTimer
interval: 1
onTriggered: {
// Update with a small delay to synchronize vs & fs updates
updateShaders(false);
}
}
}
Text {
anchors.centerIn: parent
font.pixelSize: 14
color: mainView.foregroundColor1
text: "Select an effect node to see its code."
visible: !codeEditorView.visible
}
}
}
CustomSplitView {
SplitView.fillWidth: true
orientation: Qt.Vertical
clip: true
PropertiesView {
id: propertiesView
SplitView.preferredHeight: 200
}
OutputView {
id: outputView
SplitView.fillHeight: true
SplitView.minimumHeight: 48
}
}
}
}
|