-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.qml
More file actions
375 lines (321 loc) · 15.5 KB
/
Main.qml
File metadata and controls
375 lines (321 loc) · 15.5 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import OpenGLTutorial 1.0
Window {
id: mainWindow
visible: true
width: 1280
height: 720
minimumWidth: 640
minimumHeight: 480
title: qsTr("OpenGL Tutorial")
RowLayout {
id: mainLayout
visible: true
spacing: 0
anchors.fill: parent
RowLayout {
property bool hidden: false
property int panelWidth: 185
id: lessonPanel
spacing: 0
Layout.fillHeight: true
Layout.minimumWidth: (lessonPanel.hidden?
lessonPanelVisiblityButton.width :
lessonPanel.panelWidth + lessonScrollbar.width)
Layout.maximumWidth: (lessonPanel.hidden?
lessonPanelVisiblityButton.width :
lessonPanel.panelWidth + lessonScrollbar.width)
Item {
Layout.fillWidth: true
Layout.fillHeight: true
visible: !lessonPanel.hidden
Rectangle {
color: "#202020"
anchors.fill: parent
}
Flickable {
id: lessonPanelFlickable
flickableDirection: Flickable.VerticalFlick
boundsBehavior: Flickable.StopAtBounds
anchors.fill: parent
contentWidth: lessonButtonsLayout.width
contentHeight: lessonButtonsLayout.height
ScrollBar.vertical: ScrollBar {
id: lessonScrollbar
parent: lessonPanelFlickable.parent
anchors.top: lessonPanelFlickable.top
anchors.bottom: lessonPanelFlickable.bottom
anchors.right: lessonPanelFlickable.right
visible: lessonPanelFlickable.contentHeight > lessonPanelFlickable.height
background: Rectangle {
anchors.fill: parent
color: "#202020"
}
contentItem: Rectangle {
implicitWidth: 6
implicitHeight: 100
radius: width / 2
color: lessonScrollbar.pressed? "#6e6e6e" : (lessonScrollbar.hovered? "#8c8c8c" : "#aaaaaa")
}
}
ColumnLayout {
id: lessonButtonsLayout
width: lessonPanelFlickable.width - (lessonScrollbar.visible? lessonScrollbar.width : 0)
spacing: 0
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Ekran powitalny"
lessonImage.source: "Button icons/welcomeScreen.png"
glowColor: "#aafff1a5"
onClicked:
{
mainScreenLoader.sourceComponent = welcomeScreen
mainScreenLoader.item.welcomeScreenUrl = "file:///" + currentPath + "/Assets/welcomeScreen/welcomeScreen.html"
optionsPanel.visible = false
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 1: Modele oświetlenia"
lessonImage.source: "Button icons/lesson1.png"
glowColor: "#aaffdeb7"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson1Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 2: Normal mapping"
lessonImage.source: "Button icons/lesson2.png"
glowColor: "#aaaaaa"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson2Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 3: Korekcja gamma"
lessonImage.source: "Button icons/lesson4.png"
glowColor: "#aaaacbff"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson4Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 4: HDR"
lessonImage.source: "Button icons/lesson5.png"
glowColor: "#d3795d"
onClicked: {
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson5Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 5: Bloom"
lessonImage.source: "Button icons/lesson6.png"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson6Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 6: Toon outline shader"
lessonImage.source: "Button icons/lesson7.png"
glowColor: "#a89577"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson7Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 7: Symulacja wody – fale gerstnera"
lessonImage.source: "Button icons/lesson8.png"
glowColor: "#aad1d4ff"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson8Renderer"
optionsPanel.visible = true
}
}
LessonButton {
Layout.fillWidth: true
lessonTitle.text: "Lekcja 8: Bufor szablonowy – zaznaczanie obiektów"
lessonImage.source: "Button icons/lesson9.png"
glowColor: "#bb7fc46f"
onClicked:
{
mainScreenLoader.sourceComponent = openGLView
mainScreenLoader.item.rendererClass = "Lesson9Renderer"
optionsPanel.visible = true
}
}
}
}
}
Item {
Layout.fillHeight: true
Layout.minimumWidth: lessonPanelVisiblityButton.width
Layout.maximumWidth: lessonPanelVisiblityButton.height
Rectangle {
color: "#101010"
anchors.fill: parent
}
Button {
property color normalColor: "#808080"
property color hoverColor: "#a0a0a0"
id: lessonPanelVisiblityButton
width: 10
height: 60
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
background: Rectangle {
color: lessonPanelVisiblityButton.hovered?
lessonPanelVisiblityButton.hoverColor :
lessonPanelVisiblityButton.normalColor
}
contentItem: Image {
rotation: lessonPanel.hidden? 0 : 180
anchors.fill: parent
source: "Button icons/arrow.png"
fillMode: Image.PreserveAspectFit
}
onClicked: {
lessonPanel.hidden = !lessonPanel.hidden
}
}
}
}
Item {
id: contentPanel
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
color: "#cfcfcf"
anchors.fill: parent
}
Item {
anchors.bottomMargin: parent.height - optionsPanel.anchors.topMargin
anchors.fill: parent
Loader {
id: mainScreenLoader
focus: true
anchors.fill: parent
sourceComponent: welcomeScreen
onLoaded: {
forceActiveFocus()
}
onFocusChanged: console.log("focus changed to: " + focus)
}
Component {
id: openGLView
TutorialOpenGLView {
optionsReference: options
}
}
Component {
id: welcomeScreen
WelcomeScreen {
welcomeScreenUrl: "file:///" + currentPath + "/Assets/welcomeScreen/welcomeScreen.html"
}
}
}
ColumnLayout {
property bool hidden: false
property int minPanelHeight: 50
property int panelHeight: Math.min(mainWindow.height, 450)
id: optionsPanel
visible: false
anchors.topMargin: optionsPanel.visible? (Math.max(optionsPanel.hidden?
mainWindow.height - optionsPanelVisiblityButton.height :
mainWindow.height - optionsPanel.panelHeight, 0)) : mainWindow.height
anchors.fill: parent
spacing: 0
Item {
Layout.fillWidth: true
Layout.minimumHeight: optionsPanelVisiblityButton.height
Layout.maximumHeight: optionsPanelVisiblityButton.height
MouseArea {
anchors.fill: parent
cursorShape: (!optionsPanel.hidden)? Qt.SplitVCursor : Qt.ArrowCursor
drag {
target: parent.parent
axis: Drag.YAxis
}
onClicked: {
console.log(optionsPanel.x.toString() + " " + optionsPanel.y.toString() +
" " + optionsPanel.height.toString())
}
onMouseYChanged: {
if (drag.active && !optionsPanel.hidden) {
optionsPanel.panelHeight -= mouseY;
if (optionsPanel.panelHeight < optionsPanel.minPanelHeight)
{
optionsPanel.panelHeight = optionsPanel.minPanelHeight
}
else if (optionsPanel.panelHeight > mainWindow.height)
{
optionsPanel.panelHeight = mainWindow.height
}
}
}
}
Rectangle {
color: "#101010"
anchors.fill: parent
}
Button {
property color normalColor: "#808080"
property color hoverColor: "#a0a0a0"
id: optionsPanelVisiblityButton
height: 10
width: 60
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
background: Rectangle {
color: optionsPanelVisiblityButton.hovered?
optionsPanelVisiblityButton.hoverColor :
optionsPanelVisiblityButton.normalColor
}
contentItem: Image {
rotation: optionsPanel.hidden? -90 : 90
anchors.fill: parent
source: "Button icons/arrow.png"
fillMode: Image.PreserveAspectFit
}
onClicked: {
optionsPanel.hidden = !optionsPanel.hidden
}
}
}
GenericOptions {
id: options
visible: !optionsPanel.hidden
Layout.fillHeight: true
Layout.fillWidth: true
}
}
}
}
}