summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Ali <Mahmoud.Badri@qt.io>2018-04-20 12:34:53 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2018-04-23 06:17:06 +0000
commitca2c4d1993bf94b2707eb5ed1c3846737c2bbdd2 (patch)
treea6e7e7d4e0c59570829f9f68b5a9d031e2d28921
parent425529645ecce546280ca2a93db694e83a2bae7b (diff)
Implement playhead and keyframe edit time dialogue
Task-number: QT3DS-1451 Task-number: QT3DS-1426 Change-Id: If0f692d0fc626994dacacfff764c60d69fd39036 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Application/DurationEditDlg.h12
-rw-r--r--src/Authoring/Studio/Application/TimeEditDlg.h17
-rw-r--r--src/Authoring/Studio/Application/TimeEnums.h49
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp40
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h13
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp35
-rw-r--r--src/Authoring/Studio/Qt3DStudio.pro1
7 files changed, 128 insertions, 39 deletions
diff --git a/src/Authoring/Studio/Application/DurationEditDlg.h b/src/Authoring/Studio/Application/DurationEditDlg.h
index 2dec58ba..7630b02a 100644
--- a/src/Authoring/Studio/Application/DurationEditDlg.h
+++ b/src/Authoring/Studio/Application/DurationEditDlg.h
@@ -30,23 +30,13 @@
#ifndef DURATION_EDIT_DIALOG_H
#define DURATION_EDIT_DIALOG_H
+#include "TimeEnums.h"
#include <QtWidgets/qdialog.h>
class CTimebarControl;
class IDoc;
class ITimelineKeyframesManager;
-enum ETimeFormat { MSEC, SEC_MSEC, MIN_SEC_MSEC };
-
-enum ETimeConversionOperation {
- CONVERT_MIN_TO_MSEC,
- CONVERT_SEC_TO_MSEC,
- CONVERT_MSEC_TO_MIN,
- CONVERT_MSEC_TO_SEC,
- CONVERT_TIME_TO_MSEC,
- CONVERT_MSEC_TO_MIN_SEC_MSEC
-};
-
class ITimeChangeCallback
{
public:
diff --git a/src/Authoring/Studio/Application/TimeEditDlg.h b/src/Authoring/Studio/Application/TimeEditDlg.h
index 9a58bf13..8d8ed08f 100644
--- a/src/Authoring/Studio/Application/TimeEditDlg.h
+++ b/src/Authoring/Studio/Application/TimeEditDlg.h
@@ -30,28 +30,13 @@
#ifndef TIME_EDIT_DIALOG_H
#define TIME_EDIT_DIALOG_H
+#include "TimeEnums.h"
#include <QtWidgets/qdialog.h>
class CTimebarControl;
class IDoc;
class ITimelineKeyframesManager;
-enum ETimeFormat { MSEC, SEC_MSEC, MIN_SEC_MSEC };
-
-enum ETimeConversionOperation {
- CONVERT_MIN_TO_MSEC,
- CONVERT_SEC_TO_MSEC,
- CONVERT_MSEC_TO_MIN,
- CONVERT_MSEC_TO_SEC,
- CONVERT_TIME_TO_MSEC,
- CONVERT_MSEC_TO_MIN_SEC_MSEC
-};
-
-enum EObjectAssociation {
- PLAYHEAD,
- ASSETKEYFRAME
-};
-
#ifdef QT_NAMESPACE
using namespace QT_NAMESPACE;
#endif
diff --git a/src/Authoring/Studio/Application/TimeEnums.h b/src/Authoring/Studio/Application/TimeEnums.h
new file mode 100644
index 00000000..ce671201
--- /dev/null
+++ b/src/Authoring/Studio/Application/TimeEnums.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2002 NVIDIA Corporation.
+** Copyright (C) 2018 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 TIME_ENUMS_H
+#define TIME_ENUMS_H
+
+enum ETimeFormat { MSEC, SEC_MSEC, MIN_SEC_MSEC };
+
+enum ETimeConversionOperation {
+ CONVERT_MIN_TO_MSEC,
+ CONVERT_SEC_TO_MSEC,
+ CONVERT_MSEC_TO_MIN,
+ CONVERT_MSEC_TO_SEC,
+ CONVERT_TIME_TO_MSEC,
+ CONVERT_MSEC_TO_MIN_SEC_MSEC
+};
+
+enum EObjectAssociation {
+ PLAYHEAD,
+ ASSETKEYFRAME
+};
+
+#endif // TIME_ENUMS_H
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
index 28a908ac..e2ba16af 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
@@ -385,8 +385,46 @@ 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
+// ITimelineKeyframesManager interface
+void KeyframeManager::SetKeyframeTime(long inTime)
+{
+ // Mahmoud_TODO: implement if needed
+}
+
+void KeyframeManager::SetKeyframesDynamic(bool inDynamic)
+{
+ // Mahmoud_TODO: implement if needed
+}
+
+long KeyframeManager::OffsetSelectedKeyframes(long inOffset)
+{
+ double dx = m_scene->ruler()->timeToDistance(inOffset / 1000.0);
+ moveSelectedKeyframes(dx);
+ return 0;
+}
+
+bool KeyframeManager::CanMakeSelectedKeyframesDynamic()
+{
+ // Mahmoud_TODO: implement if needed
+ return false;
+}
+
+void KeyframeManager::CommitChangedKeyframes()
+{
+ commitMoveSelectedKeyframes();
+}
+
+void KeyframeManager::RollbackChangedKeyframes()
+{
+ for (Keyframe *keyframe : qAsConst(m_selectedKeyframes))
+ keyframe->time = keyframe->binding->GetTime() / 1000.0;
+
+ for (auto row : qAsConst(m_selectedKeyframesMasterRows))
+ row->updateKeyframes();
+}
+
+// IKeyframesManager interface
bool KeyframeManager::HasSelectedKeyframes(bool inOnlyDynamic)
{
return hasSelectedKeyframes();
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h
index 80a367a8..86699184 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h
@@ -29,9 +29,9 @@
#ifndef KEYFRAMEMANAGER_H
#define KEYFRAMEMANAGER_H
+#include "Bindings/ITimelineKeyframesManager.h"
#include <QtCore/qlist.h>
#include <StudioObjectTypes.h>
-#include "IKeyframesManager.h"
class RowTimeline;
class TimelineGraphicsScene;
@@ -40,7 +40,7 @@ struct Keyframe;
QT_FORWARD_DECLARE_CLASS(QGraphicsSceneContextMenuEvent)
QT_FORWARD_DECLARE_CLASS(QRectF)
-class KeyframeManager : public IKeyframesManager
+class KeyframeManager : public ITimelineKeyframesManager
{
public:
KeyframeManager(TimelineGraphicsScene *m_scene);
@@ -70,8 +70,15 @@ 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
+ // ITimelineKeyframesManager interface
+ void SetKeyframeTime(long inTime) override;
+ void SetKeyframesDynamic(bool inDynamic) override;
+ long OffsetSelectedKeyframes(long inOffset) override;
+ bool CanMakeSelectedKeyframesDynamic() override;
+ void CommitChangedKeyframes() override;
+ void RollbackChangedKeyframes() override;
+ // IKeyframesManager interface
bool HasSelectedKeyframes(bool inOnlyDynamic) override;
bool HasDynamicKeyframes() override;
bool CanPerformKeyframeCopy() override;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index 088a7135..a549dc9d 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -51,6 +51,7 @@
#include "RowTreeContextMenu.h"
#include "RowTimelineContextMenu.h"
#include "StudioPreferences.h"
+#include "TimeEditDlg.h"
#include <QtWidgets/qcombobox.h>
#include <QtWidgets/qgraphicssceneevent.h>
@@ -686,7 +687,17 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
const QPointF scenePos = event->scenePos();
QGraphicsItem *item = itemAt(scenePos, QTransform());
if (item != nullptr) {
- item = getItemBelowType(TimelineItem::TypePlayHead, item, scenePos);
+ QGraphicsItem *itemBelowPlayhead =
+ getItemBelowType(TimelineItem::TypePlayHead, item, scenePos);
+ if (item->type() == TimelineItem::TypeRuler
+ || itemBelowPlayhead->type() == TimelineItem::TypeRuler) {
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ CTimeEditDlg timeEditDlg;
+ timeEditDlg.showDialog(doc->GetCurrentViewTime(), doc, PLAYHEAD);
+ return;
+ }
+
+ item = itemBelowPlayhead;
if (item->type() == TimelineItem::TypeRowTreeLabelItem) {
RowTreeLabelItem *treeLabelItem = static_cast<RowTreeLabelItem *>(item);
if (!treeLabelItem->parentRow()->isProperty()) {
@@ -695,13 +706,21 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
treeLabelItem->setFocus();
}
} else if (item->type() == TimelineItem::TypeRowTimeline) {
- RowTimeline *timelineItem = static_cast<RowTimeline *>(item);
- long theStartTime = timelineItem->getStartTime() * 1000;
- long theEndTime = timelineItem->getEndTime() * 1000;
- m_timelineControl->setRowTimeline(timelineItem);
- CDurationEditDlg theDurationEditDlg;
- theDurationEditDlg.showDialog(theStartTime, theEndTime,
- g_StudioApp.GetCore()->GetDoc(), m_timelineControl);
+ RowTimeline *rowTimeline = static_cast<RowTimeline *>(item);
+ Keyframe *clickedKeyframe = rowTimeline->getClickedKeyframe(scenePos);
+ if (clickedKeyframe) {
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ CTimeEditDlg timeEditDlg;
+ timeEditDlg.setKeyframesManager(m_keyframeManager);
+ timeEditDlg.showDialog(clickedKeyframe->time * 1000, doc, ASSETKEYFRAME);
+ } else if (rowTimeline->rowTree()->hasDurationBar()) {
+ long theStartTime = rowTimeline->getStartTime() * 1000;
+ long theEndTime = rowTimeline->getEndTime() * 1000;
+ m_timelineControl->setRowTimeline(rowTimeline);
+ CDurationEditDlg theDurationEditDlg;
+ theDurationEditDlg.showDialog(theStartTime, theEndTime,
+ g_StudioApp.GetCore()->GetDoc(), m_timelineControl);
+ }
}
}
diff --git a/src/Authoring/Studio/Qt3DStudio.pro b/src/Authoring/Studio/Qt3DStudio.pro
index 4d91fe8c..b0c5df00 100644
--- a/src/Authoring/Studio/Qt3DStudio.pro
+++ b/src/Authoring/Studio/Qt3DStudio.pro
@@ -417,6 +417,7 @@ SOURCES += \
HEADERS += \
Application/TimeEditDlg.h \
Application/DurationEditDlg.h \
+ Application/TimeEnums.h \
_Win/Application/StudioApp.h \
Controls/TextEditContextMenu.h \
Palettes/Action/ActionModel.h \