summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2019-08-09 08:59:34 +0300
committerJere Tuliniemi <jere.tuliniemi@qt.io>2019-08-12 09:36:32 +0300
commit1f8b29f6529ca9bd7b103592e4160c81b6563614 (patch)
tree0b5093bcd6e9286dccff42430c12339b9b108b4b
parent3e036f173937c0ab90da8df095b430ff7c5dcc55 (diff)
Add support for Float4 in the inspector
Float4 support is added to the editor, so that the W coordinate can be edited like the X, Y and Z coordinates instead of using Color type. Alpha channel editing is enabled for Color properties in custom materials. Task-number: QT3DS-3824 Change-Id: I932354cc22bcda4d2c21db119ce51f44ca93db03 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp1
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml5
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml39
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml126
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml66
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp5
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml49
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp5
-rw-r--r--src/Authoring/Qt3DStudio/qml.qrc2
m---------src/Runtime/ogl-runtime0
12 files changed, 298 insertions, 5 deletions
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
index ebd0076a..c1784e1d 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
@@ -940,6 +940,7 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
qml->setContextProperty(QStringLiteral("_xAxisColor"), s_xAxisColor);
qml->setContextProperty(QStringLiteral("_yAxisColor"), s_yAxisColor);
qml->setContextProperty(QStringLiteral("_zAxisColor"), s_zAxisColor);
+ qml->setContextProperty(QStringLiteral("_wAxisColor"), s_wAxisColor);
qml->setContextProperty(QStringLiteral("_fontSize"), s_fontSize);
qml->setContextProperty(QStringLiteral("_controlBaseHeight"), s_controlBaseHeight);
qml->setContextProperty(QStringLiteral("_idWidth"), s_idWidth);
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
index a5b905b3..f06143f0 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
@@ -421,8 +421,11 @@ Rectangle {
_tabOrderHandler.addItem(0, item.tabItem1)
if (item.tabItem2 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem2)
- if (item.tabItem3 !== undefined)
+ if (item.tabItem3 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem3)
+ if (item.tabItem4 !== undefined)
+ _tabOrderHandler.addItem(0, item.tabItem4)
+ }
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
index 8c184409..5b77dbdf 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
@@ -69,7 +69,7 @@ RowLayout {
onClicked: {
root.listenToColorChanges = true;
_inspectorModel.suspendMaterialRename(true);
- root.selectedColor = _parentView.showColorDialog(rect.color, instance, handle);
+ root.selectedColor = _parentView.showColorDialog(rect.color);
root.listenToColorChanges = false;
_inspectorModel.suspendMaterialRename(false);
root.colorSelected();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
index a101488e..39aea92e 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
@@ -119,6 +119,38 @@ ColumnLayout {
}
Component {
+ id: xyzwPropertyComponent
+
+ HandlerPropertyXYZW {
+ readonly property var propValue: propertyModel && !_parentView.propertyValueInvalid
+ && propertyModel.value !== undefined
+ ? propertyModel.value : undefined
+ label: parent ? parent.label : ""
+ valueX: propValue !== undefined ? Number(propValue.x).toFixed(numberOfDecimal) : "0.000"
+ valueY: propValue !== undefined ? Number(propValue.y).toFixed(numberOfDecimal) : "0.000"
+ valueZ: propValue !== undefined ? Number(propValue.z).toFixed(numberOfDecimal) : "0.000"
+ valueW: propValue !== undefined ? Number(propValue.w).toFixed(numberOfDecimal) : "0.000"
+
+ onPropValueChanged: {
+ // FloatTextField can set its text internally, thus breaking the binding, so
+ // let's set the text value explicitly each time value changes
+ if (propValue !== undefined) {
+ valueX = Number(propValue.x).toFixed(numberOfDecimal);
+ valueY = Number(propValue.y).toFixed(numberOfDecimal);
+ valueZ = Number(propValue.z).toFixed(numberOfDecimal);
+ valueW = Number(propValue.w).toFixed(numberOfDecimal);
+ }
+ }
+
+ onEditingFinished: {
+ _parentView.setArgumentValue(propertyModel.valueHandle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW), true);
+ }
+ }
+ }
+
+
+ Component {
id: sliderPropertyComponent
HandlerPropertySlider {
@@ -224,8 +256,11 @@ ColumnLayout {
_tabOrderHandler.addItem(0, item.tabItem1)
if (item.tabItem2 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem2)
- if (item.tabItem3 !== undefined)
+ if (item.tabItem3 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem3)
+ if (item.tabItem4 !== undefined)
+ _tabOrderHandler.addItem(0, item.tabItem4)
+ }
}
}
}
@@ -257,6 +292,8 @@ ColumnLayout {
case DataModelDataType.Float4:
if (actionProperty.additionalType === AdditionalMetaDataType.Color)
return colorBox;
+ if (actionProperty.additionalType === AdditionalMetaDataType.None)
+ return xyzwPropertyComponent;
break;
case DataModelDataType.String:
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml
new file mode 100644
index 00000000..53ee4c33
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import "../controls"
+
+/* Use for: Float4 */
+
+ColumnLayout {
+ id: root
+
+ property alias valueX: textFieldX.text
+ property alias valueY: textFieldY.text
+ property alias valueZ: textFieldZ.text
+ property alias valueW: textFieldW.text
+ property int numberOfDecimal: 3
+ property Item tabItem1: textFieldX
+ property Item tabItem2: textFieldY
+ property Item tabItem3: textFieldZ
+ property Item tabItem4: textFieldW
+
+ signal editingFinished
+ signal previewValueChanged
+ transformOrigin: Item.Center
+ spacing: 0
+
+ RowLayout {
+ transformOrigin: Item.Center
+ spacing: 0
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("X")
+ color: _xAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldX
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ }
+
+ Item { width: 10 }
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("Y")
+ color: _yAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldY
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ }
+
+ Item { width: 10 }
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("Z")
+ color: _zAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldZ
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ }
+ }
+
+ Item { height: 4 }
+
+ RowLayout {
+ transformOrigin: Item.Center
+ spacing: 0
+ Layout.leftMargin: -3
+
+ StyledLabel {
+ Layout.preferredWidth: 13
+ text: qsTr("W")
+ color: _wAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldW
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ }
+ }
+}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml
new file mode 100644
index 00000000..0c098d53
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import "../controls"
+
+/* Use for: Float4 */
+
+RowLayout {
+ id: root
+
+ property alias valueX: propertyXYZW.valueX
+ property alias valueY: propertyXYZW.valueY
+ property alias valueZ: propertyXYZW.valueZ
+ property alias valueW: propertyXYZW.valueW
+ property alias label: labelItem.text
+ property alias tabItem1: propertyXYZW.tabItem1
+ property alias tabItem2: propertyXYZW.tabItem2
+ property alias tabItem3: propertyXYZW.tabItem3
+ property alias tabItem4: propertyXYZW.tabItem4
+ property alias numberOfDecimal: propertyXYZW.numberOfDecimal
+
+ signal editingFinished
+ signal previewValueChanged
+
+ StyledLabel {
+ id: labelItem
+ Layout.alignment: Qt.AlignTop | Qt.AlignLeft
+ text: qsTr("New Value")
+ }
+
+ HandlerPropertyBaseXYZW {
+ id: propertyXYZW
+ Layout.alignment: Qt.AlignRight
+
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ }
+}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
index 2bc1272a..72a2bd24 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
@@ -1336,6 +1336,11 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
case qt3dsdm::DataModelDataType::Float4:
if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::Color) {
element->m_value = qt3dsdm::get<QColor>(value);
+ } else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::None) {
+ const QVector<float> theFloat4 = qt3dsdm::get<QVector<float>>(value);
+ const QList<double> float4Values{theFloat4[0], theFloat4[1], theFloat4[2],
+ theFloat4[3]};
+ element->m_values = QVariant::fromValue<QList<double> >(float4Values);
}
break;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
index 161599b6..c60bf5e3 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
@@ -855,7 +855,8 @@ QColor InspectorControlView::showColorDialog(const QColor &color, int instance,
bool showAlpha = false;
if (instance && handle) {
showAlpha = getBridge()->getBGColorProperty(instance).GetHandleValue() == handle
- || getBridge()->getTextColorProperty(instance).GetHandleValue() == handle;
+ || getBridge()->getTextColorProperty(instance).GetHandleValue() == handle
+ || getBridge()->IsCustomMaterialInstance(instance);
}
m_currentColor = color;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
index 332f6e77..7e7af556 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
@@ -263,6 +263,11 @@ Rectangle {
_tabOrderHandler.addItem(
indexOfThisDelegate,
item.loadedItem.tabItem3)
+ if (item.loadedItem.tabItem4 !== undefined) {
+ _tabOrderHandler.addItem(
+ indexOfThisDelegate,
+ item.loadedItem.tabItem4)
+ }
}
}
}
@@ -511,6 +516,8 @@ Rectangle {
case DataModelDataType.Float4:
if (modelData.propertyType === AdditionalMetaDataType.Color)
return colorBox;
+ if (modelData.propertyType === AdditionalMetaDataType.None)
+ return xyzwPropertyComponent;
return null;
case DataModelDataType.StringRef:
if (modelData.propertyType === AdditionalMetaDataType.None)
@@ -655,6 +662,48 @@ Rectangle {
}
Component {
+ id: xyzwPropertyComponent
+
+ RowLayout {
+ property int instance: parent.modelData.instance
+ property int handle: parent.modelData.handle
+ property variant values: parent.modelData.values
+ property alias tabItem1: xyzwHandler.tabItem1
+ property alias tabItem2: xyzwHandler.tabItem2
+ property alias tabItem3: xyzwHandler.tabItem3
+ property alias tabItem4: xyzwHandler.tabItem4
+ spacing: 0
+
+ onValuesChanged: {
+ // FloatTextField can set its text internally, thus breaking the binding, so
+ // let's set the text value explicitly each time value changes
+ xyzwHandler.valueX = Number(values[0]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueY = Number(values[1]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueZ = Number(values[2]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueW = Number(values[3]).toFixed(xyzwHandler.numberOfDecimal);
+ }
+
+ HandlerPropertyBaseXYZW {
+ id: xyzwHandler
+ valueX: Number(values[0]).toFixed(numberOfDecimal)
+ valueY: Number(values[1]).toFixed(numberOfDecimal)
+ valueZ: Number(values[2]).toFixed(numberOfDecimal)
+ valueW: Number(values[3]).toFixed(numberOfDecimal)
+ onEditingFinished: {
+ _inspectorModel.setPropertyValue(parent.instance, parent.handle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW),
+ true);
+ }
+ onPreviewValueChanged: {
+ _inspectorModel.setPropertyValue(parent.instance, parent.handle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW),
+ false);
+ }
+ }
+ }
+ }
+
+ Component {
id: xyzPropertyComponent
RowLayout {
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
index 182f9d78..66b22e58 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
@@ -269,11 +269,14 @@ float Qt3DSDMTimelineItemProperty::GetChannelValueAtTime(long inChannelIndex, lo
SFloat4 theFloat4 = qt3dsdm::get<SFloat4>(theValue);
if (inChannelIndex >= 0 && inChannelIndex < 4)
return DataModelToColor(theFloat4[inChannelIndex]);
+ } else {
+ SFloat4 theFloat4 = qt3dsdm::get<SFloat4>(theValue);
+ if (inChannelIndex >= 0 && inChannelIndex < 4)
+ return theFloat4[inChannelIndex];
}
break;
}
case DataModelDataType::Float3: {
-
SFloat3 theFloat3 = qt3dsdm::get<SFloat3>(theValue);
if (inChannelIndex >= 0 && inChannelIndex < 3)
return theFloat3[inChannelIndex];
diff --git a/src/Authoring/Qt3DStudio/qml.qrc b/src/Authoring/Qt3DStudio/qml.qrc
index 09d5451f..2ab117aa 100644
--- a/src/Authoring/Qt3DStudio/qml.qrc
+++ b/src/Authoring/Qt3DStudio/qml.qrc
@@ -43,5 +43,7 @@
<file>Palettes/Action/HandlerGenericFloat.qml</file>
<file>Palettes/Inspector/MaterialDropDown.qml</file>
<file>Application/FilterVariantsDlg.qml</file>
+ <file>Palettes/Action/HandlerPropertyXYZW.qml</file>
+ <file>Palettes/Action/HandlerPropertyBaseXYZW.qml</file>
</qresource>
</RCC>
diff --git a/src/Runtime/ogl-runtime b/src/Runtime/ogl-runtime
-Subproject 4de6ba661981f263f2de337f4d023c4849d11de
+Subproject bb6fff1b707c15853f137b5a7b8797fa9415d33