TrackViewDialog.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : CTrackViewDialog Implementation file.
  9. #pragma once
  10. #if !defined(Q_MOC_RUN)
  11. #include <IMovieSystem.h>
  12. #include "AnimationContext.h"
  13. #include "TrackViewCurveEditor.h"
  14. #include "TrackViewDopeSheetBase.h"
  15. #include "TrackViewKeyPropertiesDlg.h"
  16. #include "TrackViewNodes.h"
  17. #include "TrackViewSequence.h"
  18. #include "TrackViewSequenceManager.h"
  19. #include <AzCore/Component/EntityBus.h>
  20. #include <AzCore/std/containers/vector.h>
  21. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  22. #include <QMainWindow>
  23. #endif
  24. class QComboBox;
  25. class QLabel;
  26. class QSplitter;
  27. class CMovieCallback;
  28. class CTrackViewFindDlg;
  29. class CTrackViewDialog
  30. : public QMainWindow
  31. , public IAnimationContextListener
  32. , public IEditorNotifyListener
  33. , public ITrackViewSequenceListener
  34. , public ITrackViewSequenceManagerListener
  35. , public AZ::EntitySystemBus::Handler
  36. , private AzToolsFramework::ToolsApplicationNotificationBus::Handler
  37. , IUndoManagerListener
  38. {
  39. Q_OBJECT
  40. public:
  41. friend CMovieCallback;
  42. CTrackViewDialog(QWidget* pParent = nullptr);
  43. ~CTrackViewDialog();
  44. static void RegisterViewClass();
  45. static const GUID& GetClassID();
  46. static CTrackViewDialog* GetCurrentInstance() { return s_pTrackViewDialog; }
  47. void InvalidateDopeSheet();
  48. void Update();
  49. void ReloadSequences();
  50. void InvalidateSequence();
  51. void UpdateSequenceLockStatus();
  52. // IAnimationContextListener
  53. void OnSequenceChanged(CTrackViewSequence* pNewSequence) override;
  54. // ITrackViewSequenceListener
  55. void OnSequenceSettingsChanged(CTrackViewSequence* pSequence) override;
  56. void UpdateDopeSheetTime(CTrackViewSequence* pSequence);
  57. const CTrackViewDopeSheetBase& GetTrackViewDopeSheet() const { return *m_wndDopeSheet; }
  58. const AZStd::vector<AnimParamType>& GetDefaultTracksForEntityNode() const { return m_defaultTracksForEntityNode; }
  59. bool IsDoingUndoOperation() const { return m_bDoingUndoOperation; }
  60. //////////////////////////////////////////////////////////////////////////
  61. // AZ::EntitySystemBus
  62. void OnEntityDestruction(const AZ::EntityId& entityId) override;
  63. //~AZ::EntitySystemBus
  64. public: // static functions
  65. static QString GetEntityIdAsString(const AZ::EntityId& entityId) { return QString::number(static_cast<AZ::u64>(entityId)); }
  66. protected slots:
  67. void OnGoToPrevKey();
  68. void OnGoToNextKey();
  69. void OnAddKey();
  70. void OnDelKey();
  71. void OnMoveKey();
  72. void OnSlideKey();
  73. void OnScaleKey();
  74. void OnAddSequence();
  75. void OnDelSequence();
  76. void OnEditSequence();
  77. void OnSequenceComboBox();
  78. void OnAddSelectedNode();
  79. void OnAddDirectorNode();
  80. void OnFindNode();
  81. void OnRecord();
  82. void OnAutoRecord();
  83. void OnAutoRecordStep();
  84. void OnGoToStart();
  85. void OnGoToEnd();
  86. void OnPlay();
  87. void OnPlaySetScale();
  88. void OnStop();
  89. void OnStopHardReset();
  90. void OnPause();
  91. void OnLoop();
  92. void OnSnapNone();
  93. void OnSnapMagnet();
  94. void OnSnapFrame();
  95. void OnSnapTick();
  96. void OnSnapFPS();
  97. void OnCustomizeTrackColors();
  98. void OnBatchRender();
  99. void OnModeDopeSheet();
  100. void OnModeCurveEditor();
  101. void OnOpenCurveEditor();
  102. void OnViewTickInSeconds();
  103. void OnViewTickInFrames();
  104. void OnTracksToolBar();
  105. void OnToggleDisable();
  106. void OnToggleMute();
  107. void OnMuteAll();
  108. void OnUnmuteAll();
  109. protected:
  110. void keyPressEvent(QKeyEvent* event) override;
  111. #if defined(AZ_PLATFORM_WINDOWS)
  112. bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
  113. #endif
  114. bool event(QEvent* event) override;
  115. private slots:
  116. void ReadLayouts();
  117. void FillAddSelectedEntityMenu();
  118. private:
  119. enum class ViewMode
  120. {
  121. TrackView = 1,
  122. CurveEditor = 2,
  123. Both = 3
  124. };
  125. void setViewMode(ViewMode);
  126. void UpdateActions();
  127. void ReloadSequencesComboBox();
  128. void UpdateTracksToolBar();
  129. void ClearTracksToolBar();
  130. void AddButtonToTracksToolBar(const CAnimParamType& paramId, const QIcon& hIcon, const QString& title);
  131. void SetNodeForTracksToolBar(CTrackViewAnimNode* pNode) { m_pNodeForTracksToolBar = pNode; }
  132. void SetEditLock(bool bLock);
  133. void OnGameOrSimModeLock(bool lock);
  134. void InitMenu();
  135. void InitToolbar();
  136. void InitSequences();
  137. void OnAddEntityNodeMenu();
  138. void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
  139. bool OnInitDialog();
  140. void SaveLayouts();
  141. void SaveMiscSettings() const;
  142. void ReadMiscSettings();
  143. void SaveTrackColors() const;
  144. void ReadTrackColors();
  145. void SetCursorPosText(float fTime);
  146. #if defined(AZ_PLATFORM_WINDOWS)
  147. bool processRawInput(MSG* pMsg);
  148. #endif
  149. void OnNodeSelectionChanged(CTrackViewSequence* pSequence) override;
  150. void OnNodeRenamed(CTrackViewNode* pNode, const char* pOldName) override;
  151. void OnSequenceAdded(CTrackViewSequence* pSequence) override;
  152. void OnSequenceRemoved(CTrackViewSequence* pSequence) override;
  153. void AddSequenceListeners(CTrackViewSequence* sequence);
  154. void RemoveSequenceListeners(CTrackViewSequence* sequence);
  155. void AddDialogListeners();
  156. void RemoveDialogListeners();
  157. void BeginUndoTransaction() override;
  158. void EndUndoTransaction() override;
  159. // ToolsApplicationNotificationBus ...
  160. void AfterEntitySelectionChanged(
  161. const AzToolsFramework::EntityIdList& newlySelectedEntities,
  162. const AzToolsFramework::EntityIdList& newlyDeselectedEntities) override;
  163. // Instance
  164. static CTrackViewDialog* s_pTrackViewDialog;
  165. // GUI
  166. QSplitter* m_wndSplitter;
  167. CTrackViewNodesCtrl* m_wndNodesCtrl;
  168. CTrackViewDopeSheetBase* m_wndDopeSheet;
  169. QDockWidget* m_wndCurveEditorDock;
  170. TrackViewCurveEditorDialog* m_wndCurveEditor;
  171. CTrackViewKeyPropertiesDlg* m_wndKeyProperties;
  172. CTrackViewFindDlg* m_findDlg;
  173. QToolBar* m_mainToolBar;
  174. QToolBar* m_keysToolBar;
  175. QToolBar* m_playToolBar;
  176. QToolBar* m_viewToolBar;
  177. QToolBar* m_tracksToolBar;
  178. QComboBox* m_sequencesComboBox;
  179. QLabel* m_cursorPos;
  180. QLabel* m_activeCamStatic;
  181. // CryMovie
  182. CMovieCallback* m_pMovieCallback;
  183. // Current sequence
  184. AZ::EntityId m_currentSequenceEntityId;
  185. // State
  186. bool m_bRecord;
  187. bool m_bAutoRecord;
  188. bool m_bPlay;
  189. bool m_bPause;
  190. bool m_bNeedReloadSequence;
  191. bool m_bIgnoreUpdates;
  192. bool m_bDoingUndoOperation;
  193. bool m_lazyInitDone;
  194. bool m_bEditLock;
  195. bool m_enteringGameOrSimModeLock = false;
  196. bool m_needReAddListeners = false;
  197. float m_fLastTime;
  198. float m_fAutoRecordStep;
  199. CTrackViewAnimNode* m_pNodeForTracksToolBar;
  200. int m_currentToolBarParamTypeId;
  201. AZStd::vector<CAnimParamType> m_toolBarParamTypes;
  202. // Default tracks menu
  203. AZStd::vector<AnimParamType> m_defaultTracksForEntityNode;
  204. QHash<int, QAction*> m_actions;
  205. ViewMode m_lastMode = ViewMode::TrackView;
  206. };