summaryrefslogtreecommitdiff
path: root/retrace/daemon/ui/qml/mainwin.qml
blob: dcab4445598dd4ddf921d69595f6eca439393f81 (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
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
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import ApiTrace 1.0
import Qt.labs.settings 1.0

ApplicationWindow {
    width: 1000
    height: 800
    visible: true
    id: mainWindow

    Selection {
        id: selection
    }

    FrameRetrace {
        id : frameRetrace
        selection: selection
        argvZero: Qt.application.arguments[0]
        onOpenPercentChanged: {
            if (openPercent < 100) {
                progressBar.percentComplete = openPercent;
                return;
            }
            progressBar.visible = false;
            mainUI.visible = true;
        }
    }

    MessageDialog {
        id: fileError
        title: "FrameRetrace Error"
        icon: StandardIcon.Warning
        visible: false
        onAccepted: {
            visible = false
        }
    }

    Item {
        id: openfile
        anchors.fill:parent
        Component.onCompleted: visible = true
        Rectangle {
            id: imageBox
            anchors.top: parent.top
            anchors.topMargin: 100
            anchors.horizontalCenter: parent.horizontalCenter
            width: 800
            height: 200
            border.width: 1
            visible: true
            Image {
                height: 200
                width: 800
                id: appIcon
                source: "qrc:///qml/images/retracer_icon.png"
                visible: true
            }
        }
        Text {
            id: enterText
            width: 800
            anchors.centerIn: parent
            text: "trace file:"
        }
        Text {
            id: textHeight
            visible:false
            text: "ForHeight"
        }
        Rectangle {
            width: 800
            id: textBox
            border.width: 1
            height: textHeight.height * 1.5
            anchors.top: enterText.bottom
            anchors.left: enterText.left
            Flickable {
                id: flickText
                anchors.fill: parent
                contentWidth: textInput.width
                contentHeight: textInput.height
                flickableDirection: Flickable.HorizontalFlick
                clip: true
                TextInput {
                    anchors.verticalCenter: parent.verticalCenter
                    verticalAlignment: Text.AlignVCenter
                    height: textBox.height
                    width:500
                    selectByMouse: true
                    activeFocusOnPress : true
                    focus: true
                    id: textInput
                    text: ""

                    Settings {
                        property alias file_name: textInput.text
                    }
                    KeyNavigation.tab: file_rect
                    KeyNavigation.backtab: cancelButton
                }
            }
        }
        Rectangle {
            id: file_rect
            border.width: 1
            width: textBox.height
            height: textBox.height
            color: activeFocus ? "lightgrey" : "white"
            anchors.left: textBox.right
            anchors.bottom: textBox.bottom
            Text {
                anchors.centerIn: parent
                text: "?"
            }
            MouseArea {
                anchors.fill: parent
                onPressed : {
                    fileDialog.visible = true;
                }
            }
            KeyNavigation.tab: frameInput
            KeyNavigation.backtab: textInput
            Keys.onReturnPressed: {
                fileDialog.visible = true;
            }
        }
        FileDialog {
            id: fileDialog
            visible: false
            title: "Please choose a trace file"
            selectExisting: true
            selectMultiple: false
            nameFilters: [ "trace files (*.trace)", "All files (*)" ]
            onAccepted: {
                var path = fileDialog.fileUrl
                textInput.text = frameRetrace.urlToFilePath(path)
                fileDialog.visible = false
            }
        }
        Text {
            id: frameText
            anchors.top: file_rect.bottom
            anchors.topMargin: 10
            anchors.left: textBox.left
            text: "frame number:"
        }
        Rectangle {
            width: 100
            id: frameBox
            border.width: 1
            height: textHeight.height * 1.5
            anchors.top: frameText.bottom
            anchors.left: frameText.left
            TextInput {
                height: textHeight.height
                anchors.verticalCenter: parent.verticalCenter
                verticalAlignment: Text.AlignVCenter
                activeFocusOnPress : true
                width: parent.width
                selectByMouse: true
                focus: true
                id: frameInput
                text: ""
                Settings {
                    property alias frame_number: frameInput.text
                }
                KeyNavigation.tab: hostInput
                KeyNavigation.backtab: file_rect
            }
        }
        Text {
            id: hostText
            anchors.top: frameBox.bottom
            anchors.topMargin: 10
            anchors.left: frameBox.left
            text: "host:"
        }
        Rectangle {
            width: 500
            id: hostBox
            border.width: 1
            height: textHeight.height * 1.5
            anchors.top: hostText.bottom
            anchors.left: hostText.left
            TextInput {
                height: textHeight.height
                anchors.verticalCenter: parent.verticalCenter
                verticalAlignment: Text.AlignVCenter
                activeFocusOnPress : true
                width: parent.width
                selectByMouse: true
                focus: true
                id: hostInput
                text: "localhost"
                Settings {
                    property alias host_name: hostInput.text
                }
                KeyNavigation.tab: okButton
                KeyNavigation.backtab: frameInput
            }
        }
        Button {
            id: okButton
            anchors.left: hostBox.left
            anchors.top: hostBox.bottom
            anchors.topMargin: 10
            text: "OK"
            onClicked: {
                if (frameRetrace.setFrame(textInput.text, frameInput.text, hostInput.text)) {
                    openfile.visible = false
                    progressBar.visible = true
                } else {
                    fileError.text = "File not found:\n\t" + textInput.text;
                    fileError.visible = true;
                }
            }
            KeyNavigation.tab: cancelButton
            KeyNavigation.backtab: hostInput
            Keys.onReturnPressed: {
                okButton.clicked();
            }
        }
        Button {
            text: "Cancel"
            id: cancelButton
            anchors.left: okButton.right
            anchors.top: hostBox.bottom
            anchors.topMargin: 10
            anchors.leftMargin: 10
            onClicked: {
                Qt.quit();
            }
            KeyNavigation.tab: textInput
            KeyNavigation.backtab: okButton
            Keys.onReturnPressed: {
                cancelButton.clicked();
            }
        }
    }
    Item {
        id: progressBar
        visible: false
        anchors.fill: parent
        property int percentComplete
        onPercentCompleteChanged: {
            blueBar.width = percentComplete / 100 * progressBackground.width
        }
        Rectangle {
            id: progressBackground
            anchors.centerIn: parent
            color: "black"
            width: parent.width * 0.8
            height: 20
        }
        Rectangle {
            id: blueBar
            anchors.left: progressBackground.left
            anchors.top: progressBackground.top
            color: "light blue"
            width: 0
            height: 20
            z:1
        }
    }
    ColumnLayout {
        id: mainUI
        anchors.fill: parent
        visible: false

        RefreshControl {
            Layout.minimumHeight: 20
            Layout.maximumHeight: 20
            metricsModel: frameRetrace
            Layout.alignment: Qt.AlignTop
            Layout.fillWidth: true
            Layout.fillHeight: true
        }
        
        BarGraphControl {
            selection: selection
            metric_model: frameRetrace
            Layout.preferredHeight: 50
            Layout.alignment: Qt.AlignTop
            Layout.fillWidth: true
            Layout.fillHeight: true
        }

        TabView {
            Layout.preferredWidth: 400
            Layout.alignment: Qt.AlignTop
            Layout.fillWidth: true
            Layout.fillHeight: true
            Tab {
                title: "Shaders"
                anchors.fill: parent
                RenderShadersControl {
                    anchors.fill: parent
                    renderModel: frameRetrace.shaders
                }
            }
            Tab {
                title: "RenderTarget"
                Row {
                    Column {
                        id: renderOptions
                        CheckBox {
                            text: "Clear before render"
                            onCheckedChanged: {
                                frameRetrace.clearBeforeRender = checked;
                            }
                        }
                        CheckBox {
                            text: "Stop at render"
                            onCheckedChanged: {
                                frameRetrace.stopAtRender = checked;
                            }
                        }
                        CheckBox {
                            text: "Highlight selected render"
                            onCheckedChanged: {
                                frameRetrace.highlightRender = checked;
                            }
                        }
                    }
                    Item {
                        anchors.top: parent.top
                        anchors.bottom: parent.bottom
                        width: parent.width - renderOptions.width
                        Image {
                            id: rtDisplayImage
                            anchors.fill: parent
                            fillMode: Image.PreserveAspectFit
                            source: frameRetrace.renderTargetImage
                            cache: false
                        }
                    }
                }
            }
            Tab {
                title: "Api Calls"
                clip: true
                anchors.fill: parent
                ApiControl {
                    anchors.fill: parent
                    apiModel: frameRetrace.api
                }
            }
            Tab {
                title: "Metrics"
                id: metricTab
                anchors.fill: parent
                clip: true
                MetricTabControl {
                    metricsModel: frameRetrace.metricTab
                }
            }
        }
    }
}