diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-05-14 11:02:30 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-05-23 13:24:59 +0300 |
commit | c5338095a3ff3ae04d447125599d36351a436229 (patch) | |
tree | bbcf55120e3b1a092d57bc1b54369525ff6d805c | |
parent | c3d5b709c1ef6d2c5d43a9ff1b672421592eb4bf (diff) |
Set datainput controller target to be source referenced material
For referenced materials, use source material as target for "Set datainput
controller". Also, do not show menu choice at all for default materials.
Change-Id: Ie208f81390cc88665008a8a31a6ea98a6cb45a59
Task-id: QT3DS-3417
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
3 files changed, 29 insertions, 11 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 21281e42..f92fc58d 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -94,7 +94,7 @@ ITimelineItemBinding *RowTree::getBinding() const } // object instance handle -int RowTree::instance() const + qt3dsdm::Qt3DSDMInstanceHandle RowTree::instance() const { if (m_isProperty || !m_binding) return 0; @@ -1334,6 +1334,13 @@ void RowTree::setPropertyExpanded(bool expand) void RowTree::showDataInputSelector(const QString &propertyname, const QPoint &pos) { - m_scene->handleShowDISelector(propertyname, instance(), pos); + auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + + // Set the datainput to control property in referenced object if this + // is a referenced material. + auto refInstance = bridge->getMaterialReference(instance()); + + m_scene->handleShowDISelector(propertyname, refInstance.Valid() ? refInstance : instance(), + pos); } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h index 7ac04c11..08e85dc5 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h @@ -34,6 +34,7 @@ #include "RowTypes.h" #include "StudioObjectTypes.h" #include "RowTreeLabelItem.h" +#include "Qt3DSDMHandles.h" #include <QtCore/qpropertyanimation.h> #include <QtCore/qparallelanimationgroup.h> @@ -152,7 +153,7 @@ public: void updateLock(bool state); void updateSubpresentations(int updateParentsOnlyVal = 0); int clipX() const; - int instance() const; + qt3dsdm::Qt3DSDMInstanceHandle instance() const; protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp index e7d2898d..a7b301a2 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp @@ -70,26 +70,36 @@ void RowTreeContextMenu::initialize() } // add datainput controller submenu - if (!(m_RowTree->rowType() & (OBJTYPE_GUIDE | OBJTYPE_EFFECT | OBJTYPE_ALIAS - | OBJTYPE_SCENE))) { + if (m_RowTree->rowType() & ~(OBJTYPE_GUIDE | OBJTYPE_EFFECT | OBJTYPE_ALIAS | OBJTYPE_SCENE) + && !static_cast<Qt3DSDMTimelineItemBinding *>(m_TimelineItemBinding) + ->isDefaultMaterial()) { m_diMenu = addMenu(tr("Set datainput controller")); connect(m_diMenu, &QMenu::triggered, this, &RowTreeContextMenu::addDiController); - const QVector<qt3dsdm::Qt3DSDMPropertyHandle> propList - = doc.GetStudioSystem()->GetPropertySystem()->GetControllableProperties(instance); + QVector<qt3dsdm::Qt3DSDMPropertyHandle> propList; + + // If this is a referenced material instance, we need to get the property list from + // the referenced source, and set datainput control to point to the property + // in the referenced source. + auto refInstance = doc.GetStudioSystem()->GetClientDataModelBridge() + ->getMaterialReference(instance); + propList = doc.GetStudioSystem()->GetPropertySystem() + ->GetControllableProperties(refInstance ? refInstance : instance); QMap<int, QAction *> sections; for (const auto &prop : propList) { - QAction *action = new QAction(QString::fromStdWString( - doc.GetPropertySystem() - ->GetFormalName(instance, prop).wide_str())); + QAction *action + = new QAction(QString::fromStdWString(doc.GetPropertySystem() + ->GetFormalName( + refInstance ? refInstance : instance, + prop).wide_str())); action->setData(QString::fromStdWString( doc.GetPropertySystem() ->GetName(prop).wide_str())); auto metadata = doc.GetStudioSystem()->GetActionMetaData()->GetMetaDataPropertyInfo( doc.GetStudioSystem()->GetActionMetaData()->GetMetaDataProperty( - instance, prop)); + refInstance ? refInstance : instance, prop)); if (sections.contains(metadata->m_CompleteType) ) { m_diMenu->insertAction(sections[metadata->m_CompleteType], action); |