summaryrefslogtreecommitdiffstats
path: root/tools/qqem/qml/PropertiesView.qml
blob: 19a638f859dc0c45636cd22567664ad0ea54e2ee (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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
// 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 QtQuick.Dialogs
import QQEMLib 1.0

Item {
    id: rootItem
    property alias uniformModel: uniformTable.model
    property bool showSettings: false
    property real showSettingsAnimated: showSettings

    function truncateString(str, n) {
        return (str.length > n) ? str.substr(0, n - 3) + '...' : str;
    }

    Behavior on showSettingsAnimated {
        NumberAnimation {
            duration: 500
            easing.type: Easing.InOutQuad
        }
    }

    FileDialog {
        id: textureSourceDialog

        property int modelIndex: -1

        title: "Select an Image File"
        nameFilters: [ effectManager.getSupportedImageFormatsFilter() ]
        onAccepted: {
            if (textureSourceDialog.selectedFile !== null) {
                effectManager.uniformModel.setImage(modelIndex, textureSourceDialog.selectedFile);
            }
        }
    }

    ColorDialog {
        id: colorPickerDialog
        property var propertyItem: null
        property color initialColor: "#000000"
        options: ColorDialog.ShowAlphaChannel

        onSelectedColorChanged: {
            if (propertyItem)
                propertyItem.updateValue(selectedColor);
        }
        onAccepted: {
            if (propertyItem)
                propertyItem.updateValue(selectedColor);
        }
        onRejected: {
            if (propertyItem)
                propertyItem.updateValue(initialColor);
        }
    }

    Rectangle {
        anchors.fill: parent
        color: mainView.backgroundColor1
    }

    ColumnLayout {
        anchors.fill: parent
        clip: true
        spacing: 0
        Item {
            Layout.fillWidth: true
            height: childrenRect.height + 10
            Row {
                id: columnsHeader
                Layout.fillWidth: true
                spacing: 10
                Item {
                    id: addPropertyButton
                    width: 10 + (1.0 - designModeAnimated) * uniformTable.columnWidth(0)
                    height: parent.height
                    opacity: (1.0 - designModeAnimated)
                    CustomIconButton {
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.right: parent.right
                        height: 24
                        width: height
                        icon: "images/icon_add.png"
                        enabled: !designMode && effectManager.nodeView.effectNodeSelected
                        description: "Add property"
                        onClicked: {
                            mainWindow.addPropertyAction();
                        }
                    }
                }
                Label {
                    anchors.verticalCenter: parent.verticalCenter
                    width: uniformTable.columnWidth(1)
                    text: "TYPE"
                    verticalAlignment: Text.AlignVCenter
                    font.pixelSize: 12
                    font.bold: true
                }
                Label {
                    anchors.verticalCenter: parent.verticalCenter
                    width: uniformTable.columnWidth(2)
                    text: "NAME"
                    verticalAlignment: Text.AlignVCenter
                    font.pixelSize: 12
                    font.bold: true
                }
                Label {
                    anchors.verticalCenter: parent.verticalCenter
                    width: uniformTable.columnWidth(3)
                    text: "VALUE"
                    verticalAlignment: Text.AlignVCenter
                    font.pixelSize: 12
                    font.bold: true
                }
                Item {
                    width: uniformTable.columnWidth(4)
                    height: 1
                }
                CustomIconButton {
                    anchors.verticalCenter: parent.verticalCenter
                    height: 24
                    width: height
                    icon: "images/icon_settings.png"
                    toggledIcon: "images/icon_settings_on.png"
                    toggleButton: true
                    toggled: showSettings
                    description: "Show / hide property settings"
                    onClicked: {
                        showSettings = !showSettings;
                    }
                }
            }
        }
        Rectangle {
            Layout.fillWidth: true
            height: 1
            z: -1
            color: mainView.backgroundColor2
        }
        ListView {
            id: uniformTable
            Layout.fillHeight: true
            Layout.fillWidth: true
            flickableDirection: Flickable.VerticalFlick
            model: effectManager.uniformModel
            clip: true
            cacheBuffer: 10000
            ScrollBar.vertical: ScrollBar {
                policy: ScrollBar.AlwaysOn
            }

            property var typeStrings: [
                "bool",
                "int",
                "float",
                "vec2",
                "vec3",
                "vec4",
                "color",
                "image",
                "define"
            ]

            function convertValueToString(value, type) {
                if (type === 0) {
                    // bool
                    return String(value);
                } if (type === 1) {
                    // int
                    return String(value.toFixed(0));
                } if (type === 2) {
                    // float
                    return String(value.toFixed(3));
                } if (type === 3) {
                    // vec2
                    return "(" + value.x.toFixed(3) + ", " + value.y.toFixed(3) + ")"
                } if (type === 4) {
                    // vec3
                    return "(" + value.x.toFixed(3) + ", " + value.y.toFixed(3) + ", " + value.z.toFixed(3) + ")"
                } if (type === 5) {
                    // vec4
                    return "(" + value.x.toFixed(3) + ", " + value.y.toFixed(3) + ", " + value.z.toFixed(3) + ", " + value.w.toFixed(3) + ")"
                } if (type === 6) {
                    // color
                    return "(" + value.r.toFixed(3) + ", " + value.g.toFixed(3) + ", " + value.b.toFixed(3) + ", " + value.a.toFixed(3) + ")"
                } if (type === 7) {
                    // sampler, show filename.
                    var text = String(value).slice(value.lastIndexOf('/') + 1);
                    return text;
                } if (type === 8) {
                    // define
                    return String(value);
                }
            }

            function columnWidth(column) {
                var w = uniformTable.width - (120 - 20 * designModeAnimated);
                if (column === 0)
                    return 20;
                if (column === 1)
                    return w * 0.10;
                if (column === 2)
                    return w * 0.40;
                if (column === 3)
                    return w * 0.20;
                if (column === 4)
                    return w * 0.30;
                if (column === 5)
                    return 20;
                return 0;
            }

            delegate: Item {
                width: uniformTable.width
                height: visible ? controlsItem.height : 0
                visible: model.visible
                Rectangle {
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.leftMargin: 10
                    width: parent.width - 40
                    height: 1
                    z: -1
                    color: mainView.backgroundColor2
                }
                Row {
                    id: propertyListItemRow
                    x: 10
                    spacing: 10
                    height: parent.height
                    Item {
                        id: editPropertyButton
                        anchors.verticalCenter: parent.verticalCenter
                        width: 1 + opacity * uniformTable.columnWidth(0)
                        height: 20
                        opacity: (1.0 - designModeAnimated)
                        Image {
                            anchors.fill: parent
                            anchors.margins: 2
                            fillMode: Image.PreserveAspectFit
                            source: "images/icon_edit.png"
                            mipmap: true
                        }
                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                uniformTable.currentIndex = index;
                                // Pressing the edit button
                                propertyEditDialog.propertyIndex = model.index;
                                propertyEditDialog.initialType = model.type;
                                propertyEditDialog.initialName = model.name;
                                propertyEditDialog.initialDefaultValue = model.defaultValue;
                                propertyEditDialog.initialMinValue = model.minValue;
                                propertyEditDialog.initialMaxValue = model.maxValue;
                                propertyEditDialog.initialDescription = model.description;
                                propertyEditDialog.initialCustomValue = model.customValue;
                                propertyEditDialog.initialUseCustomValue = model.useCustomValue;
                                propertyEditDialog.initialEnableMipmap = model.enableMipmap;
                                propertyEditDialog.initialExportImage = model.exportImage;
                                propertyEditDialog.open();
                            }
                        }
                    }
                    Label {
                        id: typeLabel
                        anchors.verticalCenter: parent.verticalCenter
                        width: uniformTable.columnWidth(1)
                        text: uniformTable.typeStrings[model.type]
                        color: mainView.foregroundColor2
                        font.pixelSize: 14
                    }
                    Label {
                        id: nameLabel
                        anchors.verticalCenter: parent.verticalCenter
                        width: uniformTable.columnWidth(2)
                        text: name
                        color: mainView.foregroundColor2
                        elide: Text.ElideMiddle
                        font.pixelSize: 14
                        MouseArea {
                            id: nameLabelMouseArea
                            anchors.fill: parent
                            hoverEnabled: true
                        }
                        ToolTip {
                            parent: nameLabel
                            visible: nameLabelMouseArea.containsMouse && model.description !== ""
                            text: truncateString(model.description, 100);
                        }
                        Rectangle {
                            id: colorPickerButton
                            anchors.verticalCenter: parent.verticalCenter
                            anchors.right: parent.right
                            width: 40
                            height: 40
                            border.width: 1
                            border.color: foregroundColor2
                            color: visible ? model.value : "#000000"
                            visible: (model.type === 6)
                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    colorPickerDialog.propertyItem = controlsLoader.item;
                                    colorPickerDialog.selectedColor = model.value;
                                    colorPickerDialog.initialColor = model.value;
                                    colorPickerDialog.open();
                                }
                            }
                        }
                    }

                    Item {
                        id: controlsItem
                        width: uniformTable.columnWidth(3) + uniformTable.columnWidth(4)
                        height: controlsLoader.item ? controlsLoader.item.height : 30

                        // This will update sliders, checkbox etc. to match current value
                        function updateUIValues() {
                            var controlsItem = controlsLoader.item;
                            if (controlsItem)
                                controlsItem.updateValue(model.value);
                        }

                        Loader {
                            id: controlsLoader
                            sourceComponent: {
                                if (model.useCustomValue)
                                    return customControlsComponent;
                                if (model.type === 0)
                                    return boolControlsComponent;
                                if (model.type === 1 || model.type === 2)
                                    return floatControlsComponent;
                                if (model.type === 3)
                                    return vec2ControlsComponent
                                if (model.type === 4)
                                    return vec3ControlsComponent
                                if (model.type === 5)
                                    return vec4ControlsComponent
                                if (model.type === 6)
                                    return colorControlsComponent
                                if (model.type === 7)
                                    return imageControlsComponent
                                if (model.type === 8)
                                    return defineControlsComponent
                            }
                        }

                        // Component with a text field and a slider
                        component FloatSliderComponent : Item {

                            property alias sliderValue: valueSlider.value
                            property alias from: valueSlider.from
                            property alias to: valueSlider.to

                            function updatePropertyValue(newValue) {
                                sliderValue = newValue;
                            }

                            width: controlsItem.width
                            height: 30

                            CustomTextField {
                                id: valueTextInput

                                property string originalText: ""
                                property bool editCancelled: false
                                // Show int as int and others as float
                                readonly property int valueFormat: (model.type === 1) ? 1 : 2
                                anchors.verticalCenter: parent.verticalCenter
                                width: uniformTable.columnWidth(3)
                                height: parent.height - 2
                                text: uniformTable.convertValueToString(valueSlider.value, valueFormat)
                                validator: RegularExpressionValidator {
                                    regularExpression: model.type === 1 ? /[-]?[0-9]+/ : /[-]?(\d{1,3})([.,]\d{1,3})?$/
                                }
                                Keys.onEscapePressed: {
                                    editCancelled = true;
                                    focus = false;
                                }
                                onActiveFocusChanged: {
                                    if (activeFocus) {
                                        originalText = text;
                                        editCancelled = false;
                                        selectAll();
                                    }
                                }
                                onEditingFinished: {
                                    if (editCancelled) {
                                        text = originalText;
                                        editCancelled = false;
                                    } else {
                                        // Update slider, which updates model.value
                                        sliderValue = valueTextInput.text;
                                        if (model.exportProperty === false) {
                                            // Non-exported properties (const variables) need shader baking
                                            effectManager.bakeShaders(true);
                                        }
                                    }
                                    valueTextInput.focus = false;
                                }
                            }

                            Slider {
                                id: valueSlider
                                anchors.left: valueTextInput.right
                                anchors.leftMargin: 20
                                anchors.verticalCenter: parent.verticalCenter
                                width: uniformTable.columnWidth(4) - anchors.leftMargin
                                height: 30
                                stepSize: model.type === 1 ? 1.0 : 0.0
                            }
                        }

                        Component {
                            id: boolControlsComponent
                            Row {
                                spacing: 20
                                function updateValue(newValue) {
                                    valueCheckBox.checked = newValue;
                                    model.value = newValue;
                                }
                                Label {
                                    id: valueTextLabel
                                    anchors.verticalCenter: parent.verticalCenter
                                    width: uniformTable.columnWidth(3)
                                    text: uniformTable.convertValueToString(model.value, model.type)
                                    font.pixelSize: 14
                                    color: mainView.foregroundColor2
                                    wrapMode: Text.Wrap
                                }
                                CheckBox {
                                    id: valueCheckBox
                                    checked: model.value
                                    onToggled: model.value = checked;
                                }
                            }
                        }

                        Component {
                            id: floatControlsComponent
                            FloatSliderComponent {
                                id: valueSlider1
                                function updateValue(newValue) {
                                    valueSlider1.sliderValue = newValue;
                                    model.value = newValue;
                                }
                                from: model.minValue
                                to: model.maxValue
                                onSliderValueChanged: {
                                    if (status === Component.Ready)
                                        model.value = sliderValue;
                                }
                                Component.onCompleted: {
                                    updatePropertyValue(model.value);
                                }
                            }
                        }
                        Component {
                            id: vec2ControlsComponent
                            Column {
                                function updateValue(newValue) {
                                    valueSlider1.sliderValue = newValue.x;
                                    valueSlider2.sliderValue = newValue.y;
                                    model.value = newValue;
                                }
                                FloatSliderComponent {
                                    id: valueSlider1
                                    from: model.minValue.x
                                    to: model.maxValue.x
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.x = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.x);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider2
                                    from: model.minValue.y
                                    to: model.maxValue.y
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.y = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.y);
                                    }
                                }
                            }
                        }
                        Component {
                            id: vec3ControlsComponent
                            Column {
                                function updateValue(newValue) {
                                    valueSlider1.sliderValue = newValue.x;
                                    valueSlider2.sliderValue = newValue.y;
                                    valueSlider3.sliderValue = newValue.z;
                                    model.value = newValue;
                                }
                                FloatSliderComponent {
                                    id: valueSlider1
                                    from: model.minValue.x
                                    to: model.maxValue.x
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.x = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.x);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider2
                                    from: model.minValue.y
                                    to: model.maxValue.y
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.y = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.y);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider3
                                    from: model.minValue.z
                                    to: model.maxValue.z
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.z = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.z);
                                    }
                                }
                            }
                        }
                        Component {
                            id: vec4ControlsComponent
                            Column {
                                function updateValue(newValue) {
                                    valueSlider1.sliderValue = newValue.x;
                                    valueSlider2.sliderValue = newValue.y;
                                    valueSlider3.sliderValue = newValue.z;
                                    valueSlider4.sliderValue = newValue.w;
                                    model.value = newValue;
                                }
                                FloatSliderComponent {
                                    id: valueSlider1
                                    from: model.minValue.x
                                    to: model.maxValue.x
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.x = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.x);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider2
                                    from: model.minValue.y
                                    to: model.maxValue.y
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.y = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.y);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider3
                                    from: model.minValue.z
                                    to: model.maxValue.z
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.z = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.z);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSlider4
                                    from: model.minValue.w
                                    to: model.maxValue.w
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.w = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.w);
                                    }
                                }
                            }
                        }
                        Component {
                            id: colorControlsComponent
                            Column {
                                function updateValue(newColor) {
                                    valueSliderR.sliderValue = newColor.r;
                                    valueSliderG.sliderValue = newColor.g;
                                    valueSliderB.sliderValue = newColor.b;
                                    valueSliderA.sliderValue = newColor.a;
                                    model.value = newColor;
                                }
                                FloatSliderComponent {
                                    id: valueSliderR
                                    from: model.minValue.r
                                    to: model.maxValue.r
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.r = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.r);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSliderG
                                    from: model.minValue.g
                                    to: model.maxValue.g
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.g = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.g);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSliderB
                                    from: model.minValue.b
                                    to: model.maxValue.b
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.b = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.b);
                                    }
                                }
                                FloatSliderComponent {
                                    id: valueSliderA
                                    from: model.minValue.a
                                    to: model.maxValue.a
                                    onSliderValueChanged: {
                                        if (status === Component.Ready)
                                            model.value.a = sliderValue;
                                    }
                                    Component.onCompleted: {
                                        updatePropertyValue(model.value.a);
                                    }
                                }
                            }
                        }
                        Component {
                            id: imageControlsComponent
                            Row {
                                function updateValue(newValue) {
                                    model.value = newValue;
                                }
                                spacing: 20
                                Label {
                                    id: valueTextLabel
                                    anchors.verticalCenter: parent.verticalCenter
                                    width: uniformTable.columnWidth(3)
                                    text: uniformTable.convertValueToString(model.value, model.type)
                                    font.pixelSize: 14
                                    color: mainView.foregroundColor2
                                    wrapMode: Text.Wrap
                                }
                                Item {
                                    anchors.verticalCenter: parent.verticalCenter
                                    width: uniformTable.columnWidth(4) - 20
                                    height: 40
                                    Rectangle {
                                        anchors.fill: parent
                                        anchors.margins: 4
                                        color: mainView.foregroundColor2
                                        Image {
                                            anchors.fill: parent
                                            anchors.margins: 1
                                            fillMode: Image.PreserveAspectCrop
                                            source: model.value
                                        }
                                        Text {
                                            anchors.centerIn: parent
                                            text: "CHANGE"
                                            font.bold: true
                                            font.pixelSize: 12
                                            color: mainView.foregroundColor2
                                            style: Text.Outline
                                            styleColor: "#000000"
                                        }
                                        MouseArea {
                                            anchors.fill: parent
                                            onClicked: {
                                                textureSourceDialog.modelIndex = index;
                                                if (model.value) {
                                                    textureSourceDialog.currentFolder = effectManager.getDirectory(model.value);
                                                    textureSourceDialog.selectedFile = effectManager.addFileToURL(model.value);
                                                } else {
                                                    textureSourceDialog.currentFolder = effectManager.getDefaultImagesDirectory();
                                                }
                                                textureSourceDialog.open();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        Component {
                            id: defineControlsComponent
                            CustomTextField {
                                id: valueTextInput

                                property string originalText: ""
                                property bool editCancelled: false

                                function updateValue(newValue) {
                                    model.value = newValue;
                                }

                                anchors.verticalCenter: parent.verticalCenter
                                width: controlsItem.width
                                height: 28
                                text: model.value
                                Keys.onEscapePressed: {
                                    editCancelled = true;
                                    focus = false;
                                }
                                onActiveFocusChanged: {
                                    if (activeFocus) {
                                        originalText = text;
                                        editCancelled = false;
                                        selectAll();
                                    }
                                }
                                onEditingFinished: {
                                    if (editCancelled) {
                                        text = originalText;
                                        editCancelled = false;
                                    } else {
                                        model.value = valueTextInput.text;
                                        // Defines need shader baking
                                        effectManager.bakeShaders(true);
                                    }
                                    valueTextInput.focus = false;
                                }
                            }
                        }
                        Component {
                            id: customControlsComponent
                            Label {
                                id: valueTextLabel
                                anchors.verticalCenter: parent.verticalCenter
                                verticalAlignment: Text.AlignVCenter
                                width: controlsItem.width
                                height: 28
                                text: "[custom]"
                                font.pixelSize: 14
                                color: mainView.foregroundColor2
                                wrapMode: Text.Wrap
                            }
                        }
                    }
                    Item {
                        id: resetPropertyButton
                        anchors.verticalCenter: parent.verticalCenter
                        width: uniformTable.columnWidth(5)
                        height: 20
                        enabled: model.value !== model.defaultValue
                        Image {
                            anchors.fill: parent
                            anchors.margins: 2
                            fillMode: Image.PreserveAspectFit
                            source: "images/icon_reset.png"
                            opacity: enabled ? 1.0 : 0.5
                            mipmap: true
                        }
                        MouseArea {
                            anchors.fill: parent
                            onClicked: {
                                uniformTable.currentIndex = index;
                                effectManager.uniformModel.resetValue(index);
                                controlsItem.updateUIValues();
                            }
                        }
                    }
                }
                Item {
                    id: settingsOverlay
                    anchors.fill: parent
                    opacity: showSettingsAnimated
                    visible: opacity > 0
                    Rectangle {
                        anchors.fill: parent
                        opacity: 0.6
                        color: mainView.backgroundColor1
                        MouseArea {
                            anchors.fill: parent
                            onPressed: { }
                        }
                    }

                    Rectangle {
                        property real sideMargin: 20
                        anchors.right: parent.right
                        anchors.rightMargin: sideMargin - (1.0 - showSettingsAnimated) * (width + sideMargin)
                        height: parent.height
                        width: settingsArea.width
                        color: mainView.backgroundColor2
                        Row {
                            id: settingsArea
                            height: parent.height
                            Item {
                                width: 10
                                height: 1
                            }
                            CustomIconButton {
                                anchors.verticalCenter: parent.verticalCenter
                                height: 24
                                width: height
                                icon: "images/icon_api.png"
                                toggledIcon: "images/icon_api_on.png"
                                toggleButton: true
                                toggled: model.exportProperty
                                // Samplers & Defines can't be made to non-exportable
                                enabled: (model.type <= 6)
                                description: "Export as effect API"
                                onClicked: {
                                    model.exportProperty = !model.exportProperty;
                                }
                            }
                            CustomIconButton {
                                anchors.verticalCenter: parent.verticalCenter
                                height: 24
                                width: height
                                icon: "images/icon_arrow_up.png"
                                enabled: model.canMoveUp
                                description: "Move up"
                                onClicked: {
                                    effectManager.uniformModel.moveIndex(model.index, -1);
                                }
                            }
                            CustomIconButton {
                                anchors.verticalCenter: parent.verticalCenter
                                height: 24
                                width: height
                                icon: "images/icon_arrow_down.png"
                                enabled: model.canMoveDown
                                description: "Move down"
                                onClicked: {
                                    effectManager.uniformModel.moveIndex(model.index, 1);
                                }
                            }
                            Item {
                                width: 10
                                height: 1
                            }
                        }
                    }
                }
            }
        }
    }
}