diff options
Diffstat (limited to 'src/Authoring/Studio/Palettes/Timeline/Bindings')
24 files changed, 46 insertions, 1806 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp index 32e19a15..909efdbb 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp @@ -36,7 +36,6 @@ // Includes //============================================================================== #include "GroupTimelineItemBinding.h" -#include "BaseStateRow.h" #include "TimelineTranslationManager.h" #include "StudioApp.h" #include "Core.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.h index 3ac8a6e3..cd7f9dad 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.h @@ -42,7 +42,6 @@ //============================================================================== class ITimelineItem; class CTimelineTranslationManager; -class CBaseStateRow; //============================================================================= /** diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/IKeyframeSelector.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/IBreadCrumbProvider.h index db8b551f..1a8beb0a 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/IKeyframeSelector.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/IBreadCrumbProvider.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 NVIDIA Corporation. +** Copyright (C) 2008 NVIDIA Corporation. ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** @@ -27,26 +27,46 @@ ** ****************************************************************************/ -#ifndef INCLUDED_IKEYFRAME_SELECTOR_H -#define INCLUDED_IKEYFRAME_SELECTOR_H 1 +#ifndef INCLUDED_IBREADCRUMBPROVIDER_H +#define INCLUDED_IBREADCRUMBPROVIDER_H 1 #pragma once +#include <QColor> +#include <QString> +#include <QObject> + +QT_FORWARD_DECLARE_CLASS(QPixmap) + +struct SBreadCrumb +{ + QColor m_Color; /// Color for text of the bread crumb + QString m_String; /// Text to be displayed for the bread crumb +}; + //============================================================================= /** - * Interface that performs keyframe selection. + * A interface class for the breadcrumb control, to walk down the breadcrumb trail, without having + * to know any underlying implementations. */ -//============================================================================= -class IKeyframeSelector +class IBreadCrumbProvider : public QObject { + Q_OBJECT +public: + typedef std::vector<SBreadCrumb> TTrailList; + public: - virtual ~IKeyframeSelector() {} + virtual ~IBreadCrumbProvider() {} + + virtual TTrailList GetTrail(bool inRefresh = true) = 0; + virtual void OnBreadCrumbClicked(long inTrailIndex) = 0; - //============================================================================= - /** - * @param inTime -1 to selected (or deselect) ALL keyframes, otherwise only by time. - */ - virtual void SelectKeyframes(bool inSelected, long inTime = -1) = 0; + virtual QPixmap GetRootImage() const = 0; + virtual QPixmap GetBreadCrumbImage() const = 0; + virtual QPixmap GetSeparatorImage() const = 0; + virtual QPixmap GetActiveBreadCrumbImage() const = 0; +Q_SIGNALS: + void SigBreadCrumbUpdate(); }; -#endif // INCLUDED_IKEYFRAME_SELECTOR_H +#endif // INCLUDED_IBREADCRUMBPROVIDER_H diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h index e5af8671..b4cbe7e9 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItem.h @@ -58,8 +58,6 @@ public: virtual void SetLocked(bool) = 0; virtual bool IsVisible() const = 0; virtual void SetVisible(bool) = 0; - virtual bool IsExpanded() const = 0; - virtual void SetExpanded(bool) = 0; virtual bool IsImported() const { return false; } // Actions diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h index 5f1dfe40..2e804d85 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h @@ -33,10 +33,8 @@ #include "ITimelineItem.h" #include "ITimelineItemProperty.h" -#include "IKeyframeSelector.h" #include "SIterator.h" -class CBaseStateRow; class RowTree; class CControlWindowListener; class ITimelineKeyframesManager; @@ -51,12 +49,7 @@ public: virtual void InsertKeyframe() = 0; virtual void DeleteAllChannelKeyframes() = 0; - virtual long GetKeyframeCount() const = 0; virtual IKeyframe *GetKeyframeByTime(long inTime) const = 0; - virtual IKeyframe *GetKeyframeByIndex(long inIndex) const = 0; - virtual long OffsetSelectedKeyframes(long inOffset) = 0; - virtual void CommitChangedKeyframes() = 0; - virtual void OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) = 0; }; //============================================================================= @@ -64,7 +57,7 @@ public: * Interface to encapsulate data model specific functions, that Timeline UI objects can talk to. */ //============================================================================= -class ITimelineItemBinding : public ITimelineItemKeyframesHolder, public IKeyframeSelector +class ITimelineItemBinding : public ITimelineItemKeyframesHolder { public: // List of possible transactions that requires querying the data model if they are valid @@ -84,14 +77,12 @@ public: virtual ~ITimelineItemBinding() {} virtual ITimelineItem *GetTimelineItem() = 0; - virtual CBaseStateRow *GetRow() = 0; // Mahmoud_TODO: remove after timeline is complete virtual RowTree *getRowTree() const = 0; // UI virtual void setRowTree(RowTree *row) = 0; // Events virtual void SetSelected(bool multiSelect) = 0; virtual void OnCollapsed() = 0; - virtual void ClearKeySelection() = 0; virtual bool OpenAssociatedEditor() = 0; virtual void SetDropTarget(CDropTarget *inTarget) = 0; @@ -110,10 +101,6 @@ public: virtual bool IsLockedEnabled() const = 0; virtual bool IsVisibleEnabled() const = 0; - // Init/Cleanup - virtual void Bind(CBaseStateRow *inRow) = 0; - virtual void Release() = 0; - // ContextMenu virtual bool IsValidTransaction(EUserTransaction inTransaction) = 0; virtual void PerformTransaction(EUserTransaction inTransaction) = 0; @@ -124,13 +111,6 @@ public: virtual bool IsInternalizeable() { return false; } virtual void Internalize() {} - // Selected keyframes - virtual ITimelineKeyframesManager *GetKeyframesManager() const = 0; - - // Properties - virtual void RemoveProperty(ITimelineItemProperty *inProperty) = 0; - virtual void LoadProperties() = 0; - void setCreateUIRow(bool create) { m_createUIRow = create; } protected: diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h index 26b00c09..72488480 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h @@ -32,21 +32,18 @@ #pragma once -#include "IKeyframeSelector.h" #include "Qt3DSDMMetaData.h" #include "Qt3DSString.h" class RowTree; -class CPropertyRow; class IKeyframe; -class ITimelineKeyframesManager; //============================================================================= /** * Abstraction of a data model item's property that is displayed in the Timeline. */ //============================================================================= -class ITimelineItemProperty : public IKeyframeSelector +class ITimelineItemProperty { public: virtual ~ITimelineItemProperty() {} @@ -58,26 +55,18 @@ public: virtual float GetMinimumValue() const = 0; virtual void SetSelected() = 0; - virtual void ClearKeySelection() = 0; virtual void DeleteAllKeys() = 0; - virtual void Bind(CPropertyRow *inRow) = 0; - virtual void Release() = 0; virtual void setRowTree(RowTree *row) = 0; virtual RowTree *getRowTree() const = 0; - virtual CPropertyRow *GetRow() = 0; // Mahmoud_TODO: delete after new timeline is done // Keyframes - virtual ITimelineKeyframesManager *GetKeyframesManager() const = 0; virtual IKeyframe *GetKeyframeByTime(long inTime) const = 0; virtual IKeyframe *GetKeyframeByIndex(long inIndex) const = 0; virtual long GetKeyframeCount() const = 0; virtual long GetChannelCount() const = 0; virtual float GetChannelValueAtTime(long inChannelIndex, long inTime) = 0; virtual void SetChannelValueAtTime(long inChannelIndex, long inTime, float inValue) = 0; - virtual long OffsetSelectedKeyframes(long inOffset) = 0; - virtual void CommitChangedKeyframes() = 0; - virtual void OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) = 0; virtual bool IsDynamicAnimation() = 0; }; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp index 8b53aba0..169d1667 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp @@ -38,7 +38,6 @@ #include "ImageTimelineItemBinding.h" #include "TimelineTranslationManager.h" #include "Qt3DSDMHandles.h" -#include "BaseStateRow.h" #include "Doc.h" #include "IObjectReferenceHelper.h" #include "EmptyTimelineTimebar.h" @@ -81,12 +80,6 @@ bool CImageTimelineItemBinding::ShowToggleControls() const return false; } -void CImageTimelineItemBinding::Bind(CBaseStateRow *inRow) -{ - Qt3DSDMTimelineItemBinding::Bind(inRow); - inRow->requestSetNameReadOnly(); -} - //============================================================================= /** * Open the associated item as though it was double-clicked in explorer diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h index 187cb78a..b9343872 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h @@ -41,7 +41,6 @@ // Classes //============================================================================== class CTimelineTranslationManager; -class CBaseStateRow; class ITimelineTimebar; //============================================================================= @@ -61,7 +60,6 @@ public: void SetName(const Q3DStudio::CString &inName) override; EStudioObjectType GetObjectType() const override; bool ShowToggleControls() const override; - void Bind(CBaseStateRow *inRow) override; bool OpenAssociatedEditor() override; void SetPropertyHandle(qt3dsdm::Qt3DSDMPropertyHandle inProperty) diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp deleted file mode 100644 index 91b24663..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 NVIDIA Corporation. -** Copyright (C) 2017 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$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -#include "KeyframesManager.h" -#include "IDoc.h" -#include "TimeEditDlg.h" -#include "TimelineTranslationManager.h" -#include "Qt3DSDMTimelineKeyframe.h" -#include "Qt3DSDMTimelineItemBinding.h" -#include "CmdDataModelRemoveKeyframe.h" -#include "CmdDataModelInsertKeyframe.h" -#include "CmdDataModelChangeKeyframe.h" -#include "Qt3DSDMAnimation.h" -#include "ClientDataModelBridge.h" -#include "PasteKeyframesCommandHelper.h" -#include "IDocumentEditor.h" -#include "IKeyframe.h" -#include "Dispatch.h" -#include "StudioPreferences.h" - -#include "StudioApp.h" //for CommitCurrentCommand -#include "Core.h" -#include "Dialogs.h" - -using namespace qt3dsdm; - -bool SortKeyframeInstancePairByTime(const CKeyframesManager::SKeyframeInstancePair &inLHS, - const CKeyframesManager::SKeyframeInstancePair &inRHS) -{ - return inLHS.m_Keyframe->GetTime() < inRHS.m_Keyframe->GetTime(); -} - -//============================================================================== -// Keyframe specific. -// DataModel selection is handled by CTimelineTranslationManager. -//============================================================================== -CKeyframesManager::CKeyframesManager(CTimelineTranslationManager *inTransMgr) - : m_TransMgr(inTransMgr) - , m_OffsetKeyframeCommandHelper(*(g_StudioApp.GetCore()->GetDoc())) - , m_PasteKeyframeCommandHelper(nullptr) -{ - // Mahmoud_TODO: to be removed after further clean up -// g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(this); -} - -CKeyframesManager::~CKeyframesManager() -{ - delete m_PasteKeyframeCommandHelper; -} - -bool CKeyframesManager::HasSelectedKeyframes(bool inOnlyDynamic /*= false */) -{ - // specifically only to know if there are any selected keyframes that are dynamic - if (inOnlyDynamic) { - for (size_t theIndex = 0; theIndex < m_SelectedKeyframes.size(); ++theIndex) - if (m_SelectedKeyframes[theIndex].m_Keyframe->IsDynamic()) - return true; - - return false; - } - - bool theRetVal = !m_SelectedKeyframes.empty(); - - return theRetVal; -} - -bool CKeyframesManager::CanPerformKeyframeCopy() -{ - bool theCanCopyNewData = false; - // Legacy system actually prevents copy/pasting between different instances, so let's preserve - // that - if (!m_SelectedKeyframes.empty()) { - theCanCopyNewData = true; - if (m_SelectedKeyframes.size() > 1) { - Qt3DSDMTimelineItemBinding *theInstance = m_SelectedKeyframes[0].m_Instance; - TSelectedKeyframeList::iterator theIter = m_SelectedKeyframes.begin(); - ++theIter; - for (; theIter != m_SelectedKeyframes.end() && theCanCopyNewData; ++theIter) { - if (theIter->m_Instance != theInstance) // fail! - theCanCopyNewData = false; - } - } - } - return theCanCopyNewData; -} - -bool CKeyframesManager::CanPerformKeyframePaste() -{ - if (m_PasteKeyframeCommandHelper && m_PasteKeyframeCommandHelper->HasCopiedKeyframes()) { - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = - g_StudioApp.GetCore()->GetDoc()->GetSelectedInstance(); - if (theSelectedInstance.Valid()) { - return true; - } - } - return false; -} - -void CKeyframesManager::CopyKeyframes() -{ - CopySelectedKeyframes(); -} - -// legacy stuff that we have to support for animation tracks in the old data model to work -inline void PostExecuteCommand(IDoc *inDoc) -{ - CDoc *theDoc = dynamic_cast<CDoc *>(inDoc); - theDoc->GetCore()->CommitCurrentCommand(); - // fire render event. - // theDoc->UpdateClientScene( true ); -} - -//@param inPerformCopy true if that is a copy/cut command. false if this is a delete. -// Note: Keyframes are never explicitly copied to the clipboard (only as part of a asset copy), -// hence that means that the keyframes (only) are never copied across different instances of studio. -bool CKeyframesManager::RemoveKeyframes(bool inPerformCopy) -{ - bool theRetVal = HasSelectedKeyframes(); - - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - - if (inPerformCopy) // copy prior to removing the keyframes - CopySelectedKeyframes(); - - CCmdDataModelRemoveKeyframe *theCmd = nullptr; - if (!m_SelectedKeyframes.empty()) { - TSelectedKeyframeList::iterator theKeyIter = m_SelectedKeyframes.begin(); - for (; theKeyIter != m_SelectedKeyframes.end(); ++theKeyIter) { - Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles; - theKeyIter->m_Keyframe->GetKeyframeHandles(theKeyframeHandles); - ASSERT(!theKeyframeHandles.empty()); - Qt3DSDMTimelineKeyframe::TKeyframeHandleList::iterator theIter = - theKeyframeHandles.begin(); - if (!theCmd) { - theCmd = new CCmdDataModelRemoveKeyframe(theDoc, *theIter); - ++theIter; - } - for (; theIter != theKeyframeHandles.end(); ++theIter) - theCmd->AddKeyframeHandle(*theIter); - } - } - - if (theCmd) { - g_StudioApp.GetCore()->ExecuteCommand(theCmd); - PostExecuteCommand(theDoc); - } - return theRetVal; -} - -// note: we can't paste data from old data model system to the new one, and vice versa. so either -// the old Or the new system succeeds in pasting, never both. -void CKeyframesManager::PasteKeyframes() -{ - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - - if (m_PasteKeyframeCommandHelper && m_PasteKeyframeCommandHelper->HasCopiedKeyframes()) { - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = theDoc->GetSelectedInstance(); - if (theSelectedInstance.Valid()) { - long theCurrentViewTimeInMilliseconds = theDoc->GetCurrentViewTime(); - CCmdDataModelInsertKeyframe *theInsertKeyframesCommand = - m_PasteKeyframeCommandHelper->GetCommand(theDoc, theCurrentViewTimeInMilliseconds, - theSelectedInstance); - if (theInsertKeyframesCommand) - g_StudioApp.GetCore()->ExecuteCommand(theInsertKeyframesCommand); - } - } -} - -//============================================================================= -/** - * Sets interpolation values of all selected keyframes to the values specified - * by the user. Pops up a dialog prompting the user to choose new ease in and - * ease out values. Values in the dialog are initialized to the left-most - * selected keyframe's interpolation values. - */ -void CKeyframesManager::SetKeyframeInterpolation() -{ - if (!HasSelectedKeyframes()) - return; - - float theEaseIn = 0; - float theEaseOut = 0; - if (CStudioPreferences::GetInterpolation()) - theEaseIn = theEaseOut = 100; - - IAnimationCore *theAnimationCore = m_TransMgr->GetStudioSystem()->GetAnimationCore(); - - if (!m_SelectedKeyframes.empty()) // this is a sorted list, so we only need to grab tge ease - // in/out values from the first item in this list. - { - Qt3DSDMTimelineKeyframe *theTimelineKeyframe = m_SelectedKeyframes.front().m_Keyframe; - Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles; - theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles); - TKeyframe theKeyframeData = theAnimationCore->GetKeyframeData(theKeyframeHandles[0]); - GetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut); - } - - if (g_StudioApp.GetDialogs()->PromptForKeyframeInterpolation(theEaseIn, theEaseOut)) { - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - Q3DStudio::ScopedDocumentEditor editor(*theDoc, L"Set Keyframe Interpolation", __FILE__, - __LINE__); - TSelectedKeyframeList::iterator theKeyIter = m_SelectedKeyframes.begin(); - for (; theKeyIter != m_SelectedKeyframes.end(); ++theKeyIter) { - Qt3DSDMTimelineKeyframe *theTimelineKeyframe = theKeyIter->m_Keyframe; - Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles; - theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles); - for (size_t i = 0; i < theKeyframeHandles.size(); ++i) { - TKeyframe theKeyframeData = - theAnimationCore->GetKeyframeData(theKeyframeHandles[i]); - SetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut); - theAnimationCore->SetKeyframeData(theKeyframeHandles[i], theKeyframeData); - } - } - } -} - -bool CKeyframesManager::HasDynamicKeyframes() -{ - Qt3DSDMTimelineItemBinding *theBinding = m_TransMgr->GetSelectedBinding(); - if (theBinding) { - return theBinding->HasDynamicKeyframes(-1); - } - return false; -} - -void CKeyframesManager::SelectAllKeyframes() -{ - ITimelineItemBinding *theBinding = m_TransMgr->GetSelectedBinding(); - if (theBinding) - theBinding->SelectKeyframes(true); -} - -void CKeyframesManager::DeselectAllKeyframes() -{ - m_TransMgr->ClearBindingsKeyframeSelection(); - m_SelectedKeyframes.clear(); -} - -//============================================================================== -/** - * Sets keyframes on all the changed properties of the selected object. - * Also known as autoset keyframes, but it only applies to one object, and is - * the result of an F6 key press. Tells the TimelineCtrl to autoset keyframes. - */ -void CKeyframesManager::SetChangedKeyframes() -{ - - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = theDoc->GetSelectedInstance(); - if (theSelectedInstance.Valid()) { - using namespace Q3DStudio; - Q3DStudio::ScopedDocumentEditor editor(*theDoc, L"Set Changed Keyframes", __FILE__, - __LINE__); - CStudioSystem *theStudioSystem = theDoc->GetStudioSystem(); - // Get all animated properties. - TPropertyHandleList theProperties; - theStudioSystem->GetPropertySystem()->GetAggregateInstanceProperties(theSelectedInstance, - theProperties); - for (size_t thePropertyIndex = 0; thePropertyIndex < theProperties.size(); - ++thePropertyIndex) { - if (theStudioSystem->GetAnimationSystem()->IsPropertyAnimated( - theSelectedInstance, theProperties[thePropertyIndex])) - editor->KeyframeProperty(theSelectedInstance, theProperties[thePropertyIndex], - true); - } - } -} - -void CKeyframesManager::SetKeyframeTime(long inTime) -{ - CTimeEditDlg theTimeEditDlg; - theTimeEditDlg.setKeyframesManager(this); - theTimeEditDlg.showDialog(inTime, g_StudioApp.GetCore()->GetDoc(), ASSETKEYFRAME); -} - -void CKeyframesManager::SetKeyframeDynamic(Qt3DSDMTimelineKeyframe *inKeyframe, bool inDynamic) -{ - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - qt3dsdm::TKeyframeHandleList theKeyframeHandle; - CCmdDataModelChangeDynamicKeyframe *theCmd = nullptr; - - if (inKeyframe != nullptr) - inKeyframe->GetKeyframeHandles(theKeyframeHandle); - - qt3dsdm::IAnimationCore *theAnimationCore = theDoc->GetStudioSystem()->GetAnimationCore(); - for (size_t theKeyframe = 0; theKeyframe < theKeyframeHandle.size(); ++theKeyframe) { - qt3dsdm::Qt3DSDMAnimationHandle theAnimation( - theAnimationCore->GetAnimationForKeyframe(theKeyframeHandle.at(theKeyframe))); - if (!theCmd) - theCmd = new CCmdDataModelChangeDynamicKeyframe(theDoc, theAnimation, inDynamic); - else - theCmd->AddHandle(theAnimation); - } - - if (theCmd) - g_StudioApp.GetCore()->ExecuteCommand(theCmd); -} - -void CKeyframesManager::SetKeyframesDynamic(bool inDynamic) -{ - - Qt3DSDMTimelineKeyframe *theKeyframe; - - if (m_SelectedKeyframes.size() == 0) { - Qt3DSDMTimelineItemBinding *theBinding = m_TransMgr->GetSelectedBinding(); - IKeyframe *key = theBinding->GetKeyframeByIndex(0); - theKeyframe = dynamic_cast<Qt3DSDMTimelineKeyframe *>(key); - SetKeyframeDynamic(theKeyframe, inDynamic); - } else { - for (int i = 0; i < (int)m_SelectedKeyframes.size(); ++i) { - theKeyframe = m_SelectedKeyframes[i].m_Keyframe; - SetKeyframeDynamic(theKeyframe, inDynamic); - } - } -} - -long CKeyframesManager::OffsetSelectedKeyframes(long inOffset) -{ - m_InstanceSet.clear(); - m_InstanceList.clear(); - std::set<Qt3DSDMTimelineItemBinding *> &theInstances(m_InstanceSet); - - TSelectedKeyframeList::iterator theKeyIter = m_SelectedKeyframes.begin(); - for (; theKeyIter != m_SelectedKeyframes.end(); ++theKeyIter) { - // since this list is sorted by time and we are iterating from the first in the list - long theKeyframeTime = theKeyIter->m_Keyframe->GetTime(); - if (inOffset < 0 && theKeyframeTime + inOffset < 0) - inOffset = -theKeyframeTime; - - theKeyIter->m_Keyframe->UpdateKeyframesTime(&m_OffsetKeyframeCommandHelper, - theKeyframeTime + inOffset); - - // this contains unique instancs, i.e. mulitple keyframe can map to the same instances - if (theInstances.insert(theKeyIter->m_Instance).second) - m_InstanceList.push_back(theKeyIter->m_Instance->GetInstance()); - } - - // UI update, explicitly because this doesn't generate any events till action is committed - std::set<Qt3DSDMTimelineItemBinding *>::iterator theInstanceIter = theInstances.begin(); - for (; theInstanceIter != theInstances.end(); ++theInstanceIter) - (*theInstanceIter)->UIRefreshPropertyKeyframe(inOffset); - - if (m_InstanceList.size()) - m_TransMgr->GetDoc()->GetCore()->GetDispatch()->FireImmediateRefreshInstance( - &m_InstanceList[0], (long)m_InstanceList.size()); - - // by contract, this functions returns the "legal" offset, ie time cannot be offset to negative. - return inOffset; -} - -void CKeyframesManager::CommitChangedKeyframes() -{ - m_OffsetKeyframeCommandHelper.Finalize(); -} - -void CKeyframesManager::RollbackChangedKeyframes() -{ - m_OffsetKeyframeCommandHelper.Rollback(); -} - -bool CKeyframesManager::CanMakeSelectedKeyframesDynamic() -{ - using namespace qt3dsdm; - TKeyframeHandleList theKeyframes; - TKeyframeHandleList allTheKeyframes; - IAnimationCore &theAnimationCore( - *g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetAnimationCore()); - // Ensure that all keyframes selected are the first keyframes from the animation track. - for (size_t idx = 0, end = m_SelectedKeyframes.size(); idx < end; ++idx) { - theKeyframes.clear(); - m_SelectedKeyframes.at(idx).m_Keyframe->GetKeyframeHandles(theKeyframes); - for (size_t specificKeyframeIdx = 0, specificKeyframeEnd = theKeyframes.size(); - specificKeyframeIdx < specificKeyframeEnd; ++specificKeyframeIdx) { - Qt3DSDMKeyframeHandle theKeyframe = theKeyframes[specificKeyframeIdx]; - Qt3DSDMAnimationHandle theAnimation = - theAnimationCore.GetAnimationForKeyframe(theKeyframe); - allTheKeyframes.clear(); - theAnimationCore.GetKeyframes(theAnimation, allTheKeyframes); - if (allTheKeyframes[0] != theKeyframe) - return false; - } - } - return true; -} - -// keeps track of selected keyframes so that we don't have to iterate through the entire hierarchy -// to find them -void CKeyframesManager::SetKeyframeSelected(Qt3DSDMTimelineKeyframe *inKeyframe, bool inSelected, - Qt3DSDMTimelineItemBinding *inOwningInstance /*= nullptr */) -{ - TSelectedKeyframeList::iterator theKeyIter = m_SelectedKeyframes.begin(); - for (; theKeyIter != m_SelectedKeyframes.end(); ++theKeyIter) { - if (theKeyIter->m_Keyframe == inKeyframe) - break; - } - if (inSelected) { - ASSERT(inOwningInstance); - if (theKeyIter == m_SelectedKeyframes.end()) { // only this is not already selected - m_SelectedKeyframes.push_back(SKeyframeInstancePair(inKeyframe, inOwningInstance)); - std::sort(m_SelectedKeyframes.begin(), m_SelectedKeyframes.end(), - SortKeyframeInstancePairByTime); - } - } else if (theKeyIter != m_SelectedKeyframes.end()) { - m_SelectedKeyframes.erase(theKeyIter); - } -} - -qt3dsdm::SGetOrSetKeyframeInfo SetupKeyframeInfo(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, - qt3dsdm::IAnimationCore &inCore) -{ - TKeyframe theKeyframeData = inCore.GetKeyframeData(inKeyframe); - SEaseInEaseOutKeyframe theKeyframe = qt3dsdm::get<SEaseInEaseOutKeyframe>(theKeyframeData); - // Is this the first keyframe? - bool isDynamic = false; - if (inCore.IsFirstKeyframe(inKeyframe)) - isDynamic = inCore.GetAnimationInfo(inCore.GetAnimationForKeyframe(inKeyframe)) - .m_DynamicFirstKeyframe; - - return SGetOrSetKeyframeInfo(theKeyframe.m_KeyframeValue, theKeyframe.m_EaseIn, - theKeyframe.m_EaseOut, isDynamic); -} - -// only deal with this manager's selected keyframes -void CKeyframesManager::CopySelectedKeyframes() -{ - if (!m_SelectedKeyframes.empty()) { - if (m_PasteKeyframeCommandHelper) - m_PasteKeyframeCommandHelper->Clear(); // clear out previously copied data - else - m_PasteKeyframeCommandHelper = new CPasteKeyframeCommandHelper(); - - // note: m_SelectedKeyframes is already sorted by time - float theEarliestKeyframeTimeInSecs = - Qt3DSDMTimelineKeyframe::GetTimeInSecs(m_SelectedKeyframes[0].m_Keyframe->GetTime()); - - IAnimationCore *theAnimationCore = m_TransMgr->GetStudioSystem()->GetAnimationCore(); - TSelectedKeyframeList::iterator theIter = m_SelectedKeyframes.begin(); - for (; theIter != m_SelectedKeyframes.end(); ++theIter) { - Qt3DSDMTimelineKeyframe *theKeyframe = (*theIter).m_Keyframe; - Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles; - theKeyframe->GetKeyframeHandles(theKeyframeHandles); - qt3dsdm::SGetOrSetKeyframeInfo theInfos[3]; - size_t theValidInfos = 0; - if (!theKeyframeHandles.empty()) { - // TODO: need to figure out a good way to convert from individual keyframes back to - // SValue - SValue theValue; - switch (theKeyframeHandles.size()) { - case 1: { - theInfos[0] = SetupKeyframeInfo(theKeyframeHandles[0], *theAnimationCore); - theValidInfos = 1; - - } break; - case 3: { - theInfos[0] = SetupKeyframeInfo(theKeyframeHandles[0], *theAnimationCore); - theInfos[1] = SetupKeyframeInfo(theKeyframeHandles[1], *theAnimationCore); - theInfos[2] = SetupKeyframeInfo(theKeyframeHandles[2], *theAnimationCore); - theValidInfos = 3; - } break; - default: // not handled - break; - } - // time is relative to the earliest keyframe time. - float theRelativeTimeInSecs = - Qt3DSDMTimelineKeyframe::GetTimeInSecs(theKeyframe->GetTime()) - - theEarliestKeyframeTimeInSecs; - - Qt3DSDMAnimationHandle theAnimation = - theAnimationCore->GetAnimationForKeyframe(theKeyframeHandles[0]); - m_PasteKeyframeCommandHelper->AddKeyframeData( - theAnimationCore->GetAnimationInfo(theAnimation).m_Property, - theRelativeTimeInSecs, theInfos, theValidInfos); - } - } - } -} diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.h deleted file mode 100644 index c20de57e..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 NVIDIA Corporation. -** Copyright (C) 2017 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$ -** -****************************************************************************/ - -#ifndef INCLUDED_KEYFRAMES_MANAGER_H -#define INCLUDED_KEYFRAMES_MANAGER_H 1 - -#pragma once - -#include "ITimelineKeyframesManager.h" -#include "OffsetKeyframesCommandHelper.h" - -class CTimelineTranslationManager; -class Qt3DSDMTimelineKeyframe; -class Qt3DSDMTimelineItemBinding; -class CPasteKeyframeCommandHelper; - -//============================================================================= -/** - * Abstraction layer to the class that manages both selected keyframes. - */ -//============================================================================= -class CKeyframesManager : public ITimelineKeyframesManager -{ -public: - CKeyframesManager(CTimelineTranslationManager *inTransMgr); - virtual ~CKeyframesManager(); - - // IKeyframesManager - bool HasSelectedKeyframes(bool inOnlyDynamic = false) override; - bool HasDynamicKeyframes() override; - bool CanPerformKeyframeCopy() override; - bool CanPerformKeyframePaste() override; - void CopyKeyframes() override; - bool RemoveKeyframes(bool inPerformCopy) override; - void PasteKeyframes() override; - void SetKeyframeInterpolation() override; - void DeselectAllKeyframes() override; - void SelectAllKeyframes() override; - void SetChangedKeyframes() override; - // ITimelineKeyframesManager - void SetKeyframeTime(long inTime) override; - void SetKeyframesDynamic(bool inDynamic) override; - bool CanMakeSelectedKeyframesDynamic() override; - long OffsetSelectedKeyframes(long inOffset) override; - void CommitChangedKeyframes() override; - void RollbackChangedKeyframes() override; - - void SetKeyframeSelected(Qt3DSDMTimelineKeyframe *inKeyframe, bool inSelected, - Qt3DSDMTimelineItemBinding *inOwningInstance = nullptr); - -protected: - void SetKeyframeDynamic(Qt3DSDMTimelineKeyframe *inKeyframe, bool inDynamic); - void CopySelectedKeyframes(); - -public: - struct SKeyframeInstancePair - { - Qt3DSDMTimelineKeyframe *m_Keyframe; - Qt3DSDMTimelineItemBinding *m_Instance; - - SKeyframeInstancePair(Qt3DSDMTimelineKeyframe *inKeyframe, - Qt3DSDMTimelineItemBinding *inInstance) - { - m_Keyframe = inKeyframe; - m_Instance = inInstance; - } - }; - -protected: - typedef std::vector<SKeyframeInstancePair> TSelectedKeyframeList; ///< handle multiple keyframes - ///manipulation, e.g. - ///offsetting by dragging - - CTimelineTranslationManager *m_TransMgr; - TSelectedKeyframeList m_SelectedKeyframes; - COffsetKeyframesCommandHelper m_OffsetKeyframeCommandHelper; // so that we can commit on mouseup - CPasteKeyframeCommandHelper *m_PasteKeyframeCommandHelper; - std::set<Qt3DSDMTimelineItemBinding *> m_InstanceSet; - std::vector<qt3dsdm::Qt3DSDMInstanceHandle> m_InstanceList; -}; - -#endif // INCLUDED_IKEYFRAMES_MANAGER_H diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp index 9b11c389..0e7b0b19 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp @@ -37,7 +37,6 @@ //============================================================================== #include "LayerTimelineItemBinding.h" #include "TimelineTranslationManager.h" -#include "BaseStateRow.h" #include "ImageTimelineItemBinding.h" #include "EmptyTimelineTimebar.h" @@ -74,25 +73,6 @@ bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstan return theReturn; } - -// helper function to find the image binding class that 'represents' this property -inline CImageTimelineItemBinding *FindImageBindingByProperty(CBaseStateRow *inRow, - Qt3DSDMPropertyHandle inProperty) -{ - if (!inRow || !inProperty.Valid()) - return nullptr; - - CImageTimelineItemBinding *theInvalidImageBinding = nullptr; - for (long theIndex = 0; theIndex < inRow->GetNumNonPropertyRows(); ++theIndex) { - CImageTimelineItemBinding *theImageBinding = dynamic_cast<CImageTimelineItemBinding *>( - inRow->GetNonPropertyRow(theIndex)->GetTimelineItemBinding()); - if (theImageBinding && theImageBinding->GetPropertyHandle() == inProperty) { - theInvalidImageBinding = theImageBinding; - break; - } - } - return theInvalidImageBinding; -} } CLayerTimelineItemBinding::CLayerTimelineItemBinding(CTimelineTranslationManager *inMgr, @@ -176,66 +156,7 @@ void CLayerTimelineItemBinding::OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inInst void CLayerTimelineItemBinding::OnPropertyChanged(Qt3DSDMPropertyHandle inPropertyHandle) { - bool theHandled = false; - if (m_Row) { - qt3dsdm::IPropertySystem *thePropertySystem = - m_TransMgr->GetStudioSystem()->GetPropertySystem(); - CClientDataModelBridge *theBridge = - m_TransMgr->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::TCharStr thePropertyName = thePropertySystem->GetName(inPropertyHandle); - size_t theSlotCount = m_ImageNameFormalNamePairs.size(); - for (size_t theSlotIndex = 0; theSlotIndex < theSlotCount; ++theSlotIndex) { - qt3dsdm::TCharStr thePropName = std::get<0>(m_ImageNameFormalNamePairs[theSlotIndex]); - if (thePropertyName == thePropName) { - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, thePropName)) { - // already created, bail! - if (m_TransMgr->GetBinding(GetImage(inPropertyHandle))) - return; - - // Image property was changed from one non-zero guid value to another, delete - // the old and and create a new one - CImageTimelineItemBinding *theReplacedImageBinding = - FindImageBindingByProperty(m_Row, inPropertyHandle); - if (theReplacedImageBinding) - m_Row->RemoveChildRow(theReplacedImageBinding); - - ITimelineItemBinding *theNextImageBinding = nullptr; - // Determine if this is inserted somewhere in the existing list. - for (size_t theNextImage = theSlotIndex + 1; theNextImage < theSlotCount; - ++theNextImage) { - qt3dsdm::TCharStr theTempName = - std::get<0>(m_ImageNameFormalNamePairs[theNextImage]); - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, theTempName)) { - Qt3DSDMPropertyHandle theNextImageProperty = - theBridge->GetAggregateInstancePropertyByName(m_DataHandle, - theTempName); - theNextImageBinding = - m_TransMgr->GetBinding(GetImage(theNextImageProperty)); - break; - } - } - m_Row->AddChildRow( - GetOrCreateImageBinding( - inPropertyHandle, - std::get<1>(m_ImageNameFormalNamePairs[theSlotIndex]).wide_str()), - theNextImageBinding); - } else // check for delete - { - // GetImage will not return anything valid since the value is nuked. - // From the UI end, there is no way we can tell which image is associated with - // this property, since that is "encapsulated" in the property value. - CImageTimelineItemBinding *theInvalidImageBinding = - FindImageBindingByProperty(m_Row, inPropertyHandle); - if (theInvalidImageBinding) - m_Row->RemoveChildRow(theInvalidImageBinding); - } - theHandled = true; - break; - } - } - } - if (!theHandled) - Qt3DSDMTimelineItemBinding::OnPropertyChanged(inPropertyHandle); + Qt3DSDMTimelineItemBinding::OnPropertyChanged(inPropertyHandle); } qt3dsdm::Qt3DSDMInstanceHandle diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp index 55598353..59069db7 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp @@ -37,7 +37,6 @@ //============================================================================== #include "MaterialTimelineItemBinding.h" #include "TimelineTranslationManager.h" -#include "BaseStateRow.h" #include "ImageTimelineItemBinding.h" #include "EmptyTimelineTimebar.h" @@ -182,138 +181,14 @@ void CMaterialTimelineItemBinding::OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inI Qt3DSDMTimelineItemBinding::OnAddChild(inInstance); } -// helper function to find the image binding class that 'represents' this property -inline CImageTimelineItemBinding *FindImageBindingByProperty(CBaseStateRow *inRow, - Qt3DSDMPropertyHandle inProperty) -{ - if (!inRow || !inProperty.Valid()) - return nullptr; - - CImageTimelineItemBinding *theInvalidImageBinding = nullptr; - for (long theIndex = 0; theIndex < inRow->GetNumNonPropertyRows(); ++theIndex) { - CImageTimelineItemBinding *theImageBinding = dynamic_cast<CImageTimelineItemBinding *>( - inRow->GetNonPropertyRow(theIndex)->GetTimelineItemBinding()); - if (theImageBinding && theImageBinding->GetPropertyHandle() == inProperty) { - theInvalidImageBinding = theImageBinding; - break; - } - } - return theInvalidImageBinding; -} - void CMaterialTimelineItemBinding::OnPropertyChanged(Qt3DSDMPropertyHandle inPropertyHandle) { - bool theHandled = false; - if (m_Row) { - qt3dsdm::IPropertySystem *thePropertySystem = - m_TransMgr->GetStudioSystem()->GetPropertySystem(); - CClientDataModelBridge *theBridge = - m_TransMgr->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::TCharStr thePropertyName = thePropertySystem->GetName(inPropertyHandle); - size_t theSlotCount = m_ImageNameFormalNamePairs.size(); - for (size_t theSlotIndex = 0; theSlotIndex < theSlotCount; ++theSlotIndex) { - qt3dsdm::TCharStr thePropName = std::get<0>(m_ImageNameFormalNamePairs[theSlotIndex]); - if (thePropertyName == thePropName) { - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, thePropName)) { - // already created, bail! - if (m_TransMgr->GetBinding(GetImage(inPropertyHandle))) - return; - - // Image property was changed from one non-zero guid value to another, delete - // the old and and create a new one - CImageTimelineItemBinding *theReplacedImageBinding = - FindImageBindingByProperty(m_Row, inPropertyHandle); - if (theReplacedImageBinding) - m_Row->RemoveChildRow(theReplacedImageBinding); - - ITimelineItemBinding *theNextImageBinding = nullptr; - // Determine if this is inserted somewhere in the existing list. - for (size_t theNextImage = theSlotIndex + 1; theNextImage < theSlotCount; - ++theNextImage) { - qt3dsdm::TCharStr theTempName = - std::get<0>(m_ImageNameFormalNamePairs[theNextImage]); - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, theTempName)) { - Qt3DSDMPropertyHandle theNextImageProperty = - theBridge->GetAggregateInstancePropertyByName(m_DataHandle, - theTempName); - theNextImageBinding = - m_TransMgr->GetBinding(GetImage(theNextImageProperty)); - break; - } - } - m_Row->AddChildRow( - GetOrCreateImageBinding( - inPropertyHandle, - std::get<1>(m_ImageNameFormalNamePairs[theSlotIndex]).wide_str()), - theNextImageBinding); - } else // check for delete - { - // GetImage will not return anything valid since the value is nuked. - // From the UI end, there is no way we can tell which image is associated with - // this property, since that is "encapsulated" in the property value. - CImageTimelineItemBinding *theInvalidImageBinding = - FindImageBindingByProperty(m_Row, inPropertyHandle); - if (theInvalidImageBinding) - m_Row->RemoveChildRow(theInvalidImageBinding); - } - theHandled = true; - break; - } - } - } - if (!theHandled) - Qt3DSDMTimelineItemBinding::OnPropertyChanged(inPropertyHandle); + Qt3DSDMTimelineItemBinding::OnPropertyChanged(inPropertyHandle); } void CMaterialTimelineItemBinding::OnPropertyLinked(Qt3DSDMPropertyHandle inPropertyHandle) { - bool theHandled = false; - if (m_Row) { - qt3dsdm::IPropertySystem *thePropertySystem = - m_TransMgr->GetStudioSystem()->GetPropertySystem(); - CClientDataModelBridge *theBridge = - m_TransMgr->GetStudioSystem()->GetClientDataModelBridge(); - qt3dsdm::TCharStr thePropertyName = thePropertySystem->GetName(inPropertyHandle); - size_t theSlotCount = m_ImageNameFormalNamePairs.size(); - for (size_t theSlotIndex = 0; theSlotIndex < theSlotCount; ++theSlotIndex) { - qt3dsdm::TCharStr thePropName = std::get<0>(m_ImageNameFormalNamePairs[theSlotIndex]); - if (thePropertyName == thePropName) { - // Refresh image child row by delete and recreate - CImageTimelineItemBinding *theInvalidImageBinding = - FindImageBindingByProperty(m_Row, inPropertyHandle); - if (theInvalidImageBinding) - m_Row->RemoveChildRow(theInvalidImageBinding); - - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, thePropName)) { - ITimelineItemBinding *theNextImageBinding = nullptr; - // Determine if this is inserted somewhere in the existing list. - for (size_t theNextImage = theSlotIndex + 1; theNextImage < theSlotCount; - ++theNextImage) { - qt3dsdm::TCharStr theTempName = - std::get<0>(m_ImageNameFormalNamePairs[theNextImage]); - if (ImageSlotIsFilled(thePropertySystem, m_DataHandle, theTempName)) { - Qt3DSDMPropertyHandle theNextImageProperty = - theBridge->GetAggregateInstancePropertyByName(m_DataHandle, - theTempName); - theNextImageBinding = - m_TransMgr->GetBinding(GetImage(theNextImageProperty)); - break; - } - } - m_Row->AddChildRow( - GetOrCreateImageBinding( - inPropertyHandle, - std::get<1>(m_ImageNameFormalNamePairs[theSlotIndex]).wide_str()), - theNextImageBinding); - } - - theHandled = true; - break; - } - } - } - if (!theHandled) - Qt3DSDMTimelineItemBinding::OnPropertyLinked(inPropertyHandle); + Qt3DSDMTimelineItemBinding::OnPropertyLinked(inPropertyHandle); } qt3dsdm::Qt3DSDMInstanceHandle diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h index 80e7bc47..9f5bebdd 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h @@ -42,7 +42,6 @@ // Classes //============================================================================== class CTimelineTranslationManager; -class CBaseStateRow; //============================================================================= /** diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h index 402f8cea..83997cd1 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h @@ -41,7 +41,6 @@ // Classes //============================================================================== class CTimelineTranslationManager; -class CBaseStateRow; //============================================================================= /** diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.h index 833a265c..ea006044 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.h @@ -40,7 +40,6 @@ // Classes //============================================================================== class CTimelineTranslationManager; -class CBaseStateRow; //============================================================================= /** diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 999062da..f1e5c9cc 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -40,14 +40,12 @@ #include "TimeEditDlg.h" #include "EmptyTimelineTimebar.h" #include "Qt3DSDMTimelineTimebar.h" -#include "BaseStateRow.h" -#include "PropertyRow.h" -#include "KeyframesManager.h" #include "StudioApp.h" #include "Core.h" #include "Dialogs.h" #include "GraphUtils.h" #include "Qt3DSDMDataCore.h" +#include "DropTarget.h" // Data model specific #include "IDoc.h" @@ -72,8 +70,7 @@ using namespace qt3dsdm; Qt3DSDMTimelineItemBinding::Qt3DSDMTimelineItemBinding(CTimelineTranslationManager *inMgr, Qt3DSDMInstanceHandle inDataHandle) - : m_Row(nullptr) - , m_TransMgr(inMgr) + : m_TransMgr(inMgr) , m_DataHandle(inDataHandle) , m_Parent(nullptr) , m_TimelineTimebar(nullptr) @@ -84,8 +81,7 @@ Qt3DSDMTimelineItemBinding::Qt3DSDMTimelineItemBinding(CTimelineTranslationManag } Qt3DSDMTimelineItemBinding::Qt3DSDMTimelineItemBinding(CTimelineTranslationManager *inMgr) - : m_Row(nullptr) - , m_TransMgr(inMgr) + : m_TransMgr(inMgr) , m_DataHandle(0) , m_Parent(nullptr) , m_TimelineTimebar(nullptr) @@ -210,17 +206,6 @@ void Qt3DSDMTimelineItemBinding::SetVisible(bool inVisible) inVisible, QObject::tr("Visibility Toggle")); } -// remember the expanded state for the current presentation -bool Qt3DSDMTimelineItemBinding::IsExpanded() const -{ - return m_TransMgr->IsExpanded(m_DataHandle); -} -// remember the expanded state for the current presentation -void Qt3DSDMTimelineItemBinding::SetExpanded(bool inExpanded) -{ - m_TransMgr->SetExpanded(m_DataHandle, inExpanded); -} - bool Qt3DSDMTimelineItemBinding::HasAction(bool inMaster) { TActionHandleList theActions; @@ -373,12 +358,6 @@ ITimelineItem *Qt3DSDMTimelineItemBinding::GetTimelineItem() return this; } -// Mahmoud_TODO: remove after finishing the new timeline -CBaseStateRow *Qt3DSDMTimelineItemBinding::GetRow() -{ - return m_Row; -} - RowTree *Qt3DSDMTimelineItemBinding::getRowTree() const { return m_rowTree; @@ -412,11 +391,6 @@ void Qt3DSDMTimelineItemBinding::OnCollapsed() } } -void Qt3DSDMTimelineItemBinding::ClearKeySelection() -{ - m_TransMgr->ClearKeyframeSelection(); -} - bool Qt3DSDMTimelineItemBinding::OpenAssociatedEditor() { return false; // nothing to do by default @@ -552,34 +526,6 @@ bool Qt3DSDMTimelineItemBinding::IsVisibleEnabled() const != 0; } -void Qt3DSDMTimelineItemBinding::Bind(CBaseStateRow *inRow) -{ - ASSERT(!m_Row); - m_Row = inRow; - - // Because children(properties included) may only be loaded later, check if there are any - // keyframes without having to have the UI created. - TPropertyHandleList theProperties; - m_StudioSystem->GetPropertySystem()->GetAggregateInstanceProperties(m_DataHandle, - theProperties); - for (size_t thePropertyIndex = 0; thePropertyIndex < theProperties.size(); ++thePropertyIndex) { - if (m_StudioSystem->GetAnimationSystem()->IsPropertyAnimated( - m_DataHandle, theProperties[thePropertyIndex])) - AddKeyframes(GetOrCreatePropertyBinding(theProperties[thePropertyIndex])); - } - - // Set selection status - Qt3DSDMInstanceHandle theSelectedInstance = m_TransMgr->GetDoc()->GetSelectedInstance(); - m_Row->OnSelected(m_DataHandle == theSelectedInstance); -} - -void Qt3DSDMTimelineItemBinding::Release() -{ - m_Row = nullptr; - RemoveAllPropertyBindings(); - m_TransMgr->Unregister(this); -} - bool Qt3DSDMTimelineItemBinding::IsValidTransaction(EUserTransaction inTransaction) { qt3dsdm::Qt3DSDMInstanceHandle theInstance = GetInstance(); @@ -712,31 +658,6 @@ Q3DStudio::CString Qt3DSDMTimelineItemBinding::GetObjectPath() return CRelativePathTools::BuildAbsoluteReferenceString(m_DataHandle, theDoc); } -ITimelineKeyframesManager *Qt3DSDMTimelineItemBinding::GetKeyframesManager() const -{ - return m_TransMgr->GetKeyframesManager(); -} - -void Qt3DSDMTimelineItemBinding::RemoveProperty(ITimelineItemProperty *inProperty) -{ - Q_UNUSED(inProperty); - // TODO: This function has no use in DataModel world. This is replaced by RemovePropertyRow( - // Qt3DSDMPropertyHandle inPropertyHandle ). - // Decide if this function should be removed from ITimelineItemBinding. -} - -void Qt3DSDMTimelineItemBinding::LoadProperties() -{ - TPropertyHandleList theProperties; - m_StudioSystem->GetPropertySystem()->GetAggregateInstanceProperties(m_DataHandle, - theProperties); - for (size_t thePropertyIndex = 0; thePropertyIndex < theProperties.size(); ++thePropertyIndex) { - if (m_StudioSystem->GetAnimationSystem()->IsPropertyAnimated( - m_DataHandle, theProperties[thePropertyIndex])) - AddPropertyRow(theProperties[thePropertyIndex], true); - } -} - int Qt3DSDMTimelineItemBinding::getAnimatedPropertyIndex(int propertyHandle) const { TPropertyHandleList theProperties; @@ -800,12 +721,6 @@ void Qt3DSDMTimelineItemBinding::DeleteAllChannelKeyframes() } } -long Qt3DSDMTimelineItemBinding::GetKeyframeCount() const -{ - // This list is updated when properties are loaded and when keyframes are added & deleted. - return (long)m_Keyframes.size(); -} - IKeyframe *Qt3DSDMTimelineItemBinding::GetKeyframeByTime(long inTime) const { TAssetKeyframeList::const_iterator theIter = m_Keyframes.begin(); @@ -816,39 +731,6 @@ IKeyframe *Qt3DSDMTimelineItemBinding::GetKeyframeByTime(long inTime) const return nullptr; } -IKeyframe *Qt3DSDMTimelineItemBinding::GetKeyframeByIndex(long inIndex) const -{ - if (inIndex >= 0 && inIndex < (long)m_Keyframes.size()) - return const_cast<Qt3DSDMAssetTimelineKeyframe *>(&m_Keyframes[inIndex]); - - ASSERT(0); // should not happen - return nullptr; -} - -long Qt3DSDMTimelineItemBinding::OffsetSelectedKeyframes(long inOffset) -{ - return m_TransMgr->GetKeyframesManager()->OffsetSelectedKeyframes(inOffset); -} - -void Qt3DSDMTimelineItemBinding::CommitChangedKeyframes() -{ - m_TransMgr->GetKeyframesManager()->CommitChangedKeyframes(); -} - -void Qt3DSDMTimelineItemBinding::OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) -{ - CTimeEditDlg theTimeEditDlg; - theTimeEditDlg.setKeyframesManager(m_TransMgr->GetKeyframesManager()); - theTimeEditDlg.showDialog(inCurrentTime, g_StudioApp.GetCore()->GetDoc(), - inObjectAssociation); -} - -void Qt3DSDMTimelineItemBinding::SelectKeyframes(bool inSelected, long inTime /*= -1 */) -{ - // Callback from UI, hence skip the UI update - DoSelectKeyframes(inSelected, inTime, false); -} - Qt3DSDMInstanceHandle Qt3DSDMTimelineItemBinding::GetInstanceHandle() const { return m_DataHandle; @@ -884,20 +766,6 @@ void Qt3DSDMTimelineItemBinding::OnImmediateRefreshInstanceMultiple( void Qt3DSDMTimelineItemBinding::RefreshStateRow(bool inRefreshChildren) { - CStateRow *theRow = dynamic_cast<CStateRow *>(m_Row); - if (theRow) { - theRow->OnTimeChange(); - theRow->setDirty(false); - if (inRefreshChildren) { - const QList<ITimelineItemBinding *> children = GetChildren(); - for (auto child : children) { - Qt3DSDMTimelineItemBinding *theBinding = - static_cast<Qt3DSDMTimelineItemBinding *>(child); - if (theBinding) - theBinding->RefreshStateRow(inRefreshChildren); - } - } - } } ITimelineTimebar *Qt3DSDMTimelineItemBinding::CreateTimelineTimebar() @@ -941,7 +809,7 @@ void Qt3DSDMTimelineItemBinding::AddPropertyRow(Qt3DSDMPropertyHandle inProperty bool inAppend /*= false */) { ITimelineItemProperty *theTimelineProperty = GetPropertyBinding(inPropertyHandle); - if (theTimelineProperty && theTimelineProperty->GetRow()) // if created, bail + if (theTimelineProperty) // if created, bail return; if (!theTimelineProperty) @@ -1001,57 +869,13 @@ void Qt3DSDMTimelineItemBinding::RefreshPropertyKeyframe( if (theProperty->RefreshKeyframe(inKeyframe, inTransaction)) { // Update asset keyframes UpdateKeyframe(theProperty->GetKeyframeByHandle(inKeyframe), inTransaction); - if (m_Row) // UI update - m_Row->setDirty(true); } } } } -// called when the keyframes are updated in the UI and data model hasn't committed the change, ie no -// event callback from DataModel -void Qt3DSDMTimelineItemBinding::UIRefreshPropertyKeyframe(long inOffset) -{ - if (!m_Row) - return; - - // TODO: figure out a better way to sync m_Keyframes - TAssetKeyframeList::iterator theKeyIter = m_Keyframes.begin(); - for (; theKeyIter != m_Keyframes.end(); ++theKeyIter) { - if (theKeyIter->IsSelected()) - theKeyIter->UpdateTime(theKeyIter->GetTime() + inOffset); - } - // If a asset keyframe was "shared" by several properties' keyframes - // we need to 'break' this sharing and create for the remaining unmoved keyframes. - TPropertyBindingMap::const_iterator theIter = m_PropertyBindingMap.begin(); - for (; theIter != m_PropertyBindingMap.end(); ++theIter) { - (*theIter).second->RefreshKeyFrames(); - - for (long i = 0; i < theIter->second->GetKeyframeCount(); ++i) { - IKeyframe *theKeyframe = theIter->second->GetKeyframeByIndex(i); - UpdateKeyframe(theKeyframe, ETimelineKeyframeTransaction_Add); - - // Unfortunately, this is the way we can propagate UI updates to ALL selected keyframes - if (theKeyframe->IsSelected()) { - CPropertyRow *thePropertyRow = theIter->second->GetRow(); - if (thePropertyRow) - thePropertyRow->setDirty(true); - } - } - } - m_Row->setDirty(true); -} - void Qt3DSDMTimelineItemBinding::OnPropertyChanged(Qt3DSDMPropertyHandle inPropertyHandle) -{ // Refresh UI - CClientDataModelBridge *theBridge = m_StudioSystem->GetClientDataModelBridge(); - if (m_Row && (inPropertyHandle == theBridge->GetNameProperty() - || inPropertyHandle == theBridge->GetSceneAsset().m_Eyeball - || inPropertyHandle == theBridge->GetSceneAsset().m_Locked - || inPropertyHandle == theBridge->GetSceneAsset().m_Shy - || inPropertyHandle == theBridge->GetSceneAsset().m_StartTime - || inPropertyHandle == theBridge->GetSceneAsset().m_EndTime)) - m_Row->setDirty(true); +{ } void Qt3DSDMTimelineItemBinding::OnPropertyLinked(Qt3DSDMPropertyHandle inPropertyHandle) @@ -1096,59 +920,6 @@ void Qt3DSDMTimelineItemBinding::SetDynamicKeyframes(long inTime, bool inDynamic } } -// Update UI on the selection state of all keyframes on this row and all its properties' keyframes. -void Qt3DSDMTimelineItemBinding::DoSelectKeyframes(bool inSelected, long inTime, bool inUpdateUI) -{ - if (inTime == -1) // all keyframes - { - TAssetKeyframeList::iterator theKeyIter = m_Keyframes.begin(); - for (; theKeyIter != m_Keyframes.end(); ++theKeyIter) - theKeyIter->SetSelected(inSelected); - } else { - Qt3DSDMAssetTimelineKeyframe *theKeyframe = - dynamic_cast<Qt3DSDMAssetTimelineKeyframe *>(GetKeyframeByTime(inTime)); - if (theKeyframe) - theKeyframe->SetSelected(inSelected); - } - if (inUpdateUI && m_Row) - m_Row->RequestSelectKeysByTime(-1, inSelected); - - // legacy feature: all properties with keyframes at inTime or all if inTime is -1 are selected - // as well. - TPropertyBindingMap::iterator theIter = m_PropertyBindingMap.begin(); - for (; theIter != m_PropertyBindingMap.end(); ++theIter) - theIter->second->DoSelectKeyframes(inSelected, inTime, true, this); -} - -// When selecting by mouse-drag, if all properties are selected, select the asset keyframe. And if -// one gets de-selected, de-select. Legacy feature. -// Note that if only 1 property has a keyframe at time t, the asset keyframe gets selected -// automatically when that keyframe is selected. Its odd to me but -// that's how it has always behaved. -void Qt3DSDMTimelineItemBinding::OnPropertySelection(long inTime) -{ - IKeyframe *theAssetKeyframe = GetKeyframeByTime(inTime); - if (theAssetKeyframe) { - bool theAllSelectedFlag = true; - TPropertyBindingMap::iterator theIter = m_PropertyBindingMap.begin(); - for (; theIter != m_PropertyBindingMap.end(); ++theIter) { - IKeyframe *theKeyframe = theIter->second->GetKeyframeByTime(inTime); - if (theKeyframe && !theKeyframe->IsSelected()) { - // done, i.e selection remain unchanged. - theAllSelectedFlag = false; - break; - } - } - if (theAssetKeyframe->IsSelected() != theAllSelectedFlag) { - dynamic_cast<Qt3DSDMAssetTimelineKeyframe *>(theAssetKeyframe) - ->SetSelected(theAllSelectedFlag); - // Update UI - if (m_Row) - m_Row->RequestSelectKeysByTime(inTime, theAllSelectedFlag); - } - } -} - Q3DStudio::CId Qt3DSDMTimelineItemBinding::GetGuid() const { CClientDataModelBridge *theClientBridge = m_StudioSystem->GetClientDataModelBridge(); @@ -1244,11 +1015,6 @@ void Qt3DSDMTimelineItemBinding::UpdateKeyframe(IKeyframe *inKeyframe, m_Keyframes.push_back(Qt3DSDMAssetTimelineKeyframe(this, theKeyframeTime)); } } - if (m_Row && (theDoAddFlag - || inTransaction == ETimelineKeyframeTransaction_DynamicChanged)) { - // dynamic => only UI needs to refresh - m_Row->setDirty(true); - } } void Qt3DSDMTimelineItemBinding::OnAddChild(Qt3DSDMInstanceHandle inInstance) @@ -1286,17 +1052,10 @@ void Qt3DSDMTimelineItemBinding::OnAddChild(Qt3DSDMInstanceHandle inInstance) void Qt3DSDMTimelineItemBinding::OnDeleteChild(Qt3DSDMInstanceHandle inInstance) { - ITimelineItemBinding *theChild = m_TransMgr->GetOrCreate(inInstance); - if (theChild) { - m_Row->RemoveChildRow(theChild); - } } void Qt3DSDMTimelineItemBinding::UpdateActionStatus() { - if (m_Row) { - m_Row->requestUpdateActionStatus(); - } } //============================================================================= diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h index 9d14cc84..198ec8a3 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h @@ -51,7 +51,6 @@ // Classes //============================================================================== class CTimelineTranslationManager; -class CBaseStateRow; class Qt3DSDMTimelineItemProperty; class CCmdDataModelSetKeyframeTime; class RowTree; @@ -75,7 +74,6 @@ protected: // Typedef typedef std::vector<Qt3DSDMAssetTimelineKeyframe> TAssetKeyframeList; protected: - CBaseStateRow *m_Row; // TODO: remove after finishing the new timeline RowTree *m_rowTree = nullptr; CTimelineTranslationManager *m_TransMgr; qt3dsdm::Qt3DSDMInstanceHandle m_DataHandle; @@ -110,8 +108,6 @@ public: void SetLocked(bool) override; bool IsVisible() const override; void SetVisible(bool) override; - bool IsExpanded() const override; - void SetExpanded(bool inExpanded) override; bool HasAction(bool inMaster) override; bool ChildrenHasAction(bool inMaster) override; bool ComponentHasAction(bool inMaster) override; @@ -123,12 +119,10 @@ public: // ITimelineItemBinding ITimelineItem *GetTimelineItem() override; - CBaseStateRow *GetRow() override; // Mahmoud_TODO: remove after finishing the new timeline RowTree *getRowTree() const override; void setRowTree(RowTree *row) override; void SetSelected(bool inMultiSelect) override; void OnCollapsed() override; - void ClearKeySelection() override; bool OpenAssociatedEditor() override; void SetDropTarget(CDropTarget *inTarget) override; // Hierarchy @@ -144,31 +138,15 @@ public: bool ShowToggleControls() const override; bool IsLockedEnabled() const override; bool IsVisibleEnabled() const override; - // Init/Cleanup - void Bind(CBaseStateRow *inRow) override; - void Release() override; // ContextMenu bool IsValidTransaction(EUserTransaction inTransaction) override; void PerformTransaction(EUserTransaction inTransaction) override; Q3DStudio::CString GetObjectPath() override; - // Selected keyframes - ITimelineKeyframesManager *GetKeyframesManager() const override; - // Properties - void RemoveProperty(ITimelineItemProperty *inProperty) override; - void LoadProperties() override; // ITimelineItemKeyframesHolder void InsertKeyframe() override; void DeleteAllChannelKeyframes() override; - long GetKeyframeCount() const override; IKeyframe *GetKeyframeByTime(long inTime) const override; - IKeyframe *GetKeyframeByIndex(long inIndex) const override; - long OffsetSelectedKeyframes(long inOffset) override; - void CommitChangedKeyframes() override; - void OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) override; - - // IKeyframeSelector - void SelectKeyframes(bool inSelected, long inTime = -1) override; // IUICDMSelectable virtual qt3dsdm::Qt3DSDMInstanceHandle GetInstanceHandle() const; @@ -192,12 +170,9 @@ public: virtual void OnPropertyChanged(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); virtual void OnPropertyLinked(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); - virtual void UIRefreshPropertyKeyframe(long inOffset); // Keyframe manipulation virtual bool HasDynamicKeyframes(long inTime); virtual void SetDynamicKeyframes(long inTime, bool inDynamic); - virtual void DoSelectKeyframes(bool inSelected, long inTime, bool inUpdateUI); - virtual void OnPropertySelection(long inTime); virtual void OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inInstance); virtual void OnDeleteChild(qt3dsdm::Qt3DSDMInstanceHandle inInstance); diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp index 56783576..de9502bb 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp @@ -36,12 +36,10 @@ // Includes //============================================================================== #include "Qt3DSDMTimelineItemProperty.h" -#include "PropertyRow.h" #include "TimelineTranslationManager.h" #include "ITimelineItemBinding.h" #include "Qt3DSDMTimelineItemBinding.h" #include "Qt3DSDMTimelineKeyframe.h" -#include "KeyframesManager.h" #include "CmdDataModelChangeKeyframe.h" #include "CmdDataModelRemoveKeyframe.h" #include "StudioApp.h" @@ -74,8 +72,7 @@ inline float DataModelToColor(float inValue) Qt3DSDMTimelineItemProperty::Qt3DSDMTimelineItemProperty(CTimelineTranslationManager *inTransMgr, Qt3DSDMPropertyHandle inPropertyHandle, Qt3DSDMInstanceHandle inInstance) - : m_Row(nullptr) - , m_InstanceHandle(inInstance) + : m_InstanceHandle(inInstance) , m_PropertyHandle(inPropertyHandle) , m_TransMgr(inTransMgr) , m_SetKeyframeValueCommand(nullptr) @@ -102,7 +99,6 @@ Qt3DSDMTimelineItemProperty::Qt3DSDMTimelineItemProperty(CTimelineTranslationMan Qt3DSDMTimelineItemProperty::~Qt3DSDMTimelineItemProperty() { ReleaseKeyframes(); - Release(); } void Qt3DSDMTimelineItemProperty::CreateKeyframes() @@ -133,13 +129,6 @@ void Qt3DSDMTimelineItemProperty::CreateKeyframes() void Qt3DSDMTimelineItemProperty::ReleaseKeyframes() { - // clear any selection from m_TransMgr - TKeyframeList::iterator theIter = m_Keyframes.begin(); - for (; theIter != m_Keyframes.end(); ++theIter) { - m_TransMgr->GetKeyframesManager()->SetKeyframeSelected(*theIter, false); - - SAFE_DELETE(*theIter); - } m_Keyframes.clear(); m_AnimationHandles.clear(); } @@ -179,8 +168,7 @@ inline ITimelineItemBinding *GetParentBinding(RowTree *inRow) RowTree *theParentRow = inRow->parentRow(); if (theParentRow) { theParentBinding = theParentRow->getBinding(); - ASSERT(theParentBinding); // TimelineItemBinding should be set properly during - // CBaseStateRow::Initialize + ASSERT(theParentBinding); } } return theParentBinding; @@ -229,23 +217,11 @@ float Qt3DSDMTimelineItemProperty::GetMinimumValue() const return theRetVal; } -void Qt3DSDMTimelineItemProperty::Bind(CPropertyRow *inRow) -{ - ASSERT(!m_Row); - - m_Row = inRow; -} - RowTree *Qt3DSDMTimelineItemProperty::getRowTree() const { return m_rowTree; } -void Qt3DSDMTimelineItemProperty::Release() -{ - m_Row = nullptr; -} - // Ensures the object that owns this property is selected. void Qt3DSDMTimelineItemProperty::SetSelected() { @@ -256,11 +232,6 @@ void Qt3DSDMTimelineItemProperty::SetSelected() } } -void Qt3DSDMTimelineItemProperty::ClearKeySelection() -{ - m_TransMgr->ClearKeyframeSelection(); -} - void Qt3DSDMTimelineItemProperty::DeleteAllKeys() { if (m_Keyframes.empty()) @@ -273,11 +244,6 @@ void Qt3DSDMTimelineItemProperty::DeleteAllKeys() editor->DeleteAllKeyframes(m_AnimationHandles[idx]); } -ITimelineKeyframesManager *Qt3DSDMTimelineItemProperty::GetKeyframesManager() const -{ - return m_TransMgr->GetKeyframesManager(); -} - IKeyframe *Qt3DSDMTimelineItemProperty::GetKeyframeByTime(long inTime) const { std::vector<long> theTest; @@ -384,51 +350,11 @@ void Qt3DSDMTimelineItemProperty::SetChannelValueAtTime(long inChannelIndex, lon } } -long Qt3DSDMTimelineItemProperty::OffsetSelectedKeyframes(long inOffset) -{ - long theRetVal = m_TransMgr->GetKeyframesManager()->OffsetSelectedKeyframes(inOffset); - if (m_Row) // UI update, since the data model sends no event while the change isn't commited. - { - m_Row->Refresh(); - } - return theRetVal; -} - -void Qt3DSDMTimelineItemProperty::CommitChangedKeyframes() -{ - if (m_SetKeyframeValueCommand) { // if this is moving a keyframe value - m_SetKeyframeValueCommand->Finalize(m_SetKeyframeValueCommand->GetValue()); - g_StudioApp.GetCore()->ExecuteCommand(m_SetKeyframeValueCommand, false); - m_SetKeyframeValueCommand = nullptr; - } else // otherwise its changing keyframe times - m_TransMgr->GetKeyframesManager()->CommitChangedKeyframes(); -} - -void Qt3DSDMTimelineItemProperty::OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) -{ - (void)inObjectAssociation; - CTimeEditDlg theTimeEditDlg; - theTimeEditDlg.setKeyframesManager(m_TransMgr->GetKeyframesManager()); - theTimeEditDlg.showDialog(inCurrentTime, g_StudioApp.GetCore()->GetDoc(), ASSETKEYFRAME); -} - -void Qt3DSDMTimelineItemProperty::SelectKeyframes(bool inSelected, long inTime /*= -1 */) -{ - Qt3DSDMTimelineItemBinding *theParent = - static_cast<Qt3DSDMTimelineItemBinding *>(GetParentBinding(m_rowTree)); - DoSelectKeyframes(inSelected, inTime, false, theParent); -} - void Qt3DSDMTimelineItemProperty::setRowTree(RowTree *rowTree) { m_rowTree = rowTree; } -CPropertyRow *Qt3DSDMTimelineItemProperty::GetRow() -{ - return m_Row; -} - bool Qt3DSDMTimelineItemProperty::IsDynamicAnimation() { return m_Keyframes.size() > 0 && m_Keyframes[0]->IsDynamic(); @@ -447,10 +373,8 @@ bool Qt3DSDMTimelineItemProperty::RefreshKeyframe(qt3dsdm::Qt3DSDMKeyframeHandle TKeyframeList::iterator theIter = m_Keyframes.begin(); for (; theIter != m_Keyframes.end(); ++theIter) { Qt3DSDMTimelineKeyframe *theKeyframe = *theIter; - if (theKeyframe->HasKeyframeHandle(inKeyframe)) { // clear selection - m_TransMgr->GetKeyframesManager()->SetKeyframeSelected(theKeyframe, false); + if (theKeyframe->HasKeyframeHandle(inKeyframe)) { m_Keyframes.erase(theIter); - theHandled = true; break; } @@ -477,8 +401,6 @@ bool Qt3DSDMTimelineItemProperty::RefreshKeyframe(qt3dsdm::Qt3DSDMKeyframeHandle default: return false; } - if (theHandled && m_Row) - m_Row->Refresh(); return theHandled; } @@ -494,49 +416,6 @@ IKeyframe *Qt3DSDMTimelineItemProperty::GetKeyframeByHandle(qt3dsdm::Qt3DSDMKeyf return nullptr; } -// This is either triggered from this property's keyframe selection OR from a parent's keyframe -// selection. -void Qt3DSDMTimelineItemProperty::DoSelectKeyframes(bool inSelected, long inTime, - bool inParentTriggered, - Qt3DSDMTimelineItemBinding *inParent) -{ - // this is what it used to do before the refactor. selecting a keyframe always selects the - // asset. - if (inSelected) - SetSelected(); - - if (!inParent) - return; - - if (inTime == -1) // all keyframes - { - TKeyframeList::iterator theIter = m_Keyframes.begin(); - for (; theIter != m_Keyframes.end(); ++theIter) { - (*theIter)->SetSelected(inSelected); - m_TransMgr->GetKeyframesManager()->SetKeyframeSelected(*theIter, inSelected, inParent); - } - } else { - Qt3DSDMTimelineKeyframe *theKeyframe = - dynamic_cast<Qt3DSDMTimelineKeyframe *>(GetKeyframeByTime(inTime)); - if (theKeyframe) { - theKeyframe->SetSelected(inSelected); - m_TransMgr->GetKeyframesManager()->SetKeyframeSelected(theKeyframe, inSelected, - inParent); - } - } - // Requires UI to be updated explicitly - if (inParentTriggered && m_Row) - m_Row->RequestSelectKeysByTime(inTime, inSelected); - - // Support existing feature, selection by mouse-drag a rect, when all property keyframes are - // selected, the asset keyframe is automatically selected as well. - // and the mouse drags 'outside' a keyframe and de-selecting it, the asset keyframe has to be - // deselected as well. - if (!inParentTriggered && inTime != -1) - inParent->OnPropertySelection(inTime); -} - -//============================================================================= /** * Create a wrapper for this keyframe if doesn't exists. * @return true if created, false if already exists. diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h index 0a8e5e76..1b1524e4 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h @@ -63,33 +63,21 @@ public: float GetMaximumValue() const override; float GetMinimumValue() const override; void SetSelected() override; - void ClearKeySelection() override; void DeleteAllKeys() override; - ITimelineKeyframesManager *GetKeyframesManager() const override; IKeyframe *GetKeyframeByTime(long inTime) const override; IKeyframe *GetKeyframeByIndex(long inIndex) const override; long GetKeyframeCount() const override; long GetChannelCount() const override; float GetChannelValueAtTime(long inChannelIndex, long inTime) override; void SetChannelValueAtTime(long inChannelIndex, long inTime, float inValue) override; - long OffsetSelectedKeyframes(long inOffset) override; - void CommitChangedKeyframes() override; - void OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) override; bool IsDynamicAnimation() override; - // IKeyframeSelector - void SelectKeyframes(bool inSelected, long inTime = -1) override; void setRowTree(RowTree *rowTree) override; - void Bind(CPropertyRow *inRow) override; RowTree *getRowTree() const override; - void Release() override; - CPropertyRow *GetRow() override; // Mahmoud_TODO: delete bool RefreshKeyframe(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, ETimelineKeyframeTransaction inTransaction); IKeyframe *GetKeyframeByHandle(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe); - void DoSelectKeyframes(bool inSelected, long inTime, bool inParentTriggered, - Qt3DSDMTimelineItemBinding *inParent); void RefreshKeyFrames(void); @@ -108,7 +96,6 @@ protected: protected: typedef std::vector<Qt3DSDMTimelineKeyframe *> TKeyframeList; - CPropertyRow *m_Row; // Mahmoud_TODO: remove qt3dsdm::Qt3DSDMInstanceHandle m_InstanceHandle; qt3dsdm::Qt3DSDMPropertyHandle m_PropertyHandle; CTimelineTranslationManager *m_TransMgr; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp index 67e7275c..4f7ed646 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp @@ -46,7 +46,6 @@ #include "Core.h" #include "DurationEditDlg.h" #include "IDocumentEditor.h" -#include "BaseStateRow.h" #include "StudioFullSystem.h" #include "StudioPreferences.h" #include "ITimelineItemBinding.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp index 1afb57fc..b1a75b39 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp @@ -36,7 +36,6 @@ // Includes //============================================================================== #include "SlideTimelineItemBinding.h" -#include "BaseStateRow.h" // Data model specific #include "Doc.h" @@ -83,12 +82,6 @@ void CSlideTimelineItemBinding::SetName(const Q3DStudio::CString & /*inName*/) // Do nothing because name is read only } -void CSlideTimelineItemBinding::Bind(CBaseStateRow *inRow) -{ - Qt3DSDMTimelineItemBinding::Bind(inRow); - inRow->requestSetNameReadOnly(); -} - bool CSlideTimelineItemBinding::IsValidTransaction(EUserTransaction inTransaction) { qt3dsdm::Qt3DSDMInstanceHandle theInstance = GetInstance(); diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h index eb6a5f45..cf12c0a2 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h @@ -42,7 +42,6 @@ //============================================================================== class ITimelineItem; class CTimelineTranslationManager; -class CBaseStateRow; //============================================================================= /** @@ -58,13 +57,11 @@ public: // Qt3DSDMTimelineItemBinding ITimelineTimebar *GetTimebar() override; void SetName(const Q3DStudio::CString &inName) override; - void Bind(CBaseStateRow *inRow) override; bool IsValidTransaction(EUserTransaction inTransaction) override; // No properties long GetPropertyCount() override { return 0; } ITimelineItemProperty *GetProperty(long) override { return nullptr; } - void LoadProperties() override {} // Eye/Lock toggles are not applicable bool ShowToggleControls() const override { return false; } @@ -82,17 +79,9 @@ public: // Keyframes, not applicable to a Slide void InsertKeyframe() override {} void DeleteAllChannelKeyframes() override {} - long GetKeyframeCount() const override { return 0; } IKeyframe *GetKeyframeByTime(long) const override { return nullptr; } - IKeyframe *GetKeyframeByIndex(long) const override { return nullptr; } - long OffsetSelectedKeyframes(long) override { return 0; } - void CommitChangedKeyframes() override {} - void OnEditKeyframeTime(long, long) override {} - // IKeyframeSelector - void SelectKeyframes(bool, long inTime = -1) override { Q_UNUSED(inTime); } // Keyframe manipulation, not applicable - void UIRefreshPropertyKeyframe(long inOffset) override { Q_UNUSED(inOffset); } bool HasDynamicKeyframes(long inTime) override { Q_UNUSED(inTime); @@ -103,13 +92,6 @@ public: Q_UNUSED(inTime); Q_UNUSED(inDynamic); } - void DoSelectKeyframes(bool inSelected, long inTime, bool inUpdateUI) override - { - Q_UNUSED(inSelected); - Q_UNUSED(inTime); - Q_UNUSED(inUpdateUI); - } - void OnPropertySelection(long inTime) override { Q_UNUSED(inTime); } protected: std::shared_ptr<qt3dsdm::ISignalConnection> diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp index ffd01c3d..627fb387 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp @@ -44,15 +44,9 @@ #include "PathAnchorPointTimelineItemBinding.h" #include "PathTimelineItemBinding.h" #include "LayerTimelineItemBinding.h" -#include "KeyframesManager.h" -#include "TimelineBreadCrumbProvider.h" -#include "BaseStateRow.h" -#include "PropertyRow.h" #include "IDoc.h" #include "Qt3DSDMStudioSystem.h" #include "Qt3DSDMSlides.h" -#include "Qt3DSDMSignals.h" -#include "TimelineUIFactory.h" // Link to Data model #include "ClientDataModelBridge.h" @@ -65,17 +59,12 @@ using namespace qt3dsdm; CTimelineTranslationManager::CTimelineTranslationManager() { - m_KeyframesManager = new CKeyframesManager(this); - m_BreadCrumbProvider = new CTimelineBreadCrumbProvider(g_StudioApp.GetCore()->GetDoc()); } CTimelineTranslationManager::~CTimelineTranslationManager() { // clean up all bindings Clear(); - m_Connections.clear(); - delete m_KeyframesManager; - delete m_BreadCrumbProvider; } ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHandle inInstance) @@ -121,7 +110,6 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa m_InstanceHandleBindingMap.insert( std::make_pair(theReturn->GetInstanceHandle(), theReturn)); - m_InstanceHandleExpandedMap.insert(std::make_pair(theReturn->GetInstanceHandle(), false)); theBinding = theReturn; } @@ -130,41 +118,6 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa //============================================================================== /** - * Create a new CPropertyRow that maps to this ITimelineItemProperty. - * The caller is assumed to have ensured that this is only called once per property binding. - */ -CPropertyRow *CTimelineTranslationManager::CreateNewPropertyRow( - ITimelineItemProperty *inTimelineItemPropertyBinding, CBaseStateRow *inParentRow, - CPropertyRow *inNextRow) -{ - if (!inParentRow || !inTimelineItemPropertyBinding) - return {}; - - return TimelineUIFactory::instance()->createPropertyRow(inParentRow, inNextRow, - inTimelineItemPropertyBinding); -} - -//============================================================================== -/** - * Does the reverse of CreateNewPropertyRow, when a property has been de-animated. - */ -void CTimelineTranslationManager::RemovePropertyRow( - ITimelineItemProperty *inTimelineItemPropertyBinding) -{ - CPropertyRow *theRow = nullptr; - if (!inTimelineItemPropertyBinding - || (theRow = inTimelineItemPropertyBinding->GetRow()) == nullptr) - return; - - CBaseStateRow *theParentRow = dynamic_cast<CBaseStateRow*>(theRow->GetParentRow()); - if (theParentRow) { - inTimelineItemPropertyBinding->Release(); - theParentRow->RemovePropertyRow(theRow); // this implicitly delete the row - } -} - -//============================================================================== -/** * Clear all bindings, typically when a presentation is closed. */ void CTimelineTranslationManager::Clear() @@ -173,55 +126,6 @@ void CTimelineTranslationManager::Clear() m_InstanceHandleBindingMap.clear(); } -//============================================================================== -/** - * Called when the associated UI is no longer valid. - */ -void CTimelineTranslationManager::Unregister(ITimelineItemBinding *inTimelineItem) -{ - // DataModel - bool theDeselectItem = false; - TInstanceHandleBindingMap::iterator theInstanceIter = m_InstanceHandleBindingMap.begin(); - for (; theInstanceIter != m_InstanceHandleBindingMap.end(); ++theInstanceIter) { - if (theInstanceIter->second == inTimelineItem) { - // If this is the currently selected object and make sure that is cleared. - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = - g_StudioApp.GetCore()->GetDoc()->GetSelectedInstance(); - if (theSelectedInstance.Valid() && theSelectedInstance == theInstanceIter->first) - theDeselectItem = true; - - m_InstanceHandleBindingMap.erase(theInstanceIter); - break; - } - } - - delete inTimelineItem; -} - -CKeyframesManager *CTimelineTranslationManager::GetKeyframesManager() const -{ - return m_KeyframesManager; -} - -IBreadCrumbProvider *CTimelineTranslationManager::GetBreadCrumbProvider() const -{ - return m_BreadCrumbProvider; -} - -CBaseStateRow *CTimelineTranslationManager::GetSelectedRow() const -{ - ITimelineItemBinding *theBinding = GetSelectedBinding(); - if (theBinding) - return theBinding->GetRow(); - return nullptr; -} - -long CTimelineTranslationManager::GetCurrentViewTime() const -{ - return g_StudioApp.GetCore()->GetDoc()->GetCurrentViewTime(); -} - -//============================================================================== /** * @return the Binding object that corresponds to this instance. */ @@ -234,90 +138,6 @@ CTimelineTranslationManager::GetBinding(Qt3DSDMInstanceHandle inHandle) const return nullptr; } -Qt3DSDMTimelineItemBinding *CTimelineTranslationManager::GetSelectedBinding() const -{ - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = - g_StudioApp.GetCore()->GetDoc()->GetSelectedInstance(); - if (theSelectedInstance.Valid()) { - Qt3DSDMTimelineItemBinding *theBinding = GetBinding(theSelectedInstance); - return theBinding; - } - return nullptr; -} - -//============================================================================== -/** - * Triggered from individual binding classes, to clear all keyframe selection - */ -void CTimelineTranslationManager::ClearKeyframeSelection() -{ - m_KeyframesManager->DeselectAllKeyframes(); -} - -//============================================================================== -/** - * Set up callbacks for animation changes - */ -void CTimelineTranslationManager::OnNewPresentation() -{ - m_Connections.clear(); - m_InstanceHandleExpandedMap.clear(); - - IStudioFullSystemSignalProvider *theSignalProvider = - g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetFullSystemSignalProvider(); - m_Connections.push_back(theSignalProvider->ConnectAnimationCreated( - std::bind(&CTimelineTranslationManager::OnAnimationCreated, this, - std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectAnimationDeleted( - std::bind(&CTimelineTranslationManager::OnAnimationDeleted, this, - std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectPropertyLinked( - std::bind(&CTimelineTranslationManager::OnPropertyLinked, this, - std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectPropertyUnlinked( - std::bind(&CTimelineTranslationManager::OnPropertyUnlinked, this, - std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectKeyframeInserted( - std::bind(&CTimelineTranslationManager::OnKeyframeInserted, this, - std::placeholders::_1, std::placeholders::_2))); - m_Connections.push_back(theSignalProvider->ConnectKeyframeErased( - std::bind(&CTimelineTranslationManager::OnKeyframeDeleted, this, - std::placeholders::_1, std::placeholders::_2))); - m_Connections.push_back(theSignalProvider->ConnectKeyframeUpdated( - std::bind(&CTimelineTranslationManager::OnKeyframeUpdated, this, std::placeholders::_1))); - m_Connections.push_back(theSignalProvider->ConnectInstancePropertyValue( - std::bind(&CTimelineTranslationManager::OnPropertyChanged, this, - std::placeholders::_1, std::placeholders::_2))); - m_Connections.push_back(theSignalProvider->ConnectFirstKeyframeDynamicSet( - std::bind(&CTimelineTranslationManager::OnDynamicKeyframeChanged, this, - std::placeholders::_1, std::placeholders::_2))); - - m_Connections.push_back(theSignalProvider->ConnectInstanceCreated( - std::bind(&CTimelineTranslationManager::OnAssetCreated, this, std::placeholders::_1))); - m_Connections.push_back(theSignalProvider->ConnectInstanceDeleted( - std::bind(&CTimelineTranslationManager::OnAssetDeleted, this, std::placeholders::_1))); - - m_Connections.push_back(theSignalProvider->ConnectActionCreated( - std::bind(&CTimelineTranslationManager::OnActionEvent, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectActionDeleted( - std::bind(&CTimelineTranslationManager::OnActionEvent, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))); - - Q3DStudio::CGraph &theGraph(*g_StudioApp.GetCore()->GetDoc()->GetAssetGraph()); - m_Connections.push_back(theGraph.ConnectChildAdded( - std::bind(&CTimelineTranslationManager::OnChildAdded, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theGraph.ConnectChildRemoved( - std::bind(&CTimelineTranslationManager::OnChildRemoved, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))); - m_Connections.push_back(theGraph.ConnectChildMoved( - std::bind(&CTimelineTranslationManager::OnChildMoved, this, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3, std::placeholders::_4))); -} - -//============================================================================== - CDoc *CTimelineTranslationManager::GetDoc() const { return dynamic_cast<CDoc *>(g_StudioApp.GetCore()->GetDoc()); @@ -329,233 +149,3 @@ CStudioSystem *CTimelineTranslationManager::GetStudioSystem() const return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem(); } -void CTimelineTranslationManager::OnAnimationCreated(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) -{ - Qt3DSDMTimelineItemBinding *theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inInstance)); - if (theTimelineBinding) - theTimelineBinding->AddPropertyRow(inProperty); -} - -void CTimelineTranslationManager::OnAnimationDeleted(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) -{ - Qt3DSDMTimelineItemBinding *theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inInstance)); - if (theTimelineBinding) - theTimelineBinding->RemovePropertyRow(inProperty); -} - -void CTimelineTranslationManager::OnPropertyLinked(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) -{ - Qt3DSDMTimelineItemBinding *theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inInstance)); - if (theTimelineBinding) - theTimelineBinding->OnPropertyLinked(inProperty); -} - -void CTimelineTranslationManager::OnPropertyUnlinked(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) -{ - OnPropertyLinked(inInstance, inProperty); -} - -void CTimelineTranslationManager::RefreshKeyframe(Qt3DSDMAnimationHandle inAnimation, - Qt3DSDMKeyframeHandle inKeyframe, - ETimelineKeyframeTransaction inTransaction) -{ - Qt3DSDMTimelineItemBinding *theTimelineBinding = nullptr; - if (GetStudioSystem()->GetAnimationCore()->AnimationValid(inAnimation)) { - SAnimationInfo theAnimationInfo = - GetStudioSystem()->GetAnimationCore()->GetAnimationInfo(inAnimation); - theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(theAnimationInfo.m_Instance)); - - if (theTimelineBinding) - theTimelineBinding->RefreshPropertyKeyframe(theAnimationInfo.m_Property, inKeyframe, - inTransaction); - } - // else, animation has been nuked, ignore this event, we'll get a AnimationDelete -} - -void CTimelineTranslationManager::OnKeyframeInserted(Qt3DSDMAnimationHandle inAnimation, - Qt3DSDMKeyframeHandle inKeyframe) -{ - RefreshKeyframe(inAnimation, inKeyframe, ETimelineKeyframeTransaction_Add); -} - -void CTimelineTranslationManager::OnKeyframeDeleted(Qt3DSDMAnimationHandle inAnimation, - Qt3DSDMKeyframeHandle inKeyframe) -{ - RefreshKeyframe(inAnimation, inKeyframe, ETimelineKeyframeTransaction_Delete); -} - -void CTimelineTranslationManager::OnKeyframeUpdated(Qt3DSDMKeyframeHandle inKeyframe) -{ - IAnimationCore *theAnimationCore = GetStudioSystem()->GetAnimationCore(); - if (theAnimationCore->KeyframeValid(inKeyframe)) { - Qt3DSDMAnimationHandle theAnimationHandle = - theAnimationCore->GetAnimationForKeyframe(inKeyframe); - RefreshKeyframe(theAnimationHandle, inKeyframe, ETimelineKeyframeTransaction_Update); - } - // else, keyframe has been nuked, ignore this event, we'll get a KeyframeDeleted -} - -void CTimelineTranslationManager::OnPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty) -{ - Qt3DSDMTimelineItemBinding *theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inInstance)); - if (theTimelineBinding) - theTimelineBinding->OnPropertyChanged(inProperty); -} - -void CTimelineTranslationManager::OnDynamicKeyframeChanged(qt3dsdm::Qt3DSDMAnimationHandle inAnimation, - bool inDynamic) -{ - Q_UNUSED(inDynamic); - - Qt3DSDMTimelineItemBinding *theTimelineBinding = nullptr; - if (GetStudioSystem()->GetAnimationCore()->AnimationValid(inAnimation)) { - SAnimationInfo theAnimationInfo = - GetStudioSystem()->GetAnimationCore()->GetAnimationInfo(inAnimation); - theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(theAnimationInfo.m_Instance)); - if (theTimelineBinding) - theTimelineBinding->RefreshPropertyKeyframe( - theAnimationInfo.m_Property, 0, ETimelineKeyframeTransaction_DynamicChanged); - } -} - -void CTimelineTranslationManager::OnAssetCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance) -{ - CClientDataModelBridge *theDataModelBridge = GetStudioSystem()->GetClientDataModelBridge(); - - if (theDataModelBridge->IsSceneGraphInstance(inInstance)) - EnsureLoaded(inInstance); -} - -void CTimelineTranslationManager::OnAssetDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance) -{ - // You can't assume the instance is valid. Someone may have deleted a large number of items - // from the model and then decided to send notifications after the fact. - // if the created asset is library asset, do nothing - // start to add the scene asset to the timeline - Qt3DSDMTimelineItemBinding *theItemBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inInstance)); - if (theItemBinding) { - Qt3DSDMTimelineItemBinding *theParentBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(theItemBinding->GetParent()); - if (theParentBinding) - theParentBinding->OnDeleteChild(inInstance); - } -} - -void CTimelineTranslationManager::OnChildAdded(int /*inParent*/, int inChild, long /*inIndex*/) -{ - OnAssetCreated(inChild); -} -void CTimelineTranslationManager::OnChildRemoved(int /*inParent*/, int inChild, long /*inIndex*/) -{ - OnAssetDeleted(inChild); -} -void CTimelineTranslationManager::OnChildMoved(int /*inParent*/, int inChild, long /*inOldIndex*/, - long /*inNewIndex*/) -{ - OnAssetDeleted(inChild); - OnAssetCreated(inChild); -} - -//============================================================================== -/** - * Callback method whenever an action is either created or removed. - * Basically, it tells the owner of the action to update its timeline control to - * update the icon that shows action association status - */ -void CTimelineTranslationManager::OnActionEvent(qt3dsdm::Qt3DSDMActionHandle inAction, - qt3dsdm::Qt3DSDMSlideHandle inSlide, - qt3dsdm::Qt3DSDMInstanceHandle inOwner) -{ - Q_UNUSED(inAction); - - // the slide that action is added to is the current slide or - // is added to the master slide of the current slide - Qt3DSDMTimelineItemBinding *theTimelineBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(GetBinding(inOwner)); - if (theTimelineBinding) - theTimelineBinding->UpdateActionStatus(); -} - -//============================================================================== -/** - * Helper functions to go through ALL binding and clear any keyframes selection. - */ -void CTimelineTranslationManager::ClearBindingsKeyframeSelection() -{ - // DataModel bindings handle their own selections - TInstanceHandleBindingMap::const_iterator theIter = m_InstanceHandleBindingMap.begin(); - for (; theIter != m_InstanceHandleBindingMap.end(); ++theIter) - theIter->second->DoSelectKeyframes(false, -1, true); -} - -//============================================================================== - -ITimelineItemBinding *CTimelineTranslationManager::EnsureLoaded(Qt3DSDMInstanceHandle inHandle) -{ - ITimelineItemBinding *theBinding = GetBinding(inHandle); - bool rowLoaded = theBinding != nullptr && theBinding->GetRow() != nullptr; - if (rowLoaded == false) { - // tell my parent to load me - CClientDataModelBridge *theDataModelBridge = GetStudioSystem()->GetClientDataModelBridge(); - Qt3DSDMInstanceHandle theParent = theDataModelBridge->GetParentInstance(inHandle); - if (theParent.Valid()) { - ITimelineItemBinding *theParentBinding = EnsureLoaded(theParent); - if (theParentBinding) - theParentBinding->GetRow()->LoadChildren(); - - // The LoadChildren has an optimzation such that if it's already loaded, it won't - // recreate again - // So, if we still can't get the binding after LoadChildren, it very likely means that - // this is newly added - // so call OnAddChild to let it just add this. - theBinding = GetBinding(inHandle); - bool rowLoaded = theBinding != nullptr && theBinding->GetRow() != nullptr; - if (theParentBinding && rowLoaded == false) { - // start to add the scene asset to the timeline - Qt3DSDMTimelineItemBinding *theDMBinding = - dynamic_cast<Qt3DSDMTimelineItemBinding *>(theParentBinding); - theDMBinding->OnAddChild(inHandle); - theBinding = GetBinding(inHandle); - } - } - } - return theBinding; -} - -//============================================================================== -/** - * remember the expanded state for the current presentation - */ -bool CTimelineTranslationManager::IsExpanded(Qt3DSDMInstanceHandle inInstance) const -{ - TInstanceHandleExpandedMap::const_iterator theIter = - m_InstanceHandleExpandedMap.find(inInstance); - if (theIter != m_InstanceHandleExpandedMap.end()) { - return theIter->second; - } - return false; -} - -//============================================================================== -/** - * remember the expanded state for the current presentation - */ -void CTimelineTranslationManager::SetExpanded(Qt3DSDMInstanceHandle inInstance, bool inExpanded) -{ - TInstanceHandleExpandedMap::iterator theIter = m_InstanceHandleExpandedMap.find(inInstance); - if (theIter != m_InstanceHandleExpandedMap.end()) { - theIter->second = inExpanded; - } -} diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h index 83443c2c..18851b20 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h @@ -26,9 +26,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_TIMELINE_TRANSLATIONMANAGER_H #define INCLUDED_TIMELINE_TRANSLATIONMANAGER_H 1 @@ -39,31 +36,16 @@ #include "Doc.h" -//============================================================================== -// Classes -//============================================================================== class ITimelineItemBinding; -class ITimelineItemProperty; class Qt3DSDMTimelineItemBinding; -class CBaseStateRow; -class CPropertyRow; -class CKeyframesManager; -class IBreadCrumbProvider; - -// Link to data model -class CAsset; -class IUICDMSelectable; -class CClientDataModelBridge; // DataModel namespace qt3dsdm { class CStudioSystem; -class ISignalConnection; } class CDoc; -//============================================================================= /** * There is a TranslationManager per presentation (project) */ @@ -81,79 +63,19 @@ protected: // Properties // DataModel support TInstanceHandleBindingMap m_InstanceHandleBindingMap; - CKeyframesManager *m_KeyframesManager; - IBreadCrumbProvider *m_BreadCrumbProvider; - std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> - m_Connections; /// connections to the DataModel - - TInstanceHandleExpandedMap m_InstanceHandleExpandedMap; - public: CTimelineTranslationManager(); ~CTimelineTranslationManager(); public: ITimelineItemBinding *GetOrCreate(qt3dsdm::Qt3DSDMInstanceHandle inInstance); - CPropertyRow *CreateNewPropertyRow(ITimelineItemProperty *inTimelineItemPropertyBinding, - CBaseStateRow *inParentRow, CPropertyRow *inNextRow); - void RemovePropertyRow(ITimelineItemProperty *inTimelineItemPropertyBinding); - void Clear(); - void Unregister(ITimelineItemBinding *inTimelineItem); - CKeyframesManager *GetKeyframesManager() const; - IBreadCrumbProvider *GetBreadCrumbProvider() const; - CBaseStateRow *GetSelectedRow() const; - long GetCurrentViewTime() const; Qt3DSDMTimelineItemBinding *GetBinding(qt3dsdm::Qt3DSDMInstanceHandle inHandle) const; - Qt3DSDMTimelineItemBinding *GetSelectedBinding() const; - - void ClearKeyframeSelection(); - void OnNewPresentation(); qt3dsdm::CStudioSystem *GetStudioSystem() const; - // DataModel callback - void OnAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void OnAnimationDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void OnPropertyLinked(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void OnPropertyUnlinked(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void RefreshKeyframe(qt3dsdm::Qt3DSDMAnimationHandle inAnimation, - qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, - ETimelineKeyframeTransaction inTransaction); - void OnKeyframeInserted(qt3dsdm::Qt3DSDMAnimationHandle inAnimation, - qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe); - void OnKeyframeDeleted(qt3dsdm::Qt3DSDMAnimationHandle inAnimation, - qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe); - void OnKeyframeUpdated(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe); - void OnPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void OnDynamicKeyframeChanged(qt3dsdm::Qt3DSDMAnimationHandle inAnimation, bool inDynamic); - - void OnAssetCreated(qt3dsdm::Qt3DSDMInstanceHandle inInstance); - void OnAssetDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance); - void OnChildAdded(int inParent, int inChild, long inIndex); - void OnChildRemoved(int inParent, int inChild, long inIndex); - void OnChildMoved(int inParent, int inChild, long inOldIndex, long inNewIndex); - - void OnActionEvent(qt3dsdm::Qt3DSDMActionHandle inAction, qt3dsdm::Qt3DSDMSlideHandle inSlide, - qt3dsdm::Qt3DSDMInstanceHandle inOwner); - - // Helper function to iterate over all bindings - void ClearBindingsKeyframeSelection(); CDoc *GetDoc() const; - - // Store expanded state - bool IsExpanded(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; - void SetExpanded(qt3dsdm::Qt3DSDMInstanceHandle inInstance, bool inExpanded); - -protected: - void SetSelected(Q3DStudio::SSelectedValue inSelectable, bool inSelected); - ITimelineItemBinding *EnsureLoaded(qt3dsdm::Qt3DSDMInstanceHandle inHandle); }; #endif // INCLUDED_TIMELINE_TRANSLATIONMANAGER_H |