-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControls.qml
226 lines (188 loc) · 5.09 KB
/
Controls.qml
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
Item {
id: self
property alias softness: softnessSlider.value
property alias ascend: ascendSlider.value
property alias samples: samplesSlider.value
property alias specular: specularCheckBox.checked
property alias animate: animateLightCheckBox.checked
property int colorMapSize: colorMapSizeGroup.current.size
property int lightMapSize: lightMapSizeGroup.current.size
property int specularMapSize: specularMapSizeGroup.current.size
property alias iconScale: iconScaleSlider.value
property bool isClear: iconView.model.get(iconView.currentIndex).clear === true
property var lightModel
property string currentIcon: isClear ? '' : iconView.model.get(iconView.currentIndex).name
function setCustomLightPos(pos) {
lightView.currentItem.customPos = pos;
}
ColumnLayout {
id: controlsLayout
anchors.fill: parent
Row {
Text { text: 'Softness:' }
Slider { id: softnessSlider }
}
Row {
Text { text: 'Light ascend:' }
Slider { id: ascendSlider; minimumValue: 1.1; maximumValue: 10; value: 3 }
}
Row {
Text { text: 'Samples:' }
Slider { id: samplesSlider; minimumValue: 0.1; maximumValue: 2.0; value: 0.5 }
}
CheckBox { id: specularCheckBox; text: "Specular"; checked: true }
CheckBox { id: animateLightCheckBox; text: "Animate light"; checked: true }
Item {
Layout.fillHeight: true
}
property real fboTitleWidth: 60
Row {
Text { id: colorTitle; text: 'Color:'; width: controlsLayout.fboTitleWidth }
ExclusiveGroup { id: colorMapSizeGroup }
Repeater {
model: 6
delegate: RadioButton {
property int size: Math.pow(2, index + 5)
exclusiveGroup: colorMapSizeGroup
text: size
checked: size === 512
}
}
}
Row {
Text { id: lightTitle; text: 'Light:'; width: controlsLayout.fboTitleWidth }
ExclusiveGroup { id: lightMapSizeGroup }
Repeater {
model: 6
delegate: RadioButton {
property int size: Math.pow(2, index + 5)
exclusiveGroup: lightMapSizeGroup
text: size
checked: size === 256
}
}
}
Row {
Text { id: specularTitle; text: 'Specular:'; width: controlsLayout.fboTitleWidth }
ExclusiveGroup { id: specularMapSizeGroup }
Repeater {
model: 6
delegate: RadioButton {
property int size: Math.pow(2, index + 5)
exclusiveGroup: specularMapSizeGroup
text: size
checked: size === 512
}
}
}
Row {
Text { text: 'Lights:' }
Button {
text: 'Add'
onClicked: {
var index = global.addLight({color: 'white', size: 0.5, pos: Qt.point(0.5, 0.5)});
lightView.currentIndex = index;
}
}
Button {
text: 'Remove'
onClicked: {
global.removeLight(lightView.currentIndex);
}
}
}
ListView {
id: lightView
Layout.preferredHeight: 100
Layout.fillWidth: true
model: self.lightModel
spacing: 10
orientation: ListView.Horizontal
cacheBuffer: 1000
property ColorDialog colorDialog: ColorDialog {
showAlphaChannel: true
property var light: null
property Binding colorBinding: Binding {
target: lightView.colorDialog.light
property: 'color'
value: lightView.colorDialog.currentColor
}
}
delegate: Item {
id: delegate
property point customPos
property var light: model.light
Binding {
target: delegate.light
property: 'pos'
when: !animateLightCheckBox.checked
value: delegate.customPos
}
width: 100
height: 80
Rectangle {
anchors.fill: parent
color: delegate.light.color
border.color: 'black'
border.width: delegate.ListView.isCurrentItem ? 5 : 0
}
MouseArea {
anchors.fill: parent
onPressed: delegate.ListView.view.currentIndex = model.index;
}
Button {
anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 8 }
text: 'Select'
onClicked: {
lightView.colorDialog.light = null;
lightView.colorDialog.color = delegate.light.color;
lightView.colorDialog.open();
lightView.colorDialog.light = delegate.light;
}
}
}
}
Row {
Text { text: 'Icon scale' }
Slider { id: iconScaleSlider; value: 2; minimumValue: 1; maximumValue: 5 }
}
ListView {
id: iconView
Layout.preferredHeight: 55
Layout.fillWidth: true
orientation: ListView.Horizontal
model: ListModel {
ListElement { name: "star" }
ListElement { name: "cloud" }
ListElement { name: "gear" }
ListElement { name: "leaf" }
ListElement { name: 'blender' }
ListElement { clear: true }
}
delegate: Rectangle {
id: delegate
height: ListView.view.height
width: height
radius: 10
border.color: ListView.isCurrentItem ? "black" : "transparent"
border.width: 2
Image {
anchors { fill: parent; margins: 5 }
source: model.name ? 'icons/' + model.name + ".png" : ''
}
Text {
anchors.centerIn: parent
text: model.clear ? "CLEAR" : ''
}
MouseArea {
anchors.fill: parent
onPressed: delegate.ListView.view.currentIndex = model.index;
}
}
}
}
}