diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-07-26 14:49:10 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-09-11 09:06:10 +0300 |
commit | 025beb76e9abfba594870ee480448a1fa0a3ca09 (patch) | |
tree | 65b853dd156ab33000d6bfba1373760730011b40 | |
parent | 5665b3264179f97eabe92e77afbd7a3eaaf743f0 (diff) |
Make visibility setting for elements in master slide persistent
Make datainput-driven visibility setting persistent over slide changes, for
elements that are on master slide. This prevents slide initial value from
overriding the user set visibility. Override takes place at first DI-driven
visibility change.
Change-Id: I799872ebd9834df9e74dd1e5e53a59c57e02255f
Task-id: QT3DS-3925
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r-- | src/runtime/Qt3DSActivationManager.cpp | 28 | ||||
-rw-r--r-- | src/runtime/Qt3DSActivationManager.h | 2 | ||||
-rw-r--r-- | src/runtime/Qt3DSElementSystem.h | 13 | ||||
-rw-r--r-- | src/runtime/Qt3DSKernelTypes.h | 1 | ||||
-rw-r--r-- | src/runtime/Qt3DSQmlEngine.cpp | 13 | ||||
-rw-r--r-- | src/uipparser/Qt3DSUIPParserImpl.cpp | 3 |
6 files changed, 55 insertions, 5 deletions
diff --git a/src/runtime/Qt3DSActivationManager.cpp b/src/runtime/Qt3DSActivationManager.cpp index a976032..7015a61 100644 --- a/src/runtime/Qt3DSActivationManager.cpp +++ b/src/runtime/Qt3DSActivationManager.cpp @@ -190,6 +190,7 @@ struct STimeContext TTimeEventList m_TimeEventBackingStore; TTimeEventList m_TimeEvents; SActivationManagerNodeDirtyList m_DirtyList; + SActivationManagerNodeDirtyList m_ControlledList; QT3DSU32 m_TimeEventBackingStoreIndex; QT3DSI32 mRefCount; STimeContext *m_NextSibling; @@ -207,6 +208,7 @@ struct STimeContext , m_TimeEventBackingStore(alloc, "TimeEventBackingStore") , m_TimeEvents(alloc, "TimeEvents") , m_DirtyList(alloc) + , m_ControlledList(alloc) , m_TimeEventBackingStoreIndex(0) , mRefCount(0) , m_NextSibling(NULL) @@ -493,6 +495,11 @@ struct STimeContext } } + void setControlled(TActivityItem &item) + { + m_ControlledList.insert(item); + } + static void UpdateItemScriptStatus(SElement &inNode, bool activeAndHasScript, TElementAndSortKeyList &scriptBuffer) { @@ -542,7 +549,9 @@ struct STimeContext static void RunActivateScan(SElement &inNode, TScanBuffer &inScanBuffer, TElementAndSortKeyList &activateBuffer, TElementAndSortKeyList &deactivateBuffer, - TElementAndSortKeyList &scriptBuffer, Mutex &inElementAccessMutex, + TElementAndSortKeyList &scriptBuffer, + SActivationManagerNodeDirtyList &controlledList, + Mutex &inElementAccessMutex, bool &scriptBufferRequiresSort, bool inRunFullScan) { inScanBuffer.clear(); @@ -563,7 +572,10 @@ struct STimeContext QT3DS_ASSERT(theScanNode->IsIndependent() == false); bool parentActive = theEntry.IsParentActive(); bool wasActive = theScanNode->IsGlobalActive(); - bool isActive = theScanNode->IsGlobalActive(parentActive); + + // Override visibility for master slide elements that have datainput eyeball controller. + bool isActive = (controlledList.contains(*theScanNode) && theScanNode->m_OnMaster) + ? theScanNode->IsControlledActive() : theScanNode->IsGlobalActive(parentActive); bool wasChildDirty = theScanNode->m_ActivationManagerNode.m_Flags.IsChildDirty(); theScanNode->m_ActivationManagerNode.m_Flags.ClearChildDirty(); bool activateChange = isActive != wasActive; @@ -576,6 +588,10 @@ struct STimeContext if (checkChildren && theScanNode->m_Child) { for (SElement *theScanNodeChild = theScanNode->m_Child; theScanNodeChild; theScanNodeChild = theScanNodeChild->m_Sibling) { + // Override visibility for master slide elements that have datainput + // eyeball controller. + if (controlledList.contains(*theScanNodeChild) && theScanNodeChild->m_OnMaster) + theScanNodeChild->SetExplicitActive(theScanNodeChild->IsControlledActive()); if (theScanNodeChild->IsIndependent() == false) inScanBuffer.push_back(SScanBufferEntry(theScanNodeChild, isActive)); } @@ -612,7 +628,8 @@ struct STimeContext // dirty list. // This case has got to be extremely rare in practice, however. RunActivateScan(dirtyNode, inScanBuffer, activateBuffer, deactivateBuffer, scriptBuffer, - m_ElementAccessMutex, scriptBufferRequiresSort, m_AllNodesDirty); + m_ControlledList, m_ElementAccessMutex, scriptBufferRequiresSort, + m_AllNodesDirty); } // Set at end so while debugging you can see if all nodes were dirty on method entry. m_AllNodesDirty = false; @@ -995,6 +1012,11 @@ struct SActivityZone : public IActivityZone { GetItemTimeContext(inItem).GoToTime(inTime); } + + void setControlled(TActivityItem inItem) override + { + GetItemTimeContext(inItem).setControlled(inItem); + } }; struct SActivityZoneManager : public IActivityZoneManager diff --git a/src/runtime/Qt3DSActivationManager.h b/src/runtime/Qt3DSActivationManager.h index f343ac9..48f5d4c 100644 --- a/src/runtime/Qt3DSActivationManager.h +++ b/src/runtime/Qt3DSActivationManager.h @@ -140,6 +140,8 @@ namespace runtime { virtual void EndUpdate() = 0; virtual void GoToTime(TActivityItem item, TTimeUnit inTime) = 0; + + virtual void setControlled(TActivityItem item) = 0; }; class IActivityZoneManager : public NVRefCounted diff --git a/src/runtime/Qt3DSElementSystem.h b/src/runtime/Qt3DSElementSystem.h index 15895c0..2784420 100644 --- a/src/runtime/Qt3DSElementSystem.h +++ b/src/runtime/Qt3DSElementSystem.h @@ -201,7 +201,10 @@ namespace runtime { { return this->operator&(Q3DStudio::ELEMENTFLAG_EXPLICITACTIVE); } - + bool IsControlledActive() const + { + return this->operator&(Q3DStudio::ELEMENTFLAG_CONTROLLED_ACTIVE); + } void SetActive(bool inValue) { clearOrSet(inValue, Q3DStudio::ELEMENTFLAG_GLOBALACTIVE); @@ -283,6 +286,7 @@ namespace runtime { SElement *m_Parent; ///< Parent element in activity graph SElement *m_Sibling; ///< Next sibling element in activity graph SElement *m_Child; ///< First child element in activity graph + bool m_OnMaster = false; void *m_Association; ///< Link to associated asset in scene Q3DStudio::IPresentation *m_BelongedPresentation; SActivationManagerNode m_ActivationManagerNode; @@ -429,6 +433,13 @@ namespace runtime { } bool IsExplicitActive() const { return m_Flags.IsExplicitActive(); } + void SetControlledActive(bool inValue) + { + SetFlag(Q3DStudio::ELEMENTFLAG_CONTROLLED_ACTIVE, inValue); + } + + bool IsControlledActive() const { return m_Flags.IsControlledActive(); } + // Flag set by the activity manager. void SetActive(bool inValue) { SetFlag(Q3DStudio::ELEMENTFLAG_GLOBALACTIVE, inValue); } bool GetActive() const { return m_Flags.IsActive(); } diff --git a/src/runtime/Qt3DSKernelTypes.h b/src/runtime/Qt3DSKernelTypes.h index 0ad4ec6..bc13230 100644 --- a/src/runtime/Qt3DSKernelTypes.h +++ b/src/runtime/Qt3DSKernelTypes.h @@ -143,6 +143,7 @@ enum EElementFlag { // Flags used by the activation manager ELEMENTFLAG_AMGR_TIMEACTIVE = 1 << 13, ///< Is the element alive according to time information + ELEMENTFLAG_CONTROLLED_ACTIVE = 1 << 14 }; // Four byte aligned time unit structure. diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp index 3ef4b11..0bfddba 100644 --- a/src/runtime/Qt3DSQmlEngine.cpp +++ b/src/runtime/Qt3DSQmlEngine.cpp @@ -921,10 +921,21 @@ void CQmlEngineImpl::SetDataInputValue( << diDef.type; break; } - SetAttribute(ctrlElem.elementPath.constData(), ctrlElem.attributeName.first().constData(), reinterpret_cast<const char *>(&valueBool)); + + // Special case for eyeball (visibility) controller that targets elements + // on master slide, and whose visibility setting must be persistent over + // slide changes. + TElement *element = getTarget(ctrlElem.elementPath.constData()); + auto hash = CHash::HashAttribute(ctrlElem.attributeName.first().constData()); + + if (hash == Q3DStudio::ATTRIBUTE_EYEBALL && element->m_OnMaster) { + element->GetActivityZone().setControlled(*element); + element->SetControlledActive(valueBool); + } + break; } case ATTRIBUTETYPE_STRING: { diff --git a/src/uipparser/Qt3DSUIPParserImpl.cpp b/src/uipparser/Qt3DSUIPParserImpl.cpp index 60e4317..80187bf 100644 --- a/src/uipparser/Qt3DSUIPParserImpl.cpp +++ b/src/uipparser/Qt3DSUIPParserImpl.cpp @@ -2148,6 +2148,9 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m TPropertyDescAndValueList theAttributeList; + if (masterSlide) + inElementData.m_Element->m_OnMaster = true; + const char8_t *theRef = ""; inReader.Att("ref", theRef); if (theRef && *theRef && theRef[0] == '#') |