diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-04-13 15:17:01 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-04-16 08:24:07 +0000 |
commit | fc9ad53980349ed8e9ea2dec74642f77ac514908 (patch) | |
tree | 7d1a4c7711d9753bfd38096f307106aa3dc36747 | |
parent | a478096e0be1ee04381f46a080e694d67e380af0 (diff) |
Enable deleting keyframes from the Timeline menu
Task-number: QT3DS-1432
Change-Id: I48c44f0731db466bc628cacd4451720249a9514d
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
11 files changed, 101 insertions, 25 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/IDoc.h b/src/Authoring/Client/Code/Core/Doc/IDoc.h index bd56e9ad..8c439f5e 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDoc.h +++ b/src/Authoring/Client/Code/Core/Doc/IDoc.h @@ -49,6 +49,7 @@ class CAsset; class IKeyframesManager; class ISelectable; class CCore; +class TimelineWidget; namespace qt3ds { namespace foundation { diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp index 744dc124..cfa8136c 100644 --- a/src/Authoring/Studio/MainFrm.cpp +++ b/src/Authoring/Studio/MainFrm.cpp @@ -58,7 +58,7 @@ #include "StudioTutorialWidget.h" #include "remotedeploymentsender.h" #include "InspectorControlView.h" -#include "TimelineView.h" +#include "TimelineWidget.h" #include "ProjectView.h" #include <QtGui/qevent.h> @@ -650,9 +650,7 @@ void CMainFrame::OnTimelineSetChangedKeyframe() */ void CMainFrame::OnUpdateTimelineDeleteSelectedKeyframes() { - // TODO: reimplement in the new timeline -// m_ui->actionDelete_Selected_Keyframe_s->setEnabled( -// g_StudioApp.GetCore()->GetDoc()->GetKeyframesManager()->HasSelectedKeyframes()); + m_ui->actionDelete_Selected_Keyframe_s->setEnabled(getTimelineWidget()->hasSelectedKeyframes()); } //============================================================================== @@ -1865,9 +1863,10 @@ void CMainFrame::OnConnectionChanged(bool connected) m_ui->actionRemote_Preview->setEnabled(connected); } -TimelineView *CMainFrame::GetTimelineView() +TimelineWidget *CMainFrame::getTimelineWidget() { - return m_PaletteManager->GetTimelineView(); + return static_cast<TimelineWidget *>(m_PaletteManager->GetControl( + CPaletteManager::CONTROLTYPE_TIMELINE)->widget()); } ITimelineTimebar *CMainFrame::GetSelectedTimelineTimebar() diff --git a/src/Authoring/Studio/MainFrm.h b/src/Authoring/Studio/MainFrm.h index 6591195d..c8d62c3a 100644 --- a/src/Authoring/Studio/MainFrm.h +++ b/src/Authoring/Studio/MainFrm.h @@ -54,7 +54,7 @@ class CSceneView; class CStudioApp; class ITimelineTimebar; class RemoteDeploymentSender; -class TimelineView; +class TimelineWidget; #ifdef QT_NAMESPACE using namespace QT_NAMESPACE; @@ -229,7 +229,7 @@ public: void onCtrlNPressed(); ITimelineTimebar *GetSelectedTimelineTimebar(); - TimelineView *GetTimelineView(); + TimelineWidget *getTimelineWidget(); void EditPreferences(short inPageIndex); diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp index d83c0a5f..91b24663 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/KeyframesManager.cpp @@ -70,7 +70,8 @@ CKeyframesManager::CKeyframesManager(CTimelineTranslationManager *inTransMgr) , m_OffsetKeyframeCommandHelper(*(g_StudioApp.GetCore()->GetDoc())) , m_PasteKeyframeCommandHelper(nullptr) { - g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(this); + // Mahmoud_TODO: to be removed after further clean up +// g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(this); } CKeyframesManager::~CKeyframesManager() diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp index 400c4707..f0d470fa 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp @@ -43,9 +43,10 @@ #include "CmdDataModelRemoveKeyframe.h" #include "CmdDataModelInsertKeyframe.h" #include "Bindings/ITimelineItemBinding.h" -#include "Bindings/KeyframesManager.h" +#include "Bindings/OffsetKeyframesCommandHelper.h" #include "Bindings/Qt3DSDMTimelineKeyframe.h" + #include <qglobal.h> #include <QtCore/qhash.h> #include <QtCore/qdebug.h> @@ -220,7 +221,7 @@ void KeyframeManager::deselectAllKeyframes() m_selectedKeyframesMasterRows.clear(); } -void KeyframeManager::deleteSelectedKeyframes() +bool KeyframeManager::deleteSelectedKeyframes() { if (!m_selectedKeyframes.empty()) { CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); @@ -242,7 +243,10 @@ void KeyframeManager::deleteSelectedKeyframes() g_StudioApp.GetCore()->ExecuteCommand(cmd); PostExecuteCommand(theDoc); + return true; } + + return false; } // delete all keyframes on a row @@ -390,6 +394,63 @@ bool KeyframeManager::hasCopiedKeyframes() const return !m_copiedKeyframes.empty(); } +// IKeyframesManager interface to connect Doc and KeyframeManager +// Mahmoud_TODO: rewrite a better interface for the new timeline +bool KeyframeManager::HasSelectedKeyframes(bool inOnlyDynamic) +{ + return hasSelectedKeyframes(); +} + +bool KeyframeManager::HasDynamicKeyframes() +{ + return true; // Mahmoud_TODO: implement +} + +bool KeyframeManager::CanPerformKeyframeCopy() +{ + return true; // Mahmoud_TODO: implement +} + +bool KeyframeManager::CanPerformKeyframePaste() +{ + return true; // Mahmoud_TODO: implement +} + +void KeyframeManager::CopyKeyframes() +{ + copySelectedKeyframes(); +} + +bool KeyframeManager::RemoveKeyframes(bool inPerformCopy) +{ + return deleteSelectedKeyframes(); +} + +void KeyframeManager::PasteKeyframes() +{ + // Mahmoud_TODO: implement +} + +void KeyframeManager::SetKeyframeInterpolation() +{ + // Mahmoud_TODO: implement +} + +void KeyframeManager::SelectAllKeyframes() +{ + // Mahmoud_TODO: implement if needed +} + +void KeyframeManager::DeselectAllKeyframes() +{ + // Mahmoud_TODO: implement if needed +} + +void KeyframeManager::SetChangedKeyframes() +{ + // Mahmoud_TODO: implement if needed +} + const QHash<int, QList<QString>> KeyframeManager::SUPPORTED_ROW_PROPS = { { OBJTYPE_LAYER, { "Left", diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h index 7687c203..80a367a8 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h @@ -31,6 +31,7 @@ #include <QtCore/qlist.h> #include <StudioObjectTypes.h> +#include "IKeyframesManager.h" class RowTimeline; class TimelineGraphicsScene; @@ -39,7 +40,7 @@ struct Keyframe; QT_FORWARD_DECLARE_CLASS(QGraphicsSceneContextMenuEvent) QT_FORWARD_DECLARE_CLASS(QRectF) -class KeyframeManager +class KeyframeManager : public IKeyframesManager { public: KeyframeManager(TimelineGraphicsScene *m_scene); @@ -53,12 +54,12 @@ public: void deselectKeyframe(Keyframe *keyframe); void deselectConnectedKeyframes(Keyframe *keyframe); void deselectAllKeyframes(); - void deleteSelectedKeyframes(); void deleteKeyframes(RowTimeline *row, bool repaint = true); void copySelectedKeyframes(); void pasteKeyframes(RowTimeline *row); void moveSelectedKeyframes(double dx); void commitMoveSelectedKeyframes(); + bool deleteSelectedKeyframes(); bool oneMasterRowSelected() const; bool hasSelectedKeyframes() const; bool hasCopiedKeyframes() const; @@ -69,6 +70,20 @@ public: QList<Keyframe *> m_copiedKeyframes; // for copy, cut, paste QList<RowTimeline *> m_selectedKeyframesMasterRows; + // IKeyframesManager interface + // Mahmoud_TODO: rewrite a better interface for the new timeline + bool HasSelectedKeyframes(bool inOnlyDynamic) override; + bool HasDynamicKeyframes() override; + bool CanPerformKeyframeCopy() override; + bool CanPerformKeyframePaste() override; + void CopyKeyframes() override; + bool RemoveKeyframes(bool inPerformCopy) override; + void PasteKeyframes() override; + void SetKeyframeInterpolation() override; + void SelectAllKeyframes() override; + void DeselectAllKeyframes() override; + void SetChangedKeyframes() override; + private: static const QHash<int, QList<QString>> SUPPORTED_ROW_PROPS; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h index ec29bab4..29948333 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h @@ -46,6 +46,7 @@ class RowMover; class RowManager; class KeyframeManager; class TimelineControl; +class IKeyframesManager; struct Keyframe; QT_FORWARD_DECLARE_CLASS(QGraphicsLinearLayout) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp index 3da15a55..07b5d817 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp @@ -193,6 +193,9 @@ TimelineWidget::TimelineWidget(QWidget *parent) layoutRoot->addWidget(m_toolbar); setLayout(layoutRoot); + g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager( + static_cast<IKeyframesManager *>(m_graphicsScene->keyframeManager())); + // connect graphics scene geometryChanged connect(m_graphicsScene->widgetRoot(), &QGraphicsWidget::geometryChanged, this, [this]() { const QRectF rect = m_graphicsScene->widgetRoot()->rect(); @@ -660,3 +663,8 @@ TimelineToolbar *TimelineWidget::toolbar() const { return m_toolbar; } + +bool TimelineWidget::hasSelectedKeyframes() const +{ + return m_graphicsScene->keyframeManager()->hasSelectedKeyframes(); +} diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h index 11c3d7ef..f83d04af 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h @@ -69,6 +69,7 @@ public: //CClientPlayChangeListener void OnTimeChanged(long inTime) override; + bool hasSelectedKeyframes() const; protected: // DataModel callbacks diff --git a/src/Authoring/Studio/_Win/Palettes/PaletteManager.cpp b/src/Authoring/Studio/_Win/Palettes/PaletteManager.cpp index 9b99a954..99891278 100644 --- a/src/Authoring/Studio/_Win/Palettes/PaletteManager.cpp +++ b/src/Authoring/Studio/_Win/Palettes/PaletteManager.cpp @@ -120,6 +120,7 @@ CPaletteManager::CPaletteManager(CMainFrame *inMainFrame) m_timelineGVDock->setAllowedAreas(Qt::BottomDockWidgetArea); m_timelineWidget = new TimelineWidget(m_timelineGVDock); m_timelineGVDock->setWidget(m_timelineWidget); + m_ControlList.insert(std::make_pair(CONTROLTYPE_TIMELINE, m_timelineGVDock)); m_actionDock = new QDockWidget(QObject::tr("Action"), inMainFrame); m_actionDock->setObjectName("action"); @@ -246,17 +247,6 @@ bool CPaletteManager::tabNavigateFocusedWidget(bool tabForward) return false; } -//============================================================================== -/** - * A helper for CMainFrame::GetTimelineControl() to access the CTimelineControl - * inside the QDockWidget - */ - -TimelineView *CPaletteManager::GetTimelineView() const -{ - return m_timelineView; -} - void CPaletteManager::onTimeChanged(long time) { //m_timeLineToolbar->onTimeChanged(time); diff --git a/src/Authoring/Studio/_Win/Palettes/PaletteManager.h b/src/Authoring/Studio/_Win/Palettes/PaletteManager.h index 07e94f6c..69183053 100644 --- a/src/Authoring/Studio/_Win/Palettes/PaletteManager.h +++ b/src/Authoring/Studio/_Win/Palettes/PaletteManager.h @@ -104,7 +104,6 @@ public: QDockWidget *GetControl(long inType) const; QWidget *getFocusWidget() const; bool tabNavigateFocusedWidget(bool tabForward); - TimelineView *GetTimelineView() const; void onTimeChanged(long time); ProjectView *projectView() const; |