summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp')
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp135
1 files changed, 81 insertions, 54 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
index 9a12aab3..a4248fad 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
@@ -35,16 +35,19 @@
#include "StudioApp.h"
#include "Core.h"
#include "Doc.h"
+#include "SlideSystem.h"
#include "StudioClipboard.h"
#include "CmdDataModelRemoveKeyframe.h"
#include "CmdDataModelInsertKeyframe.h"
#include "CmdDataModelChangeKeyframe.h"
#include "ClientDataModelBridge.h"
-#include "Bindings/OffsetKeyframesCommandHelper.h"
#include "Bindings/PasteKeyframesCommandHelper.h"
+#include "Bindings/ITimelineItemBinding.h"
#include "StudioPreferences.h"
#include "Dialogs.h"
#include "TimeEnums.h"
+#include "RowTimelinePropertyGraph.h"
+#include "IDocumentEditor.h"
using namespace qt3dsdm;
@@ -138,14 +141,17 @@ QList<Keyframe *> KeyframeManager::selectedKeyframes() const
return m_selectedKeyframes;
}
-// update bindings after selected keyframes are moved
void KeyframeManager::commitMoveSelectedKeyframes()
{
- CDoc *theDoc = g_StudioApp.GetCore()->GetDoc();
- COffsetKeyframesCommandHelper h(*theDoc);
+ Q3DStudio::ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(),
+ QObject::tr("Set Keyframe Time"), __FILE__, __LINE__);
+ for (Keyframe *keyframe : qAsConst(m_selectedKeyframes)) {
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList kfHandles;
+ keyframe->binding->GetKeyframeHandles(kfHandles);
- for (Keyframe *keyframe : qAsConst(m_selectedKeyframes))
- keyframe->binding->UpdateKeyframesTime(&h, keyframe->time);
+ for (auto h : kfHandles)
+ editor->SetKeyframeTime(h, keyframe->time);
+ }
}
void KeyframeManager::selectKeyframesInRect(const QRectF &rect)
@@ -164,6 +170,11 @@ void KeyframeManager::selectKeyframesInRect(const QRectF &rect)
m_selectedKeyframesMasterRows.append(keyframe->rowMaster);
}
}
+
+ if (row->propertyExpanded()
+ && row->propBinding()->animationType() == EAnimationTypeBezier) {
+ row->rowTimeline()->propertyGraph()->selectBezierKeyframesInRange(rect);
+ }
}
row = m_scene->rowManager()->getRowAtPos(QPointF(0, row->y() + row->size().height()));
}
@@ -209,6 +220,11 @@ void KeyframeManager::deselectAllKeyframes()
m_selectedKeyframes.clear();
m_selectedKeyframesMasterRows.clear();
+
+ // deselect bezier keyframes
+ const auto expandedPropGraphs = m_scene->rowManager()->getExpandedPropertyGraphs();
+ for (auto g : expandedPropGraphs)
+ g->deselectAllBezierKeyframes();
}
void KeyframeManager::deselectRowKeyframes(RowTree *row)
@@ -296,7 +312,7 @@ void KeyframeManager::copySelectedKeyframes()
Qt3DSDMTimelineKeyframe *kf = keyframe->binding;
Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
kf->GetKeyframeHandles(theKeyframeHandles);
- qt3dsdm::SGetOrSetKeyframeInfo info[3];
+ qt3dsdm::SGetOrSetKeyframeInfo info[4];
size_t infoCount = 0;
if (!theKeyframeHandles.empty()) {
switch (theKeyframeHandles.size()) {
@@ -310,11 +326,18 @@ void KeyframeManager::copySelectedKeyframes()
info[2] = setKeyframeInfo(theKeyframeHandles[2], *animationCore);
infoCount = 3;
break;
+ case 4:
+ info[0] = setKeyframeInfo(theKeyframeHandles[0], *animationCore);
+ info[1] = setKeyframeInfo(theKeyframeHandles[1], *animationCore);
+ info[2] = setKeyframeInfo(theKeyframeHandles[2], *animationCore);
+ info[3] = setKeyframeInfo(theKeyframeHandles[3], *animationCore);
+ infoCount = 4;
+ break;
default:
break;
}
- float dt = Qt3DSDMTimelineKeyframe::GetTimeInSecs(kf->GetTime() - minTime);
+ long dt = kf->GetTime() - minTime;
qt3dsdm::Qt3DSDMAnimationHandle animation
= animationCore->GetAnimationForKeyframe(theKeyframeHandles[0]);
m_pasteKeyframeCommandHelper->AddKeyframeData(
@@ -325,19 +348,14 @@ void KeyframeManager::copySelectedKeyframes()
}
qt3dsdm::SGetOrSetKeyframeInfo KeyframeManager::setKeyframeInfo(
- qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, qt3dsdm::IAnimationCore &inCore)
-{
- qt3dsdm::TKeyframe theKeyframeData = inCore.GetKeyframeData(inKeyframe);
- qt3dsdm::SEaseInEaseOutKeyframe keyframe =
- qt3dsdm::get<qt3dsdm::SEaseInEaseOutKeyframe>(theKeyframeData);
- bool isDynamic = false;
- if (inCore.IsFirstKeyframe(inKeyframe)) {
- isDynamic = inCore.GetAnimationInfo(inCore.GetAnimationForKeyframe(inKeyframe))
- .m_DynamicFirstKeyframe;
- }
+ qt3dsdm::Qt3DSDMKeyframeHandle keyframeHandle, qt3dsdm::IAnimationCore &animCore)
+{
+ qt3dsdm::TKeyframe keyframeData = animCore.GetKeyframeData(keyframeHandle);
- return qt3dsdm::SGetOrSetKeyframeInfo(keyframe.m_KeyframeValue, keyframe.m_EaseIn,
- keyframe.m_EaseOut, isDynamic);
+ bool isDynamic = animCore.IsFirstKeyframe(keyframeHandle) && animCore.GetAnimationInfo(
+ animCore.GetAnimationForKeyframe(keyframeHandle)).m_DynamicFirstKeyframe;
+
+ return qt3dsdm::SGetOrSetKeyframeInfo(keyframeData, isDynamic);
}
void KeyframeManager::pasteKeyframes()
@@ -346,10 +364,9 @@ void KeyframeManager::pasteKeyframes()
if (m_pasteKeyframeCommandHelper && m_pasteKeyframeCommandHelper->HasCopiedKeyframes()) {
qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = theDoc->GetSelectedInstance();
if (theSelectedInstance.Valid()) {
- long theCurrentViewTimeInMilliseconds = theDoc->GetCurrentViewTime();
- CCmdDataModelInsertKeyframe *theInsertKeyframesCommand =
- m_pasteKeyframeCommandHelper->GetCommand(theDoc, theCurrentViewTimeInMilliseconds,
- theSelectedInstance);
+ CCmdDataModelInsertKeyframe *theInsertKeyframesCommand
+ = m_pasteKeyframeCommandHelper->GetCommand(theDoc, theDoc->GetCurrentViewTime(),
+ theSelectedInstance);
if (theInsertKeyframesCommand)
g_StudioApp.GetCore()->ExecuteCommand(theInsertKeyframesCommand);
}
@@ -476,23 +493,33 @@ void KeyframeManager::RollbackChangedKeyframes()
row->updateKeyframes();
}
-// IKeyframesManager interface
-bool KeyframeManager::HasSelectedKeyframes()
+bool KeyframeManager::HasSelectedKeyframes() const
{
return hasSelectedKeyframes();
}
-bool KeyframeManager::HasDynamicKeyframes()
+bool KeyframeManager::HasDynamicKeyframes() const
{
return false; // Mahmoud_TODO: implement
}
-bool KeyframeManager::CanPerformKeyframeCopy()
+bool KeyframeManager::CanPerformKeyframeCopy() const
{
return !m_selectedKeyframes.empty() && m_selectedKeyframesMasterRows.count() == 1;
}
-bool KeyframeManager::CanPerformKeyframePaste()
+bool KeyframeManager::canSetKeyframeInterpolation() const
+{
+ for (Keyframe *kf : qAsConst(m_selectedKeyframes)) {
+ auto animType = kf->rowProperty->rowTree()->propBinding()->animationType();
+ if (animType == qt3dsdm::EAnimationTypeEaseInOut)
+ return true;
+ }
+
+ return false;
+}
+
+bool KeyframeManager::CanPerformKeyframePaste() const
{
if (m_pasteKeyframeCommandHelper && m_pasteKeyframeCommandHelper->HasCopiedKeyframes()) {
qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance =
@@ -526,36 +553,36 @@ void KeyframeManager::SetKeyframeInterpolation()
if (!hasSelectedKeyframes())
return;
- float theEaseIn = 0;
- float theEaseOut = 0;
- if (CStudioPreferences::GetInterpolation())
- theEaseIn = theEaseOut = 100;
-
- CDoc *theDoc = g_StudioApp.GetCore()->GetDoc();
- IAnimationCore *theAnimationCore = theDoc->GetStudioSystem()->GetAnimationCore();
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ IAnimationCore *animCore = doc->GetStudioSystem()->GetAnimationCore();
- if (!m_selectedKeyframes.empty()) {
- Qt3DSDMTimelineKeyframe *theTimelineKeyframe = m_selectedKeyframes.front()->binding;
- Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
- theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles);
- TKeyframe theKeyframeData = theAnimationCore->GetKeyframeData(theKeyframeHandles[0]);
- GetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut);
+ // find the first easing keyframe and use it to get the current easing values
+ auto firstEaseKeyframeIter = m_selectedKeyframes.begin();
+ while ((*firstEaseKeyframeIter)->rowProperty->rowTree()->propBinding()->animationType()
+ != EAnimationTypeEaseInOut) {
+ firstEaseKeyframeIter++;
}
- if (g_StudioApp.GetDialogs()->PromptForKeyframeInterpolation(theEaseIn, theEaseOut)) {
- // Note: Having "editor" variable here is important as its destructor
- // creates proper transaction
- Q3DStudio::ScopedDocumentEditor editor(*theDoc, QObject::tr("Set Keyframe Interpolation"),
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ (*firstEaseKeyframeIter)->binding->GetKeyframeHandles(keyframeHandles);
+
+ TKeyframe keyframeData = animCore->GetKeyframeData(keyframeHandles[0]);
+
+ float easeIn = CStudioPreferences::isInterpolation() ? 100 : 0;
+ float easeOut = CStudioPreferences::isInterpolation() ? 100 : 0;
+ getEaseInOutValues(keyframeData, easeIn, easeOut);
+
+ if (g_StudioApp.GetDialogs()->displayKeyframeInterpolation(easeIn, easeOut)) {
+ // Having "editor" variable here is important as its destructor creates proper transaction
+ Q3DStudio::ScopedDocumentEditor editor(*doc, QObject::tr("Set Keyframe Interpolation"),
__FILE__, __LINE__);
for (Keyframe *keyframe : qAsConst(m_selectedKeyframes)) {
- Qt3DSDMTimelineKeyframe *theTimelineKeyframe = keyframe->binding;
- Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
- theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles);
- for (size_t i = 0; i < theKeyframeHandles.size(); ++i) {
- TKeyframe theKeyframeData =
- theAnimationCore->GetKeyframeData(theKeyframeHandles[i]);
- SetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut);
- theAnimationCore->SetKeyframeData(theKeyframeHandles[i], theKeyframeData);
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ keyframe->binding->GetKeyframeHandles(keyframeHandles);
+ for (size_t i = 0; i < keyframeHandles.size(); ++i) {
+ TKeyframe keyframeData = animCore->GetKeyframeData(keyframeHandles[i]);
+ setEaseInOutValues(keyframeData, easeIn, easeOut);
+ animCore->SetKeyframeData(keyframeHandles[i], keyframeData);
}
}
}