TrackViewDialog.h 7.1 KB

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