2023-08-21 11:52:11 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
import QtQuick
|
2023-08-22 17:05:28 +03:00
|
|
|
import QtQuick.Dialogs
|
2023-08-21 11:52:11 +03:00
|
|
|
import QtQuick.Layouts
|
|
|
|
import HelperWidgets as HelperWidgets
|
|
|
|
import StudioControls as StudioControls
|
2024-01-16 12:30:29 +01:00
|
|
|
import StudioTheme as StudioTheme
|
2024-01-26 14:55:50 +02:00
|
|
|
import EffectComposerBackend
|
2023-08-21 11:52:11 +03:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
property bool editing: false
|
|
|
|
property bool disableMoreMenu: false
|
2024-11-26 14:15:10 +02:00
|
|
|
property bool isDependencyNode: true
|
2024-11-05 17:21:33 +02:00
|
|
|
property alias editPropertyFormParent: editPropertyFormPlaceholder
|
|
|
|
|
|
|
|
height: layout.implicitHeight + editPropertyFormPlaceholder.height + column.spacing
|
2023-12-01 15:20:34 +02:00
|
|
|
visible: !uniformUseCustomValue
|
|
|
|
|
2024-03-19 14:52:20 +02:00
|
|
|
signal reset()
|
2024-11-05 17:21:33 +02:00
|
|
|
signal remove()
|
|
|
|
signal edit()
|
2024-11-26 14:15:10 +02:00
|
|
|
signal openCodeEditor()
|
2024-03-19 14:52:20 +02:00
|
|
|
|
2023-08-22 17:05:28 +03:00
|
|
|
Component.onCompleted: {
|
2024-02-02 13:08:01 +02:00
|
|
|
if (uniformType === "int") {
|
2024-03-07 10:50:35 +02:00
|
|
|
if (uniformControlType === "channel")
|
|
|
|
valueLoader.source = "ValueChannel.qml"
|
|
|
|
else
|
|
|
|
valueLoader.source = "ValueInt.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "vec2") {
|
2023-08-22 17:05:28 +03:00
|
|
|
valueLoader.source = "ValueVec2.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "vec3") {
|
2023-08-22 17:05:28 +03:00
|
|
|
valueLoader.source = "ValueVec3.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "vec4") {
|
2023-08-22 17:05:28 +03:00
|
|
|
valueLoader.source = "ValueVec4.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "bool") {
|
2023-08-22 17:05:28 +03:00
|
|
|
valueLoader.source = "ValueBool.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "color") {
|
2023-08-24 15:21:52 +03:00
|
|
|
valueLoader.source = "ValueColor.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "sampler2D") {
|
2023-08-25 16:27:01 +03:00
|
|
|
valueLoader.source = "ValueImage.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
} else if (uniformType === "define") {
|
|
|
|
if (uniformControlType === "int")
|
|
|
|
valueLoader.source = "ValueInt.qml"
|
|
|
|
else if (uniformControlType === "bool")
|
|
|
|
valueLoader.source = "ValueBool.qml"
|
|
|
|
else
|
|
|
|
valueLoader.source = "ValueDefine.qml"
|
|
|
|
} else {
|
2023-08-22 17:05:28 +03:00
|
|
|
valueLoader.source = "ValueFloat.qml"
|
2024-02-02 13:08:01 +02:00
|
|
|
}
|
2023-08-22 17:05:28 +03:00
|
|
|
}
|
2023-08-21 11:52:11 +03:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
Column {
|
|
|
|
id: column
|
2023-08-21 11:52:11 +03:00
|
|
|
anchors.fill: parent
|
2024-11-05 17:21:33 +02:00
|
|
|
spacing: 5
|
2023-08-21 11:52:11 +03:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
RowLayout {
|
|
|
|
id: layout
|
2023-09-08 13:21:27 +03:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
width: parent.width
|
2024-03-19 14:52:20 +02:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
Text {
|
|
|
|
id: textName
|
2023-08-21 11:52:11 +03:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
text: (root.editing ? qsTr("[Editing] ") : "") + uniformDisplayName
|
|
|
|
color: root.editing ? StudioTheme.Values.themeControlOutlineInteraction
|
|
|
|
: StudioTheme.Values.themeTextColor
|
|
|
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
|
|
|
horizontalAlignment: Text.AlignRight
|
|
|
|
Layout.preferredWidth: 140
|
|
|
|
Layout.maximumWidth: Layout.preferredWidth
|
|
|
|
Layout.minimumWidth: Layout.preferredWidth
|
|
|
|
elide: Text.ElideRight
|
2024-03-19 14:52:20 +02:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
HelperWidgets.ToolTipArea {
|
|
|
|
id: tooltipArea
|
2024-03-19 14:52:20 +02:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
tooltip: uniformDescription
|
|
|
|
}
|
2024-03-19 14:52:20 +02:00
|
|
|
}
|
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
Item {
|
|
|
|
Layout.preferredHeight: 30
|
|
|
|
Layout.preferredWidth: 30
|
|
|
|
Layout.maximumWidth: Layout.preferredWidth
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HelperWidgets.IconButton {
|
|
|
|
id: iconButton
|
|
|
|
|
|
|
|
buttonSize: 24
|
|
|
|
icon: StudioTheme.Constants.reload_medium
|
2024-11-26 14:15:10 +02:00
|
|
|
iconSize: StudioTheme.Values.mediumIconFontSize
|
2024-11-05 17:21:33 +02:00
|
|
|
anchors.centerIn: parent
|
2024-11-26 14:15:10 +02:00
|
|
|
visible: !warningButton.visible && (mouseArea.containsMouse || iconButton.containsMouse)
|
2024-11-05 17:21:33 +02:00
|
|
|
tooltip: qsTr("Reset value")
|
2024-11-26 14:15:10 +02:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
onClicked: root.reset()
|
|
|
|
}
|
2024-11-26 14:15:10 +02:00
|
|
|
|
|
|
|
HelperWidgets.IconButton {
|
|
|
|
id: warningButton
|
|
|
|
|
|
|
|
buttonSize: 24
|
|
|
|
icon: StudioTheme.Constants.warning_medium
|
|
|
|
iconSize: StudioTheme.Values.mediumIconFontSize
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: !uniformIsInUse && !root.isDependencyNode
|
|
|
|
tooltip: qsTr("This property is not used in the shader code of the effect.")
|
|
|
|
iconColor: StudioTheme.Values.themeWarning
|
|
|
|
|
|
|
|
onClicked: root.openCodeEditor()
|
|
|
|
}
|
2024-11-05 17:21:33 +02:00
|
|
|
}
|
2024-03-19 14:52:20 +02:00
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
Loader {
|
|
|
|
id: valueLoader
|
|
|
|
Layout.fillWidth: true
|
2024-03-19 14:52:20 +02:00
|
|
|
}
|
|
|
|
|
2024-11-05 17:21:33 +02:00
|
|
|
Item {
|
|
|
|
Layout.preferredHeight: 30
|
|
|
|
Layout.preferredWidth: 30
|
|
|
|
Layout.maximumWidth: Layout.preferredWidth
|
|
|
|
|
|
|
|
HelperWidgets.IconButton {
|
|
|
|
id: moreButton
|
|
|
|
buttonSize: 24
|
|
|
|
icon: StudioTheme.Constants.more_medium
|
|
|
|
iconSize: 10
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
tooltip: root.disableMoreMenu ? qsTr("Additional actions disabled while editing existing property.")
|
|
|
|
: qsTr("Access additional property actions.")
|
|
|
|
enabled: !root.disableMoreMenu
|
2024-11-26 14:15:10 +02:00
|
|
|
visible: !root.isDependencyNode
|
2024-11-05 17:21:33 +02:00
|
|
|
|
|
|
|
onClicked: menuLoader.show()
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: menuLoader
|
|
|
|
|
|
|
|
active: false
|
|
|
|
|
|
|
|
function show() {
|
|
|
|
menuLoader.active = true
|
|
|
|
item.popup()
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
StudioControls.Menu {
|
|
|
|
id: menu
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
|
|
|
text: qsTr("Edit")
|
|
|
|
onTriggered: root.edit()
|
|
|
|
}
|
|
|
|
|
|
|
|
StudioControls.MenuItem {
|
|
|
|
text: qsTr("Remove")
|
|
|
|
onTriggered: root.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-19 14:52:20 +02:00
|
|
|
}
|
2024-11-05 17:21:33 +02:00
|
|
|
Item {
|
|
|
|
id: editPropertyFormPlaceholder
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2023-08-21 11:52:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|