diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-10-06 11:49:09 +0000 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-10-06 16:58:43 +0200 |
commit | 07840524085bd1785b8f9142b03d942f678c5c51 (patch) | |
tree | 499c1674fdd1b3e0c07688d8e4e56748dfea2ca3 /src/Authoring/Studio/DragAndDrop |
Initial import
Diffstat (limited to 'src/Authoring/Studio/DragAndDrop')
24 files changed, 2803 insertions, 0 deletions
diff --git a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp new file mode 100644 index 00000000..089a9c97 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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" + +//============================================================================== +// Includes +//============================================================================== +#include "BasicObjectDropSource.h" +#include "Doc.h" +#include "DropTarget.h" + +#include "Dialogs.h" +#include "Dispatch.h" +#include "StudioApp.h" +#include "Core.h" +#include "UICDMStudioSystem.h" +#include "ClientDataModelBridge.h" +#include "UICDMDataCore.h" +#include "IDocumentEditor.h" +#include "ImportUtils.h" +#include "BasicObjectsModel.h" +#include "IDragable.h" +#include "IDocSceneGraph.h" +#include "UICTextRenderer.h" +#include "HotKeys.h" +#include "StudioUtils.h" + +#include <QDir> + +//=============================================================================== +/** + * + */ +CBasicObjectDropSource::CBasicObjectDropSource(long inFlavor, IDragable *inDragable) + : CDropSource(inFlavor, 0) + , m_IsIndependent(false) +{ + auto item = dynamic_cast<BasicObjectItem *>(inDragable); + if (item) { + m_ObjectType = item->objectType(); + m_PrimitiveType = item->primitiveType(); + } +} + +//=============================================================================== +/** + * + */ +bool CBasicObjectDropSource::ValidateTarget(CDropTarget *inTarget) +{ + using namespace Q3DStudio; + + EStudioObjectType targetType = (EStudioObjectType)inTarget->GetObjectType(); + bool theValidTarget = false; + + // the only thing we want to do from here is check the type. + theValidTarget = + CStudioObjectTypes::AcceptableParent((EStudioObjectType)m_ObjectType, targetType); + + if (!theValidTarget) { + SetHasValidTarget(theValidTarget); + return theValidTarget; + } else { + if (CHotKeys::IsKeyDown(Qt::AltModifier) && targetType != OBJTYPE_SCENE + && targetType != OBJTYPE_COMPONENT) { + UICDM::CUICDMInstanceHandle theTarget = inTarget->GetInstance(); + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + IDocumentReader &theReader(theDoc->GetDocumentReader()); + UICDM::CUICDMSlideHandle toSlide = theReader.GetAssociatedSlide(theTarget); + ; + + if (!theReader.IsMasterSlide(toSlide)) + theValidTarget = false; + } + + SetHasValidTarget(theValidTarget); + return theValidTarget; + } +} + +//=============================================================================== +/** + * + */ +bool CBasicObjectDropSource::CanMove() +{ + return true; +} + +//=============================================================================== +/** + * + */ +bool CBasicObjectDropSource::CanCopy() +{ + return true; +} + +CCmd *CBasicObjectDropSource::GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) +{ + using namespace Q3DStudio; + using UICDM::ComposerObjectTypes; + using namespace std; + + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + CPt thePoint; + // if ( CHotKeys::IsKeyDown( CHotKeys::KEY_MENU ) ) + // thePoint = GetCurrentPoint(); + + long theStartTime = -1; + if (CHotKeys::IsKeyDown(Qt::ControlModifier)) + theStartTime = theDoc->GetCurrentViewTime(); + + DocumentEditorInsertType::Enum theInsertType(ImportUtils::GetInsertTypeForDropType(inDestType)); + ComposerObjectTypes::Enum theComposerType; + switch (m_ObjectType) { + case OBJTYPE_SCENE: + theComposerType = ComposerObjectTypes::Scene; + break; + case OBJTYPE_LAYER: + theComposerType = ComposerObjectTypes::Layer; + break; + case OBJTYPE_BEHAVIOR: + theComposerType = ComposerObjectTypes::Behavior; + break; + case OBJTYPE_MATERIAL: + theComposerType = ComposerObjectTypes::Material; + break; + case OBJTYPE_CAMERA: + theComposerType = ComposerObjectTypes::Camera; + break; + case OBJTYPE_LIGHT: + theComposerType = ComposerObjectTypes::Light; + break; + case OBJTYPE_MODEL: + theComposerType = ComposerObjectTypes::Model; + break; + case OBJTYPE_GROUP: + theComposerType = ComposerObjectTypes::Group; + break; + case OBJTYPE_IMAGE: + theComposerType = ComposerObjectTypes::Image; + break; + case OBJTYPE_TEXT: + theComposerType = ComposerObjectTypes::Text; + break; + case OBJTYPE_COMPONENT: + theComposerType = ComposerObjectTypes::Component; + break; + case OBJTYPE_ALIAS: + theComposerType = ComposerObjectTypes::Alias; + break; + case OBJTYPE_PATH: + theComposerType = ComposerObjectTypes::Path; + break; + default: + QT3DS_ASSERT(false); + theComposerType = ComposerObjectTypes::Unknown; + break; + } + if (theComposerType != ComposerObjectTypes::Unknown) { + if (theComposerType == ComposerObjectTypes::Text) { + // For Text, we need to check if user already has font file inside fonts folder + CFilePath theFontFile; + CFilePath theFontDir = CFilePath::CombineBaseAndRelative(theDoc->GetDocumentDirectory(), + CFilePath(L"fonts")); + if (!theFontDir.Exists()) { + // Create font dir if necessary + theFontDir.CreateDir(true); + } else { + // Recursively find the first font file in font dir + vector<CFilePath> theFiles; + theFontDir.RecursivelyFindFilesOfType(nullptr, theFiles, false); + for (size_t i = 0; i < theFiles.size(); ++i) { + if (CDialogs::IsFontFileExtension(theFiles[i].GetExtension())) { + // Reuse the font in fonts subdirectory + theFontFile = theFiles[i]; + break; + } + } + } + + if (theFontFile == L"") { + // If user doesn't have any font file, copy the default font file from Studio's res + // folder + + CFilePath theResFontFile; + + QDir theResFontDir(resourcePath() + "/Font"); + Q_FOREACH (QFileInfo fontFile, theResFontDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot)) { + CString ext = CString::fromQString(fontFile.suffix()); + if (CDialogs::IsFontFileExtension(ext)) { + theResFontFile = CString::fromQString(fontFile.absoluteFilePath()); + theFontFile = CFilePath::CombineBaseAndRelative(theFontDir, CString::fromQString(fontFile.fileName())); + break; + } + } + + if (theResFontFile == L"") { + QT3DS_ASSERT(false); + std::shared_ptr<IImportFailedHandler> theHandler( + theDoc->GetImportFailedHandler()); + if (theHandler) + theHandler->DisplayImportFailed( + theResFontDir.absolutePath(), + QObject::tr("Default Font File Doesn't Exist in the Directory"), + false); + return nullptr; + } + + // Copy the file to project's fonts folder + SFileTools::Copy(theFontFile, + Q3DStudio::FileOpenFlags(Q3DStudio::FileOpenFlagValues::Create), + theResFontFile); + // Force the text renderer to refresh + if (theDoc->GetSceneGraph() && theDoc->GetSceneGraph()->GetTextRenderer()) + theDoc->GetSceneGraph()->GetTextRenderer()->ReloadFonts(); + } + + // Lastly, we use the font file to create the Text object. This is similar to drag-drop + // the font file from Project Palette to Scene. + SCOPED_DOCUMENT_EDITOR(*theDoc, QObject::tr("Add Text")) + ->ImportFile(DocumentEditorFileType::Font, theFontFile, inTarget, inSlide, + CDialogs::GetImportFileExtension(), + Q3DStudio::ImportUtils::GetInsertTypeForDropType(inDestType), thePoint, + theStartTime); + } else { + SCOPED_DOCUMENT_EDITOR(*theDoc, QObject::tr("Add Instance")) + ->CreateSceneGraphInstance(theComposerType, inTarget, inSlide, theInsertType, + thePoint, (EPrimitiveType)m_PrimitiveType, theStartTime); + } + } + return nullptr; +} diff --git a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.h b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.h new file mode 100644 index 00000000..454fce9e --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __BasicObjectDropSource_H__ +#define __BasicObjectDropSource_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropSource.h" +#include "StudioObjectTypes.h" + +class CStudioApp; +class CDropTarget; + +class CBasicObjectDropSource : public CDropSource +{ +public: + CBasicObjectDropSource(long inFlavor, IDragable *inDragable); + + // CDropSource + bool CanMove() override; + bool CanCopy() override; + bool ValidateTarget(CDropTarget *inTarget) override; + + CCmd *GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) override; + +protected: + EPrimitiveType m_PrimitiveType; + bool m_IsIndependent; +}; + +#endif // #ifndef __BasicObjectDropSource_H__ diff --git a/src/Authoring/Studio/DragAndDrop/DropContainer.cpp b/src/Authoring/Studio/DragAndDrop/DropContainer.cpp new file mode 100644 index 00000000..b1ed7a6c --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropContainer.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "stdafx.h" +#include "StudioApp.h" +#include "DropContainer.h" +#include "HotKeys.h" +#include "MouseCursor.h" +#include "FileDropSource.h" +#include "ResourceCache.h" + +//=============================================================================== +/** + * A derived object will call this to subscribe to Drop Flavors. + * @param inMainFlavor the Flavor to add. + * @see CDropSource.h + */ +void CDropContainer::AddMainFlavor(long inMainFlavor) +{ + m_Flavors.push_back(inMainFlavor); +} + +//=============================================================================== +/** + * This an accessor to get the begining of the iterator. + * @return the Iterator + */ +CDropContainer::TFlavorItr CDropContainer::GetFlavorBegin() +{ + return m_Flavors.begin(); +} + +//=============================================================================== +/** + * This is an iterator to the end. + * @return the Iterator + */ +CDropContainer::TFlavorItr CDropContainer::GetFlavorEnd() +{ + return m_Flavors.end(); +} + +//=============================================================================== +/** + * Constructor to build the container. + * This also sets up the DropProxy. + * @see CDropProxy + */ +CWinDropContainer::CWinDropContainer() + : m_DropProxy(this) +{ +} +//=============================================================================== +/** + * Destructor + */ +CWinDropContainer::~CWinDropContainer() +{ +} + +//=============================================================================== +/** + * This is so the Window that is derived from CWinContainer can receive drags. + * @param inWindow the outer to drag. + */ +void CWinDropContainer::RegiserForDnd(QWidget *inWindow) +{ + // This passes the inWindow down to the COLEDropSource. + m_DropProxy.Register(inWindow); +} diff --git a/src/Authoring/Studio/DragAndDrop/DropContainer.h b/src/Authoring/Studio/DragAndDrop/DropContainer.h new file mode 100644 index 00000000..808a5bf4 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropContainer.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2003 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_DROPCONTAINER +#define INCLUDED_DROPCONTAINER + +//============================================================================== +// Includes +//============================================================================== +#include "DropProxy.h" +#include "DropSource.h" +#include <vector> + +class CStudioApp; + +class CDropContainer +{ +public: + typedef std::vector<long> TFlavor; + typedef TFlavor::iterator TFlavorItr; + +protected: + TFlavor m_Flavors; ///< This is a list of flavors handled by this container. + +public: + CDropContainer() {} + virtual ~CDropContainer() {} + + CDropContainer::TFlavorItr GetFlavorBegin(); + CDropContainer::TFlavorItr GetFlavorEnd(); + + void AddMainFlavor(long inMainFlavor); + + // These need to get implemented by the Cross platform Container. + virtual bool OnDragWithin(CDropSource &inSource) = 0; + virtual bool OnDragReceive(CDropSource &inSource) = 0; + virtual void OnDragLeave() = 0; + virtual void OnReflectMouse(CPt &inPoint, Qt::KeyboardModifiers inFlags) = 0; +}; + +class CWinDropContainer : public CDropContainer +{ +public: + CWinDropContainer(); + virtual ~CWinDropContainer(); + + void RegiserForDnd(QWidget *inWindow); + long ReflectMouse(long inX, long inY); + +protected: + // These are utility functions. + CDropProxy m_DropProxy; ///< The COLEDropSource pass through. +}; + +#endif
\ No newline at end of file diff --git a/src/Authoring/Studio/DragAndDrop/DropSource.cpp b/src/Authoring/Studio/DragAndDrop/DropSource.cpp new file mode 100644 index 00000000..06a3fc8a --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropSource.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2003 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$ +** +****************************************************************************/ + +//============================================================================== +// Includes +//============================================================================== +#include "stdafx.h" +#include "DropTarget.h" +#include "StudioObjectTypes.h" +#include "HotKeys.h" +#include "Doc.h" +#include "IDragable.h" +#include "FileDropSource.h" +#include "ExplorerFileDropSource.h" +#include "TimelineDropSource.h" +#include "BasicObjectDropSource.h" +#include "ListBoxDropSource.h" + +CDropSource::CDropSource(long inFlavor, unsigned long inSize) + : m_Flavor(inFlavor) + , m_Size(inSize) + , m_ObjectType(0) + , m_HasValidTarget(false) + , m_CurrentFlags(0) +{ +} + +CDropSource::~CDropSource() +{ +} + +CDropSource *CDropSourceFactory::Create(long inFlavor, void *inData, unsigned long inSize) +{ + CDropSource *theDropSource(nullptr); + switch (inFlavor) { + + case EUIC_FLAVOR_FILE: { + theDropSource = new CExplorerFileDropSource(inFlavor, inData, inSize); + } break; + case EUIC_FLAVOR_TEXT: + // Don't do anythiing for this + break; + + case EUIC_FLAVOR_ASSET_UICFILE: + // make an Aset out of this. + theDropSource = new CFileDropSource(inFlavor, inData, inSize); + break; + } + + return theDropSource; +} + +CDropSource *CDropSourceFactory::Create(long inFlavor, IDragable *inDragable) +{ + CDropSource *theDropSource(nullptr); + switch (inFlavor) { + case EUIC_FLAVOR_LISTBOX: + theDropSource = new CListBoxDropSource(inFlavor, inDragable); + break; + + case EUIC_FLAVOR_BASIC_OBJECTS: + theDropSource = new CBasicObjectDropSource(inFlavor, inDragable); + break; + + case EUIC_FLAVOR_ASSET_TL: + theDropSource = new CTimeLineDropSource(inFlavor, inDragable); + break; + + default: + theDropSource = Create(inFlavor, reinterpret_cast<void *>(inDragable), sizeof(inDragable)); + } + + return theDropSource; +} + +CDropSource *CDropSourceFactory::Extract(long inFlavor, void *inData, unsigned long /*inSize*/) +{ + CDropSource *theDropSource(nullptr); + switch (inFlavor) { + // For all of the Studio Flavors we just need to extract the dropsource out of it. + case EUIC_FLAVOR_LISTBOX: + // make an Aset out of this. + theDropSource = static_cast<CListBoxDropSource *>(inData); + break; + + case EUIC_FLAVOR_BASIC_OBJECTS: + // make an Aset out of this. + theDropSource = static_cast<CBasicObjectDropSource *>(inData); + break; + + case EUIC_FLAVOR_ASSET_TL: + // cast it to the right type just so we don't loose the virtual table. + theDropSource = static_cast<CTimeLineDropSource *>(inData); + break; + + case EUIC_FLAVOR_ASSET_UICFILE: + theDropSource = static_cast<CFileDropSource *>(inData); + + break; + default: + theDropSource = nullptr; + } + + return theDropSource; +} diff --git a/src/Authoring/Studio/DragAndDrop/DropSource.h b/src/Authoring/Studio/DragAndDrop/DropSource.h new file mode 100644 index 00000000..542b14ac --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropSource.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2003 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$ +** +****************************************************************************/ + +//============================================================================== +// Includes +//============================================================================== +#ifndef INCLUDED_DROPSOURCE +#define INCLUDED_DROPSOURCE + +#include "UICDMHandles.h" +#include "Pt.h" +#include "Cmd.h" + +#include <QMimeData> + +typedef enum _EDROPDESTINATION { + EDROPDESTINATION_ON, ///< drop occurs on the target asset + EDROPDESTINATION_ABOVE, ///< drop occurs above the target asset + EDROPDESTINATION_BELOW ///< drop occurs below the target asset +} EDROPDESTINATION; + +class CDropTarget; +class IDragable; +class CStudioApp; + +class CDropSource : public QMimeData +{ +protected: + long m_Flavor; + unsigned long m_Size; + + UICDM::TInstanceHandleList m_Instances; + long m_ObjectType; + bool m_HasValidTarget; + CPt m_CurrentPoint; + Qt::KeyboardModifiers m_CurrentFlags; + +public: + CDropSource(long inFlavor, unsigned long inSize); + virtual ~CDropSource(); + + virtual bool CanMove() = 0; + virtual bool CanCopy() = 0; + long GetObjectType() const { return m_ObjectType; } + long GetFlavor() const { return m_Flavor; } + virtual bool ValidateTarget(CDropTarget *) = 0; + + virtual bool GetHasValidTarget() const { return m_HasValidTarget; } + virtual void SetHasValidTarget(bool inValid) { m_HasValidTarget = inValid; } + virtual void InterpretKeyFlags(long) {} + + virtual void SetCurrentPoint(CPt &inPoint) { m_CurrentPoint = inPoint; } + virtual CPt GetCurrentPoint() const { return m_CurrentPoint; } + + virtual void SetCurrentFlags(Qt::KeyboardModifiers inFlags) { m_CurrentFlags = inFlags; } + virtual Qt::KeyboardModifiers GetCurrentFlags() const { return m_CurrentFlags; } + + virtual CCmd *GenerateAssetCommand(UICDM::CUICDMInstanceHandle, EDROPDESTINATION, + UICDM::CUICDMSlideHandle) + { + return nullptr; + } + virtual CCmd *GenerateSlideCommand(long) { return nullptr; } +}; + +class CDropSourceFactory +{ +public: + static CDropSource *Create(long inFlavor, IDragable *inDragable); + static CDropSource *Create(long inFlavor, void *inData, unsigned long inSize); + static CDropSource *Extract(long inFlavor, void *inData, unsigned long inSize); +}; + +#endif diff --git a/src/Authoring/Studio/DragAndDrop/DropTarget.cpp b/src/Authoring/Studio/DragAndDrop/DropTarget.cpp new file mode 100644 index 00000000..2ca783e5 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropTarget.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2003 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$ +** +****************************************************************************/ + +//============================================================================== +// Includes +//============================================================================== + +#include "stdafx.h" +#include "StudioApp.h" +#include "Core.h" +#include "Doc.h" +#include "UICDMStudioSystem.h" +#include "UICDMSlides.h" +#include "DropTarget.h" + +CDropTarget::CDropTarget() + : m_Instance(0) + , m_ObjectType(OBJTYPE_UNKNOWN) +{ +} + +bool CDropTarget::CanAddToMaster() +{ + long theTargetObjectType = GetObjectType(); + if (theTargetObjectType == OBJTYPE_SCENE || theTargetObjectType == OBJTYPE_COMPONENT) + return true; + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + UICDM::ISlideSystem *theSlideSystem = theDoc->GetStudioSystem()->GetSlideSystem(); + UICDM::CUICDMSlideHandle theTargetSlide = theSlideSystem->GetAssociatedSlide(GetInstance()); + return theTargetSlide && theSlideSystem->IsMasterSlide(theTargetSlide); +} diff --git a/src/Authoring/Studio/DragAndDrop/DropTarget.h b/src/Authoring/Studio/DragAndDrop/DropTarget.h new file mode 100644 index 00000000..7bbec133 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/DropTarget.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2003 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_DROPTARGET +#define INCLUDED_DROPTARGET + +#pragma once + +//============================================================================== +// Includes +//============================================================================== +#include "StudioObjectTypes.h" +#include "UICDMHandles.h" + +class CDropSource; +class CStudioApp; + +class CDropTarget +{ +protected: + UICDM::CUICDMInstanceHandle m_Instance; + long m_ObjectType; + +public: + CDropTarget(); + virtual ~CDropTarget() {} + + virtual bool Accept(CDropSource &inSource) = 0; + virtual bool Drop(CDropSource &inSource) = 0; + virtual long GetObjectType() = 0; + + virtual void SetInstance(UICDM::CUICDMInstanceHandle inInstance) { m_Instance = inInstance; } + virtual UICDM::CUICDMInstanceHandle GetInstance() { return m_Instance; } + + virtual bool IsRelative(UICDM::CUICDMInstanceHandle) { return false; } + virtual bool IsSelf(UICDM::CUICDMInstanceHandle) { return false; } + virtual bool IsMaster() { return false; } + virtual bool CanAddToMaster(); +}; + +#endif
\ No newline at end of file diff --git a/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp new file mode 100644 index 00000000..f32cbe9b --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== + +//============================================================================== +// Includes +//============================================================================== +#include "stdafx.h" +#include "qtAuthoring-config.h" +#include "ExplorerFileDropSource.h" +#include "Dialogs.h" +#include "DropTarget.h" +#include "StudioObjectTypes.h" +#include "IDragable.h" +#include "UICFileTools.h" +#include "ImportUtils.h" + +bool CExplorerFileDropSource::s_FileHasValidTarget = false; + +//=============================================================================== +/** + * + */ +bool CExplorerFileDropSource::ValidateTarget(CDropTarget *inTarget) +{ + // Check the type is valid and if target can accept + bool theValidTarget = + ((m_ObjectType != OBJTYPE_UNKNOWN) && (inTarget->GetObjectType() == EUIC_FLAVOR_FILE)); + SetHasValidTarget(theValidTarget); + + return theValidTarget; +} + +//=============================================================================== +/** + * + */ +CExplorerFileDropSource::CExplorerFileDropSource(long inFlavor, void *inData, unsigned long inSize) + : CDropSource(inFlavor, inSize) + , m_File("") +{ + // Pull out all of the SDropItemData and build a file. + m_File = *(CUICFile *)inData; + Q3DStudio::CFilePath thePath(m_File.GetAbsolutePath()); + m_ObjectType = Q3DStudio::ImportUtils::GetObjectFileTypeForFile(thePath).m_IconType; + // Fix because DAE files are the *only* thing you can drop onto the project + if (thePath.GetExtension().Compare(CDialogs::GetWideDAEFileExtension(), + Q3DStudio::CString::ENDOFSTRING, false)) { + m_ObjectType = OBJTYPE_GROUP; + } +#ifdef QT_3DSTUDIO_FBX + else if (thePath.GetExtension().Compare(CDialogs::GetWideFbxFileExtension(), + Q3DStudio::CString::ENDOFSTRING, false)) { + m_ObjectType = OBJTYPE_GROUP; + } +#endif +} + +//=============================================================================== +/** + * + */ +void CExplorerFileDropSource::SetHasValidTarget(bool inValid) +{ + m_HasValidTarget = inValid; + CExplorerFileDropSource::s_FileHasValidTarget = inValid; +} + +//=============================================================================== +/** + * + */ +bool CExplorerFileDropSource::GetHasValidTarget() +{ + return CExplorerFileDropSource::s_FileHasValidTarget; +} + +//=============================================================================== +/** + * + */ +bool CExplorerFileDropSource::CanMove() +{ + return false; +} + +//=============================================================================== +/** + * + */ +bool CExplorerFileDropSource::CanCopy() +{ + return true; +} diff --git a/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.h b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.h new file mode 100644 index 00000000..03269aaf --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __EXPLORERFILEDROPSOURCE_H__ +#define __EXPLORERFILEDROPSOURCE_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropSource.h" +#include "UICFile.h" + +class CStudioApp; +class CDropTarget; + +//============================================================================== +/** + * @class CExplorerFileDropSource + * @brief Drop Source for EUIC_FLAVOR_UICFILE + * + * This class is meant to handle drag and drop for EUIC_FLAVOR_UICFILE, + * for example when user drags a file from Explorer Window (outside Studio). + */ +class CExplorerFileDropSource : public CDropSource +{ +protected: + CUICFile m_File; + static bool s_FileHasValidTarget; + +public: + CExplorerFileDropSource(long inFlavor, void *inData, unsigned long inSize); + + bool CanMove() override; + bool CanCopy() override; + bool ValidateTarget(CDropTarget *inTarget) override; + bool GetHasValidTarget(); + void SetHasValidTarget(bool inValid) override; + CUICFile GetFile() const { return m_File; } +}; + +#endif // #ifndef __EXPLORERFILEDROPSOURCE_H__ diff --git a/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp new file mode 100644 index 00000000..a4164e02 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== + +//============================================================================== +// Includes +//============================================================================== +#include "stdafx.h" +#include "Dialogs.h" +#include "FileDropSource.h" +#include "DropTarget.h" +#include "StudioObjectTypes.h" +#include "HotKeys.h" +#include "Doc.h" +#include "StudioApp.h" +#include "Core.h" +#include "UICDMStudioSystem.h" +#include "ClientDataModelBridge.h" +#include "IDocumentEditor.h" +#include "UICFileTools.h" +#include "ImportUtils.h" + +bool CFileDropSource::s_FileHasValidTarget = false; + +//=============================================================================== +/** + * + */ +bool CFileDropSource::ValidateTarget(CDropTarget *inTarget) +{ + using namespace Q3DStudio; + + EStudioObjectType targetType = (EStudioObjectType)inTarget->GetObjectType(); + bool theValidTarget = false; + + // the only thing we want to do from here is check the type. + theValidTarget = CStudioObjectTypes::AcceptableParent( + (EStudioObjectType)m_ObjectType, (EStudioObjectType)inTarget->GetObjectType()); + + if (!theValidTarget) { + SetHasValidTarget(theValidTarget); + return theValidTarget; + } else { + if (CHotKeys::IsKeyDown(Qt::AltModifier) && targetType != OBJTYPE_SCENE + && targetType != OBJTYPE_COMPONENT) { + UICDM::CUICDMInstanceHandle theTarget = inTarget->GetInstance(); + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + IDocumentReader &theReader(theDoc->GetDocumentReader()); + UICDM::CUICDMSlideHandle toSlide = theReader.GetAssociatedSlide(theTarget); + ; + + if (!theReader.IsMasterSlide(toSlide)) + theValidTarget = false; + } + + SetHasValidTarget(theValidTarget); + return theValidTarget; + } +} + +//=============================================================================== +/** + * + */ +CFileDropSource::CFileDropSource(long inFlavor, void *inData, unsigned long inSize) + : CDropSource(inFlavor, inSize) + , m_File("") +{ + // Pull out all of the SDropItemData and build a file. + m_File = *(CUICFile *)inData; + m_ObjectType = + Q3DStudio::ImportUtils::GetObjectFileTypeForFile(m_File.GetAbsolutePath()).m_ObjectType; +} + +//=============================================================================== +/** + * + */ +void CFileDropSource::SetHasValidTarget(bool inValid) +{ + m_HasValidTarget = inValid; + CFileDropSource::s_FileHasValidTarget = inValid; +} + +//=============================================================================== +/** + * + */ +bool CFileDropSource::GetHasValidTarget() +{ + return CFileDropSource::s_FileHasValidTarget; +} + +//=============================================================================== +/** + * + */ +bool CFileDropSource::CanMove() +{ + return false; +} + +//=============================================================================== +/** + * + */ +bool CFileDropSource::CanCopy() +{ + return true; +} + +CCmd *CFileDropSource::GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) +{ + UICDM::CUICDMInstanceHandle theTarget = inTarget; + + CDoc &theDoc(*g_StudioApp.GetCore()->GetDoc()); + Q3DStudio::CFilePath theFilePath(m_File.GetAbsolutePath()); + CPt thePoint; + // if ( CHotKeys::IsKeyDown( Qt::AltModifier ) ) + // thePoint = GetCurrentPoint(); + + long theStartTime = -1; + if (CHotKeys::IsKeyDown(Qt::ControlModifier)) + theStartTime = theDoc.GetCurrentViewTime(); + + if (theFilePath.IsFile()) { + Q3DStudio::DocumentEditorFileType::Enum theDocType( + Q3DStudio::ImportUtils::GetObjectFileTypeForFile(theFilePath).m_FileType); + QString theCommandName; + // TODO: internationalize + switch (theDocType) { + case Q3DStudio::DocumentEditorFileType::DAE: + theCommandName = QObject::tr("File Drop DAE File"); + break; + case Q3DStudio::DocumentEditorFileType::Import: + theCommandName = QObject::tr("File Drop Import File"); + break; + case Q3DStudio::DocumentEditorFileType::Image: + theCommandName = QObject::tr("File Drop Image File"); + break; + case Q3DStudio::DocumentEditorFileType::Behavior: + theCommandName = QObject::tr("File Drop Behavior File"); + break; + case Q3DStudio::DocumentEditorFileType::Mesh: + theCommandName = QObject::tr("File Drop Mesh File"); + break; + case Q3DStudio::DocumentEditorFileType::Font: + theCommandName = QObject::tr("File Drop Font File"); + break; + case Q3DStudio::DocumentEditorFileType::Effect: + theCommandName = QObject::tr("File Drop Effect File"); + break; + case Q3DStudio::DocumentEditorFileType::Material: + theCommandName = QObject::tr("File Drop Material File"); + break; + case Q3DStudio::DocumentEditorFileType::Path: + theCommandName = QObject::tr("File Drop Path File"); + break; + } + + Q3DStudio::SCOPED_DOCUMENT_EDITOR(theDoc, theCommandName) + ->ImportFile(theDocType, theFilePath, theTarget, inSlide, + CDialogs::GetImportFileExtension(), + Q3DStudio::ImportUtils::GetInsertTypeForDropType(inDestType), thePoint, + theStartTime); + } + return nullptr; +} diff --git a/src/Authoring/Studio/DragAndDrop/FileDropSource.h b/src/Authoring/Studio/DragAndDrop/FileDropSource.h new file mode 100644 index 00000000..57127b0d --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/FileDropSource.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __FILEDROPSOURCE_H__ +#define __FILEDROPSOURCE_H__ + +//============================================================================== +// Includes +//============================================================================== +// This should go into its own FileDropSourceFile. +#include "DropSource.h" +#include "UICFile.h" + +class CStudioApp; +class CDropTarget; + +//============================================================================== +/** + * @class CFileDropSource + * @brief Drop Source for EUIC_FLAVOR_ASSET_UICFILE + * + * This class is meant to handle drag and drop for EUIC_FLAVOR_ASSET_UICFILE, + * for example when user drags a file from within Studio. + */ +class CFileDropSource : public CDropSource +{ +protected: + CUICFile m_File; + static bool s_FileHasValidTarget; + +public: + CFileDropSource(long inFlavor, void *inData, unsigned long inSize); + + bool CanMove() override; + bool CanCopy() override; + bool ValidateTarget(CDropTarget *inTarget) override; + bool GetHasValidTarget(); + void SetHasValidTarget(bool inValid) override; + + CCmd *GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) override; +}; + +#endif // #ifndef __FILEDROPSOURCE_H__ diff --git a/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.cpp b/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.cpp new file mode 100644 index 00000000..da602679 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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" + +//============================================================================== +// Includes +//============================================================================== +#include "ListBoxDropSource.h" +#include "DropTarget.h" +#include "ListBoxItem.h" +#include "IDragable.h" + +//=============================================================================== +/** + * Constructor + */ +CListBoxDropSource::CListBoxDropSource(long inFlavor, IDragable *inDragable) + : CDropSource(inFlavor, 0) +{ + m_Item = reinterpret_cast<CListBoxItem *>(inDragable); +} + +//=============================================================================== +/** + * Validate that the drop target is EUIC_FLAVOR_LISTBOX type. + * @param inTarget Drop target for validation + * @return true if inTarget is EUIC_FLAVOR_LISTBOX; false if otherwise + */ +bool CListBoxDropSource::ValidateTarget(CDropTarget *inTarget) +{ + bool theValidTarget = (inTarget->GetObjectType() == EUIC_FLAVOR_LISTBOX); + SetHasValidTarget(theValidTarget); + + return theValidTarget; +} + +//=============================================================================== +/** + * @return true + */ +bool CListBoxDropSource::CanMove() +{ + return true; +} + +//=============================================================================== +/** + * @return true + */ +bool CListBoxDropSource::CanCopy() +{ + return true; +}
\ No newline at end of file diff --git a/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.h b/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.h new file mode 100644 index 00000000..a28678d4 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ListBoxDropSource.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __ListBoxDropSource_H__ +#define __ListBoxDropSource_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropSource.h" + +class CStudioApp; +class CDropTarget; +class CListBoxItem; + +class CListBoxDropSource : public CDropSource +{ +protected: + CListBoxItem *m_Item; + +public: + CListBoxDropSource(long inFlavor, IDragable *inDragable); + + bool CanMove() override; + bool CanCopy() override; + bool ValidateTarget(CDropTarget *inTarget) override; + + CListBoxItem *GetItem() { return m_Item; } +}; + +#endif // #ifndef __ListBoxDropSource_H__ diff --git a/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.cpp b/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.cpp new file mode 100644 index 00000000..752cc430 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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" + +//============================================================================== +// Includes +//============================================================================== +#include "ListBoxDropTarget.h" +#include "ListBoxDropSource.h" +#include "IDragable.h" + +//=============================================================================== +/** + * Constructor + */ +CListBoxDropTarget::CListBoxDropTarget() + : m_Item(nullptr) +{ +} + +//=============================================================================== +/** + * This get called on every DragWithin. + * Note: the source will validate the target instead of the otherway around. + * This is because the DropSource knows how to get information from itself without + * creating an asset. This is mainly for DropSources that have a lazy creation idiom. + * like files. + * @param the DropSource in question. + * @return true if the DropSource likes the DropTarget. + */ +bool CListBoxDropTarget::Accept(CDropSource &inSource) +{ + return inSource.ValidateTarget(this); +} + +//=============================================================================== +/** + * This is where is actually happens. + * Note: At this point everything should be verified, and setup in the dropsource. + * The only thing left to do is to get the Assets and move/copy or connect them. + * @param inSource the Object in question. + * @return true if the drop was successful . + */ +bool CListBoxDropTarget::Drop(CDropSource &inSource) +{ + if (m_Item) { + inSource; + /* + CSlideDropSource* theSlideDropSource = static_cast< CSlideDropSource* >( + &inSource ); + CSlideControl* theSlideControl = theSlideDropSource->GetSlide( ); + CTimeContext* theTimeContext = theSlideControl->GetTimeContext( ); + + // Reorder this slide to the position held by this drop target. + CCmdRearrangeTimeContext* theCommand = new CCmdRearrangeTimeContext( theTimeContext, + m_SlideInsert->GetInsertIndex( ) ); + if ( theCommand ) + { + theTimeContext->GetAsset( )->ExecuteCommand( theCommand, false ); + } + */ + } + + // we are always successful + return true; +} + +//=============================================================================== +/** + * This will get the objec ttype from the Asset. + * Note: The asset can change all of the time, so i always ask the asset for its type. + * @return the Studio object type. + */ +long CListBoxDropTarget::GetObjectType() +{ + return EUIC_FLAVOR_LISTBOX; +} + +//=============================================================================== +/** + * Set the SlideInsertionControl that is the drop target + */ +void CListBoxDropTarget::SetItem(CListBoxItem *inItem) +{ + m_Item = inItem; +}
\ No newline at end of file diff --git a/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.h b/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.h new file mode 100644 index 00000000..44199092 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ListBoxDropTarget.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __ListBoxDropTarget_H__ +#define __ListBoxDropTarget_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropTarget.h" + +class CDropSource; +class CListBoxItem; + +//============================================================================== +/** + * @class + * @brief justin.ebert needs to enter a brief description here. + * + * justin.ebert needs to enter a long description here. + */ +class CListBoxDropTarget : public CDropTarget +{ +protected: + CListBoxItem *m_Item; ///< The list item that we can drop on + +public: + CListBoxDropTarget(); + bool Accept(CDropSource &inSource) override; + bool Drop(CDropSource &inSource) override; + long GetObjectType() override; + + void SetItem(CListBoxItem *inItem); +}; + +#endif // #ifndef __ListBoxDropTarget_H__ diff --git a/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp new file mode 100644 index 00000000..5344d459 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 "stdafx.h" +#include "qtAuthoring-config.h" +#include "ProjectDropTarget.h" +#include "DropSource.h" +#include "ExplorerFileDropSource.h" +#include "IDragable.h" +#include "StudioApp.h" +#include "Core.h" +#include "Dialogs.h" +#include "Doc.h" +#include "UICFile.h" +#include "UICFileTools.h" +#include "UICImportPerformImport.h" +#include "UICImportTranslation.h" +#include "IDocumentEditor.h" +#include "PathImportTranslator.h" + +//=============================================================================== +/** + * Constructor + */ +CProjectDropTarget::CProjectDropTarget(const Q3DStudio::CFilePath &inTargetDir) + : m_TargetDir(inTargetDir) +{ +} + +//=============================================================================== +/** + * This get called on every DragWithin. + * Note: the source will validate the target instead of the otherway around. + * This is because the DropSource knows how to get information from itself without + * creating an asset. This is mainly for DropSources that have a lazy creation idiom. + * like files. + * @param the DropSource in question. + * @return true if the DropSource likes the DropTarget. + */ +bool CProjectDropTarget::Accept(CDropSource &inSource) +{ + return inSource.ValidateTarget(this); +} + +//=============================================================================== +/** + * This is where is actually happens. + * Note: At this point everything should be verified, and setup in the dropsource. + * The only thing left to do is to get the Assets and move/copy or connect them. + * @param inSource the Object in question. + * @return true if the drop was successful . + */ +bool CProjectDropTarget::Drop(CDropSource &inSource) +{ + using namespace Q3DStudio; + using namespace UICIMP; + // Drag and Drop - From Explorer window to Project Palette + // For all valid Project File Types: + // - This performs a file copy from the source Explorer location to the selected Project Palette + // Folder + // - The destination copy must NOT be read-only even if the source is read-only + // For DAE, it will import the file. + if (inSource.GetFlavor() == EUIC_FLAVOR_FILE) { + // Create target directory if it doesn't exist + if (!m_TargetDir.Exists()) + m_TargetDir.CreateDir(true); + // also make sure that target directory is a directory, not a file + else if (m_TargetDir.IsFile()) + m_TargetDir = m_TargetDir.GetDirectory(); + + // Sanity check + ASSERT(m_TargetDir.IsDirectory()); + + // Get the Source file to be copied + CExplorerFileDropSource *theFileDropSource = + static_cast<CExplorerFileDropSource *>(&inSource); + CFilePath theSourceFile(theFileDropSource->GetFile().GetAbsolutePath()); + + if (theSourceFile.IsFile() && m_TargetDir.IsDirectory()) { + // Get the file extension + Q3DStudio::CString theExtension(theSourceFile.GetExtension()); + + Q3DStudio::CString theFileStem = theSourceFile.GetFileStem(); + Q3DStudio::CString outputFileName(theFileStem + L"." + + CDialogs::GetImportFileExtension()); + + if (theExtension.Compare(CDialogs::GetWideDAEFileExtension(), + Q3DStudio::CString::ENDOFSTRING, false)) { + SColladaTranslator theTranslator(theSourceFile.toQString()); + + CFilePath theOutputDir = + SFileTools::FindUniqueDestDirectory(m_TargetDir, theFileStem); + CFilePath theFullOutputFile( + CFilePath::CombineBaseAndRelative(theOutputDir, outputFileName)); + SImportResult theImportResult = + CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); + bool forceError = theFullOutputFile.IsFile() == false; + IDocumentEditor::DisplayImportErrors( + theSourceFile.toQString(), theImportResult.m_Error, + g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler(), + theTranslator.m_TranslationLog, forceError); +#ifdef QT_3DSTUDIO_FBX + } else if (theExtension.Compare(CDialogs::GetWideFbxFileExtension(), + Q3DStudio::CString::ENDOFSTRING, false)) { + SFbxTranslator theTranslator(theSourceFile.toQString()); + + CFilePath theOutputDir = + SFileTools::FindUniqueDestDirectory(m_TargetDir, theFileStem); + CFilePath theFullOutputFile( + CFilePath::CombineBaseAndRelative(theOutputDir, outputFileName)); + SImportResult theImportResult = + CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); + bool forceError = theFullOutputFile.IsFile() == false; + IDocumentEditor::DisplayImportErrors( + theSourceFile.toQString(), theImportResult.m_Error, + g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler(), + theTranslator.m_TranslationLog, forceError); +#endif + } else if (theExtension.Compare(L"svg", Q3DStudio::CString::ENDOFSTRING, false)) { + IDocumentReader &theReader(g_StudioApp.GetCore()->GetDoc()->GetDocumentReader()); + SPathImportTranslator theTranslator(theSourceFile.toQString(), *theReader.GetLuaContext(), + theReader.GetFoundation()); + CFilePath theOutputDir = + SFileTools::FindUniqueDestDirectory(m_TargetDir, theFileStem); + CFilePath theFullOutputFile( + CFilePath::CombineBaseAndRelative(theOutputDir, outputFileName)); + SImportResult theImportResult = + CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); + bool forceError = theFullOutputFile.IsFile() == false; + IDocumentEditor::DisplayImportErrors( + theSourceFile.toQString(), theImportResult.m_Error, + g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler(), + theTranslator.m_TranslationLog, forceError); + } else { + // Copy the file to target directory + // FindAndCopyDestFile will make sure the file name is unique and make sure it is + // not read only. + SFileErrorCodeFileNameAndNumBytes theCopyResult = SFileTools::FindAndCopyDestFile( + m_TargetDir, CFilePath::GetAbsolutePath(theSourceFile)); + + // Sanity check + ASSERT(theCopyResult.m_Error == Q3DStudio::FileErrorCodes::NoError); + ASSERT(theCopyResult.m_DestFilename.Exists()); + + // For effect and custom material files, automatically copy related resources + if (CDialogs::IsEffectFileExtension(theExtension) + || CDialogs::IsMaterialFileExtension(theExtension)) { + std::shared_ptr<IImportFailedHandler> theHandler( + g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler()); + CFilePath theShaderFile(theSourceFile); + + if (theShaderFile.GetExtension() != "effect" + && theShaderFile.GetExtension() != "material") { + ASSERT(false); // what file is this? + } else { + } + + std::vector<Q3DStudio::CString> theEffectFileSourcePaths; + g_StudioApp.GetCore() + ->GetDoc() + ->GetDocumentReader() + .ParseSourcePathsOutOfEffectFile( + Q3DStudio::CFilePath::GetAbsolutePath(theSourceFile), + theEffectFileSourcePaths); + + CFilePath theFileDir( + Q3DStudio::CFilePath::GetAbsolutePath(theSourceFile).GetDirectory()); + CFilePath theDocumentDir( + g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory()); + for (size_t idx = 0; idx < theEffectFileSourcePaths.size(); ++idx) { + CFilePath theSourcePath = CFilePath::CombineBaseAndRelative( + theFileDir, theEffectFileSourcePaths[idx]); + CFilePath theResultPath = CFilePath::CombineBaseAndRelative( + theDocumentDir, theEffectFileSourcePaths[idx]); + CFilePath theResultDir(theResultPath.GetDirectory()); + theResultDir.CreateDir(true); + // If the file already exists, these file flags will ensure it won't get + // overwritten. + SFileTools::Copy(theResultPath, + qt3ds::foundation::FileOpenFlags( + qt3ds::foundation::FileOpenFlagValues::Create + | qt3ds::foundation::FileOpenFlagValues::Write), + theSourcePath); + } + } + } + } + } + + // we are always successful + return true; +} + +//=============================================================================== +/** + * This will get the objec ttype from the Asset. + * Note: The asset can change all of the time, so i always ask the asset for its type. + * @return the Studio object type. + */ +long CProjectDropTarget::GetObjectType() +{ + return EUIC_FLAVOR_FILE; +} diff --git a/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.h b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.h new file mode 100644 index 00000000..234c30ed --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __PROJECTDROPTARGET_H__ +#define __PROJECTDROPTARGET_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropTarget.h" +#include "UICFileTools.h" + +class CDropSource; + +//============================================================================== +/** + * @class CProjectDropTarget + * @brief Drop Target for Project Palette + */ +class CProjectDropTarget : public CDropTarget +{ +public: + CProjectDropTarget(const Q3DStudio::CFilePath &inTargetDir); + + bool Accept(CDropSource &inSource) override; + bool Drop(CDropSource &inSource) override; + long GetObjectType() override; + +protected: + Q3DStudio::CFilePath m_TargetDir; ///< The target directory to copy file to. +}; + +#endif // #ifndef __PROJECTDROPTARGET_H__ diff --git a/src/Authoring/Studio/DragAndDrop/SceneDropTarget.cpp b/src/Authoring/Studio/DragAndDrop/SceneDropTarget.cpp new file mode 100644 index 00000000..47850e80 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/SceneDropTarget.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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" + +//============================================================================== +// Includes +//============================================================================== +#include "SceneDropTarget.h" +#include "DropTarget.h" +#include "DropSource.h" + +#include "StudioApp.h" +#include "Doc.h" + +#include "HotKeys.h" +#include "IDropTargetHelper.h" +#include "Core.h" +#include "GraphUtils.h" +#include "UICDMStudioSystem.h" +#include "ClientDataModelBridge.h" +#include "UICDMDataCore.h" +#include "UICDMSlides.h" + +// Sceneview stuff +//=============================================================================== +/** + * Constructor. + */ +CSceneViewDropTarget::CSceneViewDropTarget() + : m_DropTime(-1) +{ + m_ObjectType = OBJTYPE_LAYER; + m_DropSourceObjectType = OBJTYPE_UNKNOWN; +} + +//=============================================================================== +/** + * This will get the objec ttype from the Asset. + * Note: The asset can change all of the time, so i always ask the asset for its type. + * @return the Studio object type. + */ +long CSceneViewDropTarget::GetObjectType() +{ + UICDM::CUICDMInstanceHandle theInstance = GetInstance(); + + if (theInstance.Valid()) { + CClientDataModelBridge *theBridge = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + m_ObjectType = theBridge->GetObjectType(theInstance); + return m_ObjectType; + } + return OBJTYPE_UNKNOWN; +} + +//=============================================================================== +/** + * This get called on every DragWithin. + * Note: the source will validate the target instead of the otherway around. + * This is because the DropSource knows how to get information from itself without + * creating an asset. This is mainly for DropSources that have a lazy creation idiom. + * like files. + * Dropping into "locked" layers are not allowed. + * @param inSource the DropSource in question. + * @return true if the DropSource likes the DropTarget. + */ +bool CSceneViewDropTarget::Accept(CDropSource &inSource) +{ + CClientDataModelBridge *theBridge = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + + // We have to set this so we can adjust the Target to accept this source. + SetDropSourceObjectType(inSource.GetObjectType()); + + bool theAcceptable = false; + + // We don't want to generate an asset right now so let the DropSource ask us if it can drop. + theAcceptable = inSource.ValidateTarget(this); + + // The DropSource already generated the asset for this in the above. + if (theAcceptable && m_Instance.Valid()) { + theAcceptable = !theBridge->IsLockedAtAll(m_Instance); + } + + return theAcceptable; +} + +//=============================================================================== +/** + * This is so the questioned object type can be cached so we can get the correct asset. + * @param inObjType the object type of the Questioned object. + */ +void CSceneViewDropTarget::SetDropSourceObjectType(long inObjType) +{ + m_DropSourceObjectType = inObjType; +} + +//=============================================================================== +/** + * This is where is actually happens. + * Note: At this point either everything should be verified, and setup in the dropsource. + * Then the only thing left to do is to get the Assets and move/copy or connect them. + * Or the dropsource needs the target to perform the actual drop. + * Note that if the Control key is depressed, the start time follows the current view time( + *i.e. playhead position ) + * And if the Alt key (KEY_MENU) is depressed, the object is dropped at the mouse location. + * + * @param inSource the Object in question. + * @return true if the drop was successful . + */ +bool CSceneViewDropTarget::Drop(CDropSource &inSource) +{ + // The Parent is a tree control item, so iwe know it can be converted to an Asset. + + // We have to set this so we can adjust the Target to accept this source. + SetDropSourceObjectType(inSource.GetObjectType()); + + UICDM::CUICDMInstanceHandle theTargetInstance = GetInstance(); + if (theTargetInstance.Valid()) { + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + UICDM::ISlideSystem *theSlideSystem = theDoc->GetStudioSystem()->GetSlideSystem(); + UICDM::CUICDMSlideHandle theSlide = theDoc->GetActiveSlide(); + if (!theSlideSystem->IsMasterSlide(theSlide) + && (inSource.GetCurrentFlags() & CHotKeys::MODIFIER_ALT)) { + if (CanAddToMaster()) { + UICDM::CUICDMSlideHandle theMasterSlideHandle = + theSlideSystem->GetMasterSlide(theSlide); + if (theMasterSlideHandle.Valid()) + theSlide = theMasterSlideHandle; + } + } + CCmd *command = + inSource.GenerateAssetCommand(theTargetInstance, EDROPDESTINATION_ON, theSlide); + if (command != nullptr) + theDoc->GetCore()->ExecuteCommand(command); + } + + return true; +} + +//=============================================================================== +/** + * @return the Asset that we would like the DropSource to drop on to. + */ +UICDM::CUICDMInstanceHandle CSceneViewDropTarget::GetInstance() +{ + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + UICDM::CUICDMInstanceHandle theRootObject = theDoc->GetActiveRootInstance(); + EStudioObjectType theRootObjType = + theDoc->GetStudioSystem()->GetClientDataModelBridge()->GetObjectType(theRootObject); + + // Check if the inObjectType can just go ahead and drop onto the Root object. + if (CStudioObjectTypes::AcceptableParent((EStudioObjectType)m_DropSourceObjectType, + theRootObjType)) { + m_Instance = theRootObject; + } else if (theRootObject == theDoc->GetSceneInstance() + && CStudioObjectTypes::AcceptableParent((EStudioObjectType)m_DropSourceObjectType, + OBJTYPE_LAYER)) { + m_Instance = theDoc->GetActiveLayer(); + } + + return m_Instance; +} + +//=============================================================================== +/** + * Check to see if the Asset is a relative of our asset. + * @return true if the inAsset is a parent grandparent...etc. of this asset. + */ +bool CSceneViewDropTarget::IsRelative(UICDM::CUICDMInstanceHandle inInstance) +{ + bool theReturn = false; + + UICDM::CUICDMInstanceHandle theThisInstance = GetInstance(); + // This will check to see if the inAsset is already a parent, grandparent....etc. + if (theThisInstance.Valid()) + theReturn = IsAscendant(theThisInstance, inInstance, + g_StudioApp.GetCore()->GetDoc()->GetAssetGraph()); + return theReturn; +} + +//=============================================================================== +/** + * Check to see if the inAsset is our asset. + * @param inAsset The Asset to check. + * @return true if we are the same. + */ +bool CSceneViewDropTarget::IsSelf(UICDM::CUICDMInstanceHandle inInstance) +{ + UICDM::CUICDMInstanceHandle theThisInstance = GetInstance(); + return (theThisInstance == inInstance); +} + +//=============================================================================== +/** + * Set the Drop time for all sources. + * @param inDropTime The time to drop the source. + */ +void CSceneViewDropTarget::SetDropTime(long inDropTime) +{ + m_DropTime = inDropTime; +} + +//=============================================================================== +/** + * @return The time that all sources will be droped. + */ +long CSceneViewDropTarget::GetDropTime() +{ + return m_DropTime; +} + +// Last Sceneview related stuff. diff --git a/src/Authoring/Studio/DragAndDrop/SceneDropTarget.h b/src/Authoring/Studio/DragAndDrop/SceneDropTarget.h new file mode 100644 index 00000000..cdcb7afc --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/SceneDropTarget.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __SCENEDROPTARGET_H__ +#define __SCENEDROPTARGET_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropTarget.h" + +//============================================================================== +/** + * @class + * @brief LEONARD.PONCE needs to enter a brief description here. + * + * LEONARD.PONCE needs to enter a long description here. + */ +class CSceneViewDropTarget : public CDropTarget +{ +protected: + long m_DropTime; ///< The Time to drop any thing. + long m_DropSourceObjectType; + +public: + CSceneViewDropTarget(); + bool Accept(CDropSource &inSource) override; + bool Drop(CDropSource &inSource) override; + UICDM::CUICDMInstanceHandle GetInstance() override; + + bool IsRelative(UICDM::CUICDMInstanceHandle inInstance) override; + bool IsSelf(UICDM::CUICDMInstanceHandle inInstance) override; + long GetObjectType() override; + void SetDropSourceObjectType(long inObjType); + void SetDropTime(long inDropTime); + long GetDropTime(); +}; +#endif // #ifndef __SCENEDROPTARGET_H__ diff --git a/src/Authoring/Studio/DragAndDrop/TimelineDropSource.cpp b/src/Authoring/Studio/DragAndDrop/TimelineDropSource.cpp new file mode 100644 index 00000000..cf664825 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/TimelineDropSource.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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" + +//============================================================================== +// Includes +//============================================================================== +#include "TimelineDropSource.h" +#include "FileDropSource.h" +#include "Dispatch.h" +#include "DropTarget.h" +#include "StudioObjectTypes.h" +#include "HotKeys.h" +#include "Core.h" +#include "Doc.h" +#include "UICDMStudioSystem.h" +#include "ClientDataModelBridge.h" +#include "UICDMSlides.h" +#include "Bindings/UICDMTimelineItemBinding.h" +#include "IDocumentEditor.h" +#include "ImportUtils.h" + +#pragma warning(disable : 4100) + +using namespace Q3DStudio; + +//=============================================================================== +/** + * + */ +CTimeLineDropSource::CTimeLineDropSource(long inFlavor, IDragable *inDraggable) + : CDropSource(inFlavor, sizeof(inDraggable)) +{ + m_Copy = true; + + m_Instances = g_StudioApp.GetCore()->GetDoc()->GetSelectedValue().GetSelectedInstances(); + if (m_Instances.size()) + m_ObjectType = g_StudioApp.GetCore() + ->GetDoc() + ->GetStudioSystem() + ->GetClientDataModelBridge() + ->GetObjectType(m_Instances[0]); + else + m_ObjectType = OBJTYPE_UNKNOWN; +} + +//=============================================================================== +/** + * + */ +bool CTimeLineDropSource::CanMove() +{ + return !m_Copy; +} + +//=============================================================================== +/** + * + */ +bool CTimeLineDropSource::CanCopy() +{ + bool theReturn = false; + // This is here because some Assets can not be copied ( scene, material ) + theReturn = m_Copy && g_StudioApp.GetCore()->GetDoc()->CanCopyObject(m_Instances); + + return theReturn; +} + +//=============================================================================== +/** + * + */ +void CTimeLineDropSource::InterpretKeyFlags(long inModifyerKeys) +{ + m_Copy = ((inModifyerKeys & CHotKeys::MODIFIER_CONTROL) != 0); +} + +//=============================================================================== +/** + * + */ +bool CTimeLineDropSource::ValidateTarget(CDropTarget *inTarget) +{ + // the only thing we want to do from here is check the type. + bool theValidTarget = CStudioObjectTypes::AcceptableParent( + (EStudioObjectType)GetObjectType(), (EStudioObjectType)inTarget->GetObjectType()); + + for (size_t idx = 0, end = m_Instances.size(); idx < end && theValidTarget; ++idx) { + UICDM::CUICDMInstanceHandle theHandle(m_Instances[idx]); + + if (theValidTarget && theHandle.Valid()) { + theValidTarget &= (!inTarget->IsSelf(theHandle) && !inTarget->IsRelative(theHandle)); + UICDM::ISlideSystem *theSlideSystem = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetSlideSystem(); + UICDM::CUICDMSlideHandle theSlide = theSlideSystem->GetAssociatedSlide(theHandle); + bool theIsMaster = theSlideSystem->IsMasterSlide(theSlide); + + theValidTarget &= !(theIsMaster && !inTarget->IsMaster()); + } + } + + SetHasValidTarget(theValidTarget); + + return theValidTarget; +} + +using namespace UICDM; +using namespace Q3DStudio; + +inline void Rearrange(CDoc &inDoc, const UICDM::TInstanceHandleList &inInstances, + CUICDMInstanceHandle inTarget, DocumentEditorInsertType::Enum inInsertType) +{ + SCOPED_DOCUMENT_EDITOR(inDoc, QObject::tr("Rearrange Object")) + ->RearrangeObjects(inInstances, inTarget, inInsertType); +} + +CCmd *CTimeLineDropSource::GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) +{ + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + CClientDataModelBridge *theBridge = theDoc->GetStudioSystem()->GetClientDataModelBridge(); + + if (CanCopy()) { + SCOPED_DOCUMENT_EDITOR(*theDoc, QObject::tr("Duplicate Object")) + ->DuplicateInstances(m_Instances, inTarget, + ImportUtils::GetInsertTypeForDropType(inDestType)); + } else { + // We can't do the rearrange inline because it deletes a timeline item. + // So we will effectively postmessage and do it out of line. + theDoc->GetCore()->GetDispatch()->FireOnAsynchronousCommand( + std::bind(Rearrange, std::ref(*theDoc), m_Instances, inTarget, + ImportUtils::GetInsertTypeForDropType(inDestType))); + } + + return nullptr; +} diff --git a/src/Authoring/Studio/DragAndDrop/TimelineDropSource.h b/src/Authoring/Studio/DragAndDrop/TimelineDropSource.h new file mode 100644 index 00000000..3a385518 --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/TimelineDropSource.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __TIMELINEDROPSOURCE_H__ +#define __TIMELINEDROPSOURCE_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "StudioApp.h" +#include "DropSource.h" + +//============================================================================== +// Forward +//============================================================================== +class CDropTarget; +class IDragable; + +class CTimeLineDropSource : public CDropSource +{ +protected: + bool m_Copy; + +public: + CTimeLineDropSource(long inFlavor, IDragable *inDraggable); + + bool CanMove() override; + bool CanCopy() override; + bool ValidateTarget(CDropTarget *inTarget) override; + void InterpretKeyFlags(long inModifyerKeys) override; + + CCmd *GenerateAssetCommand(UICDM::CUICDMInstanceHandle inTarget, + EDROPDESTINATION inDestType, + UICDM::CUICDMSlideHandle inSlide) override; +}; + +#endif // #ifndef __TIMELINEDROPSOURCE_H__ diff --git a/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.cpp b/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.cpp new file mode 100644 index 00000000..25a1352b --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== + +//============================================================================== +// Includes +//============================================================================== +#include "stdafx.h" +#include "TimelineDropTarget.h" +#include "StudioApp.h" +#include "DropSource.h" +#include "HotKeys.h" +#include "Core.h" +#include "Doc.h" +#include "IDropTargetHelper.h" +#include "GraphUtils.h" +#include "UICDMStudioSystem.h" +#include "ClientDataModelBridge.h" +#include "UICDMSlides.h" + +// Timeline stuff + +//=============================================================================== +/** + * This get called on every DragWithin. + * Note: the source will validate the target instead of the otherway around. + * This is because the DropSource knows how to get information from itself without + * creating an asset. This is mainly for DropSources that have a lazy creation idiom. + * like files. + * @param the DropSource in question. + * @return true if the DropSource likes the DropTarget. + */ +bool CTimeLineDropTarget::Accept(CDropSource &inSource) +{ + bool theDropFlag = inSource.ValidateTarget(this); + return theDropFlag; +} + +//=============================================================================== +/** + * This is where is actually happens. + * Note: At this point either everything should be verified, and setup in the dropsource. + * Then the only thing left to do is to get the Assets and move/copy or connect them. + * Or the dropsource needs the target to perform the actual drop. + * Note that if the Control key is depressed, the start time follows the current view time( + *i.e. playhead position ) + * + * @param inSource the Object in question. + * @return true if the drop was successful . + */ +bool CTimeLineDropTarget::Drop(CDropSource &inSource) +{ + UICDM::CUICDMInstanceHandle theTargetInstance = GetInstance(); + + if (theTargetInstance.Valid()) { + CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); + UICDM::ISlideSystem *theSlideSystem = theDoc->GetStudioSystem()->GetSlideSystem(); + UICDM::CUICDMSlideHandle theSlide = theDoc->GetActiveSlide(); + if (!theSlideSystem->IsMasterSlide(theSlide) + && (inSource.GetCurrentFlags() & CHotKeys::MODIFIER_ALT)) { + if (CanAddToMaster()) { + UICDM::CUICDMSlideHandle theMasterSlideHandle = + theSlideSystem->GetMasterSlide(theSlide); + if (theMasterSlideHandle.Valid()) + theSlide = theMasterSlideHandle; + } + } + CCmd *theCmd = inSource.GenerateAssetCommand(theTargetInstance, m_Destination, theSlide); + if (theCmd) + g_StudioApp.GetCore()->ExecuteCommand(theCmd); + } + + return true; +} + +//=============================================================================== +/** + * This will get the objec ttype from the Asset. + * Note: The asset can change all of the time, so i always ask the asset for its type. + * @return the Studio object type. + */ +long CTimeLineDropTarget::GetObjectType() +{ + UICDM::CUICDMInstanceHandle theTargetInstance = GetTargetInstance(); + if (theTargetInstance.Valid()) { + CClientDataModelBridge *theBridge = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + return theBridge->GetObjectType(theTargetInstance); + } + + return m_ObjectType; +} + +//=============================================================================== +/** + * Check to see if the Asset is a relative of our asset. + * @return true if the inAsset is a parent grandparent...etc. of this asset. + */ +bool CTimeLineDropTarget::IsRelative(UICDM::CUICDMInstanceHandle inInstance) +{ + bool theReturn = false; ///< Default return value. + UICDM::CUICDMInstanceHandle theThisInstance = GetInstance(); + + // This will check to see if the inAsset is already some sort of parent grandparent....etc. + if (theThisInstance.Valid()) + theReturn = IsAscendant(theThisInstance, inInstance, + g_StudioApp.GetCore()->GetDoc()->GetAssetGraph()); + + return theReturn; +} + +//=============================================================================== +/** + * Check to see if the inAsset is our asset. + * @param inAsset The Asset to check. + * @return true if we are the same. + */ +bool CTimeLineDropTarget::IsSelf(UICDM::CUICDMInstanceHandle inInstance) +{ + UICDM::CUICDMInstanceHandle theThisInstance = GetInstance(); + // true if self..... + return (theThisInstance == inInstance); +} + +//=============================================================================== +/** + * This method is used to detirmine validity for dropping on Master items. + * We do not allow Master items to be dropped on non-master targets because + * it does not make any hierarchical sense. Also checks for NULL and Scene object. + * (The scene object reports as a master object so that we can re-arrange layers (On the master + *slide).) + * Changed checking for scene to checking for root object, which may be a component. This + * would allow for the root component (as in edit component) to re-arrange its children, even if + *either + * party is not a master. + * @param inAsset The Asset to check. + * @return true if we are the same. + */ +bool CTimeLineDropTarget::IsMaster() +{ + if (!m_Instance.Valid()) + return true; + else if (m_Instance == g_StudioApp.GetCore()->GetDoc()->GetActiveRootInstance()) + return true; + else { + UICDM::ISlideSystem *theSlideSystem = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetSlideSystem(); + UICDM::CUICDMSlideHandle theSlide = theSlideSystem->GetAssociatedSlide(m_Instance); + return theSlideSystem->IsMasterSlide(theSlide); + } +} + +void CTimeLineDropTarget::SetDestination(EDROPDESTINATION inDestination) +{ + m_Destination = inDestination; +} + +EDROPDESTINATION CTimeLineDropTarget::GetDestination() const +{ + return m_Destination; +} + +//=============================================================================== +/** + * Figure out the destination (parent) asset that the drop is to occur. + * In the case that the drop occurs ON this asset, then the to-be-dropped asset becomes a child + *of m_Asset + * Otherwise, this m_Asset ends up being a sibling + */ +UICDM::CUICDMInstanceHandle CTimeLineDropTarget::GetTargetInstance() +{ + UICDM::CUICDMInstanceHandle theInstance = GetInstance(); + if (!theInstance.Valid()) + return 0; + + CClientDataModelBridge *theBridge = + g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); + bool theIsActiveComponent = false; + bool theIsComponent = (theBridge->GetObjectType(theInstance) == OBJTYPE_COMPONENT); + if (theIsComponent) + theIsActiveComponent = theBridge->IsActiveComponent(theInstance); + + // If the drop destination is ON, it will be valid if this is not a component or it's in the + // component timeline + if (m_Destination == EDROPDESTINATION_ON) { + if (!theIsComponent || theIsActiveComponent) + return theInstance; + else + return 0; + } + + // if target is a component, and we want to insert it above/below, and we are viewing this + // component, then it's an invalid operation + // thus set the target to 0. + if (theIsActiveComponent) + return 0; + + return theBridge->GetParentInstance(theInstance); +} + +// LASTTIMELINE RELATED CODE
\ No newline at end of file diff --git a/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.h b/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.h new file mode 100644 index 00000000..29133afd --- /dev/null +++ b/src/Authoring/Studio/DragAndDrop/TimelineDropTarget.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 1999-2002 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 +//============================================================================== +#ifndef __TIMELINEDROPTARGET_H__ +#define __TIMELINEDROPTARGET_H__ + +//============================================================================== +// Includes +//============================================================================== +#include "DropTarget.h" +#include "DropSource.h" + +class CControl; +class CDropSource; + +//============================================================================== +/** + * @class + * @brief LEONARD.PONCE needs to enter a brief description here. + * + * LEONARD.PONCE needs to enter a long description here. + */ +class CTimeLineDropTarget : public CDropTarget +{ + +public: + CTimeLineDropTarget() + : m_Destination(EDROPDESTINATION_ON) + , m_InsertionMarkedRow(nullptr) + , m_InsertionMarkedIndent(0) + { + } + bool Accept(CDropSource &inSource) override; + bool Drop(CDropSource &inSource) override; + long GetObjectType() override; + + bool IsRelative(UICDM::CUICDMInstanceHandle inInstance) override; + bool IsSelf(UICDM::CUICDMInstanceHandle inInstance) override; + bool IsMaster() override; + + void SetDestination(EDROPDESTINATION inDestination); + EDROPDESTINATION GetDestination() const; + + // Return info where the insertion markers is supposed to be drawn at. + CControl *GetInsertionMarkerRow() const { return m_InsertionMarkedRow; } + void SetInsertionMarkerRow(CControl *inControl) { m_InsertionMarkedRow = inControl; } + long GetInsertionMarkerIndent() const { return m_InsertionMarkedIndent; } + void SetInsertionMarkerIndent(long inIndent) { m_InsertionMarkedIndent = inIndent; } + +protected: + UICDM::CUICDMInstanceHandle GetTargetInstance(); + +protected: + EDROPDESTINATION m_Destination; + CControl *m_InsertionMarkedRow; + long m_InsertionMarkedIndent; +}; + +#endif // #ifndef __TIMELINEDROPTARGET_H__ |