diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-08-20 15:52:27 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-08-22 07:59:43 +0000 |
commit | 275c1dfaed5bccd67aea033c2b596eac21643182 (patch) | |
tree | 877ea322f24964bc82d9caee166ed51273eefe78 /src/Authoring/Studio/Palettes | |
parent | bb90c47e34c49a4dcd53af09c20c4b545aacd538 (diff) |
Visualize in-use sub-presentations on the timeline rows
The left-most part of a timeline row is colored for rows that have a
sub-presentation in-use. If a collapsed row has a descendant with a sub-presentation, it is highlighted in a different shade of the main
color.
Task-number: QT3DS-2100
Change-Id: Id26fb554050e5df8c635e71266ae52665d0ad836
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes')
7 files changed, 111 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h index ba1b7547..4308fb2b 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h @@ -66,6 +66,9 @@ public: virtual bool ChildrenHasAction(bool inMaster) = 0; virtual bool ComponentHasAction(bool inMaster) = 0; + // subpresentations + virtual bool hasSubpresentation() const = 0; + virtual ITimelineTimebar *GetTimebar() = 0; }; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 99be9332..8a1b1adb 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -301,6 +301,28 @@ bool Qt3DSDMTimelineItemBinding::ComponentHasAction(bool inMaster) return false; } +bool Qt3DSDMTimelineItemBinding::hasSubpresentation() const +{ + CClientDataModelBridge *bridge(m_StudioSystem->GetClientDataModelBridge()); + IPropertySystem *propSystem = m_StudioSystem->GetPropertySystem(); + EStudioObjectType objType = GetObjectType(); + + if (objType == OBJTYPE_LAYER) { + SValue sourcePathValue; + propSystem->GetInstancePropertyValue(m_DataHandle, bridge->GetSourcePathProperty(), + sourcePathValue); + return get<TDataStrPtr>(sourcePathValue)->GetLength() > 0; + } else if (objType == OBJTYPE_IMAGE) { + SValue subPresValue; + propSystem->GetInstancePropertyValue(m_DataHandle, + bridge->GetSceneImage().m_SubPresentation, + subPresValue); + return get<TDataStrPtr>(subPresValue)->GetLength() > 0; + } + + return false; +} + ITimelineTimebar *Qt3DSDMTimelineItemBinding::GetTimebar() { if (!m_TimelineTimebar) diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h index b0367f70..5ababf96 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h @@ -111,6 +111,7 @@ public: bool IsVisibilityControlled() const override; bool ChildrenHasAction(bool inMaster) override; bool ComponentHasAction(bool inMaster) override; + bool hasSubpresentation() const override; ITimelineTimebar *GetTimebar() override; // INamable diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp index cd74854d..f533e960 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp @@ -508,8 +508,9 @@ void TimelineWidget::onAssetCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance) if (binding && !rowExists) { Qt3DSDMTimelineItemBinding *bindingParent = getBindingForHandle(m_bridge ->GetParentInstance(inInstance), m_binding); - m_graphicsScene->rowManager() - ->createRowFromBinding(binding, bindingParent->getRowTree()); + RowTree *row = m_graphicsScene->rowManager() + ->createRowFromBinding(binding, bindingParent->getRowTree()); + row->updateSubpresentations(); insertToHandlesMap(binding); } } @@ -522,6 +523,7 @@ void TimelineWidget::onAssetDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance) RowTree *row = m_handlesMap.value(inInstance); if (row) { // scene object exists + row->updateSubpresentations(-1); m_graphicsScene->rowManager()->deleteRow(row); m_handlesMap.remove(inInstance); m_graphicsScene->expandMap().remove(inInstance); @@ -699,16 +701,24 @@ void TimelineWidget::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance const SDataModelSceneAsset &asset = m_bridge->GetSceneAsset(); CDoc *doc = g_StudioApp.GetCore()->GetDoc(); - auto ctrldPropHandle = doc->GetPropertySystem()->GetAggregateInstancePropertyByName( - inInstance, L"controlledproperty"); + EStudioObjectType instanceType = m_bridge->GetObjectType(inInstance); + auto ctrldPropHandle = doc->GetPropertySystem() + ->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty"); + if (inProperty == asset.m_Eyeball || inProperty == asset.m_Locked || inProperty == asset.m_Shy - || inProperty == asset.m_StartTime || inProperty == asset.m_EndTime - || inProperty == m_bridge->GetNameProperty() - || inProperty == ctrldPropHandle) { + || inProperty == asset.m_StartTime || inProperty == asset.m_EndTime + || inProperty == m_bridge->GetNameProperty() || inProperty == ctrldPropHandle) { m_dirtyProperties.insert(inInstance, inProperty); if (!m_asyncUpdateTimer.isActive()) m_asyncUpdateTimer.start(); - } + } else if ((instanceType == OBJTYPE_LAYER && inProperty == m_bridge->GetSourcePathProperty()) + || (instanceType == OBJTYPE_IMAGE && inProperty == m_bridge->GetSceneImage() + .m_SubPresentation)) { + // subpresentation property change + m_subpresentationChanges.insert(inInstance); + if (!m_asyncUpdateTimer.isActive()) + m_asyncUpdateTimer.start(); + } } void TimelineWidget::onAsyncUpdate() @@ -731,6 +741,11 @@ void TimelineWidget::onAsyncUpdate() m_graphicsScene->updateController(); onSelectionChange(doc->GetSelectedValue()); m_toolbar->setNewLayerEnabled(!m_graphicsScene->rowManager()->isComponentRoot()); + + // update suppresentation indicators + for (auto *row : m_handlesMap) + row->updateSubpresentations(); + } else { if (!m_moveMap.isEmpty()) { // Flip the hash around so that we collect moves by parent. @@ -758,8 +773,14 @@ void TimelineWidget::onAsyncUpdate() while (indexIt.hasNext()) { indexIt.next(); RowTree *row = m_handlesMap.value(indexIt.value()); - if (row) + if (row) { + bool isReparent = rowParent != row->parentRow(); + if (isReparent) + row->updateSubpresentations(-1); rowParent->addChildAt(row, indexIt.key()); + if (isReparent) + row->updateSubpresentations(1); + } } expandRows.insert(rowParent); } @@ -848,6 +869,15 @@ void TimelineWidget::onAsyncUpdate() } updateActionStates(rowSet); } + + if (!m_subpresentationChanges.isEmpty()) { + for (int id : qAsConst(m_subpresentationChanges)) { + RowTree *row = m_handlesMap.value(id); + if (row) + row->updateSubpresentations(); + } + } + if (!m_keyframeChangesMap.isEmpty()) { const auto objects = m_keyframeChangesMap.keys(); for (int object : objects) { @@ -863,6 +893,7 @@ void TimelineWidget::onAsyncUpdate() m_dirtyProperties.clear(); m_moveMap.clear(); m_actionChanges.clear(); + m_subpresentationChanges.clear(); m_keyframeChangesMap.clear(); m_graphicsScene->rowManager()->finalizeRowDeletions(); } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h index da01a1b0..20afd7a9 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h @@ -164,6 +164,7 @@ private: QMultiHash<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle> m_dirtyProperties; QHash<int, int> m_moveMap; // key: child handle, value: parent handle QSet<int> m_actionChanges; // key: object handle + QSet<int> m_subpresentationChanges; // key: object handle QMultiHash<int, int> m_keyframeChangesMap; // key: object handle, value: property handle QTimer m_asyncUpdateTimer; bool m_fullReconstruct = false; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 60e76447..c4afd2cb 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -179,6 +179,7 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q return; static const int ICON_SIZE = 16; + static const int LEFT_DIVIDER = 18; const int offset = 5 + m_depth * TimelineConstants::ROW_DEPTH_STEP; const int iconY = (TimelineConstants::ROW_H / 2) - (ICON_SIZE / 2); @@ -210,7 +211,7 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q // left divider painter->setPen(CStudioPreferences::timelineWidgetBgColor()); - painter->drawLine(18, 0, 18, size().height() - 1); + painter->drawLine(LEFT_DIVIDER, 0, LEFT_DIVIDER, size().height() - 1); // Shy, eye, lock separator painter->fillRect(QRect(treeWidth() - TimelineConstants::TREE_ICONS_W, @@ -253,6 +254,15 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q static const QPixmap pixCompAction = QPixmap(":/images/Action-ComponentAction.png"); if (!isProperty()) { + // subpresentation indicators + if (m_hasSubpresentation) { + painter->fillRect(QRect(0, 0, LEFT_DIVIDER, size().height() - 1), + CStudioPreferences::timelineRowSubpColor()); + } else if (!expanded() && m_numDescendantSubpresentations > 0) { + painter->fillRect(QRect(0, 0, LEFT_DIVIDER, size().height() - 1), + CStudioPreferences::timelineRowSubpDescendantColor()); + } + if (m_actionStates & ActionState::MasterAction) // has master action painter->drawPixmap(0, 0, pixMasterAction); else if (m_actionStates & ActionState::Action) // has action @@ -865,6 +875,35 @@ void RowTree::updateLock(bool state) m_scene->keyframeManager()->deselectRowKeyframes(this); } +void RowTree::updateSubpresentations(int updateParentsOnlyVal) +{ + if (updateParentsOnlyVal != 0) { + int n = m_numDescendantSubpresentations; + if (m_hasSubpresentation) + n++; + if (n > 0) { + RowTree *parentRow = m_parentRow; + while (parentRow) { + parentRow->m_numDescendantSubpresentations += n * updateParentsOnlyVal; + parentRow = parentRow->m_parentRow; + } + } + } else { + auto binding = static_cast<Qt3DSDMTimelineItemBinding *>(m_binding); + bool hasSubp = binding->hasSubpresentation(); + + if (m_hasSubpresentation != hasSubp) { + m_hasSubpresentation = hasSubp; + int n = hasSubp ? 1 : -1; + RowTree *parentRow = m_parentRow; + while (parentRow) { + parentRow->m_numDescendantSubpresentations += n; + parentRow = parentRow->m_parentRow; + } + } + } +} + void RowTree::updateLabelPosition() { int offset = 5 + m_depth * TimelineConstants::ROW_DEPTH_STEP + 30; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h index b714765c..d606d83f 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h @@ -91,7 +91,7 @@ public: void addChildAt(RowTree *child, int index); void removeChild(RowTree *child); void setDnDState(DnDState state, DnDState onlyIfState = DnDState::Any, bool recursive = false); - void setActionStates(RowTree::ActionStates states); + void setActionStates(ActionStates states); void setTreeWidth(double w); void setBinding(ITimelineItemBinding *binding); void setPropBinding(ITimelineItemProperty *binding); // for property rows @@ -146,7 +146,7 @@ public: void updateArrowVisibility(); void updateFilter(); void updateLock(bool state); - + void updateSubpresentations(int updateParentsOnlyVal = 0); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; @@ -182,6 +182,8 @@ private: bool m_visibilityCtrld = false; DnDState m_dndState = DnDState::None; ActionStates m_actionStates = ActionState::None; + bool m_hasSubpresentation = false; + int m_numDescendantSubpresentations = 0; ExpandState m_expandState = ExpandState::HiddenCollapsed; TimelineGraphicsScene *m_scene; RowTreeLabelItem m_labelItem; |