File: MaterialControl.qml

package info (click to toggle)
qt6-quick3d 6.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 140,860 kB
  • sloc: cpp: 380,464; ansic: 36,078; xml: 252; sh: 241; makefile: 29
file content (127 lines) | stat: -rw-r--r-- 4,261 bytes parent folder | download | duplicates (2)
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
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Rectangle {
    property real metalness: metalness.sliderValue
    property real roughness: roughness.sliderValue
    property real specular: specular.sliderValue
    property real specularTint: specularTint.sliderValue
    property real opacityValue: opacityValue.sliderValue

    color: "#6b7080"
    width: parent.width
    height: 75

    Component {
        id: propertySlider
        RowLayout {
            Label {
                id: propText
                text: name
                color: "#222840"
                font.pointSize: 12
                Layout.minimumWidth: 150
                Layout.maximumWidth: 150
            }
            Slider {
                id: slider
                from: fromValue
                to: toValue
                value: sliderValue
                stepSize: 0.01
                onValueChanged: sliderValue = value
                Layout.minimumWidth: 200
                Layout.maximumWidth: 200
                background: Rectangle {
                    x: slider.leftPadding
                    y: slider.topPadding + slider.availableHeight / 2 - height / 2
                    implicitWidth: 200
                    implicitHeight: 4
                    width: slider.availableWidth
                    height: implicitHeight
                    radius: 1
                    color: "#222840"

                    Rectangle {
                        width: slider.visualPosition * parent.width
                        height: parent.height
                        color: "#848895"
                        radius: 1
                    }
                }
                handle: Rectangle {
                    x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
                    y: slider.topPadding + slider.availableHeight / 2 - height / 2
                    implicitWidth: 20
                    implicitHeight: 20
                    radius: 5
                    color: slider.pressed ? "#222840" : "#6b7080"
                    border.color: "#848895"
                }
            }
            Label {
                id: valueText
                text: slider.value.toFixed(2)
                color: "#222840"
                font.pointSize: 12
                font.bold: true
                Layout.minimumWidth: 40
                Layout.maximumWidth: 40
            }
        }
    }

    ColumnLayout {
        anchors.horizontalCenter: parent.horizontalCenter
        RowLayout {
            spacing: 20
            Loader {
                id: metalness
                property real sliderValue: 1.0
                property string name: "Metalness"
                property real fromValue: 0.0
                property real toValue: 1.0
                sourceComponent:  propertySlider
            }
            Loader {
                id: roughness
                property real sliderValue: 0.2
                property string name: "Roughness"
                property real fromValue: 0.0
                property real toValue: 1.0
                sourceComponent:  propertySlider
            }
        }
        RowLayout {
            spacing: 20
            Loader {
                id: specular
                property real sliderValue: 0.0
                property string name: "Specular Power"
                property real fromValue: 0.0
                property real toValue: 1.0
                sourceComponent:  propertySlider
            }
            Loader {
                id: specularTint
                property real sliderValue: 0.0
                property string name: "Specular Tint"
                property real fromValue: 0.0
                property real toValue: 1.0
                sourceComponent: propertySlider
            }
            Loader {
                id: opacityValue
                property real sliderValue: 1.0
                property string name: "Opacity"
                property real fromValue: 0.0
                property real toValue: 1.0
                sourceComponent: propertySlider
            }
        }
    }
}