TrackViewCurveEditor.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWCURVEEDITOR_H
  9. #define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWCURVEEDITOR_H
  10. #pragma once
  11. #include "TrackViewDopeSheetBase.h"
  12. #include "TrackViewSplineCtrl.h"
  13. #include "Controls/TimelineCtrl.h"
  14. #include "TrackViewTimeline.h"
  15. #include <QWidget>
  16. namespace Ui
  17. {
  18. class TrackViewCurveEditor;
  19. }
  20. /** CTrackViewGraph dialog.
  21. Placed at the same position as tracks dialog, and display spline graphs of track.
  22. */
  23. class CTrackViewCurveEditor
  24. : public QWidget
  25. , public IAnimationContextListener
  26. , public IEditorNotifyListener
  27. , public ITrackViewSequenceListener
  28. {
  29. friend class TrackViewCurveEditorDialog;
  30. public:
  31. CTrackViewCurveEditor(QWidget* parent);
  32. virtual ~CTrackViewCurveEditor();
  33. void SetEditLock(bool bLock);
  34. void SetFPS(float fps);
  35. float GetFPS() const;
  36. void SetTickDisplayMode(ETVTickMode mode);
  37. CTrackViewSplineCtrl& GetSplineCtrl();
  38. void ResetSplineCtrlZoomLevel();
  39. void SetPlayCallback(const std::function<void()>& callback);
  40. // IAnimationContextListener
  41. void OnSequenceChanged(CTrackViewSequence* pNewSequence) override;
  42. void OnTimeChanged(float newTime) override;
  43. protected:
  44. void showEvent(QShowEvent* event) override;
  45. private:
  46. void OnSplineChange();
  47. void OnSplineCmd(UINT cmd);
  48. void OnSplineCmdUpdateUI();
  49. void OnTimelineChange();
  50. void OnSplineTimeMarkerChange();
  51. // IEditorNotifyListener
  52. void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
  53. //ITrackViewSequenceListener
  54. void OnKeysChanged(CTrackViewSequence* pSequence) override;
  55. void OnKeyAdded(CTrackViewKeyHandle& addedKeyHandle) override;
  56. void OnKeySelectionChanged(CTrackViewSequence* pSequence) override;
  57. void OnNodeChanged(CTrackViewNode* pNode, ENodeChangeType type) override;
  58. void OnNodeSelectionChanged(CTrackViewSequence* pSequence) override;
  59. void OnSequenceSettingsChanged(CTrackViewSequence* pSequence) override;
  60. //~ITrackViewSequenceListener
  61. void UpdateSplines();
  62. void UpdateTimeRange(CTrackViewSequence* pSequence);
  63. void AddSpline(CTrackViewTrack* pTrack);
  64. TrackView::CTrackViewTimelineWidget m_timelineCtrl;
  65. bool m_bIgnoreSelfEvents;
  66. bool m_bLevelClosing;
  67. QScopedPointer<Ui::TrackViewCurveEditor> m_ui;
  68. };
  69. class TrackViewCurveEditorDialog
  70. : public QWidget
  71. , public ITrackViewSequenceListener
  72. , public IAnimationContextListener
  73. {
  74. public:
  75. TrackViewCurveEditorDialog(QWidget* parent);
  76. virtual ~TrackViewCurveEditorDialog() {}
  77. void SetPlayCallback(const std::function<void()>& callback) { m_widget->SetPlayCallback(callback); }
  78. void SetEditLock(bool bLock) { m_widget->SetEditLock(bLock); }
  79. CTrackViewSplineCtrl& GetSplineCtrl(){ return m_widget->GetSplineCtrl(); }
  80. void SetFPS(float fps) { m_widget->SetFPS(fps); }
  81. float GetFPS() const { return m_widget->GetFPS(); }
  82. void SetTickDisplayMode(ETVTickMode mode) { m_widget->SetTickDisplayMode(mode); }
  83. void OnSequenceChanged(CTrackViewSequence* pNewSequence) override { m_widget->OnSequenceChanged(pNewSequence); }
  84. void OnTimeChanged(float newTime) override { m_widget->OnTimeChanged(newTime); }
  85. // ITrackViewSequenceListener delegation to m_widget
  86. void OnKeysChanged(CTrackViewSequence* pSequence) override { m_widget->OnKeysChanged(pSequence); }
  87. void OnKeyAdded(CTrackViewKeyHandle& addedKeyHandle) override { m_widget->OnKeyAdded(addedKeyHandle); }
  88. void OnKeySelectionChanged(CTrackViewSequence* pSequence) override { m_widget->OnKeySelectionChanged(pSequence); }
  89. void OnNodeChanged(CTrackViewNode* pNode, ENodeChangeType type) override { m_widget->OnNodeChanged(pNode, type); }
  90. void OnNodeSelectionChanged(CTrackViewSequence* pSequence) override { m_widget->OnNodeSelectionChanged(pSequence); }
  91. void OnSequenceSettingsChanged(CTrackViewSequence* pSequence) override { m_widget->OnSequenceSettingsChanged(pSequence); }
  92. //~ITrackViewSequenceListener
  93. private:
  94. CTrackViewCurveEditor* m_widget;
  95. };
  96. #endif // CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWCURVEEDITOR_H