diff options
Diffstat (limited to 'src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp | 241 |
1 files changed, 0 insertions, 241 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp deleted file mode 100644 index ff7077aa..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp +++ /dev/null @@ -1,241 +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$ -** -****************************************************************************/ - -#include "Qt3DSCommonPrecompile.h" -#include "TimelineBreadCrumbProvider.h" -#include "Core.h" - -// Link to data model -#include "Doc.h" -#include "StudioApp.h" -#include "Cmd.h" -#include "ResourceCache.h" -#include "CColor.h" - -#include "ClientDataModelBridge.h" -#include "Qt3DSDMStudioSystem.h" -#include "Qt3DSDMSlides.h" -#include "CmdActivateSlide.h" - -using namespace qt3dsdm; - -//============================================================================= -/** - * Constructor - */ -CTimelineBreadCrumbProvider::CTimelineBreadCrumbProvider(CDoc *inDoc) - : m_Doc(inDoc) -{ -} - -//============================================================================= -/** - */ -CTimelineBreadCrumbProvider::~CTimelineBreadCrumbProvider() -{ -} - -//============================================================================= -/** - * determine the color and text string for this breadcrumb - */ -static inline void FillBreadCrumb(SBreadCrumb &outBreadCrumb, - qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc) -{ - // Get the MasterSlide Handle associated with inAsset - CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge(); - ISlideSystem *theSlideSystem = inDoc->GetStudioSystem()->GetSlideSystem(); - Q3DStudio::CId theId = theBridge->GetGUID(inInstance); - qt3dsdm::Qt3DSDMSlideHandle theMasterSlide = - theSlideSystem->GetMasterSlideByComponentGuid(GuidtoSLong4(theId)); - Q_ASSERT(theMasterSlide.Valid()); // it should be valid because inAsset should be OBJTYPE_SCENE or - // non-library OBJTYPE_COMPONENT - - // Get the active slide index of the master slide. Master Slide always has index 0 - long theActiveIndex = theSlideSystem->GetActiveSlideIndex(theMasterSlide); - bool theIsMaster = (theActiveIndex == 0); - - // Determine the color - outBreadCrumb.m_Color = - theIsMaster ? CColor(0, 0, 255) : CColor(0, 0, 0); // blue for master, black otherwise - - // Determine the text string - outBreadCrumb.m_String = theBridge->GetName(inInstance).toQString(); - outBreadCrumb.m_String += " ("; - if (theIsMaster) { - outBreadCrumb.m_String += QObject::tr("Master"); - } else { - Qt3DSDMSlideHandle theActiveSlide = - theSlideSystem->GetSlideByIndex(theMasterSlide, theActiveIndex); - Qt3DSDMInstanceHandle theInstanceHandle = theSlideSystem->GetSlideInstance(theActiveSlide); - Q_ASSERT(theInstanceHandle.Valid()); - outBreadCrumb.m_String += theBridge->GetName(theInstanceHandle).toQString(); - } - outBreadCrumb.m_String += ")"; -} - -//============================================================================= -/** - * return the trail of breadcrumb. - * This constructs a list of the "time context tree" from Scene down to the current active time - * context. - * @param inRefresh true to refresh the list, false to get existing. - */ -CTimelineBreadCrumbProvider::TTrailList -CTimelineBreadCrumbProvider::GetTrail(bool inRefresh /*= true */) -{ - if (inRefresh) - RefreshSlideList(); - - TTrailList theList; - for (size_t theIndex = 0; theIndex < m_BreadCrumbList.size(); ++theIndex) { - SBreadCrumb theBreadCrumb; - FillBreadCrumb(theBreadCrumb, m_BreadCrumbList[theIndex], m_Doc); - theList.push_back(theBreadCrumb); - } - return theList; -} - -//============================================================================= -/** - * switch current time context to the one 'represented' by the breadcrumbs. - * @param inTrailIndex index into the trail list - */ -void CTimelineBreadCrumbProvider::OnBreadCrumbClicked(long inTrailIndex) -{ - if (inTrailIndex >= 0 && inTrailIndex < (long)m_BreadCrumbList.size()) { - CCmdActivateSlide *theCmd = new CCmdActivateSlide(m_Doc, m_BreadCrumbList[inTrailIndex]); - theCmd->SetForceRefresh(false); - m_Doc->GetCore()->ExecuteCommand(theCmd, false); - } -} - -QPixmap CTimelineBreadCrumbProvider::GetRootImage() const -{ - return CResourceCache::GetInstance()->GetBitmap("breadcrumb_component_scene.png"); -} - -QPixmap CTimelineBreadCrumbProvider::GetBreadCrumbImage() const -{ - return CResourceCache::GetInstance()->GetBitmap("breadcrumb_component_button.png"); -} - -QPixmap CTimelineBreadCrumbProvider::GetSeparatorImage() const -{ - return CResourceCache::GetInstance()->GetBitmap("breadcrumb_component_colon_button.png"); -} - -QPixmap CTimelineBreadCrumbProvider::GetActiveBreadCrumbImage() const -{ - return CResourceCache::GetInstance()->GetBitmap("breadcrumb_component_grey_button.png"); -} - -//============================================================================= -/** - * Called when active time context is changed. - */ -void CTimelineBreadCrumbProvider::RefreshSlideList() -{ - ClearSlideList(); - - qt3dsdm::Qt3DSDMInstanceHandle theActiveRoot = m_Doc->GetActiveRootInstance(); - if (!theActiveRoot.Valid()) - return; - FillSlideList(theActiveRoot); -} - -//============================================================================= -/** - * Callback that inAsset has its name changed, fire off a signal to the UI control. - * All the assets' signals are connected to this object and we'll let the UI control check iterate - * through the list for changes and refresh. - * Alternative we can set up additional classes that listens to specific assets and only the asset - * affected refreshed. the former is easier for now. - */ -void CTimelineBreadCrumbProvider::OnNameDirty() -{ - Q_EMIT SigBreadCrumbUpdate(); -} - -void CTimelineBreadCrumbProvider::ClearSlideList() -{ - m_Connections.clear(); - m_BreadCrumbList.clear(); -} - -//============================================================================= -/** - * This will recurse up the time context tree, so that we can fill the list in a top-down (i.e - * Scene) first manner - */ -void CTimelineBreadCrumbProvider::FillSlideList(qt3dsdm::Qt3DSDMInstanceHandle inInstance) -{ - if (!inInstance.Valid()) - return; - - CClientDataModelBridge *theBridge = m_Doc->GetStudioSystem()->GetClientDataModelBridge(); - ISlideSystem *theSlideSystem = m_Doc->GetStudioSystem()->GetSlideSystem(); - Q3DStudio::CId theId = theBridge->GetGUID(inInstance); - - // Recurse - FillSlideList(theBridge->GetParentComponent(inInstance)); - - m_BreadCrumbList.push_back(inInstance); - - Qt3DSDMPropertyHandle theNameProp = - m_Doc->GetStudioSystem()->GetClientDataModelBridge()->GetNameProperty(); - IStudioFullSystemSignalProvider *theEngine = - m_Doc->GetStudioSystem()->GetFullSystemSignalProvider(); - std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle)> theSetter( - std::bind(&CTimelineBreadCrumbProvider::OnNameDirty, this)); - - // Listen to name changes on the Asset - m_Connections.push_back( - theEngine->ConnectInstancePropertyValue( - std::bind(qt3dsdm::MaybackCallbackInstancePropertyValue<std::function<void( - Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle)>>, - std::placeholders::_1, std::placeholders::_2, inInstance, - theNameProp, theSetter))); - - // Listen to name changes on the non-master Slides - qt3dsdm::Qt3DSDMSlideHandle theMasterSlide = - theSlideSystem->GetMasterSlideByComponentGuid(GuidtoSLong4(theId)); - long theSlideCount = (long)theSlideSystem->GetSlideCount(theMasterSlide); - - for (long theIndex = 1; theIndex < theSlideCount; ++theIndex) { - Qt3DSDMSlideHandle theSlide = theSlideSystem->GetSlideByIndex(theMasterSlide, theIndex); - Qt3DSDMInstanceHandle theSlideInstance = theSlideSystem->GetSlideInstance(theSlide); - m_Connections.push_back( - theEngine->ConnectInstancePropertyValue( - std::bind(qt3dsdm::MaybackCallbackInstancePropertyValue<std::function<void( - Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle)>>, - std::placeholders::_1, std::placeholders::_2, theSlideInstance, - theNameProp, theSetter))); - } -} |