diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-01-30 15:08:08 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-02-02 09:04:42 +0000 |
commit | 6f0e23369633b42ad05c84e42eaac6178c278a07 (patch) | |
tree | e3657d783532db99127df716ea746134e7eda22f /src | |
parent | fa88aa5e366e4d9f7cd2de76cc65b5e6be4fe590 (diff) |
Stop animation while handling a mouse click on scene
Dragging while animation is running caused nasty side
effects like crashing and creating multitude of keyframes for the
dragged item. To avoid these issues, playback is stopped when mouse
press on scene is detected, and the playback is resumed when the mouse
is released.
Task-number: QT3DS-603
Change-Id: I216e18d09ad1fdb33c329ae0e48bd1ea78912bdb
Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/Authoring/Studio/_Win/Application/StudioApp.cpp | 5 | ||||
-rw-r--r-- | src/Authoring/Studio/_Win/Application/StudioApp.h | 1 | ||||
-rw-r--r-- | src/Authoring/Studio/_Win/UI/PlayerWnd.cpp | 12 | ||||
-rw-r--r-- | src/Authoring/Studio/_Win/UI/PlayerWnd.h | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/src/Authoring/Studio/_Win/Application/StudioApp.cpp b/src/Authoring/Studio/_Win/Application/StudioApp.cpp index 96895d3f..e3f5c6d7 100644 --- a/src/Authoring/Studio/_Win/Application/StudioApp.cpp +++ b/src/Authoring/Studio/_Win/Application/StudioApp.cpp @@ -1020,6 +1020,11 @@ void CStudioApp::PlaybackRewind() } } +bool CStudioApp::IsPlaying() +{ + return m_Core->GetDoc()->IsPlaying(); +} + //============================================================================= /** * Performs a file revert. diff --git a/src/Authoring/Studio/_Win/Application/StudioApp.h b/src/Authoring/Studio/_Win/Application/StudioApp.h index 525a0583..62c8f4a6 100644 --- a/src/Authoring/Studio/_Win/Application/StudioApp.h +++ b/src/Authoring/Studio/_Win/Application/StudioApp.h @@ -180,6 +180,7 @@ public: void PlaybackPlay(); void PlaybackStopNoRestore(); void PlaybackRewind(); + bool IsPlaying(); void OnRevert(); bool CanRevert(); void OnFileOpenRecent(const Qt3DSFile &inDocument); diff --git a/src/Authoring/Studio/_Win/UI/PlayerWnd.cpp b/src/Authoring/Studio/_Win/UI/PlayerWnd.cpp index 415f289c..8bdb7b59 100644 --- a/src/Authoring/Studio/_Win/UI/PlayerWnd.cpp +++ b/src/Authoring/Studio/_Win/UI/PlayerWnd.cpp @@ -152,6 +152,14 @@ void CPlayerWnd::mousePressEvent(QMouseEvent *event) { const Qt::MouseButton btn = event->button(); if ((btn == Qt::LeftButton) || (btn == Qt::RightButton)) { + // Pause playback for the duration of the mouse click + if (g_StudioApp.IsPlaying()) { + g_StudioApp.PlaybackStopNoRestore(); + m_resumePlayOnMouseRelease = true; + } else { + m_resumePlayOnMouseRelease = false; + } + long theToolMode = g_StudioApp.GetToolMode(); g_StudioApp.GetCore()->GetDispatch()->FireSceneMouseDown(SceneDragSenderType::SceneWindow, event->pos(), theToolMode); @@ -179,6 +187,10 @@ void CPlayerWnd::mouseReleaseEvent(QMouseEvent *event) g_StudioApp.GetCore()->GetDispatch()->FireSceneMouseUp(SceneDragSenderType::SceneWindow); g_StudioApp.GetCore()->CommitCurrentCommand(); m_IsMouseDown = false; + if (m_resumePlayOnMouseRelease) { + m_resumePlayOnMouseRelease = false; + g_StudioApp.PlaybackPlay(); + } } else if (btn == Qt::MiddleButton) { event->ignore(); } diff --git a/src/Authoring/Studio/_Win/UI/PlayerWnd.h b/src/Authoring/Studio/_Win/UI/PlayerWnd.h index 0f905f4e..eefb6952 100644 --- a/src/Authoring/Studio/_Win/UI/PlayerWnd.h +++ b/src/Authoring/Studio/_Win/UI/PlayerWnd.h @@ -77,6 +77,7 @@ protected: CPlayerContainerWnd *m_ContainerWnd; bool m_IsMouseDown; + bool m_resumePlayOnMouseRelease = false; long m_PreviousToolMode; ///< The previous tool mode (used when toggling with hotkeys to switch ///back to previous mode on release) bool m_FitClientToWindow; ///< True if we are in Fit to Window Mode |